API reference¶
This page is automatically generated from the PyCO2SYS source code.
PyCO2SYS¶
Marine carbonate system calculations in Python.
CO2System
¶
Bases: UserDict
An equilibrium model of the marine carbonate system.
Methods:
Name | Description |
---|---|
adjust |
Adjust the system to a different temperature and/or pressure. |
get_grads |
Calculate derivatives of parameters with respect to each other. |
keys_all |
Return a tuple of all possible results keys, including those that have not yet been solved for. |
plot_graph |
Draw graphs showing the relationships between the different parameters. |
propagate |
Propagate independent uncertainties through the calculations. |
solve |
Calculate parameter(s) and store them internally. |
to_pandas |
Return parameters as a pandas |
to_xarray |
Return parameters as an xarray |
Attributes:
Name | Type | Description |
---|---|---|
grads |
dict
|
Derivatives of parameters with respect to each other, calculated with
|
opts |
dict
|
The optional settings being used for calculations. Constructed when
the |
uncertainty |
dict
|
Uncertainties in parameters with respect to each other, calculated with
|
Advanced attributes
c_state : dict
Colours for plotting the state graph (see plot_graph
).
c_valid : dict
Colours for plotting the validity graph (see plot_graph
)
checked_valid : bool
Whether the validity of the system has been checked.
data : dict
The known parameters (either user provided or solved for).
funcs : dict
Functions that connect the parameters to each other.
graph : nx.DiGraph
The graph of calculations.
icase : int
Which known core parameters were provided.
ignored : list
Which kwargs or keys in data
were ignored.
nodes_original : tuple
Which parameters were user-provided or took fixed default values.
pd_index : pd.Index
If data
was a pandas DataFrame
, this contains its index.
requested : list
Which parameters have been directly requested for solving.
xr_dims : tuple
If data
was an xarray Dataset
, this contains all its dimensions.
xr_shape : tuple
If data
was an xarray Dataset
, this contains its fullest shape.
In addition to the methods listed above, all of the methods usually
available for a dict
can be used. Methods such as keys
, values
and
items
will run only over parameters that have already been solved for.
Source code in PyCO2SYS/engine.py
949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 |
|
__init__(pd_index=None, xr_dims=None, xr_shape=None, **kwargs)
¶
Initialise a CO2System
.
For advanced users only - use pyco2.sys
instead.
Initialising the system directly requires that all kwargs are correctly
formatted as scalar floats or NumPy arrays with dtype float
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kwargs
|
The known parameters of the carbonate system to be modelled.
Values must be scalar floats or NumPy arrays with dtype |
{}
|
|
pd_index
|
For internal use only. |
None
|
|
xr_dims
|
For internal use only. |
None
|
|
xr_shape
|
For internal use only. |
None
|
Returns:
Type | Description |
---|---|
CO2System
|
|
Source code in PyCO2SYS/engine.py
1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 |
|
_get_func_of(var_of)
¶
Create a function to compute var_of
directly from an input set
of values.
The created function has the signature
value_of = get_value_of(**values)
where the values
are the originally user-defined values, obtained
with either of the following:
values_original = {k: sys.data[k] for k in sys.nodes_original}
values_original = sys.get_values_original()
Source code in PyCO2SYS/engine.py
1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 |
|
_get_func_of_from_wrt(get_value_of, var_wrt)
¶
Reorganise a function created with _get_func_of
so that one of
its kwargs is instead a positional arg (and which can thus be gradded).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
get_value_of
|
func
|
Function created with |
required |
var_wrt
|
str
|
Name of the value to use as a positional arg instead. |
required |
Returns:
Type | Description |
---|---|
A function with the signature
|
value_of = get_of_from_wrt(value_wrt, **other_values_original) |
Source code in PyCO2SYS/engine.py
1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 |
|
adjust(temperature=None, pressure=None, data=None, store_steps=1, method_fCO2=1, opt_which_fCO2_insitu=1, bh_upsilon=None)
¶
Adjust the system to a different temperature and/or pressure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
temperature
|
float
|
Temperature in °C to adjust to. If |
None
|
pressure
|
float
|
Hydrostatic pressure in dbar to adjust to. If |
None
|
store_steps
|
int
|
Whether/which non-requested parameters calculated during intermediate calculation steps should be stored. The options are:
|
1
|
method_fCO2
|
int
|
If this is a single-parameter system, which method to use for the adjustment. The options are:
|
1
|
opt_which_fCO2_insitu
|
int
|
If this is a single-parameter system and |
1
|
bh_upsilon
|
float
|
If this is a single-parameter system and |
None
|
Returns:
Type | Description |
---|---|
CO2System
|
A new |
Source code in PyCO2SYS/engine.py
1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 |
|
check_valid(ignore=None)
¶
Check which parameters are valid.
Source code in PyCO2SYS/engine.py
2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 |
|
get_grad(var_of, var_wrt)
¶
Compute the derivative of var_of
with respect to var_wrt
and
store it in sys.grads[var_of][var_wrt]
. If there is already a value
there, then that value is returned instead of recalculating.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
var_of
|
str
|
The name of the variable to get the derivative of. |
required |
var_wrt
|
str
|
The name of the variable to get the derivative with respect to.
This must be one of the fixed values provided when creating the
|
required |
Source code in PyCO2SYS/engine.py
1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 |
|
get_grads(vars_of, vars_wrt)
¶
Compute the derivatives of vars_of
with respect to vars_wrt
and
store them in sys.grads[var_of][var_wrt]
. If there are already values
there, then those values are returned instead of recalculating.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vars_of
|
list
|
The names of the variables to get the derivatives of. |
required |
vars_wrt
|
list
|
The names of the variables to get the derivatives with respect to.
These must all be one of the fixed values provided when creating the
|
required |
Source code in PyCO2SYS/engine.py
1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 |
|
keys_all()
¶
Return a tuple of all possible results keys, including those that have not yet been solved for.
Source code in PyCO2SYS/engine.py
2144 2145 2146 2147 2148 |
|
plot_graph(ax=None, exclude_nodes=None, show_tsp=True, show_unknown=True, keep_unknown=None, show_isolated=True, skip_nodes=None, prog_graphviz=None, root_graphviz=None, args_graphviz='', nx_layout=nx.spring_layout, nx_args=None, nx_kwargs=None, node_kwargs=None, edge_kwargs=None, label_kwargs=None, mode='state')
¶
Draw a graph showing the relationships between the different parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ax
|
matplotlib axes
|
The axes on which to plot. If |
None
|
exclude_nodes
|
list of str
|
List of nodes to exclude from the plot, by default |
None
|
prog_graphviz
|
str
|
Name of Graphviz layout program, by default "neato". |
None
|
show_tsp
|
bool
|
Whether to show temperature, salinity and pressure nodes, by default
|
True
|
show_unknown
|
bool
|
Whether to show nodes for parameters that have not (yet) been calculated,
by default |
True
|
show_isolated
|
bool
|
Whether to show nodes for parameters that are not connected to the
graph, by default |
True
|
skip_nodes
|
bool
|
List of nodes to skip from the plot, by default |
None
|
Returns:
Type | Description |
---|---|
matplotlib axes
|
The axes on which the graph is plotted. |
Source code in PyCO2SYS/engine.py
1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 |
|
propagate(uncertainty_into, uncertainty_from)
¶
Propagate independent uncertainties through the calculations. Covariances are not accounted for.
New entries are added in the uncertainty
attribute, for example:
co2s = pyco2.sys(dic=2100, alkalinity=2300)
co2s.propagate("pH", {"dic": 2, "alkalinity": 2})
co2s.uncertainty["pH"]["total"] # total uncertainty in pH
co2s.uncertainty["pH"]["dic"] # component of ^ due to DIC uncertainty
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uncertainty_into
|
list
|
The parameters to calculate the uncertainty in. |
required |
uncertainty_from
|
dict
|
The parameters to propagate the uncertainty from (keys) and their uncertainties (values). |
required |
Source code in PyCO2SYS/engine.py
1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 |
|
solve(parameters=None, store_steps=1)
¶
Calculate parameter(s) and store them internally.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameters
|
str or list of str
|
Which parameter(s) to calculate and store, by default |
None
|
store_steps
|
int
|
Whether/which non-requested parameters calculated during
intermediate calculation steps should be stored, by default |
1
|
Returns:
Type | Description |
---|---|
CO2System
|
The original |
PARAMETERS THAT CAN BE SOLVED FOR
|
|
=================================
|
|
Note that some parameters may be available only for certain
|
|
combinations of core carbonate system parameters optional settings.
|
|
pH on different scales
Key | Description
-------: | :-----------------------------------------------------------
pH | pH on the scale specified by opt_pH_scale
.
pH_total | pH on the total scale.
pH_sws | pH on the seawater scale.
pH_free | pH on the free scale.
pH_nbs | pH on the NBS scale.
fH | H+ activity coefficient for conversions to/from NBS scale.
Chemical speciation
All are substance contents in units of µmol/kg.
Key | Description |
---|---|
H_free | "Free" protons. |
OH | Hydroxide ion. |
CO3 | Carbonate ion. |
HCO3 | Bicarbonate ion. |
CO2 | Aqueous CO2. |
BOH4 | Tetrahydroxyborate. |
BOH3 | Boric acid. |
H3PO4 | Phosphoric acid. |
H2PO4 | Dihydrogen phosphate. |
HPO4 | Monohydrogen phosphate. |
PO4 | Phosphate. |
H4SiO4 | Orthosilicic acid. |
H3SiO4 | Trihydrogen orthosilicate. |
NH3 | Ammonia. |
NH4 | Ammonium. |
HS | Bisulfide. |
H2S | Hydrogen sulfide. |
HSO4 | Bisulfate. |
SO4 | Sulfate. |
HF | Hydrofluoric acid. |
F | Fluoride. |
HNO2 | Nitrous acid. |
NO2 | Nitrite. |
Chemical buffer factors
Key | Description
------------------------: | :------------------------------------------ revelle_factor | Revelle factor. psi | Psi of FCG94. gamma_dic | Buffer factors from ESM10. beta_dic | Buffer factors from ESM10. omega_dic | Buffer factors from ESM10. gamma_alkalinity | Buffer factors from ESM10. beta_alkalinity | Buffer factors from ESM10. omega_alkalinity | Buffer factors from ESM10. Q_isocap | Isocapnic quotient from HDW18. Q_isocap_approx | Approximate isocapnic quotient from HDW18. dlnfCO2_dT | temperature sensitivity of ln(fCO2). dlnpCO2_dT | temperature sensitivity of ln(pCO2). substrate_inhibitor_ratio | HCO3/H_free, from B15.
Equilibrium constants
All are returned on the pH scale specified by opt_pH_scale
.
Key | Description
----------: | :-------------------------------------------------------- k_CO2 | Henry's constant for CO2. k_H2CO3 | First dissociation constant for carbonic acid. k_HCO3 | Second dissociation constant for carbonic acid. k_H2O | Water dissociation constant. k_BOH3 | Boric acid equilibrium constant. k_HF_free | HF dissociation constant (always free scale). k_HSO4_free | Bisulfate dissociation constant (always free scale). k_H3PO4 | First dissociation constant for phosphoric acid. k_H2PO4 | Second dissociation constant for phosphoric acid. k_HPO4 | Third dissociation constant for phosphoric acid. k_Si | Silicic acid dissociation constant. k_NH3 | Ammonia equilibrium constant. k_H2S | Hydrogen sulfide dissociation constant. k_HNO2 | Nitrous acid dissociation constant.
Other results
Key | Description (unit)
--------------: | :---------------------------------------------------- upsilon | Temperature-sensitivity of fCO2 (%/°C) fugacity_factor | Converts between pCO2 and fCO2. vp_factor | Vapour pressure factor, converts pCO2 and xCO2. gas_constant | Universal gas constant (ml/bar/mol/K).
Source code in PyCO2SYS/engine.py
1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 |
|
to_pandas(parameters=None, store_steps=1)
¶
Return parameters as a pandas Series
or DataFrame
. All parameters should
be scalar or one-dimensional vectors of the same size.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameters
|
str or list of str
|
The parameter(s) to return. These are solved for if not already available.
If |
None
|
store_steps
|
int
|
See |
1
|
Returns:
Type | Description |
---|---|
Series or DataFrame
|
The parameter(s) as a |
Source code in PyCO2SYS/engine.py
1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 |
|
to_xarray(parameters=None, store_steps=1)
¶
Return parameters as an xarray DataArray
or Dataset
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameters
|
str or list of str
|
The parameter(s) to return. These are solved for if not already
available. If |
None
|
store_steps
|
int
|
See |
1
|
Returns:
Type | Description |
---|---|
DataArray or Dataset
|
The parameter(s) as a |
Source code in PyCO2SYS/engine.py
1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 |
|
sys(data=None, **kwargs)
¶
Initialise a CO2System
.
Once initialised, various methods are available including solve
, adjust
and `propagate.
PARAMETERS PROVIDED AS KWARGS¶
There are many possible kwargs, so they are grouped into sections below.
Data as separate variables
If the input data are all stored as separate variables, they can be
provided with the appropriate kwargs from below. In this case, each
variable must be one of a scalar, a list
or a NumPy array
, and the
shapes of these arrays must be mutually broadcastable. For example:
import PyCO2SYS as pyco2, numpy as np dic = [2100, 2150] temperature = np.array([15, 13.5]) co2s = pyco2.sys(dic=dic, pH=8.1, temperature=temperature)
Data variables in a container
If the input data are gathered in a dict
, pandas DataFrame
or xarray
Dataset
, then this can be provided with the data
kwarg. The keys in
the container dataset must be strings and they should correspond to the
kwargs below. If they do not correspond, then the kwarg can be passed with
the corresponding key instead. For example:
import PyCO2SYS as pyco2 data = {"dic": [2100, 2150], "pH_lab": 8.1, "t_lab": 25} co2s = pyco2.sys(data=data, pH="pH_lab", temperature="t_lab")
Core marine carbonate system parameters
A maximum of two core parameters may be provided, and not all combinations are valid. In some cases, a subset of calculations can still be carried out with only one parameter. It is also possible to pass none of these parameters and still calculate e.g. equilibrium constants.
Parameter | Description (unit)
-------------------: | :---------------------------------------------------
alkalinity | Total alkalinity (µmol/kg)
dic | Dissolved inorganic carbon (µmol/kg)
pH | Seawater pH on the scale given by opt_pH_scale
pCO2 | Seawater partial pressure of CO2 (µatm)
fCO2 | Seawater fugacity of CO2 (µatm)
CO2 | Aqueous CO2 content (µmol/kg)
HCO3 | Bicarbonate ion content (µmol/kg)
CO3 | Carbonate ion content (µmol/kg)
xCO2 | Seawater dry air mole fraction of CO2 (ppm)
saturation_calcite | Saturation state with respect to calcite
saturation_aragonite | Saturation state with respect to aragonite
Hydrographic conditions
Middle column gives default values if not provided.
Parameter | Df. | Description (unit)
------------------: | --: | :---------------------------------------------- salinity | 35 | Practical salinity temperature | 25 | Temperature (°C) pressure | 0 | Hydrostatic pressure (dbar) pressure_atmosphere | 1 | Atmospheric pressure (atm)
Nutrients and other solutes
Middle column gives default values; S = calculated from salinity.
Parameter | Df. | Description (unit)
--------------: | :-: | :---------------------------------------------- total_silicate | 0 | Total dissolved silicate (µmol/kg) total_phosphate | 0 | Total dissolved phosphate (µmol/kg) total_ammonia | 0 | Total dissolved ammonia (µmol/kg) total_sulfide | 0 | Total dissolved sulfide (µmol/kg) total_nitrite | 0 | Total dissolved nitrite (µmol/kg) total_borate | S | Total dissolved borate (µmol/kg) total_fluoride | S | Total dissolved fluoride (µmol/kg) total_sulfate | S | Total dissolved sulfate (µmol/kg) Ca | S | Dissolved calcium (µmol/kg)
SETTINGS PROVIDED AS KWARGS¶
Options such as which pH scale to use and the choice of parameterisation for various e.g. equilibrium constants can also be altered with kwargs. These kwargs must all be scalar integers.
Citations use a code with the initials of the first few authors' surnames plus the final two digits of the year of publication. Refer to the online documentation for full references.
pH scale
opt_pH_scale: pH scale of pH
(if provided), also used for calculating
equilibrium constants.
1: total [DEFAULT].
2: seawater.
3: free.
4: NBS.
Carbonic acid dissociation
opt_k_carbonic: parameterisation for carbonic acid dissociation (K1 and K2). 1: RRV93. 2: GP89. 3: H73a and H73b refit by DM87. 4: MCHP73 refit by DM87. 5: H73a, H73b and MCHP73 refit by DM87. 6: MCHP73 ("GEOSECS"). 7: MCHP73 ("GEOSECS-Peng"). 8: M79 (freshwater). 9: CW98. 10: LDK00 [DEFAULT]. 11: MM02. 12: MPL02. 13: MGH06. 14: M10. 15: WMW14. 16: SLH20. 17: SB21. 18: PLR18. opt_factor_k_H2CO3: pressure correction for the first carbonic acid dissociation constant (K1). 1: M95 [DEFAULT]. 2: EG70 (GEOSECS). 3: M83 (freshwater). opt_factor_k_HCO3: pressure correction for the second carbonic acid dissociation constant (K2). 1: M95 [DEFAULT]. 2: EG70 (GEOSECS). 3: M83 (freshwater).
Other equilibrium constants
opt_k_BOH3: parameterisation for boric acid equilibrium. 1: D90b [DEFAULT]. 2: LTB69 (GEOSECS). opt_k_H2O: parameterisation for water dissociation. 1: M95 [DEFAULT]. 2: M79 (GEOSECS). 3: HO58 refit by M79 (freshwater). opt_k_HF: parameterisation for hydrogen fluoride dissociation. 1: DR79 [DEFAULT]. 2: PF87. opt_k_HNO2: parameterisation for nitrous acid dissociation. 1: BBWB24 for seawater [DEFAULT]. 2: BBWB24 for freshwater. opt_k_HSO4: parameterisation for bisulfate dissociation. 1: D90a [DEFAULT]. 2: KRCB77. 3: WM13/WMW14. opt_k_NH3: parameterisation for ammonium dissociation. 1: CW95 [DEFAULT]. 2: YM95. opt_k_phosphate: parameterisation for the phosphoric acid dissocation constants. 1: YM95 [DEFAULT]. 2: KP67 (GEOSECS). opt_k_Si: parameterisation for bisulfate dissociation. 1: YM95 [DEFAULT]. 2: SMB64 (GEOSECS). opt_k_aragonite: parameterisation for aragonite solubility product. 1: M83 [DEFAULT]. 2: ICHP73 (GEOSECS). opt_k_calcite: parameterisation for calcite solubility product. 1: M83 [DEFAULT]. 2: I75 (GEOSECS).
Other dissociation constant pressure corrections
opt_factor_k_BOH3: pressure correction for boric acid equilibrium. 1: M79 [DEFAULT]. 2: EG70 (GEOSECS). opt_factor_k_H2O: pressure correction for water dissociation. 1: M95 [DEFAULT]. 2: M83 (freshwater).
Total salt contents
These settings are ignored if their values are provided directly as kwargs.
opt_total_borate: for calculating total_borate
from salinity
.
1: U74 [DEFAULT].
2: LKB10.
3: KSK18 (Baltic Sea).
opt_Ca: for calculating Ca
from salinity
.
1: RT67 [DEFAULT].
2: C65 (GEOSECS).
Other settings
opt_gas_constant: the universal gas constant (R)
1: DOEv2 (consistent with pre-July 2020 CO2SYS software).
2: DOEv3.
3: 2018 CODATA [DEFAULT].
opt_fugacity_factor: how to convert between partial pressure and fugacity.
1: with a fugacity factor [DEFAULT].
2: assuming they are equal (GEOSECS).
opt_HCO3_root: with known dic
and HCO3
, which root to solve for.
1: the lower pH root.
2: the higher pH root [DEFAULT].
opt_fCO2_temperature: sensitivity of fCO2 to temperature.
1: H24 parameterisation [DEFAULT].
2: TOG93 linear fit.
3: TOG93 quadratic fit.
Equilibrium constants
Any equilibrium constant calculated within PyCO2SYS can be provided
directly as an input instead. The kwarg should use the same key as would
be used to solve for this parameter. See the docs for CO2System.solve
for more detail.
Source code in PyCO2SYS/engine.py
2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 |
|