xwmt.eos module#
Equation-of-state handling for xwmt, delegated to the xeos package.
xwmt derives seawater density (and the thermal-expansion alpha / haline-
contraction beta coefficients used to split density transformations into
heat- and salt-driven components) from layer temperature and salinity. The
actual equation-of-state (EOS) evaluation is delegated to xeos
(hdrake/xeos), so any EOS that xeos supports can be
selected — ideally the same EOS used by the ocean model that produced the data.
See list_eos() (or xeos.list_eos()) for the available formulations.
Two helpers bridge xwmt’s data conventions and xeos:
resolve_eos()turns a user-facingeosspecification (a canonicalxeosid such as"teos10"or"wright97-full", an already-builtxeos.EquationOfState, orNone) into anxeos.EquationOfState(orNone).convert_ts()converts the dataset’s temperature/salinity — whose kinds the user declares viat_var/s_var— into the temperature/salinity kinds the chosen EOS expects, usinggsw. This guards against the silent- corruption failure mode where, e.g., conservative temperature is fed to an EOS that expects potential temperature.
- xwmt.eos.convert_ts(t, s, eos, t_var, s_var, p, lon=None, lat=None)#
Convert
(t, s)into the temperature/salinity kinds thateosexpects.All conversions go through absolute salinity / conservative temperature (the “hubs” that
gsw’s conversion routines are written around) and are applied lazily viaxarray.apply_ufunc(), so xarray labels and dask laziness are preserved. When the input kinds already match whateoswants (e.g. the default conservative/absolute inputs for a TEOS-10 EOS), the inputs are returned unchanged with no conversion.- Parameters:
t (xr.DataArray) – Temperature and salinity whose kinds are declared by
t_var/s_var.s (xr.DataArray) – Temperature and salinity whose kinds are declared by
t_var/s_var.eos (xeos.EquationOfState) – Target EOS; its
temperature/salinityproperties give the required kinds.t_var ({"conservative", "potential", "in-situ"}) – Kind of the input temperature
t.s_var ({"absolute", "practical"}) – Kind of the input salinity
s.p (xr.DataArray) – In-situ sea pressure [dbar], used by the salinity and in-situ-temperature conversions.
lon (xr.DataArray, optional) – Longitude/latitude, used for the practical<->absolute salinity conversion.
lat (xr.DataArray, optional) – Longitude/latitude, used for the practical<->absolute salinity conversion.
- Returns:
(temp, salt) – Temperature and salinity in the kinds required by
eos.- Return type:
tuple of xr.DataArray
- xwmt.eos.list_eos()#
Return the sorted list of canonical EOS ids supported by
xeos.
- xwmt.eos.resolve_eos(eos)#
Resolve an
eosspecification to anxeos.EquationOfState.- Parameters:
eos (None, str, or xeos.EquationOfState) –
None: no EOS; the caller must supplyalpha,betaand the requested density variable directly in the dataset.str: a canonicalxeosEOS id (seelist_eos()), e.g."teos10","wright97-full","jmd95".xeos.EquationOfState: used as-is (e.g. one built withxeos.from_model(...)or a parameterisedxeos.equation_of_state("linear", rho0=..., talpha=..., sbeta=...)).
- Return type:
xeos.EquationOfState or None