Skip to main content

xarray-enabled wrappers for various Equations of State of seawater

Project description

xeos

Lightweight, xarray-enabled wrappers for seawater equations of state.

Ocean models (MOM6, MITgcm, MPAS-Ocean, Oceananigans) differ in the equation of state (EOS) they use, and many let you change it at run time. Python post-processing then often applies a different EOS than the simulation did, silently corrupting derived quantities like density, thermal expansion, and water-mass transformation diagnostics. xeos lets you pick the EOS that matches your run — by the model's own selector string — and apply it to xarray/dask data through one uniform API.

It stays lightweight on purpose: the polynomial/rational equations of state are vendored as small numpy kernels, so the core install needs only numpy + xarray. TEOS-10 (via gsw) is an optional extra.

Install

pip install xeos              # core (numpy + xarray): all vendored EOS
pip install xeos[teos10]      # adds TEOS-10 via gsw
pip install xeos[complete]    # gsw + numba acceleration

Usage

Match your model run by its selector string:

import xeos

# MOM6 run with EQN_OF_STATE = "WRIGHT_FULL"
eos = xeos.from_model("MOM6", "WRIGHT_FULL")
rho = eos.rho(theta, salt, pressure)     # xarray DataArrays in, labeled DataArray out
a   = eos.alpha(theta, salt, pressure)   # thermal expansion
b   = eos.beta(theta, salt, pressure)    # haline contraction

# MITgcm eosType = 'JMD95Z'
xeos.from_model("MITgcm", "JMD95Z").rho(theta, salt, p)

# MPAS-Ocean config_eos_type = 'jm'
xeos.from_model("MPAS-Ocean", "jm").rho(theta, salt, p)

# Oceananigans TEOS10EquationOfState
xeos.from_model("Oceananigans", "TEOS10EquationOfState").rho(CT, SA, p)

Or address an EOS directly:

xeos.equation_of_state("jmd95").rho(t, s, p)
xeos.rho(t, s, p, eos="wright97-full")          # one-off functional form
xeos.list_eos()                                  # what's available

Inputs may be scalars, numpy arrays, or xarray DataArrays (dask-backed arrays stay lazy). Pressure is sea pressure in dbar by default.

Conventions

xeos does not silently convert inputs. Each EOS declares the temperature and salinity it expects: TEOS-10 and the Roquet polynomials use conservative temperature + absolute salinity; the others use potential temperature + practical salinity (see eos.temperature / eos.salinity). Explicit conversion helpers live in xeos.conventions (these need the gsw extra).

Supported equations of state

xeos.list_eos() returns the current set. As of now:

  • linear — configurable (MOM6/MITgcm/Oceananigans LINEAR)
  • wright97-full, wright97-reduced — Wright 1997 (MOM6 WRIGHT_FULL, WRIGHT/WRIGHT_RED)
  • jmd95 — Jackett & McDougall 1995 (MITgcm JMD95Z/JMD95P; also MOM6 UNESCO/JACKETT_MCD, which are this fit — not EOS-80)
  • unesco — UNESCO/EOS-80, Fofonoff & Millard 1983 (MITgcm UNESCO)
  • mdjwf — McDougall et al. 2003 (MITgcm MDJWF)
  • teos10-poly55 — Roquet 55-term polynomial / TEOS-10 density form (Oceananigans TEOS10EquationOfState, MOM6 ROQUET_RHO/NEMO)
  • roquet-spv — Roquet 55-term specific-volume form (MOM6 ROQUET_SPV)
  • roquet-{linear,cabbeling,cabbeling-thermobaricity,freezing,second-order,simplest-realistic} — idealized second-order Roquet forms (Oceananigans RoquetSeawaterPolynomial(:…))
  • mpas-linear, mpas-jm, mpas-wright — MPAS-Ocean / E3SM config_eos_type = linear/jm/wright; mpas-jm and mpas-wright reuse the jmd95 and wright97-reduced kernels (MPAS-O's jm/wright are the same EOS)
  • teos10 — TEOS-10 via gsw (its 75-term Roquet polynomial, not the exact Gibbs function; MOM6/MITgcm TEOS10)

Not yet implemented (planned, slot into the same registry): MOM6 JACKETT_06 and WRIGHT legacy-buggy, and MITgcm POLY3 (per-level runtime coefficients).

Full literature references with DOIs are in the usage docs.

Development

pip install -e .[test]
pytest                       # validates vendored kernels against frozen fixtures

Test "truth" values are generated from authoritative reference packages in a pinned, separate environment and frozen into xeos/tests/reference/truth.json; the test suite reads that file and stays lightweight. See xeos/tests/reference/README.md to regenerate.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xeos-0.1.0.tar.gz (69.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xeos-0.1.0-py3-none-any.whl (80.4 kB view details)

Uploaded Python 3

File details

Details for the file xeos-0.1.0.tar.gz.

File metadata

  • Download URL: xeos-0.1.0.tar.gz
  • Upload date:
  • Size: 69.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for xeos-0.1.0.tar.gz
Algorithm Hash digest
SHA256 63ea705977f355293546610f6c7e331503e9f418b2dba960f10be6d36c94d245
MD5 4e043f1c39d78e07560194c9ccbc6a30
BLAKE2b-256 2856d80c5810f75a6e8d64cd6d26d7e64054a67a7b4d815119667921cb4507c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for xeos-0.1.0.tar.gz:

Publisher: python-publish.yml on hdrake/xeos

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xeos-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: xeos-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 80.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for xeos-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7ca8ef946fa692bcd1b42cce760adfa8b15b2cefac2aa1ab1c7ceda49d1ef3d9
MD5 419d9a75097e5db4cbdd783dba42292c
BLAKE2b-256 ec91c9298660411238506555084bd46601fd4ee77773bad767b566c1770cbbe5

See more details on using hashes here.

Provenance

The following attestation bundles were made for xeos-0.1.0-py3-none-any.whl:

Publisher: python-publish.yml on hdrake/xeos

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page