Skip to main content

MyAMI specific ion interaction model for calculating stoichiometric equilibrium constants in modified seawater.

Project description

MyAMI

The MyAMI Specific Ion Interaction Model for correcting stoichiometric equilibrium constants (Ks) for variations in seawater composition, made available available as the pymyami python package.

This package is a re-factor of the MyAMI model published by Hain et al. (2015), which is available here. The key differences between the original model and this package are:

  • Speed: All calculations have been vectorised using NumPy, making MyAMI 2-3 orders of magnitude faster.
  • Direct Calculation: pymyami directly calculates correction factors using the MyAMI model. This differs from Hain et al. (2015), where the focus was on modifying parameters that could be input into the standard equations for calculating stoichiometric equilibrium products.
  • Correction Factor Focus: pymyami produces corrections factors (FX,MyAMI) that can be applied to adjust stoichiometric equilibrium constants for variations in seawater composition, following KX,corr = KX,empirical * FX,MyAMI. For the direct calculation of Ks, including the corrections calculated by pymyami, please see the Kgen project.
  • Available Ions: pymyami allows the modification of any ion in the model, rather than just Mg and Ca: Na+, K+, Mg2+, Ca2+, Sr2+, Cl-, B(OH)4-, HCO3-, CO32- and SO42-.
  • Parameter Transparrency: Wherever possible, parameter tables are now constructed on-the-fly from raw tables in the Appendix of Millero & Pierrot, 1998, making the origin of parameters explicit.
  • Pure Python: There is no longer interface code for interacting with other languages (i.e. MATLAB). This caused a substantial performance bottleneck, and is discouraged. The Kgen project provides a convenient interface to use pymyami in R and MATLAB.
  • Approximation Method: Where very fast calculations are required (e.g. Monte Carlo methods), pymyami uses a high-dimensional polynomial to approximate FX,MyAMI as a function of temperature, salinity, Mg and Ca. This is a very fast approximation, but is only accurate to within ~0.25%.

Kgen

pymyami only calculations correction factors that can be applied to stoichiometric equilibrium constants (Ks). If you are looking for a convenient way to adjust Ks for variations in seawater composition, please see the Kgen project.

Consistency with Hain et al. (2015)

The K correction factors calculated by pymyami are identical to those calculated by the code of Hain et al. (2015), with the exception of K2, KspA and KspC, which differ by 0.36%. This difference arises from minor typo corrections in CO3 coefficients from the original code.

Installation

The model is available as a PyPI package, which can be installed by:

pip install pymyami

Example Usage

from pymyami import calc_Fcorr, approximate Fcorr

# run the model to calculate correction factors
calc_Fcorr(TempC=35, Sal=36.2, Mg=0.03, Ca=0.012)

# use the polynomial approximation to calculate correction factors
approximate_Fcorr(TempC=35, Sal=36.2, Mg=0.03, Ca=0.012)

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

pymyami-2.0a3.tar.gz (1.5 MB view hashes)

Uploaded Source

Built Distribution

pymyami-2.0a3-py3-none-any.whl (1.5 MB view hashes)

Uploaded Python 3

Supported by

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