momlevel.derived module

derived.py - module for calculating derived fields

momlevel.derived.adjust_negative_n2(n2, zcoord='z_l')

Function to adjust negative values of N^2

This function removes negative values of the buoyancy frequency based on the methods described in:

Chelton, D. B., et al. (1998). Geographical Variability of the First

Baroclinic Rossby Radius of Deformation, Journal of Physical Oceanography, 28(3), 433-460. https://doi.org/10.1175/1520-0485(1998)028%3C0433:GVOTFB%3E2.0.CO;2

Parameters:
  • n2 (xarray.core.dataarray.DataArray) – Brunt-Väisälä frequency, or buoyancy frequency, in s-2

  • zcoord (str, optional) – Vertical coorindate name, by default “z_l”

Returns:

Adjusted Brunt-Väisälä frequency, or buoyancy frequency, in s-2

Return type:

xarray.core.dataarray.DataArray

momlevel.derived.calc_alpha(thetao, so, pres, eos='Wright')

Function to calculate the thermal expansion coefficient (alpha)

This function calculates the thermal expansion coefficient from potential temperature, salinity, and pressure. The equation of state can be specified with and available one from the momlevel.eos module.

Parameters:
  • thetao (xarray.core.dataarray.DataArray) – Sea water potential temperature in units = degC

  • so (xarray.core.dataarray.DataArray) – Sea water salinity in units = 0.001

  • pres (xarray.core.dataarray.DataArray) – Sea water absolute pressure, in units of Pa

  • eos (str) – Equation of state, by default “Wright”

Returns:

Thermal expansion coefficient

Return type:

xarray.core.dataarray.DataArray

momlevel.derived.calc_beta(thetao, so, pres, eos='Wright')

Function to calculate the haline contraction coefficient (beta)

This function calculates the haline contraction coefficient from potential temperature, salinity, and pressure. The equation of state can be specified with and available one from the momlevel.eos module.

Parameters:
  • thetao (xarray.core.dataarray.DataArray) – Sea water potential temperature in units = degC

  • so (xarray.core.dataarray.DataArray) – Sea water salinity in units = 0.001

  • pres (xarray.core.dataarray.DataArray) – Sea water absolute pressure, in units of Pa

  • eos (str) – Equation of state, by default “Wright”

Returns:

Thermal expansion coefficient

Return type:

xarray.core.dataarray.DataArray

momlevel.derived.calc_coriolis(lat)

Function to calculate the coriolis parameter

This function calculates the coriolis parameter from an array of latitude values

Parameters:

lat (xarray.core.dataarray.DataArray) –

Returns:

Coriolis parameter in units of s-1

Return type:

xarray.core.dataarray.DataArray

momlevel.derived.calc_dz(levels, interfaces, depth, top=0.0, bottom=None, fraction=False)

Function to calculate dz that accounts for partial bottom cells

This function uses the 2-dimensional bathymetry and the vertical coordinate levels and interfaces to calculate a 3-dimensional dz field that properly accounts for partial bottom cells.

A specific depth range can be provided using the top and bottom arguments to request dz over a specified depth range.

Parameters:
  • levels (xarray.core.dataarray.DataArray) – Vertical coordinate cell centers (1-dimensional)

  • interfaces (xarray.core.dataarray.DataArray) – Vertical coordinate cell interfaces (1-dimensional)

  • depth (xarray.core.dataarray.DataArray) – Bathymetry field in same units as coordinate (2-dimensional)

  • top (float) – Upper bound if a specific depth range is requested. Must be in the same units as depth, by default 0.0

  • bottom (float) – Lower bound if a specific depth range is requested. Must be in the same units as depth, by default None

  • fraction (bool) – If True, return fraction of cell. If False, return raw dz, by default False

Returns:

dz (3-dimensional)

Return type:

xarray.core.dataarray.DataArray

momlevel.derived.calc_masso(rho, volcello, tcoord='time')

Function to calculate the total ocean mass

This function calculates the total ocean mass by multiplying the in situ density by cell volume and summing across all non-time coordinates and applying appropriate CF metadata.

Parameters:
  • rho (xarray.core.dataarray.DataArray) – The in situ density field in units of kg m-3

  • volcello (xarray.core.dataarray.DataArray) – The volcello field in units of m3

  • tcoord (str, optional) – Name of the time coordinate, if present, by default “time”

Returns:

Scalar total ocean mass (kg)

