Private types and functions
Documentation for ClimaOcean.jl
's internal interface.
ClimaOcean
Diagnostics
InitialConditions
DataWrangling
ClimaOcean.DataWrangling.NearestNeighborInpainting
— TypeNearestNeighborInpainting{M}
A structure representing the nearest neighbor inpainting algorithm, where a missing value is substituted with the average of the surrounding valid values. This process is repeated a maximum of maxiter
times or until the field is completely inpainted.
ClimaOcean.DataWrangling.continue_downwards!
— Methodcontinue_downwards!(field, mask)
Continue downwards a field with missing values within mask
. Cells where mask[i, k, k] == false
will be preserved.
ClimaOcean.DataWrangling.download_progress
— Methoddownload_progress(total, now; filename="")
ClimaOcean.DataWrangling.inpaint_mask!
— Methodinpaint_mask!(field, mask; max_iter = Inf)
Inpaint field
within mask
, using values outside mask
. In other words, regions where mask[i, j, k] == 1
is inpainted and regions where mask[i, j, k] == 0
are preserved.
Arguments
field
:Field
to be inpainted.mask
: Boolean-valuedField
, values wheremask[i, j, k] == true
are inpainted.inpainting
: The inpainting algorithm to use. For the moment, the only option isNearestNeighborInpainting(maxiter)
, where an average of the valid surrounding values is usedmaxiter
times.
ClimaOcean.DataWrangling.netrc_downloader
— Methodnetrc_downloader(username, password, machine, dir)
Create a downloader that uses a netrc file to authenticate with the given machine. This downlader writes the username and password in a file named auth.netrc
(for Unix) and auth_netrc
(for Windows), located in the directory dir
. To avoid leaving the password on disk after the downloader has been used, it is recommended to initialize the downloader in a temporary directory, which will be removed after the download is complete.
For example:
mktempdir(dir) do tmp
dowloader = netrc_downloader(username, password, machine, tmp)
Downloads.download(fileurl, filepath; downloader)
end
ClimaOcean.DataWrangling.propagate_horizontally!
— Functionpropagate_horizontally!(inpainting, field, mask [, tmp_field=deepcopy(field)])
Horizontally propagate the values of field
into the mask
. In other words, cells where mask[i, j, k] == false
are preserved, and cells where mask[i, j, k] == true
are painted over.
The first argument inpainting
is the inpainting algorithm to use in the _propagate_field!
step.
ECCO
ClimaOcean.DataWrangling.ECCO.ECCOFieldTimeSeries
— TypeECCOFieldTimeSeries(metadata::ECCOMetadata [, arch_or_grid=CPU() ];
time_indices_in_memory = 2,
time_indexing = Cyclical(),
inpainting = nothing,
cache_inpainted_data = true)
Create a field time series object for ECCO data.
Arguments
metadata
:ECCOMetadata
containing information about the ECCO dataset.arch_or_grid
: Either a grid to interpolate the ECCO data to, or anarch
itecture to use for the native ECCO grid. Default: CPU().
Keyword Arguments
time_indices_in_memory
: The number of time indices to keep in memory. Default: 2.time_indexing
: The time indexing scheme to use. Default:Cyclical()
.inpainting
: The inpainting algorithm to use for ECCO interpolation. The only option isNearestNeighborInpainting(maxiter)
, where an average of the valid surrounding values is usedmaxiter
times.cache_inpainted_data
: Iftrue
, the data is cached to disk after inpainting for later retrieving. Default:true
.
ClimaOcean.DataWrangling.ECCO.ECCONetCDFBackend
— MethodECCONetCDFBackend(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.
ClimaOcean.DataWrangling.ECCO.ECCO_times
— MethodECCO_times(metadata; start_time = first(metadata).dates)
Extract the time values from the given metadata and calculates the time difference from the start time.
Arguments
metadata
: The metadata containing the date information.start_time
: The start time for calculating the time difference. Defaults to the first date in the metadata.
Returns
An array of time differences in seconds.
ClimaOcean.DataWrangling.ECCO.download_dataset
— Methoddownload_dataset(metadata::ECCOMetadata; url = urls(metadata))
Download the dataset specified by ECCOMetadata
. If ECCOMetadata.dates
is a single date, the dataset is downloaded directly. If ECCOMetadata.dates
is a vector of dates, each date is downloaded individually.
The data download requires a username and password to be provided in the ECCO_USERNAME
and ECCO_PASSWORD
environment variables. This can be done by exporting the environment variables in the shell before running the script, or by launching julia with
ECCO_USERNAME=myusername ECCO_PASSWORD=mypassword julia
or by invoking
julia> ENV["ECCO_USERNAME"] = "myusername"
julia> ENV["ECCO_PASSWORD"] = "mypassword"
within julia.
Arguments
metadata::ECCOMetadata
: The metadata specifying the dataset to be downloaded.
JRA55
ClimaOcean.DataWrangling.JRA55.JRA55NetCDFBackend
— MethodJRA55NetCDFBackend(length)
Represents a JRA55 FieldTimeSeries backed by JRA55 native .nc files.
ClimaOcean.DataWrangling.JRA55.JRA55PrescribedAtmosphere
— TypeJRA55PrescribedAtmosphere(architecture::AA, time_indices=Colon();
backend = nothing,
time_indexing = Cyclical(),
reference_height = 10, # meters
include_rivers_and_icebergs = false,
other_kw...)
Return a PrescribedAtmosphere
representing JRA55 reanalysis data.
ClimaOcean.DataWrangling.JRA55.JRA55_field_time_series
— MethodJRA55_field_time_series(variable_name;
architecture = CPU(),
grid = nothing,
location = nothing,
url = nothing,
dir = download_jra55_cache,
filename = nothing,
shortname = nothing,
latitude = nothing,
longitude = nothing,
backend = InMemory(),
time_indexing = Cyclical(),
preprocess_chunk_size = 10,
preprocess_architecture = CPU(),
time_indices = nothing)
Return a FieldTimeSeries
containing atmospheric reanalysis data for variable_name
, which describes one of the variables in the "repeat year forcing" dataset derived from the Japanese 55-year atmospheric reanalysis for driving ocean-sea ice models (JRA55-do). For more information about the derivation of the repeat-year forcing dataset, see
Stewart et al. (2020). JRA55-do-based repeat year forcing datasets for driving ocean–sea-ice models, Ocean Modelling, 147, 101557, https://doi.org/10.1016/j.ocemod.2019.101557.
The variable_name
s (and their shortname
s used in NetCDF files) available from the JRA55-do are:
:river_freshwater_flux
("friver"):rain_freshwater_flux
("prra"):snow_freshwater_flux
("prsn"):iceberg_freshwater_flux
("licalvf"):specific_humidity
("huss"):sea_level_pressure
("psl"):relative_humidity
("rhuss"):downwelling_longwave_radiation
("rlds"):downwelling_shortwave_radiation
("rsds"):temperature
("ras"):eastward_velocity
("uas"):northward_velocity
("vas")
Keyword arguments
architecture
: Architecture for theFieldTimeSeries
. Default: CPU()time_indices
: Indices of the timeseries to extract from file. For example,time_indices=1:3
returns aFieldTimeSeries
with the first three time snapshots ofvariable_name
.latitude
: Guiding latitude bounds for the resulting grid. Used to slice the data when loading into memory. Default: nothing, which retains the latitude range of the native grid.longitude
: Guiding longitude bounds for the resulting grid. Used to slice the data when loading into memory. Default: nothing, which retains the longitude range of the native grid.url
: The url accessed to download the data forvariable_name
. Default:ClimaOcean.JRA55.urls[variable_name]
.filename
: The name of the downloaded file. Default:ClimaOcean.JRA55.filenames[variable_name]
.shortname
: The "short name" ofvariable_name
inside its NetCDF file. Default:ClimaOcean.JRA55.jra55_short_names[variable_name]
.interpolated_file
: file holding an Oceananigans compatible version of the JRA55 data. If it does not exist it will be generated.time_chunks_in_memory
: number of fields held in memory. Ifnothing
then the whole timeseries is loaded (not recommended).
Bathymetry
ClimaOcean.Bathymetry.remove_minor_basins!
— Methodremove_minor_basins!(z_data, keep_major_basins)
Remove independent basins from the bathymetry data stored in z_data
by identifying connected regions below sea level. Basins are removed from smallest to largest until only keep_major_basins
remain.
Arguments
z_data
: A 2D array representing the bathymetry data.keep_major_basins
: The maximum number of connected regions to keep. IfInf
is provided then all connected regions are kept.
VerticalGrids
ClimaOcean.VerticalGrids.stretched_vertical_faces
— Methodstretched_vertical_faces(; surface_layer_Δz = 5.0,
surface_layer_height = 100.0,
constant_bottom_spacing_depth = Inf,
maximum_Δz = Inf,
stretching = PowerLawStretching(1.02),
rounding_digits = 1,
depth = 5000)
Return an array of cell interfaces with surface_layer_Δz
spacing in a surface layer of height surface_layer_height
, and stretched according to the function stretching(Δz_above, z_above)
down to depth
. The interfaces extends from Lz = -z[1]
to 0 = z[end]
, where Lz ≥ depth
.
The grid spacing Δz
is limited to be less than maximum_Δz
. The grid is also uniformly-spaced below constant_bottom_spacing_depth
.
rounding_digits
controls the accuracy with which the grid face positions are saved.
OceanSeaIceModels
ClimaOcean.OceanSeaIceModels.FreezingLimitedOceanTemperature
— TypeFreezingLimitedOceanTemperature(FT::DataType) = FreezingLimitedOceanTemperature(LinearLiquidus(FT))
The minimal possible sea ice representation, providing an "Insulating layer" on the surface and clipping the temperature below to the freezing point. Not really a `model'' per se, however, it is the most simple way to make sure that temperature does not dip below freezing. All fluxes are shut down when the surface is below the
T < Tₘ` except for heating to allow temperature to increase.
the melting temperature is a function of salinity and is controlled by the liquidus
.
CrossRealmFluxes
ClimaOcean.OceanSeaIceModels.CrossRealmFluxes.BulkTemperature
— Typestruct BulkTemperature
A type to represent the surface temperature used in fixed-point iteration for surface fluxes following similarity theory. The surface temperature is not calculated but instead provided by either the ocean or the sea ice model.
ClimaOcean.OceanSeaIceModels.CrossRealmFluxes.LatitudeDependentAlbedo
— TypeLatitudeDependentAlbedo([FT::DataType=Float64]; diffuse = 0.069, direct = 0.011)
Constructs a LatitudeDependentAlbedo
object. The albedo of the ocean surface is assumed to be a function of the latitude, obeying the following formula (Large and Yeager, 2009):
α(φ) = α.diffuse - α.direct * cos(2φ)
where φ
is the latitude, α.diffuse
is the diffuse albedo, and α.direct
is the direct albedo.
Arguments
FT::DataType
: The data type of the albedo values. Default isFloat64
.
Keyword Arguments
diffuse
: The diffuse albedo value. Default is0.069
.direct
: The direct albedo value. Default is0.011
.
ClimaOcean.OceanSeaIceModels.CrossRealmFluxes.Radiation
— TypeRadiation([arch = CPU(), FT=Float64];
ocean_emissivity = 0.97,
sea_ice_emissivity = 1.0,
ocean_albedo = LatitudeDependentAlbedo(FT),
sea_ice_albedo = 0.7,
stefan_boltzmann_constant = 5.67e-8)
Constructs a Radiation
object that represents the radiation properties of the ocean and sea ice.
Arguments
arch
: The architecture of the system. Default:CPU()
.FT
: The floating-point type to use. Default:Float64
.
Keyword Arguments
ocean_emissivity
: The emissivity of the ocean surface. Default:0.97
.sea_ice_emissivity
: The emissivity of the sea ice surface. Default:1.0
.ocean_albedo
: The albedo of the ocean surface. Default:LatitudeDependentAlbedo(FT)
.sea_ice_albedo
: The albedo of the sea ice surface. Default:0.7
.stefan_boltzmann_constant
: The Stefan-Boltzmann constant. Default:5.67e-8
.
ClimaOcean.OceanSeaIceModels.CrossRealmFluxes.SimilarityTheoryTurbulentFluxes
— TypeSimilarityTheoryTurbulentFluxes(FT::DataType = Float64;
gravitational_acceleration = default_gravitational_acceleration,
von_karman_constant = convert(FT, 0.4),
turbulent_prandtl_number = convert(FT, 1),
gustiness_parameter = convert(FT, 6.5),
stability_functions = default_stability_functions(FT),
thermodynamics_parameters = PATP(FT),
water_vapor_saturation = ClasiusClapyeronSaturation(),
water_mole_fraction = convert(FT, 0.98),
roughness_lengths = default_roughness_lengths(FT),
similarity_profile_type = LogarithmicSimilarityProfile(),
surface_temperature_type = BulkTemperature(),
bulk_velocity = RelativeVelocity(),
tolerance = 1e-8,
maxiter = 100,
fields = nothing)
SimilarityTheoryTurbulentFluxes
contains parameters and settings to calculate sea-air turbulent fluxes using Monin-Obukhov similarity theory.
Keyword Arguments
gravitational_acceleration
: The gravitational acceleration. Default:default_gravitational_acceleration
.von_karman_constant
: The von Karman constant. Default: 0.4.turbulent_prandtl_number
: The turbulent Prandtl number. Default: 1.gustiness_parameter
: The gustiness parameter that accounts for low wind speed areas. Default: 6.5.stability_functions
: The stability functions. Default:default_stability_functions(FT)
that follow the formulation of Edson et al. (2013).thermodynamics_parameters
: The thermodynamics parameters used to calculate atmospheric stability and saturation pressure. Default:PATP(FT)
, alias forPrescribedAtmosphereThermodynamicsParameters
.water_vapor_saturation
: The water vapor saturation law. Default:ClasiusClapyeronSaturation()
that follows the Clasius-Clapyeron pressure formulation.water_mole_fraction
: The water mole fraction used to calculate theseawater_saturation_specific_humidity
. Default: 0.98, the rest is assumed to be other substances such as chlorine, sodium sulfide, and magnesium.roughness_lengths
: The roughness lengths used to calculate the characteristic scales for momentum, temperature and water vapor. Default:default_roughness_lengths(FT)
, formulation taken from Edson et al (2013).similarity_profile_type
: The type of similarity profile used to relate the atmospheric state to the surface fluxes / characteristic scales.bulk_velocity
: The velocity used to calculate the characteristic scales. Default:RelativeVelocity()
(difference between atmospheric and oceanic speed).tolerance
: The tolerance for convergence. Default: 1e-8.maxiter
: The maximum number of iterations. Default: 100.fields
: The fields to calculate. Default: nothing.
ClimaOcean.OceanSeaIceModels.CrossRealmFluxes.SkinTemperature
— Typestruct SkinTemperature
A type to represent the surface temperature used in the flux calculation. The surface temperature is calculated from the flux balance at the surface. In particular, the surface temperature $θₛ$ is the root of:
\[F(θₛ) - Jᵀ = 0\]
where $Jᵀ$ are the fluxes at the top of the surface (turbulent + radiative), and $F$ is the internal diffusive flux dependent on the surface temperature itself.
Note that all fluxes positive upwards.