Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "MeshArrays"
uuid = "cb8c808f-1acf-59a3-9d2b-6e38d009f683"
version = "0.4.7"
version = "0.4.8"
authors = ["gaelforget <[email protected]>"]

[deps]
Expand Down
24 changes: 15 additions & 9 deletions src/grids/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ function GridSpec_default(xy=NamedTuple(), nFaces=1; ID=:unknown)
else
error("unknown grid ID")
end
GridSpec_default_xy(xy,nFaces)
GridSpec_default_xy(xy,nFaces,path="_default_"*string(ID))
end
end

function GridSpec_default_xy(xy::NamedTuple, nFaces=1)
function GridSpec_default_xy(xy::NamedTuple, nFaces=1; path="_default")
(; xc, yc, xg, yg) = xy

dx=diff(xg)[1]
Expand All @@ -73,7 +73,6 @@ function GridSpec_default_xy(xy::NamedTuple, nFaces=1)
ioSize=[ni nj]
facesSize=[(nni, nnj), (nni, nnj), (nni, nnj), (nni, nnj)]
ioPrec=Float32
path="_default"

g=gcmgrid(path, grTopo, nFaces, facesSize, ioSize, ioPrec, read, write)
end
Expand Down Expand Up @@ -118,10 +117,10 @@ true
"""
function GridLoad(γ=GridSpec(); ID=:default, option=:minimal, verbose=false)
gr = (ID!==:default ? GridSpec(ID=ID) : γ)
if gr.path=="_default"
if occursin("_default",gr.path)
verbose ? println("GridLoad_default") : nothing
GridLoad_default(gr)
elseif gr.path=="_ones"
elseif occursin("_ones",gr.path)
verbose ? println("GridLoad_ones") : nothing
GridLoad_ones(gr; option=option)
else
Expand Down Expand Up @@ -295,10 +294,17 @@ include("NEMO.jl")
MeshArrays.GridSpec_default(ID=:IAP)
```
"""
function GridLoad_default(gr=GridSpec())#; ID=:unknown)
# xy=Grids_simple.xy_IAP()
# gr=Grids_simple.grid_factors(xy)

function GridLoad_default(gr=GridSpec())
xy=(if gr.path=="_default_IAP"
Grids_simple.xy_IAP()
elseif gr.path=="_default_Oscar"
Grids_simple.xy_Oscar()
elseif gr.path=="_default_OISST"
Grids_simple.xy_OISST()
else
error("unknown grid ID")
end)
gr=Grids_simple.grid_factors(xy)
dep=[10 100 1000]; msk=ones(gr[:XC].fSize[1]...,3)
gr=Grids_simple.grid_add_z(gr,dep,msk)
end
Expand Down
13 changes: 6 additions & 7 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,11 @@ end
@test isa(G,Dict)
end

if false
γ = GridSpec(ID=:OISST)
γ = GridSpec(ID=:LLC90)
#γ=MeshArrays.GridSpec_ones("CubeSphere",6,20)
γ = GridSpec("ones")
Γ = GridLoad(γ;option="full")
@testset "GridSpec:" begin
γ = GridSpec(ID=:Oscar)
γ = GridSpec(ID=:IAP)
GridLoad(GridSpec(ID=:OISST))
GridLoad(GridSpec("ones"))
end

@testset "Plotting:" begin
Expand Down Expand Up @@ -395,7 +394,7 @@ end

@testset "polygon operations" begin
fil=MeshArrays.Dataset("countries_shp1",do_read=false)
pol=MeshArrays.read_shp(fil,format=0.2)
pol=MeshArrays.read_shp(fil,format=:Shapefile)
name,rule=MeshArrays.within_pol(pol; ID=11)
rule_vec = (x,y) -> rule.(x,y)

Expand Down
Loading