Return type:

xarray.core.dataarray.DataArray

momlevel.derived.calc_n2(thetao, so, eos='Wright', gravity=-9.8, patm=101325.0, zcoord='z_l', interfaces=None, adjust_negative=False)

Function to calculate the buoyancy frequency

This function calculates the Brunt-Väisälä frequency which is commonly used to evaluate stratification. The equivalent field in CMIP is obvfsq.

The buoyancy frequency is calculated independent of the effects of pressure by calculating derivatives from locally referenced potential temperature.

Note that this field differs from the online calculation of obvfsq in that the default behavior is to calculate the buoyancy frequency at the cell centers whereas the model’s default behavior is calculate this quantity on the cell edges.

This field can be converted to cycles per hour (CPH) via:

np.sqrt(n2)*3600.

If adjust_negative is True, negative values are corrected according to the method described in Chelton et al. 1998.

Parameters:
  • thetao (xarray.core.dataarray.DataArray) – Sea water potential temperature in units = degC

  • so (xarray.core.dataarray.DataArray) – Sea water salinity in units = 0.001

  • eos (str, optional) – Equation of state to use in calculations, by default “Wright”

  • gravity (float, optional) – Gravitational acceleration constant in m s-2, by default -9.8

  • patm (float or xarray.core.dataarray.DataArray) – Atmospheric pressure at the sea surface in Pa, by default 101325 Pa (US Standard Atmosphere)

  • zcoord (str, optional) – Vertical coorindate name, by default “z_l”

  • interfaces (xarray.core.dataarray.DataArray, optional) – Vertical coordinate cell interfaces, by default None If provided, calculation will be performed on cell edges.

  • adjust_negative (bool, optional) – Adjust negative values, by default False

Returns:

Brunt-Väisälä frequency, or buoyancy frequency, in s-2

Return type:

xarray.core.dataarray.DataArray

See also

adjust_negative_n2

Adjustment for negative values of N2

calc_alpha

Calculates thermal expansion coefficient

calc_beta

Calculates haline contraction coefficient

momlevel.derived.calc_pv(zeta, coriolis, n2, gravity=9.8, coord_dict=None, symmetric=False, units='m', interp_n2=True)

Function to calculate ocean potential vorticity

This function calculates potential vorticity given the relative vorticity, Coriolis parameter, and buoyancy frequency as inputs.

Parameters:
  • zeta (xarray.core.dataarray.DataArray) – Vertical component of the relative vorticity in units = s-1

  • coriolis (xarray.core.dataarray.DataArray) – Coriolis parameter grid cell corners, in units = s-1

  • n2 (xarray.core.dataarray.DataArray) – Brunt-Väisälä frequency in units = s-2

  • gravity (float, optional) – Gravitational acceleration constant, by default 9.8 m s-2

  • coord_dict (dict, optional) – Dictionary of xgcm coordinate name mappings, if different from the MOM6 default values, by default None

  • interp_n2 (bool, optional) – Interpolate N^2 to the corner points. Set to False to calculate potential vorticity on the cell centers, by default True

  • symmetric (bool) – Flag denoting symmetric grid, by default False

  • units (str, optional) – Output units convention of either m or cm per second. The cm per second option takes the absolute value of potential vorticity and multiplies by 1.e14, by default “m”

Returns:

Ocean potential vorticity in m-1 s-1

Return type:

xarray.core.dataarray.DataArray

See also

calc_n2

Calculates Brunt-Väisälä (buoyancy) frequency

calc_rel_vort

Calculate relative vorticity (zeta)

momlevel.derived.calc_rel_vort(dset, varname_map=None, coord_dict=None, symmetric=False)

Function to calculate relative vorticity

This function calculates the vertical component of the relative vorticity from the u and v components of the flow.

Parameters:
  • dset (xarray.core.dataset.Dataset) – Input dataset. Required variables are uo, vo, dxCu, dyCv, and areacello_bu

  • varname_map (dict, optional) – Dictionary of variable mappings. Variables are renamed according to these mappings at the start of the routine, by default None.

  • coord_dict (dict, optional) – Dictionary of xgcm coordinate name mappings, if different from the MOM6 default values, by default None

  • symmetric (bool) – Flag denoting symmetric grid, by default False

Returns:

Ocean relative vorticity in s-1

Return type:

xarray.core.dataarray.DataArray

momlevel.derived.calc_rho(thetao, so, pres, eos='Wright')

