Skip to content

Commit

Permalink
Merge pull request #123 from gaelforget/v0p4p7a
Browse files Browse the repository at this point in the history
V0p4p7a
  • Loading branch information
gaelforget authored Jun 1, 2024
2 parents 0989179 + 4f3f0e0 commit 75d12d5
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "IndividualDisplacements"
uuid = "b92f0c32-5b7e-11e9-1d7b-238b2da8b0e6"
authors = ["gaelforget <[email protected]>"]
version = "0.4.6"
version = "0.4.7"

[deps]
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
Expand Down
55 changes: 55 additions & 0 deletions src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,61 @@ struct 𝐹_Array3D{T} <: FlowFields
𝑇::Array{T}
end

"""
FlowFields(; u::Union{Array,Tuple}=[], v::Union{Array,Tuple}=[], w::Union{Array,Tuple}=[],
period::Union{Array,Tuple}=[], gridtype::Symbol=:centered)
Construct FlowFields data structure based on keywords.
```
uC, vC, _ = SimpleFlowFields(16)
F=FlowFields(u=uC,v=vC,period=(0,10.))
```
"""
function FlowFields(; u::Union{Array,Tuple}=[], v::Union{Array,Tuple}=[], w::Union{Array,Tuple}=[],
period::Union{Array,Tuple}=[], gridtype::Symbol=:centered)
(isa(u,Tuple)||length(u[:])==2) ? (u0=u[1]; u1=u[2]) : (u0=u; u1=u)
(isa(v,Tuple)||length(v[:])==2) ? (v0=v[1]; v1=v[2]) : (v0=v; v1=v)
(isa(w,Tuple)||length(w[:])==2) ? (w0=w[1]; w1=w[2]) : (w0=w; w1=w)
if isempty(period)
@warn "period needs to be defined"
else
if gridtype==:centered
to_C_grid!(u0,dims=1)
to_C_grid!(u1,dims=1)
to_C_grid!(v0,dims=2)
to_C_grid!(v1,dims=2)
if !isempty(w0)
to_C_grid!(w0,dims=3)
to_C_grid!(w1,dims=3)
end
end
end
if !isempty(u0) && !isempty(v0)
if !isempty(w0)
FlowFields(u0,u1,v0,v1,w0,w1,period)
else
FlowFields(u0,u1,v0,v1,period)
end
else
[]
end
end

to_C_grid!(x;dims=0) = begin
if (dims==1)&&(ndims(x)==2)
x.=0.5*(circshift(x, (1,0))+x)
elseif (dims==2)&&(ndims(x)==2)
x.=0.5*(circshift(x, (0,1))+x)
elseif dims==1
x.=0.5*(circshift(x, (1,0,0))+x)
elseif dims==2
x.=0.5*(circshift(x, (0,1,0))+x)
elseif dims==3
x.=0.5*(circshift(x, (0,0,1))+x)
end
end

function FlowFields(u0::Array{T,3},u1::Array{T,3},v0::Array{T,3},v1::Array{T,3},
w0::Array{T,3},w1::Array{T,3},𝑇::Union{Array,Tuple}) where T
#test for type of 𝑇 and fix if needed
Expand Down
8 changes: 7 additions & 1 deletion src/IndividualDisplacements.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ include("data_wrangling.jl")
include("toy_models.jl")
include("various.jl")

export Individuals, ∫!
DiffEqBase.solve!(𝐼::Individuals,args...)=∫!(𝐼::Individuals,args...)
DataFrames.groupby(I::Individuals,args...) = groupby(I.🔴,args...)
DataFrames.DataFrame(I::Individuals) = I.🔴
F_Array3D=𝐹_Array3D; F_Array2D=𝐹_Array2D; F_MeshArray3D=𝐹_MeshArray3D; F_MeshArray2D=𝐹_MeshArray2D

export Individuals, ∫!, solve!, DataFrame, groupby
export FlowFields, convert_to_FlowFields
export 𝐹_Array3D, 𝐹_Array2D, 𝐹_MeshArray3D, 𝐹_MeshArray2D
export F_Array3D, F_Array2D, F_MeshArray3D, F_MeshArray2D
export dxdt!, dxy_dt_CyclicArray, dxy_dt_replay
export postprocess_MeshArray, add_lonlat!, postprocess_xy, interp_to_xy
export nearest_to_xy, randn_lonlat, interp_to_lonlat
Expand Down

0 comments on commit 75d12d5

Please sign in to comment.