Skip to content

Commit

Permalink
Merge pull request #12 from bradyrx/carbon_pco2_tdecomp_potpco2
Browse files Browse the repository at this point in the history
add to carbon: pco2 thermal/non-thermal decomposition and potential pco2
  • Loading branch information
bradyrx authored Feb 7, 2019
2 parents cd4e1cd + d7fad09 commit 94540de
Show file tree
Hide file tree
Showing 3 changed files with 850 additions and 4 deletions.
69 changes: 65 additions & 4 deletions esmtools/carbon.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""
import numpy as np


def co2_sol(t, s):
"""
Compute CO2 sollubility per the equation used in CESM. The mean will be taken over
Expand All @@ -16,7 +17,7 @@ def co2_sol(t, s):
Input
-----
t : SST time series (degC)
t : SST time series (degC)
s : SSS time series (PSU)
Return
Expand All @@ -41,9 +42,10 @@ def co2_sol(t, s):
a[3] * t_sq + d0 * s )
return ff


def schmidt(t):
"""
Computes the dimensionless Schmidt number. The mean will be taken over the
Computes the dimensionless Schmidt number. The mean will be taken over the
time series provided to produce the average Schmidt number over this time period.
The polynomials used are for SST ranges between 0 and 30C and a salinity of 35.
Expand All @@ -57,10 +59,69 @@ def schmidt(t):
Reference
--------
Sarmiento and Gruber (2006). Ocean Biogeochemical Dynamics.
Sarmiento and Gruber (2006). Ocean Biogeochemical Dynamics.
Table 3.3.1
"""
c = [2073.1, 125.62, 3.6276, 0.043219]
t = np.mean(t)
Sc = c[0] - c[1]*t + c[2]*(t**2) - c[3]*(t**3)
Sc = c[0] - c[1] * t + c[2] * (t ** 2) - c[3] * (t ** 3)
return Sc


def temp_decomp_takahashi(ds, time_dim='time', temperature='tos', pco2='spco2'):
"""
Decompose spco2 into thermal and non-thermal component.
Reference
---------
Takahashi, Taro, Stewart C. Sutherland, Colm Sweeney, Alain Poisson, Nicolas
Metzl, Bronte Tilbrook, Nicolas Bates, et al. “Global Sea–Air CO2 Flux
Based on Climatological Surface Ocean PCO2, and Seasonal Biological and
Temperature Effects.” Deep Sea Research Part II: Topical Studies in
Oceanography, The Southern Ocean I: Climatic Changes in the Cycle of
Carbon in the Southern Ocean, 49, no. 9 (January 1,2002): 1601–22.
https://doi.org/10/dmk4f2.
Input
-----
ds : xr.Dataset containing spco2[ppm] and tos[C or K]
Output
------
thermal, non_thermal : xr.DataArray
thermal and non-thermal components in ppm units
"""
fac = 0.0432
tos_mean = ds[temperature].mean(time_dim)
tos_diff = ds[temperature] - tos_mean
thermal = ds[pco2].mean(time_dim) * (np.exp(tos_diff * fac))
non_thermal = ds[pco2] * (np.exp(tos_diff * -fac))
return thermal, non_thermal


def potential_pco2(t_insitu, pco2_insitu):
"""
Calculate potential pco2 in the inner ocean. Requires the first index of
depth to be at the surface.
Input
-----
t_insitu : xr object
SST with depth [C or K]
pco2_insitu : xr object
pCO2 with depth [ppm]
Output
------
pco2_potential : xr object
potential pco2 with depth
Reference:
- Sarmiento, Jorge Louis, and Nicolas Gruber. Ocean Biogeochemical Dynamics.
Princeton, NJ: Princeton Univ. Press, 2006., p.421, eq. (10:3:1)
"""
t_sfc = t_insitu.isel(depth=0)
pco2_potential = pco2_insitu * (1 + 0.0423 * (t_sfc - t_insitu))
return pco2_potential
389 changes: 389 additions & 0 deletions notebooks/Primary_Production.ipynb

Large diffs are not rendered by default.

396 changes: 396 additions & 0 deletions notebooks/pco2.ipynb

Large diffs are not rendered by default.

0 comments on commit 94540de

Please sign in to comment.