Skip to content
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

Fix ECCOrestoring show method #311

Merged
merged 5 commits into from
Dec 22, 2024
Merged
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
52 changes: 28 additions & 24 deletions src/DataWrangling/ECCO/ECCO_restoring.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using Oceananigans.Utils: Time

using Base
using NCDatasets
using JLD2
using JLD2

using Dates: Second
using ClimaOcean: stateindex
Expand Down Expand Up @@ -35,7 +35,10 @@ end
Adapt.adapt_structure(to, b::ECCONetCDFBackend{N, C}) where {N, C} = ECCONetCDFBackend{N, C}(b.start, b.length, nothing, nothing)

"""
ECCONetCDFBackend(length; on_native_grid=false, inpainting=NearestNeighborInpainting(Inf))
ECCONetCDFBackend(length, metadata;
on_native_grid = false,
cache_inpainted_data = false,
inpainting = NearestNeighborInpainting(Inf))

Represent an ECCO FieldTimeSeries backed by ECCO native netCDF files.
Each time instance is stored in an individual file.
Expand Down Expand Up @@ -76,7 +79,7 @@ function set!(fts::ECCOFieldTimeSeries)
end

"""
ECCO_times(metadata; start_time = metadata.dates[1])
ECCO_times(metadata; start_time = first(metadata).dates)

Extract the time values from the given metadata and calculates the time difference
from the start time.
Expand Down Expand Up @@ -106,7 +109,8 @@ end
ECCOFieldTimeSeries(metadata::ECCOMetadata [, arch_or_grid=CPU() ];
time_indices_in_memory = 2,
time_indexing = Cyclical(),
inpainting = nothing)
inpainting = nothing,
cache_inpainted_data = true)

Create a field time series object for ECCO data.

Expand All @@ -115,7 +119,7 @@ Arguments

- `metadata`: `ECCOMetadata` containing information about the ECCO dataset.

- `arch_or_grid`: Either a grid to interpolate ECCO data to, or an `arch`itecture
- `arch_or_grid`: Either a grid to interpolate the ECCO data to, or an `arch`itecture
to use for the native ECCO grid. Default: CPU().

Keyword Arguments
Expand Down Expand Up @@ -236,44 +240,44 @@ end
ECCORestoring(variable_name::Symbol, [ arch_or_grid = CPU(), ];
version = ECCO4Monthly(),
dates = all_ECCO_dates(version),
time_indices_in_memory = 2,
time_indices_in_memory = 2,
time_indexing = Cyclical(),
mask = 1,
rate = 1,
inpainting = NearestNeighborInpainting(Inf),
cache_inpainted_data = true)

Build a forcing term that restores to values stored in an ECCO field time series.
The restoring is applied as a forcing on the right hand side of the evolution equations calculated as
Return a forcing term that restores to values stored in an ECCO field time series.
The restoring is applied as a forcing on the right hand side of the evolution
equations calculated as:

```math
Fψ = r μ (ψ_{ECCO} - ψ)
```

where ``μ`` is the mask, ``r`` is the restoring rate, ``ψ`` is the simulation variable,
and the ECCO variable ``ψ_ECCO`` is linearly interpolated in space and time from the
ECCO dataset of choice to the simulation grid and time.
and ``ψ_{ECCO}`` is the ECCO variable that is linearly interpolated in space and time
from the ECCO dataset of choice to the simulation grid and time.

Arguments
=========

- `variable_name`: The name of the variable to restore. Choices include:
* `:temperature`,
* `:salinity`,
* `:u_velocity`,
* `:v_velocity`,
* `:sea_ice_thickness`,
* `:sea_ice_area_fraction`.

Note that `ECCOMetadata` may be provided as the first argument instead
of `variable_name`. In this case the `version` and `dates` kwargs (described below)
cannot be provided.
* `:temperature`,
* `:salinity`,
* `:u_velocity`,
* `:v_velocity`,
* `:sea_ice_thickness`,
* `:sea_ice_area_fraction`.

- `arch_or_grid`: Either the architecture of the simulation, or a grid on which the ECCO data
is pre-interpolated when loaded. If an `arch`itecture is provided, such as
`arch_or_grid = CPU()` or `arch_or_grid = GPU()`, ECCO data
will be interpolated on-the-fly when the forcing tendency is computed.
Default: CPU().
`arch_or_grid = CPU()` or `arch_or_grid = GPU()`, ECCO data are interpolated
on-the-fly when the forcing tendency is computed. Default: CPU().

!!! info "Providing `ECCOMetadata` instead of `variable_name`"
Note that `ECCOMetadata` may be provided as the first argument instead of `variable_name`.
In this case the `version` and `dates` kwargs (described below) cannot be provided.

Keyword Arguments
=================
Expand Down Expand Up @@ -340,7 +344,7 @@ function Base.show(io::IO, p::ECCORestoring)
"├── restoring dataset: ", summary(p.field_time_series.backend.metadata), '\n',
"├── restoring rate: ", p.rate, '\n',
"├── mask: ", summary(p.mask), '\n',
"└── grid: ", summary(p.grid))
"└── grid: ", summary(p.native_grid))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the bug fix

end

regularize_forcing(forcing::ECCORestoring, field, field_name, model_field_names) = forcing
Loading