Seawater Chemistry Calculator

Marine carbonate chemistry

by K-Dense-AI · MIT license · ★ 45,977 on GitHub · updated Sep 21

Marine carbonate chemistry cover

Solves seawater carbonate chemistry with PyCO2SYS for chemical oceanography, ocean acidification, and marine carbon-cycle research. Use for paired total alkalinity, dissolved inorganic carbon, pH, or seawater pCO2/fCO2 measurements;…

---
name: marine-carbonate-chemistry
description: Solves seawater carbonate chemistry with PyCO2SYS for chemical oceanography, ocean acidification, and marine carbon-cycle research. Use for paired total alkalinity, dissolved inorganic carbon, pH, or seawater pCO2/fCO2 measurements; carbonate speciation; aragonite and calcite saturation; Revelle factors; lab-to-in-situ temperature and pressure corrections; and measurement uncertainty propagation. Applies to carbonate-system calculations, not general aqueous speciation or air-sea gas-flux estimation.
license: MIT
compatibility: Requires Python 3.13 with PyCO2SYS 1.8.3.4 and NumPy. Network access is needed only to install packages or obtain external data; bundled calculations run locally without credentials.
metadata:
  version: "1.1"
  skill-author: K-Dense Inc.
  upstream-version: "PyCO2SYS 1.8.3.4"
  last-reviewed: "2026-10-01"
---

# Marine Carbonate Chemistry

