xoa.grid.dz2depth

xoa.grid.dz2depth(dz, positive=None, zdim=None, ref=None, ref_type='infer', centered=False)[source]

Integrate layer thicknesses to compute depths

The output depths are the depths at the bottom of the layers and the top is at a depth of zero. Thus, the output array has the same dimensions as the input array of layer thinknesses.

Parameters:
  • dz (xarray.DataArray) – Layer thinknesses

  • positive (str, int, None) – Direction over wich coordinates are increasing: 0|"infer"|"guess", 1|"up", -1|"down" When “up”, the first level is supposed to be the bottom and the output coordinates are negative. When “down”, first level is supposed to be the top and the output coordinates are positive. When “guess”, the dz array must have an axis coordinate of the same name as the z dimension, and this coordinate must have a valid positive attribute.

  • zdim (str) – Name of the vertical dimension. If note set, it is infered with get_cf_dims().

  • ref (xarray.DataArray) –

    Reference array converting layer thicknesses to depth:

    • If positive up, it is expected to be the SSH (sea surface heigth) by default

    • If positive down, it is expected to be by default the depth of ground also known as bathymetry, which should be positive.

  • ref_type (str, int) – Type of ref: 0|"infer", 1|"top"|"ssh", -1|"bottom"|"bathy"

  • centered (bool) – Get depth a the middle of layers instead at their edge

Returns:

xarray.DataArray – Output depths with the same dimensions as input array.

Example

In [1]: dz = xr.DataArray([1., 3., 4.], dims="nz")

# Positive down
In [2]: print(dz2depth(dz, "down"))
<xarray.DataArray 'depth' (nz: 4)>
array([0., 1., 4., 8.])
Dimensions without coordinates: nz
Attributes:
    positive:       down
    axis:           Z
    long_name:      Depth
    standard_name:  ocean_layer_depth
    units:          m

# Positive up
In [3]: print(dz2depth(dz, "up"))
<xarray.DataArray 'depth' (nz: 4)>
array([-8., -7., -4.,  0.])
Dimensions without coordinates: nz
Attributes:
    positive:       up
    axis:           Z
    long_name:      Depth
    standard_name:  ocean_layer_depth
    units:          m