seapopym.function package
Subpackages
Submodules
seapopym.function.apply_coefficient_to_primary_production module
Wrapper for the application of the transfert cooeficient to primary production. Use xarray.map_block.
- seapopym.function.apply_coefficient_to_primary_production.primary_production_by_fgroup(state: SeapopymState) xr.Dataset
It is equivalent to generate the fisrt cohort of pre-production.
Input
primary_production [time, latitude, longitude]
functional_group_coefficient [functional_group]
Output
primary_production [functional_group, time, latitude, longitude]
seapopym.function.apply_mask_to_state module
This module provides a function to apply a mask to a Seapopym state dataset.
The apply_mask_to_state function checks if a global mask is present in the state dataset and applies it to filter the dataset accordingly. If no mask is found, the state dataset is returned unchanged.
- seapopym.function.apply_mask_to_state.apply_mask_to_state(state: SeapopymState) SeapopymState
Apply a mask to a state dataset.
seapopym.function.average_acidity module
An average acidity by fgroup computation wrapper. Use xarray.map_block.
- seapopym.function.average_acidity.average_acidity(state: SeapopymState) Dataset
In the open ocean, pH does not exhibit significant temporal or spatial variability. However, in coastal shelf and estuarine regions, pH can fluctuate both diurnally and spatially due to biological activity and freshwater input. Additionally, pH varies with depth. This function is designed to capture such potential variability (e.g. could be useful in a future version of the model that includes vertical diurnal migration of pteropods.).
Depend on: - compute_daylength - mask_by_fgroup.
Input
mask_by_fgroup() [time, latitude, longitude]
compute_daylength() [functional_group, latitude, longitude] in day
day/night_layer [functional_group]
acidity [time, latitude, longitude, layer] dimensionless (pH)
Output
average_acidity [functional_group, time, latitude, longitude] dimensionless (pH)
seapopym.function.average_temperature module
An average temperature by fgroup computation wrapper. Use xarray.map_block.
- seapopym.function.average_temperature.average_temperature(state: SeapopymState) xr.Dataset
Depend on: - compute_daylength - mask_by_fgroup.
Input
mask_by_fgroup() [time, latitude, longitude]
compute_daylength() [functional_group, latitude, longitude] in day
day/night_layer [functional_group]
temperature [time, latitude, longitude, layer] in degC
Output
avg_temperature [functional_group, time, latitude, longitude] in degC
seapopym.function.biomass module
This module contains the post-production function used to compute the biomass. They are run after the production process.
- seapopym.function.biomass.biomass(state: SeapopymState) xr.Dataset
Wrap the biomass computation arround the Numba function biomass_sequence.
seapopym.function.cell_area module
Module specific to the cell surface area computation.
seapopym.function.day_length module
Functions used to calculate the length of the day.
- seapopym.function.day_length.day_length(state: SeapopymState) xr.Dataset
seapopym.function.global_mask module
Funcitons used to generate a landmask from any forcing data.
- seapopym.function.global_mask.global_mask(state: SeapopymState) xr.Dataset
Create a global mask from temperature forcing in the state of the model.
seapopym.function.limits module
Compute the layers depth. Based on the O. Titaud work from 2018.
- seapopym.function.limits.compute_limits_from_zeu_lat_sst(zeu: DataArray, sst: DataArray, layer_bounds: dict | None = None) Dataset
Compute the layers limits from zeu and definition. Apply a correction based on latitude and sst.
Based on 2020 report evolution for cmems.
Parameters
- zeuxarray.DataArray
3D DataArray containing euphotic depth data.
- sstxarray.DataArray
3D DataArray countaining sea surface temperature data.
- layer_boundsdict
layer bounds definition w.r.t. zeu Default: {“epipelagic”: 1.5, “upper_mesopelagic”: 4.5, “lower_mesopelagic”: 10.5, “treshold”: 1000.0}
Returns
- xarray.Dataset
A Dataset containing limits of layers wrt to euphotic depth.
seapopym.function.mask_by_functional_group module
Funcitons used to generate a landmask from any forcing data.
seapopym.function.mask_temperature module
A temperature mask computation wrapper. Use xarray.map_block.
- seapopym.function.mask_temperature.mask_temperature(state: SeapopymState) xr.Dataset
It uses the min_temperature.
Depend on
min_temperature()
average_temperature()
Input
min_temperature [cohort_age]
average_temperature [functional_group, time, latitude, longitude]
Output
mask_temperature_by_cohort_by_functional_group [functional_group, time, latitude, longitude, cohort_age]
NOTE(Jules): Warning : average temperature by functional group (because of daily vertical migration) and not by layer. We therefore have a function with a high cost in terms of computation and memory space.
seapopym.function.min_temperature module
An average temperature by fgroup computation wrapper. Use xarray.map_block.
- seapopym.function.min_temperature.min_temperature_by_cohort(state: SeapopymState) xr.Dataset
Define the minimal temperature of a cohort to be recruited.
Input
mean_timestep [functional_group, cohort_age]
tr_max [functional_group]
tr_rate [functional_group]
Output
min_temperature [functional_group, cohort_age] : a datarray with cohort_age as coordinate and
minimum temperature as value.
Note:
The minimal temperature for recruitment is defined as: - Temperature = log(Tau_r / Tau_r_0) / Gamma_Tau_r Which is calculated from the equation Tau_r = Tau_r_0 * exp(Gamma_Tau_r * Temperature) Where Tau_r is equal to the cohorte age (delta_t -> Tau_r_0).
seapopym.function.mortality_acidity_field module
Mortality field calculations for ocean acidification effects.
- seapopym.function.mortality_acidity_field.mortality_acidity_bed_field(state: SeapopymState) xr.Dataset
Generate mortality field using Bednarsek et al. (2022) equation.
Uses the linear relationship between temperature, pH and mortality from Bednarsek equation: mortality = lambda_0_bed + gamma_lambda_temperature_bed * T + gamma_lambda_acidity_bed * pH The result is converted to a daily mortality rate.
Parameters
- stateSeapopymState
The model state containing forcing and configuration data.
Returns
- xr.Dataset
Dataset containing the mortality_field variable with Bednarsek mortality rates.
Notes
Original Bednarsek equation gives weekly mortality percentage
Converted to daily rate by dividing by (100 * 7)
Negative values are clipped to 0
- seapopym.function.mortality_acidity_field.mortality_acidity_field(state: SeapopymState) xr.Dataset
Use the relation between temperature, pH and mortality to generate the mortality field.
Depend on
average_temperature()
acidity
Input
average_temperature [functional_group, time, latitude, longitude]
acidity [time, latitude, longitude] (pH)
inv_lambda_max [functional_group]
inv_lambda_rate [functional_group]
Output
mortality_field [functional_group, time, latitude, longitude]
seapopym.function.mortality_field module
A temperature mask computation wrapper. Use xarray.map_block.
- seapopym.function.mortality_field.mortality_field(state: SeapopymState) xr.Dataset
Use the relation between temperature and mortality to generate the mortality field.
Depend on
average_temperature()
Input
average_temperature [functional_group, time, latitude, longitude]
lambda_temperature_0 [functional_group]
gamma_lambda_temperature [functional_group]
Output
mortality_field [functional_group, time, latitude, longitude]
Note:
The mortality field is computed as follow: - lambda = lambda_temperature_0 * exp(gamma_lambda_temperature * T) - B_t = B_(t-1) * exp(-dt * lambda)
Which is equivalent to: - tau_m = tau_m_0 * exp(gamma_tau_m * T) Where tau_m is equal to 1/lambda, tau_m_0 is equal to 1/lambda_temperature_0 and gamma_tau_m is equal to -gamma_lambda_temperature.
seapopym.function.production module
This module contains the function used to compute the recruited population in the NotTransport model. They are run in sequence in timeseries order.
- seapopym.function.production.production(state: SeapopymState) xr.Dataset
Compute the production using a numba jit function.
- seapopym.function.production.production_initial_condition(state: SeapopymState) xr.Dataset
Compute the production using a numba jit function. Export the initial conditions.
- seapopym.function.production.production_space_optimized(state: SeapopymState) xr.Dataset
Compute the production using a numba jit function.
- seapopym.function.production.production_unrecruited(state: SeapopymState) xr.Dataset
Compute the production using a numba jit function. Export the unrecruited production (pre-production).