Turn two independent seawater carbonate measurements into a reproducible speciation
table, mineral saturation estimates, and a record of the calculation assumptions.
Targets **PyCO2SYS 1.8.3.4**, tested with Python 3.13 and NumPy 2.5.3. As reviewed on
2026-10-01, this remains the stable PyPI release. The [v2 documentation](https://mvdh.xyz/PyCO2SYS/)

Overview

Turn two independent seawater carbonate measurements into a reproducible speciation table, mineral saturation estimates, and a record of the calculation assumptions. Targets PyCO2SYS 1.8.3.4, tested with Python 3.13 and NumPy 2.5.3. As reviewed on 2026-10-01, this remains the stable PyPI release. The v2 documentation is for a beta with breaking changes; use the v1 documentation for this pin.

Manual install (npx, ZIP)
Claude Codenpx skills add K-Dense-AI/scientific-agent-skills --skill marine-carbonate-chemistry -g -a claude-code
Claude Code (degit)npx degit K-Dense-AI/scientific-agent-skills/skills/marine-carbonate-chemistry#main ~/.claude/skills/marine-carbonate-chemistry
Claude.ai / desktopZip the folder and upload it under Settings → Capabilities → Skills.
Codex, Cursor, other agentsPoint them at SKILL.md. The other files are plain text.

Connects with Agent Alley MCP · agentalley.io/mcp

Files included

  • SKILL.md9.3 KB
Read SKILL.md here
K-Dense-AI/main1 file shown
SKILL.md
Show the full text160 lines

Marine Carbonate Chemistry

Turn two independent seawater carbonate measurements into a reproducible speciation table, mineral saturation estimates, and a record of the calculation assumptions. Targets PyCO2SYS 1.8.3.4, tested with Python 3.13 and NumPy 2.5.3. As reviewed on 2026-10-01, this remains the stable PyPI release. The v2 documentation is for a beta with breaking changes; use the v1 documentation for this pin.

When to use

  • Analyze bottle samples, shipboard carbonate measurements, or acidification experiments.
  • Calculate total-scale pH, seawater pCO2/fCO2, carbonate ion, aragonite/calcite saturation state, or the Revelle factor from a valid measured pair.
  • Convert a system determined at laboratory conditions to specified ocean conditions.
  • Quantify how stated measurement uncertainties affect the calculated results.

This workflow concerns seawater carbonate equilibria. Freshwater, porewaters with substantial uncharacterized alkalinity, brines outside the selected calibration range, and reaction/transport models require additional chemistry and validation. Do not infer an air-sea flux or atmospheric carbon removal from a carbonate equilibrium alone.

Establish the measurement contract

Before running a solver, identify the two measured variables, their units, quality flags, and their temperature/pressure basis. Retain a separate source table containing station, depth, timestamps, methods, reference materials, and original QC codes, joined by sample ID. Do not turn missing values or rejected measurements into zero.

Quantity Required convention
Total alkalinity (TA), DIC, nutrients micromol per kg seawater, not per litre or kg water
Salinity Practical Salinity, not Absolute Salinity in g/kg
Temperature In-situ/measurement temperature in degrees Celsius, not potential or Conservative Temperature
Pressure Sea pressure in dbar; surface sample is 0, not 1 atmosphere
pH Declared total, seawater, free, or NBS scale, at the declared measurement conditions
pCO2 / fCO2 Seawater partial pressure / fugacity in microatm; these are distinct quantities

TA and DIC remain constant during the solver's temperature/pressure conversion for a closed sample. pH and gas parameters change. Two inputs measured at different conditions cannot simply share one temperature value. Establish a consistent measurement basis first. Temperature correction does not repair sample changes caused by gas exchange, biology, evaporation, or mineral dissolution/precipitation.

Use two independent carbonate parameters. pCO2 plus fCO2 is not an independent pair. Three or more measurements enable an overdetermination check: solve independent pairs and compare predicted versus measured third parameters, including their uncertainty. Do not average inconsistent solutions to hide a calibration or scale mismatch.

Install

Create a dedicated environment in the user's working directory:

uv venv --python 3.13 .venv
uv pip install --python .venv/bin/python "PyCO2SYS==1.8.3.4" "numpy==2.5.3"

On Windows the environment's interpreter is .venv/Scripts/python.exe. The commands below use the POSIX interpreter path. Set the shell variable SKILL_DIR to this installed skill's directory. Keep inputs and generated outputs in the working directory.

Workflow

  1. Prepare paired measurements. Use the schema in references/input-and-results.md. Resolve units and quality flags before creating the input file. Supply phosphate and silicate explicitly; zero is an assumption to justify, not a missing-data code.
  2. Choose equilibrium constants. Read references/chemistry-decisions.md for pH scales, carbonic-acid constants, borate, saturation interpretation, and uncertainty limits. Match the study's validated convention and report it. The helper supports carbonic-acid options 10 and 15; other systems require a separately verified direct PyCO2SYS call.
  3. Solve with scripts/solve_carbonate.py. It validates the full input table, solves the pair, checks finite outputs and DIC species balance, then writes carbonate.csv and provenance.json into a new output directory.
  4. Review flags and consistency. Inspect calibration-range and gas-pressure flags, carbonate balance, measured-third-parameter residuals when available, and controls. A successful solve does not validate the sample, constants, or measurement method.
  5. Report at the intended conditions. Results ending _out describe the supplied output temperature/pressure. Unsuffixed results describe input conditions. Gas results retain the helper's uncorrected hydrostatic gas convention (see below). Include parameter pair, pH scale, units, constants, nutrient assumptions, uncertainty scope, software versions, and excluded/flagged samples with the result table.

Worked example: closed-sample condition correction

The following values are synthetic, not field observations. Save this as samples.csv in a working directory. The two samples differ only in DIC; the second represents a fixed-alkalinity CO2-addition comparison. Their measurements are at 25 C and 0 dbar; results are also requested at 10 C and 1000 dbar.

sample_id,par1,par2,salinity,temperature,pressure,total_phosphate,total_silicate,temperature_out,pressure_out,u_par1,u_par2
baseline,2300,2000,35,25,0,0,0,10,1000,2,2
added_co2,2300,2100,35,25,0,0,0,10,1000,2,2

Run from that working directory:

.venv/bin/python "$SKILL_DIR/scripts/solve_carbonate.py" samples.csv \
  --par1-type alkalinity --par2-type dic --k-carbonic 10 \
  --output-dir carbonate-results

For the baseline, the tested version gives input-condition total pH 8.045886, pCO2 396.958 microatm, and aragonite saturation 3.386201. At the specified output conditions, total pH is 8.241241 and aragonite saturation 2.605691. These rounded values are regression checks for this exact setup, not universal seawater benchmarks. With independent 2 micromol/kg uncertainties in TA and DIC only, u_pH_total is about 0.004580. This excludes equilibrium-constant and other input uncertainty. Both rows carry gas_pressure_correction_disabled_output: the output pH and mineral saturation include pressure effects, but the reported pCO2/fCO2 do not include the hydrostatic corrections to CO2 solubility and fugacity. Do not compare those gas values directly with a pressure-corrected subsurface sensor measurement.

For TA + measured pH, use --par2-type ph --ph-scale total only if the source explicitly identifies total-scale pH; replace par2 and u_par2 with the measured pH and its absolute standard uncertainty. A column named merely pH is insufficient to establish its scale.

Uncertainty and interpretation

Optional u_ input columns contain absolute one-standard-deviation uncertainties. They propagate to total pH, pCO2, and aragonite saturation at each requested condition. The helper assumes independent errors and treats unlisted inputs/constants as exact. For covariance, constants uncertainty, or strongly nonlinear uncertainty, follow the decision guide and validate a tailored propagation instead of calling these outputs a complete uncertainty budget.

Omega < 1 indicates thermodynamic undersaturation with respect to the named mineral. It does not establish a dissolution rate or an organism's response. A lower pH across unmatched samples is not by itself evidence of an anthropogenic acidification trend.

Sources and validation boundary

Repository tests exercise the pinned solver, independent-pair round trips, carbon balance, pH-scale equivalence, condition correction, Revelle-factor derivatives, gas-pressure conventions, uncertainty quadrature, CSV errors, and the worked example. The helper calls the local pyco2.sys Python API; it has no HTTP endpoints or authentication. Tests establish software behavior, not independent field-data validation; upstream's validation page also contains historical examples, including a removed pyco2.test interface.

1---
2name: marine-carbonate-chemistry
3description: Solves seawater carbonate chemistry with PyCO2SYS for chemical oceanography, ocean acidification, and marine carbon-cycle research. Use for paired total alkalinity, dissolved inorganic carbon, pH, or seawater pCO2/fCO2 measurements; carbonate speciation; aragonite and calcite saturation; Revelle factors; lab-to-in-situ temperature and pressure corrections; and measurement uncertainty propagation. Applies to carbonate-system calculations, not general aqueous speciation or air-sea gas-flux estimation.
4license: MIT
5compatibility: Requires Python 3.13 with PyCO2SYS 1.8.3.4 and NumPy. Network access is needed only to install packages or obtain external data; bundled calculations run locally without credentials.
6metadata:
7 version: "1.1"
8 skill-author: K-Dense Inc.
9 upstream-version: "PyCO2SYS 1.8.3.4"
10 last-reviewed: "2026-10-01"
11---
12 
13# Marine Carbonate Chemistry
14 
15Turn two independent seawater carbonate measurements into a reproducible speciation
16table, mineral saturation estimates, and a record of the calculation assumptions.
17Targets **PyCO2SYS 1.8.3.4**, tested with Python 3.13 and NumPy 2.5.3. As reviewed on
182026-10-01, this remains the stable PyPI release. The [v2 documentation](https://mvdh.xyz/PyCO2SYS/)
19is for a beta with breaking changes; use the v1 documentation for this pin.
20 
21## When to use
22 
23- Analyze bottle samples, shipboard carbonate measurements, or acidification experiments.
24- Calculate total-scale pH, seawater pCO2/fCO2, carbonate ion, aragonite/calcite
25 saturation state, or the Revelle factor from a valid measured pair.
26- Convert a system determined at laboratory conditions to specified ocean conditions.
27- Quantify how stated measurement uncertainties affect the calculated results.
28 
29This workflow concerns seawater carbonate equilibria. Freshwater, porewaters with
30substantial uncharacterized alkalinity, brines outside the selected calibration range,
31and reaction/transport models require additional chemistry and validation. Do not
32infer an air-sea flux or atmospheric carbon removal from a carbonate equilibrium alone.
33 
34## Establish the measurement contract
35 
36Before running a solver, identify the two measured variables, their units, quality flags,
37and their temperature/pressure basis. Retain a separate source table containing station,
38depth, timestamps, methods, reference materials, and original QC codes, joined by sample ID.
39Do not turn missing values or rejected measurements into zero.
40 
41| Quantity | Required convention |
42|---|---|
43| Total alkalinity (TA), DIC, nutrients | micromol per **kg seawater**, not per litre or kg water |
44| Salinity | Practical Salinity, not Absolute Salinity in g/kg |
45| Temperature | In-situ/measurement temperature in degrees Celsius, not potential or Conservative Temperature |
46| Pressure | Sea pressure in dbar; surface sample is 0, not 1 atmosphere |
47| pH | Declared total, seawater, free, or NBS scale, at the declared measurement conditions |
48| pCO2 / fCO2 | Seawater partial pressure / fugacity in microatm; these are distinct quantities |
49 
50TA and DIC remain constant during the solver's temperature/pressure conversion for a
51closed sample. pH and gas parameters change. Two inputs measured at different conditions
52cannot simply share one `temperature` value. Establish a consistent measurement basis
53first. Temperature correction does not repair sample changes caused by gas exchange,
54biology, evaporation, or mineral dissolution/precipitation.
55 
56Use two independent carbonate parameters. pCO2 plus fCO2 is not an independent pair.
57Three or more measurements enable an overdetermination check: solve independent pairs
58and compare predicted versus measured third parameters, including their uncertainty.
59Do not average inconsistent solutions to hide a calibration or scale mismatch.
60 
61## Install
62 
63Create a dedicated environment in the user's working directory:
64 
65```bash
66uv venv --python 3.13 .venv
67uv pip install --python .venv/bin/python "PyCO2SYS==1.8.3.4" "numpy==2.5.3"
68```
69 
70On Windows the environment's interpreter is `.venv/Scripts/python.exe`. The commands
71below use the POSIX interpreter path. Set the shell variable `SKILL_DIR` to this installed
72skill's directory. Keep inputs and generated outputs in the working directory.
73 
74## Workflow
75 
761. **Prepare paired measurements.** Use the schema in
77 [references/input-and-results.md](references/input-and-results.md). Resolve units and
78 quality flags before creating the input file. Supply phosphate and silicate explicitly;
79 zero is an assumption to justify, not a missing-data code.
802. **Choose equilibrium constants.** Read
81 [references/chemistry-decisions.md](references/chemistry-decisions.md) for pH scales,
82 carbonic-acid constants, borate, saturation interpretation, and uncertainty limits.
83 Match the study's validated convention and report it. The helper supports carbonic-acid
84 options 10 and 15; other systems require a separately verified direct PyCO2SYS call.
853. **Solve with `scripts/solve_carbonate.py`.** It validates the full input table, solves
86 the pair, checks finite outputs and DIC species balance, then writes `carbonate.csv`
87 and `provenance.json` into a new output directory.
884. **Review flags and consistency.** Inspect calibration-range and gas-pressure flags,
89 carbonate balance, measured-third-parameter residuals when available, and controls.
90 A successful solve does not validate the sample, constants, or measurement method.
915. **Report at the intended conditions.** Results ending `_out` describe the supplied
92 output temperature/pressure. Unsuffixed results describe input conditions. Gas results
93 retain the helper's uncorrected hydrostatic gas convention (see below). Include
94 parameter pair, pH scale, units, constants, nutrient assumptions, uncertainty scope,
95 software versions, and excluded/flagged samples with the result table.
96 
97## Worked example: closed-sample condition correction
98 
99The following values are synthetic, not field observations. Save this as `samples.csv`
100in a working directory. The two samples differ only in DIC; the second represents a
101fixed-alkalinity CO2-addition comparison. Their measurements are at 25 C and 0 dbar;
102results are also requested at 10 C and 1000 dbar.
103 
104```csv
105sample_id,par1,par2,salinity,temperature,pressure,total_phosphate,total_silicate,temperature_out,pressure_out,u_par1,u_par2
106baseline,2300,2000,35,25,0,0,0,10,1000,2,2
107added_co2,2300,2100,35,25,0,0,0,10,1000,2,2
108```
109 
110Run from that working directory:
111 
112```bash
113.venv/bin/python "$SKILL_DIR/scripts/solve_carbonate.py" samples.csv \
114 --par1-type alkalinity --par2-type dic --k-carbonic 10 \
115 --output-dir carbonate-results
116```
117 
118For the baseline, the tested version gives input-condition total pH **8.045886**,
119pCO2 **396.958 microatm**, and aragonite saturation **3.386201**. At the specified output
120conditions, total pH is **8.241241** and aragonite saturation **2.605691**. These rounded
121values are regression checks for this exact setup, not universal seawater benchmarks.
122With independent 2 micromol/kg uncertainties in TA and DIC only, `u_pH_total` is about
123**0.004580**. This excludes equilibrium-constant and other input uncertainty.
124Both rows carry `gas_pressure_correction_disabled_output`: the output pH and mineral
125saturation include pressure effects, but the reported pCO2/fCO2 do not include the
126hydrostatic corrections to CO2 solubility and fugacity. Do not compare those gas values
127directly with a pressure-corrected subsurface sensor measurement.
128 
129For TA + measured pH, use `--par2-type ph --ph-scale total` only if the source explicitly
130identifies total-scale pH; replace `par2` and `u_par2` with the measured pH and its absolute
131standard uncertainty. A column named merely `pH` is insufficient to establish its scale.
132 
133## Uncertainty and interpretation
134 
135Optional `u_` input columns contain absolute **one-standard-deviation** uncertainties.
136They propagate to total pH, pCO2, and aragonite saturation at each requested condition.
137The helper assumes independent errors and treats unlisted inputs/constants as exact.
138For covariance, constants uncertainty, or strongly nonlinear uncertainty, follow the
139decision guide and validate a tailored propagation instead of calling these outputs a
140complete uncertainty budget.
141 
142Omega < 1 indicates thermodynamic undersaturation with respect to the named mineral.
143It does not establish a dissolution rate or an organism's response. A lower pH across
144unmatched samples is not by itself evidence of an anthropogenic acidification trend.
145 
146## Sources and validation boundary
147 
148- [PyCO2SYS v1 arguments, units, settings, and result keys](https://pyco2sys.readthedocs.io/en/latest/co2sys_nd/)
149- [Uncertainty propagation](https://pyco2sys.readthedocs.io/en/latest/uncertainty/)
150- [Upstream validation](https://pyco2sys.readthedocs.io/en/latest/validate/)
151- [Stable release](https://github.com/mvdh7/PyCO2SYS/releases/tag/v1.8.3.4)
152- [Humphreys et al. (2022), PyCO2SYS v1.8](https://doi.org/10.5194/gmd-15-15-2022)
153 
154Repository tests exercise the pinned solver, independent-pair round trips, carbon balance,
155pH-scale equivalence, condition correction, Revelle-factor derivatives, gas-pressure
156conventions, uncertainty quadrature, CSV errors, and the worked example. The helper calls
157the local `pyco2.sys` Python API; it has no HTTP endpoints or authentication. Tests establish
158software behavior, not independent field-data validation; upstream's validation page also
159contains historical examples, including a removed `pyco2.test` interface.
160 
View all files on GitHub →

Details

Updated
Sep 21, 2026
License
MIT
Stars on the repo
★ 45,977
Checked
Source
K-Dense-AI/scientific-agent-skills ↗
Creator
K-Dense-AI · 168 listings
View creator

Similar skills

See all →

More from K-Dense-AI

SkillAdaptyv Bio Foundry APIK-Dense-AI/scientific-agent-skills · by K-Dense-AIHow to use the Adaptyv Bio Foundry API and Python SDK for protein experiment design, submission, and results retrieval. Use this skill whenever the user mentions Adaptyv, Foundry API, protein binding assays, protein screening experiments, BLI/SPR assays, thermostability assays, or wants to submit protein sequences for experimental characterization. Also trigger when code imports `adaptyv`, `adaptyv_sdk`, or `FoundryClient`, or references `foundry-api-public.adaptyvbio.com`.★ 46k GitHub starsSkillTime Series MLK-Dense-AI/scientific-agent-skills · by K-Dense-AIThis skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.★ 46k GitHub starsSkillAnalytical Method ValidatorK-Dense-AI/scientific-agent-skills · by K-Dense-AIPlan, execute, and document validation, verification, and transfer of analytical procedures under the governing framework - ICH Q2(R2) and Q14, USP <1220>/<1225>/<1226>, ICH M10 bioanalytical, CLSI EP, or ISO/IEC 17025. Use for HPLC, LC-MS/MS, GC, CE, ICP-MS, dissolution, qNMR, qPCR, NIR, and ligand binding or cell-based assays whenever the question is whether a procedure is fit for its intended purpose. Triggers include "method validation", "analytical method validation", "AMV", "validation protocol", "acceptance criteria", "linearity", "reportable range", "accuracy and precision", "repeatability", "intermediate precision", "recovery", "LOD", "LOQ", "detection limit", "quantitation limit", "specificity", "robustness", "method transfer", "method comparison", "Deming", "Passing-Bablok", "Bland-Altman", "equivalence testing", "OOS investigation", "ICH Q2", "Q2(R2)", "Q14", "USP 1225", "ICH M10", "incurred sample reanalysis", "ISR", "CLSI EP", and any request to show that an assay works.★ 46k GitHub starsSkillSingle-Cell Data StructureK-Dense-AI/scientific-agent-skills · by K-Dense-AIData structure for annotated matrices in single-cell analysis. Use when working with .h5ad files or integrating with the scverse ecosystem. This is the data format skill—for analysis workflows use scanpy; for probabilistic models use scvi-tools; for population-scale queries use cellxgene-census.★ 46k GitHub starsSkillAutonomous Artifact OptimizerK-Dense-AI/scientific-agent-skills · by K-Dense-AIAutonomously improve a real artifact (code, training recipe, agent harness, data pipeline, prompt) against an objective and an evaluator, using Hypothesis Tree Refinement (HTR) from the Arbor paper. Use this whenever someone wants to iteratively optimize something over many experiments without overfitting — e.g. "get my model's eval score up", "improve this agent/harness", "tune this pipeline", "beat the baseline on this benchmark", "run a search over approaches and keep the best", "do an MLE-bench / Kaggle-style optimization", or any long-horizon "make this artifact better and don't just memorize the dev set" task. Trigger it even when the user doesn't say "Arbor" or "hypothesis tree" but describes repeated experiment-and-evaluate loops, branching exploration of competing ideas, or worries about a dev/test gap. Runs Claude itself as the coordinator with subagent executors in isolated git worktrees; for the standalone `arbor` CLI tool see references/arbor-upstream.md.★ 46k GitHub starsSkillGene Regulatory Network InferrerK-Dense-AI/scientific-agent-skills · by K-Dense-AIInfer gene regulatory networks (GRNs) from gene expression data using scalable algorithms (GRNBoost2, GENIE3). Use when analyzing transcriptomics data (bulk RNA-seq, single-cell RNA-seq) to identify transcription factor-target gene relationships and regulatory interactions. Supports distributed computation for large-scale datasets.★ 46k GitHub stars