PyESPER
PyESPER is a Python implementation of MATLAB Empirical Seawater Property Estimation Routines (ESPERs), and the present version consists of a preliminary package which implements these routines. These routines provide estimates of seawater biogeochemical properties at user-provided sets of coordinates, depth, and available biogeochemical properties.
This package is developed in parallel with TRACE-Python.
Installation
To install PyESPER, clone this repository and navigate to the PyESPER folder. It is recommended that you create a virtual environment and install all packages listed in the requirements.txt file. Open a terminal in the PyESPER directory and run
pip install PyESPER
to install the package and required dependencies listed in requirements.txt. Note: Examples rely on the GLODAPv2.2023 dataset, which requires the separate glodap package.
Algorithms
PyESPER offers three algorithms to predict desired variables:
- PyESPER_LIR: Interpolated linear networks (LIRv.3 / ESPERv1.1).
- PyESPER_NN: Neural network estimations (ESPERv1.1).
- PyESPER_Mixed: An averaged ensemble of LIR and NN estimates.
Estimation Logic
The routines calculate coefficients and intercepts across up to 16 equation combinations. The base predictors are always Salinity (S) and Temperature (T). The remaining predictors (A, B, C) shift depending on the target variable.
| Desired Variable | Predictor A | Predictor B | Predictor C |
|---|---|---|---|
| TA, DIC, pH, phosphate | Nitrate | Oxygen | Silicate |
| nitrate | Phosphate | Oxygen | Silicate |
| silicate | Phosphate | Oxygen | Nitrate |
| oxygen | Phosphate | Nitrate | Silicate |
Equation Options:
- S, T, A, B, C
- S, T, A, C
- S, T, B, C
- S, T, C
- S, T, A, B
- S, T, A
- S, T, B
- S, T
- S, A, B, C
- S, A, C
- S, B, C
- S, C
- S, A, B
- S, A
- S, B
- S
Usage
import PyESPER
outputs = PyESPER.emlr_estimate(
DesiredVariables=["TA", "DIC"],
Path="/path/to/Mat_fullgrid/",
OutputCoordinates={
"longitude": [0.0, 180.0],
"latitude": [85.0, -20.0],
"depth": [10, 1000]
},
PredictorMeasurements={
"salinity": [35.0, 34.1],
"temperature": [0.1, 10.0],
"oxygen": [202.3, 214.7],
"silicate": [15.0, 45.2],
"nitrate": [1.2, 30.5]
},
EstDates=[2020.5, 2020.5],
Equations=[1, 2, 8, 16],
PerKgSwTF=True
)
Required Parameters
| Parameter | Type | Description |
|---|---|---|
DesiredVariables |
list[str] |
Variables to return. Options: "TA", "DIC", "pH", "phosphate", "nitrate", "silicate", "oxygen". |
Path |
str |
Absolute or relative path to the downloaded LIR .mat files. |
OutputCoordinates |
dict |
Keys: "longitude" (°E), "latitude" (°N), "depth" (m). Values must be arrays of length n. |
PredictorMeasurements |
dict |
Keys: "salinity", "temperature", "phosphate", "nitrate", "silicate", "oxygen". Values are arrays of length n. Unmeasured variables can be omitted or filled with NaN. |
Optional Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
EstDates |
list[float] |
2002.0 |
Decimal dates for the estimates. Crucial for DIC and pH accuracy. |
Equations |
list[int] |
1:16 |
Specific equation permutations to run (1-16). |
MeasUncerts |
dict |
WOCE Defaults | Keys: "sal_u", "temp_u", "phosphate_u", "nitrate_u", "silicate_u", "oxygen_u". |
pHCalcTF |
bool |
False |
Recalculates pH as if derived from TA/DIC rather than measured via dye. |
PerKgSwTF |
bool |
True |
Set to False if your inputs are volumetric (µmol/L) rather than molal (µmol/kg). Outputs are always molal. |
VerboseTF |
bool |
True |
Toggles terminal logging. |
Outputs
PyESPER returns three dictionaries, shape (n, e) where n is the number of coordinates and e is the number of equations computed:
- Estimates: The computed variables (µmol/kg, except for unitless pH).
- Coefficients: The equation intercepts and weights used for the estimation (LIR algorithm only).
- Uncertainties: The propagated uncertainty bounds for the estimate.
Missing Data Handling: Passing NaN as a coordinate or required predictor parameter will cascade and return NaN for all dependent equation estimates.
References
If you use this package, cite the relevant publications:
- PyESPER Implementation: Carter et al., 2021 (doi: 10.1002/lom3/10461)
- LIRv3 / ESPER_NN (ESPERv1.1): Carter, 2021 (doi: 10.5281/ZENODO.5512697)
- LIARv1: Carter et al., 2016 (doi: 10.1002/lom3.10087)
- LIARv2, LIPHR, LINR: Carter et al., 2018 (doi: 10.1002/lom3.10232)
- LIPR, LISIR, LIOR: Carter et al., 2021 (doi: 10.1002/lom3/10232)
- Neural Network Inspiration (CANYON-B): Bittig et al., 2018 (doi: 10.3389/fmars.2018.00328)
Metadata
Release files for PyESPER 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyesper-1.1.1.tar.gz | 871.3 kB | Without provenance | Details for pyesper-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyesper-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for pyesper-1.1.1-py3-none-any.whl |
Total release size: 1.8 MB
Release files / pyesper-1.1.1.tar.gz
| Download URL | pyesper-1.1.1.tar.gz |
|---|---|
| Size | 871.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
773eafc38761662a530f84561ee483cc82433475e804e521d861cd1264be6085
|
|
BLAKE2b-256 checksum How to use checksums |
e25db9381dd52a8184f8b445cd55e5fd87937064c76b558985d43ff7a26ea74e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / pyesper-1.1.1-py3-none-any.whl
| Download URL | pyesper-1.1.1-py3-none-any.whl |
|---|---|
| Size | 890.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ddaf34f565eeeb4136805acbe2ca3fbec0a89cd415cdb72e3086b3a1932cb61b
|
|
BLAKE2b-256 checksum How to use checksums |
41a7183244863225a869aad02cbb23211b65471722961b4c429a18b147c07eb4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Security for PyESPER 1.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.