Skip to content

Commit

Permalink
update variable names and default
Browse files Browse the repository at this point in the history
  • Loading branch information
gaelforget committed Sep 21, 2024
1 parent 33cc1a2 commit 9d161cc
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/Integration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,24 @@ DEPTHS=[(0,100),(100,200),(200,300),(300,400),(400,500),(500,600),(600,700),
(2000,2500),(2500,3000),(3000,4000),(4000,5000),(5000,7000)]

"""
define_regions(;option=:basins,grid::NamedTuple)
define_regions(;option=:global,grid::NamedTuple)
Define regional integration mask (one value period region).
"""
function define_regions(;option=:basins,grid::NamedTuple)
function define_regions(;option=:global,grid::NamedTuple)
if option==:basins
demo.ocean_basins()
elseif option==:global
mask=1.0*(grid.hFacC[:,1].>0)
(map=mask,name=["Global"])
(mask=mask,name=["Global"])

Check warning on line 42 in src/Integration.jl

View check run for this annotation

Codecov / codecov/patch

src/Integration.jl#L42

Added line #L42 was not covered by tests
elseif option==:dlat_10
mask=1.0*(grid.hFacC[:,1].>0)
la=grid.YC
lats=[-90 ; -75:10:75 ; 90]
nl=length(lats)-1
name=[Symbol("lat_$(lats[l])_to_$(lats[l+1])") for l in 1:nl]
[mask[findall((mask.>0)*(la.>=lats[l])*(la.<lats[l+1]))].=l for l in 1:nl]
(map=mask,name=name)
(mask=mask,name=name)
elseif isa(option,Tuple)
dlo=option[1]; dla=option[2]
mask=1.0*(grid.hFacC[:,1].>0)
Expand All @@ -72,7 +72,7 @@ function define_regions(;option=:basins,grid::NamedTuple)
end
end
end
(map=mask,name=name)
(mask=mask,name=name)
else
error("unknown option")
end
Expand All @@ -89,19 +89,19 @@ layer_mask(dF,d0,d1)=begin
end

"""
define_sums(;option=:loops, grid::NamedTuple, regions=:basins, depths=[(0,7000)])
define_sums(;option=:loops, grid::NamedTuple, regions=:global, depths=[(0,7000)])
Define regional integration function for each basin and depth range.
"""
function define_sums(;option=:loops, grid::NamedTuple, regions=:basins, depths=[(0,7000)])
function define_sums(;option=:loops, grid::NamedTuple, regions=:global, depths=[(0,7000)])
dep=(isa(depths,Tuple) ? [depths] : depths)
nd=length(dep)
rgns=define_regions(option=regions,grid=grid)
nb=length(rgns.name)
allones=1.0 .+0*grid.hFacC
nr=length(grid.RC)

xymsk(b) = 1.0*(rgns.map.==b)
xymsk(b) = 1.0*(rgns.mask.==b)
func_h(X,b)=sum(xymsk(b)*X)
tmp2d=MeshArray(grid.XC.grid,Float32)

Expand Down Expand Up @@ -154,9 +154,9 @@ function define_sums(;option=:loops, grid::NamedTuple, regions=:basins, depths=[
end

if option==:loops
gridmask(rgns.map,BXh.name,depths,BXh.hsum,BXv.vint,tmp2d,tmp3d)
gridmask(rgns.mask,BXh.name,depths,BXh.hsum,BXv.vint,tmp2d,tmp3d)
elseif option==:streamlined_loop
gridmask(rgns.map,BX.name,depths,BX.volsum,[],tmp2d,tmp3d)
gridmask(rgns.mask,BX.name,depths,BX.volsum,[],tmp2d,tmp3d)
else
error("unknown option")
end
Expand Down

0 comments on commit 9d161cc

Please sign in to comment.