Skip to content

New interface for ECCORestoring #185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 44 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
2a9b254
start changing ecco restoring
simone-silvestri Sep 19, 2024
3c7c0ce
this should work?
simone-silvestri Sep 20, 2024
82fd2d5
new interface
simone-silvestri Sep 20, 2024
fc33335
fix docstring
simone-silvestri Sep 20, 2024
d2f51d1
simplify
simone-silvestri Sep 20, 2024
bc8c226
adding a maxiter
simone-silvestri Sep 20, 2024
c9036ec
make it work
simone-silvestri Sep 20, 2024
8941604
remove manifest
simone-silvestri Sep 20, 2024
9f16b60
adding maxiter
simone-silvestri Sep 20, 2024
a94f083
some changes
simone-silvestri Sep 20, 2024
e53a807
add range checks
simone-silvestri Sep 20, 2024
7597b1b
fix docstring
simone-silvestri Sep 20, 2024
b5d1661
inpainting_iterations?
simone-silvestri Sep 20, 2024
f6f40ad
better docstring
simone-silvestri Sep 20, 2024
58517cb
better defaults
simone-silvestri Sep 20, 2024
beb0836
correct docstring
simone-silvestri Sep 20, 2024
764ad91
adding a show method
simone-silvestri Sep 20, 2024
ee03ff3
fixed tests
simone-silvestri Sep 23, 2024
f82292e
more fixes
simone-silvestri Sep 24, 2024
a474956
fix ranges check
simone-silvestri Sep 24, 2024
78012d0
fix ecco tests
simone-silvestri Sep 24, 2024
32fd953
fix ecco tests
simone-silvestri Oct 7, 2024
bda2828
correct the precompile runtime
simone-silvestri Oct 9, 2024
fc82bf8
remove concurrency
simone-silvestri Oct 21, 2024
e1c05a2
Merge branch 'main' into ss/ecco-restoring-interface
simone-silvestri Oct 21, 2024
cf5a861
bugfix
simone-silvestri Oct 24, 2024
27bf157
Merge branch 'main' into ss/ecco-restoring-interface
simone-silvestri Oct 24, 2024
1bbfd7b
flux form
simone-silvestri Oct 24, 2024
a3e4807
Merge branch 'main' into ss/ecco-restoring-interface
simone-silvestri Oct 28, 2024
df7bed2
NearestNeighborInpainting
simone-silvestri Oct 28, 2024
701c3d1
some more comments plus fix tests
simone-silvestri Oct 28, 2024
644370b
check inpainting
simone-silvestri Oct 28, 2024
9346a64
remove space
simone-silvestri Oct 28, 2024
defa077
bugfix
simone-silvestri Oct 28, 2024
819142c
bugfix
simone-silvestri Oct 28, 2024
2b5af9a
fix a couple of bugs
simone-silvestri Oct 29, 2024
0c407dc
fix tests
simone-silvestri Oct 29, 2024
3bb195c
corrected tests
simone-silvestri Oct 29, 2024
862d77a
setting
simone-silvestri Oct 29, 2024
7bd6559
bugfix
simone-silvestri Oct 30, 2024
5ba0558
Merge branch 'main' into ss/ecco-restoring-interface
simone-silvestri Nov 1, 2024
f24e672
Merge branch 'main' into ss/ecco-restoring-interface
simone-silvestri Nov 4, 2024
1dc6f88
try setting the runtime version
simone-silvestri Nov 5, 2024
72cfb20
whoops
simone-silvestri Nov 5, 2024
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: 0 additions & 2 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ env:
steps:
- label: "initialize"
key: "init"
concurrency: 1
concurrency_group: 'depot/climaocean-ci'
env:
TEST_GROUP: "init"
command:
Expand Down
6 changes: 4 additions & 2 deletions src/ClimaOcean.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ export
SimilarityTheoryTurbulentFluxes,
JRA55_prescribed_atmosphere,
JRA55NetCDFBackend,
ECCOMetadata,
regrid_bathymetry,
retrieve_bathymetry,
stretched_vertical_faces,
exponential_z_faces,
PowerLawStretching, LinearStretching,
exponential_z_faces,
JRA55_field_time_series,
ECCO_field, ECCOMetadata,
ECCO_field,
ECCOMetadata,
ECCORestoring,
LinearlyTaperedPolarMask,
ocean_simulation,
initialize!

Expand Down
6 changes: 3 additions & 3 deletions src/DataWrangling/ECCO/ECCO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module ECCO

