polaris.ocean.eos.convert_tracers
- polaris.ocean.eos.convert_tracers(ds: Dataset, source: str, target: str, pressure: DataArray | float, lon: DataArray | ndarray | float, lat: DataArray | ndarray | float, tracer_pairs: Sequence[tuple[str, str]] = (('temperature', 'salinity'),)) Dataset[source]
Convert temperature and salinity pairs in
dsbetween the TEOS-10 convention (conservative temperature and absolute salinity) and the MPAS-Ocean convention (potential temperature and practical salinity) using GSW.The conversion is performed on a copy;
dsis not modified. Cells where either tracer is NaN (e.g. below the bathymetry) stay NaN.Notes
gsw.pt_from_CT()andgsw.CT_from_pt()take no pressure at all, sopressureenters only throughgsw.SP_from_SA()andgsw.SA_from_SP(), whose sensitivity to pressure is far smaller than the absolute-salinity correction itself. An approximate pressure is therefore entirely adequate. In particular, when converting from the MPAS-Ocean convention to TEOS-10, a pressure computed from the (not yet converted) tracers is accurate enough.- Parameters:
ds (xarray.Dataset) – Dataset containing each of the temperature and salinity variables named in
tracer_pairs.source ({'teos-10', 'mpas-ocean'}) – The tracer convention of the temperature and salinity in
ds.target ({'teos-10', 'mpas-ocean'}) – The tracer convention to convert to.
pressure (float or xarray.DataArray) – Sea (gauge) pressure in Pa, broadcastable against the tracers.
lon (float, numpy.ndarray or xarray.DataArray) – Longitude(s) in degrees, either a nominal scalar value (e.g. on a planar mesh) or an array with dimension
nCells.lat (float, numpy.ndarray or xarray.DataArray) – Latitude(s) in degrees, a scalar or an array with dimension
nCells, as forlon.tracer_pairs (sequence of tuple of str, optional) – The (temperature, salinity) variable-name pairs to convert.
- Returns:
xarray.Dataset – A new dataset with the given tracer pairs in the
targetconvention.