Skip to content

Commit

Permalink
Fix ECCOrestoring show method (#311)
Browse files Browse the repository at this point in the history
* fix ECCOrestoring show

* fix docstring rendering

* fix more docs

* Update ECCO_restoring.jl

* Update ECCO_restoring.jl
  • Loading branch information
navidcy authored Dec 22, 2024
1 parent d8992d5 commit 0d7da30
Showing 1 changed file with 28 additions and 24 deletions.
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))
end

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

0 comments on commit 0d7da30

Please sign in to comment.