polaris.ocean.vertical.diagnostics.vertical_coord_from_location

polaris.ocean.vertical.diagnostics.vertical_coord_from_location(ds, location, allow_reconstruct=False, ds_vert=None)[source]

Get the vertical coordinate field appropriate for a variable at a given location in ds

Parameters:
  • ds (xarray.Dataset) – A dataset with no Time dimension or a Time dimension of length one

  • location ({'cell-center', 'cell-interfaces', 'cell-top'}) – Where the variable is defined: layer midpoints, layer interfaces, or the top of each layer

  • allow_reconstruct (bool, optional) – Whether to reconstruct the coordinate from layerThickness via _reconstruct_z_mid_and_interface() when the data set does not carry the field directly

  • ds_vert (xarray.Dataset, optional) – The vertical coordinate dataset containing bottomDepth and optionally minLevelCell and maxLevelCell, used when reconstructing the geometry

Returns:

coord (xarray.DataArray) – The elevation of ds[var_name], in m, positive up, on nCells and the vertical dimension appropriate to location. A Time dimension of length one is retained if present. var_name is zMid, GeomZInterface or zTop for location 'cell-center', 'cell-interfaces' or 'cell-top', respectively

Raises:

ValueError – If location is not one of the supported values, the corresponding field is not present in the dataset and it may not be reconstructed, or ds has a Time dimension of length other than one