Learn R Programming

⚠️There's a newer version (3.3.3) of this package.Take me there.

seacarb

Carbonate chemistry with R

In 2003, Aurélien Proye and I put together seacarb, an R package that calculates various parameters of the carbonate system in seawater. The package was subsequently upgraded. In 2008, a new version (2.0) was built with the assistance of Héloïse Lavigne. Five additional functions were included to assist the design of perturbation experiments to investigate ocean acidification and other functions were revised in order to strictly follow the "Guide to best practices for ocean CO2 measurements" (Dickson et al., 2007). Seacarb uses equations mostly from the following four sources:

  • Dickson A. G., Sabine C. L. & Christian J. R., 2007. Guide to best practices for ocean CO2 measurements. PICES Special Publication 3:1-191.
  • DOE, 1994. Handbook of methods for the analysis of the various parameters of the carbon dioxide system in sea water; version 2. Dickson, A. G. and Goyet, C., editors. ORNL/CDIAC-74, 1994.
  • Frankignoulle M., 1994. A complete set of buffer factors for acid/base CO2 system in seawater. Journal of Marine Systems 5: 111-118.
  • Zeebe R. E. & Wolf-Gladrow D. A., 2001. CO2 in seawater: equilibrium, kinetics, isotopes. Amsterdam: Elsevier, 346 pp.

A portion of the code has been adapted, with permission from the authors, from the Matlab files mentioned above. I am grateful to Richard Zeebe and Dieter Wolf-Gladrow for that. Portions of code and/or corrections have also been contributed by Jean-Marie Epitalon (2004), Bernard Gentili (2006), Karline Soetaert (2007) and Jim Orr (2007, 2010). Héloïse Lavigne contributed a lot to seacarb in 2008 and 2009; this was critical to the launch of version 2.0 and subsequent updates. Jean-Marie Epitalon considerably improved the code, leading to much faster calculations in version 3.0.

This program is provided free under the GNU General Public License (GNU GPL). The current version (3.0) will be improved using the comments that I will receive. If you are new to R, please check the manuals and FAQs available on the R-project web site to get information on how to install R and the seacarb package on your system. Please only report and comment on seacarb, not on general problems related to R.

Briefly, after installing R and if you have an Internet connection, here is the simplest way to install seacarb:

  • Launch R
  • To install seacarb (to be done only once), type the following command: install.packages("seacarb")
  • To load the seacarb package into memory in order to use it (to be done each time R is launched), type the following command: library(seacarb)

The seacarb package can be downloaded from the Comprehensive R Archive Network (CRAN). The documentation is included in the package and is accessible using standard R commands. Please give due credit to the publications mentioned above and cite seacarb as follows:

Lavigne H., Epitalon, J.-M. & Gattuso J.-P., 2011. seacarb: seawater carbonate chemistry with R. R package version 3.0. http://CRAN.R-project.org/package=seacarb

Copy Link

Version

Install

install.packages('seacarb')

Monthly Downloads

831

Version

3.2

License

GPL (>= 2)

Maintainer

Jean-Pierre Gattuso

Last Published

June 19th, 2017

Functions in seacarb (3.2)

K1p

First dissociation constant of phosphoric acid (mol/kg)
K2

Second dissociation constant of carbonic acid (mol/kg)
Kf

Equilibrium constant of hydrogen fluoride (mol/kg)
Khs

Dissociation constant of hydrogen sulfide (mol/kg)
K2p

Second dissociation constant of phosphoric acid (mol/kg)
K2si

Second dissociation constant of Si(OH)4
K3p

Third dissociation constant of phosphoric acid (mol/kg)
Kb

Dissociation constant of boric acid (mol/kg)
K0

Henry's constant mol/(kg/atm)
K1

First dissociation constant of carbonic acid (mol/kg)
Om

Carbonate saturation state for magnesian calcites
Pcoeffs

Coefficients used for pressure-correcting the equilibrium constants
Kspc

Solubility product of calcite (mol/kg)
Kw

Ion product of water (mol2/kg2)
Pcorrect

Pressure correction of equilibrium constants
alkalinity

Example data file for function at
buffer

Buffer parameters of the seawater carbonate system
buffergen

Buffer factors of the seawater carbonate system as defined by Hagens and Middelburg (2016)
Ksi

Dissociation constant of Si(OH)4
Kspa

Solubility product of aragonite (mol/kg)
carbb

Parameters of the seawater carbonate system
oa

Perturbation of the seawater carbonate system
p2d

Converts pressure in dbar to depth in meters
bjerrum

Bjerrum plot
bor

Total boron concentration (mol/kg)
d2p

Converts depth in meters to pressure in dbar
derivnum

Numerical derivatives of seawater carbonate system variables
buffesm

Buffer capacities of the seawater carbonate system as defined by Egleston et al. (2010)
carb

Parameters of the seawater carbonate system
errors

Error propagation for computed marine carbonate system variables
f2pCO2

Converts the CO2 fugacity to CO2 partial pressure
p2fCO2

Converts pCO2 (partial pressure in CO2) into fCO2 (fugacity of CO2)
p2xCO2

Converts partial pressure of CO2 to mole fraction of CO2
rho

Density of seawater (kg/m3)
Kn

Dissociation constant of ammonium (mol/kg)
Ks

Stability constant of hydrogen sulfate (mol/kg)
amp

pH value of the AMP buffer
pCa

pCa
pH

Potentiometric pH
ppH

ppH
pHconv

Conversion of pH
pHinsi

pH at in situ temperature
sa2sp_geo

From absolute to practical salinity
psi

Molar ratio of CO2 released vs CaCO3 precipitated
seacarb_test_P0

Test data file (at P=0) to test the use of the carb function
carbfull

Parameters of the seawater carbonate system - extension of carb
kconv

Conversion factors to change the pH scale of dissociation constants
kfg

variable for internal use
pHslope

Slope of the calibration curve of a pH electrode
pTA

pTA
sp2sa_geo

From practical to absolute salinity
speciation

ionic forms as a function of pH
vapress

Computes vapor pressure of seawater
x2pCO2

Converts mole fraction to partial pressure of CO2
sa2sp_chem

From absolute to practical salinity
theta

Potential temperature of seawater
tris

pH value of the TRIS buffer
at

Calculates total alkalinity from potentiometric titration data
eos2teos_chem

Convert temperature and salinity from EOS-80 to TEOS-10
eos2teos_geo

Convert temperature and salinity from EOS-80 to TEOS-10
pgas

pgas
pmix

pmix
seacarb_test_P300

Test data file (at P=300) to test the use of the carb function
sp2sa_chem

From Practical to absolute salinity
teos2eos_chem

Convert temperature and salinity from TEOS-10 to EOS-80
teos2eos_geo

Convert temperature and salinity from TEOS-10 to EOS-80