Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add to carbon: pco2 decomp and potential #12

Merged
merged 4 commits into from
Feb 7, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 52 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,56 @@ 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'):
"""
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['tos'].mean(time_dim)
aaronspring marked this conversation as resolved.
Show resolved Hide resolved
tos_diff = ds['tos'] - tos_mean
thermal = ds['spco2'].mean(time_dim) * (np.exp(tos_diff * fac))
non_thermal = ds['spco2'] * (np.exp(tos_diff * -fac))
return thermal, non_thermal


def potential_pco2(t_insitu, pco2_insitu):
"""
Calculate potential pco2 in the inner ocean.

aaronspring marked this conversation as resolved.
Show resolved Hide resolved
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.sel(depth=6)
aaronspring marked this conversation as resolved.
Show resolved Hide resolved
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.