export ECCOMetadata, ECCO_field, ECCO_mask, adjusted_ECCO_tracers, initialize!
export ECCO2Monthly, ECCO4Monthly, ECCO2Daily
export ECCO_restoring_forcing
export ECCORestoring, LinearlyTaperedPolarMask

using ClimaOcean.DataWrangling: inpaint_mask!
using ClimaOcean.InitialConditions: three_dimensional_regrid!, interpolate!
Expand Down Expand Up @@ -206,14 +206,14 @@ Keyword Arguments:
function inpainted_ECCO_field(metadata::ECCOMetadata;
architecture = CPU(),
mask = ECCO_mask(metadata, architecture),
maxiter = Inf,
inpainting = NearestNeighborInpainting(Inf),
kw...)

f = ECCO_field(metadata; architecture, kw...)

# Make sure all values are extended properly
@info "In-painting ECCO $(metadata.name)"
inpaint_mask!(f, mask; maxiter)
inpaint_mask!(f, mask; inpainting)

fill_halo_regions!(f)

Expand Down
50 changes: 50 additions & 0 deletions src/DataWrangling/ECCO/ECCO_mask.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Oceananigans.Architectures: AbstractArchitecture
import ClimaOcean: stateindex

"""
ECCO_mask(architecture = CPU(); minimum_value = Float32(-1e5))
Expand Down Expand Up @@ -39,3 +40,52 @@ end
@inbounds mask[i, j, k] = (Tᵢ[i, j, k] == 0)
end

struct LinearlyTaperedPolarMask{N, S, Z}
northern :: N
southern :: S
z :: Z
end

"""
LinearlyTaperedPolarMask(; northern = (70, 75),
southern = (-75, -70),
z = (-20, 0))

Build a mask that is linearly tapered in latitude inbetween the northern and southern edges.
The mask is constant in depth between the z and is equal to zero everywhere else.
The mask has the following functional form:

```julia
n = 1 / (northern[2] - northern[1]) * (φ - northern[1])
s = 1 / (southern[1] - southern[2]) * (φ - southern[2])

within_depth = (z[1] < z < z[2])

mask = within_depth ? max(n, s, 0) : 0
```
"""
function LinearlyTaperedPolarMask(; northern = (70, 75),
southern = (-75, -70),
z = (-20, 0))

northern[1] > northern[2] && throw(ArgumentError("Northern latitude range is invalid, northern[1] > northern[2]."))
southern[1] > southern[2] && throw(ArgumentError("Southern latitude range is invalid, southern[1] > southern[2]."))
z[1] > z[2] && throw(ArgumentError("Depth range is invalid, z[1] > z[2]."))

return LinearlyTaperedPolarMask(northern, southern, z)
end

@inline function (mask::LinearlyTaperedPolarMask)(φ, z)
n = 1 / (mask.northern[2] - mask.northern[1]) * (φ - mask.northern[1])
s = 1 / (mask.southern[1] - mask.southern[2]) * (φ - mask.southern[2])

within_depth = (mask.z[1] < z < mask.z[2])

return ifelse(within_depth, max(n, s, zero(n)), zero(n))
end

@inline function stateindex(mask::LinearlyTaperedPolarMask, i, j, k, grid, time, loc)
LX, LY, LZ = loc
λ, φ, z = node(i, j, k, grid, LX(), LY(), LZ())
return mask(φ, z)
end
4 changes: 4 additions & 0 deletions src/DataWrangling/ECCO/ECCO_metadata.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ Base.show(io::IO, metadata::ECCOMetadata) =
"├── version: $(metadata.version)", '\n',
"└── dir: $(metadata.dir)")

Base.summary(data::ECCOMetadata{<:Any, <:ECCO2Daily}) = "Daily ECCO2 $(data.name) dataset, from $(first(data.dates)) to $(last(data.dates))"
Base.summary(data::ECCOMetadata{<:Any, <:ECCO2Monthly}) = "Monthly ECCO2 $(data.name) dataset, from $(first(data.dates)) to $(last(data.dates))"
Base.summary(data::ECCOMetadata{<:Any, <:ECCO4Monthly}) = "Monthly ECCO4 $(data.name) dataset, from $(first(data.dates)) to $(last(data.dates))"

"""
ECCOMetadata(name::Symbol;
dates = DateTimeProlepticGregorian(1993, 1, 1),
Expand Down
Loading
Loading