PyCO2SYS v2 beta version

PyCO2SYS v2 beta version

To get an update when a new version is released, ‘watch’ this topic!

PyCO2SYS v2 is currently still being developed but a beta version is publicly available for you to try out. Please do so and post any feedback (good or bad) here! The beta release is updated when certain milestones are reached, I’ll post an update here when that happens.

You can find the documentation (including install instructions) for PyCO2SYS v2 at mvdh.xyz/PyCO2SYS

At present the core carbonate system calculator is robust and ready to use in production. Other more advanced aspects are still being developed and may still change (see below).

The last update to the beta version was back in August 2025, and then other things intervened (PyCO2SYS is a hobby, not a funded project!). But I’ve been making a lot more progress again in the last few weeks, thanks to a boost from the recent Ocean Sciences Meeting in Glasgow, so another update should not be too far away.


In progress

Adding additional parameterisations with @mmartinmayor
Uncertainty propagation with covariances
Simplify back-end for easier development
Finalise validity checker
Allow adding arbitrary extra (simple) alkalinity components
Integrate NICA-Donnan for organic alkalinity (probably won’t be in the initial v2 release)

For the first time since last August(!), I’ve just released an updated beta version, v2.0.0-b6.

Please give it a try and report back here with any feedback! Even if you just tried it and didn’t run into any problems, that’s still very useful to know.

2 Likes

Awesome! I’ll put @mmartinmayor’s K2 on my to-do list.

2 Likes

Another update has just landed, v2.0.0b7. As per usual, you can install or update to this with pip following the docs at mvdh.xyz/PyCO2SYS.

What’s changed?

  • The store_steps kwarg and functionality has been re-enabled (this was dropped during revisions for the previous beta version). Some intermediate parameters rarely need to be stored, and with store_steps they can be automatically forgotten, saving memory.

Time for another update: v2.0.0b8. Install or update to this with pip following the docs at mvdh.xyz/PyCO2SYS.

What’s changed?

The main change is better __repr__ functions for CO2Systems and CO2System.opts. For example, if you make and then print a CO2System:

import PyCO2SYS as pyco2

co2s = pyco2.sys(ta=2300, dic=2100, t=12.5, s=34)
print(co2s)

then the output might look like this:

CO2System with known alkalinity and dic.
├─ User-defined parameters:
│  └─ alkalinity, dic, salinity, temperature.
└─ Parameterisations and options:
   ├───── opt_pH_scale[ 1]: total pH scale.
   ├─── opt_k_carbonic[10]: Lueker et al. (2000).
   ├─ opt_total_borate[ 1]: Uppström (1974).
   └─────────────── Others: see CO2System.opts.

and if you want to see all the optional settings:

print(co2s.opts)

now gives

CO2System settings.
├─ EQUILIBRIUM CONSTANTS:
│  ├──── opt_pH_scale[ 1]: total pH scale.
│  ├── opt_k_carbonic[10]: Lueker et al. (2000).
│  ├────── opt_k_HSO4[ 1]: Dickson (1990a).
│  ├──────── opt_k_HF[ 1]: Dickson & Riley (1979).
│  ├────── opt_k_BOH3[ 1]: Dickson (1990b).
│  ├─ opt_k_phosphate[ 1]: Yao & Millero (1995).
│  ├─────── opt_k_NH3[ 1]: Clegg & Whitfield (1995).
│  ├──────── opt_k_Si[ 1]: Yao & Millero (1995).
│  ├─── opt_k_calcite[ 1]: Mucci (1983).
│  ├─ opt_k_aragonite[ 1]: Mucci (1983).
│  ├─────── opt_k_H2O[ 1]: Millero (1995).
│  └────── opt_k_HNO2[ 1]: Borer et al. (2024).
├─ PRESSURE CORRECTION FACTORS:
│  ├─ opt_factor_k_H2CO3[ 1]: Millero (1995).
│  ├── opt_factor_k_HCO3[ 1]: Millero (1995).
│  ├── opt_factor_k_BOH3[ 1]: Millero (1979).
│  └─── opt_factor_k_H2O[ 1]: Millero (1995).
├─ TOTAL SALT CONTENTS:
│  ├─ opt_total_borate[ 1]: Uppström (1974).
│  └─────────── opt_Ca[ 1]: Riley & Tongudai (1967).
└─ OTHER SETTINGS:
   ├─────── opt_HCO3_root[ 2]: find high-pH root with DIC-HCO3 known pair.
   ├──── opt_gas_constant[ 3]: 2018 CODATA.
   └─ opt_fugacity_factor[ 1]: pCO2 ≠ fCO2.
Only parameterisations with multiple options are included.

Other changes:

  • A couple of minor bugs squashed (inaccuracies in the online docs).
  • opt_which_fCO2_insitu is now which_fCO2_insitu.
1 Like

This should simplify reporting PyCO2SYS parameters in the attributes of TRACE outputs. Thanks!

1 Like