Function to calculate in situ density

This function calculates in situ density from potential temperature, salinity, and pressure. The equation of state can be specified with and available one from the momlevel.eos module.

Parameters:
  • thetao (xarray.core.dataarray.DataArray) – Sea water potential temperature in units = degC

  • so (xarray.core.dataarray.DataArray) – Sea water salinity in units = 0.001

  • pres (xarray.core.dataarray.DataArray) – Sea water absolute pressure, in units of Pa

  • eos (str) – Equation of state, by default “Wright”

Returns:

In situ sea water density

Return type:

xarray.core.dataarray.DataArray

momlevel.derived.calc_rhoga(masso, volo)

Function to calculate global average ocean density

This function calculates the global average ocean density based on the total ocean mass and volume and applies appropriate metadata.

Parameters:
  • masso (xarray.core.dataarray.DataArray) – Total ocean mass (kg)

  • volo (xarray.core.dataarray.DataArray) – Total ocean volume (m3)

Returns:

Scalar of global average ocean density

Return type:

xarray.core.dataarray.DataArray

momlevel.derived.calc_rossby_rd(wave_speed, coriolis)

Function to calculate Rossby radius of deformation

This function calculates the Rossby radius of deformation given the wave speed and coriolis parameter.

Parameters:
  • wave_speed (xarray.core.dataarray.DataArray) – Ocean gravity wave speed, typically for the first baroclinic mode in units of m s-1

  • coriolis (xarray.core.dataarray.DataArray) – Coriolis parameter grid cell corners, in units = s-1

Returns:

Rossby radius of deformation, in units = m

Return type:

xarray.core.dataarray.DataArray

momlevel.derived.calc_spice(thetao, so)

Function to calculate seawater spiciness

This function uses the Flament 2002 methodology for calculating seawater spiciness:

Flament, P. 2002: A state variable for characterizing water masses and their diffusive stability: spiciness. Progress in Oceanography, 54, 493–501. https://doi.org/10.1016/S0079-6611(02)00065-4

Parameters:
  • thetao (xarray.core.dataarray.DataArray) – Sea water potential temperature in deg C

  • so (xarray.core.dataarray.DataArray) – Sea water practical salinity in PSU

Returns:

Sea water spiciness, unitless

Return type:

xarray.core.dataarray.DataArray

momlevel.derived.calc_stability_angle(thetao, so, pres, eos='Wright', zcoord='z_l')

Function to calculate the stability angle

This function calculates the stability angle, also known as the Turner angle, which indicates the stability properties of the water column with respect to double diffusion.

The water column is considered stable if the angle is between -45 and 45 degrees. The column is unstable with respect to salt fingering if the angle is less than -45 degrees. The column is unstable with respect to diffusion.

Parameters:
  • thetao (xarray.core.dataarray.DataArray) – Sea water potential temperature in units = degC

  • so (xarray.core.dataarray.DataArray) – Sea water salinity in units = 0.001

  • pres (xarray.core.dataarray.DataArray) – Sea water absolute pressure, in units of Pa

  • eos (str) – Equation of state, by default “Wright”

  • zcoord (str, optional) – Vertical coorindate name, by default “z_l”

Returns:

Stability angle in degrees

Return type:

xarray.core.dataarray.DataArray

momlevel.derived.calc_volo(volcello)

Function to calculate the total ocean volume

This function sums the 3-dimensional volcello field and adds in the appropriate CF metadata.

Parameters:

volcello (xarray.core.dataarray.DataArray) – The volcello field as a function of z, y, and x (m3)

Returns:

Scalar total ocean volume (m3)

Return type:

xarray.core.dataarray.DataArray

momlevel.derived.calc_wave_speed(n2, dz, zcoord='z_l')

Function to calculate the gravity wave speed of first baroclinic mode

This function calculates the c1 based on the buoyancy frequency (N^2). N^2 is adjusted to account for negative values.

Parameters:
  • n2 (xarray.core.dataarray.DataArray) – Brunt-Väisälä frequency, or buoyancy frequency, in s-2

  • dz (xarray.core.dataarray.DataArray) – 3-dimensional dz field accounting for partial bottom cells

  • zcoord (str, optional) – Vertical coorindate name, by default “z_l”

Returns:

Ocean gravity wave speed of the first baroclinic mode in units of m s-1

Return type:

xarray.core.dataarray.DataArray