Skip to content

Commit 330f7eb

Browse files
authored
Merge pull request #61 from ocefpaf/fixes_14
updated version of o2sat
2 parents d749886 + 2ee4211 commit 330f7eb

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ language: minimal
22

33
sudo: false
44

5+
addons:
6+
apt:
7+
packages:
8+
- xvfb
9+
510
env:
611
global:
712
# Doctr deploy key for pyoceans/python-oceans
@@ -30,6 +35,7 @@ before_install:
3035
# GUI tests.
3136
- "export DISPLAY=:99.0"
3237
- "sh -e /etc/init.d/xvfb start"
38+
— sleep 3
3339

3440
install:
3541
# Test source distribution.

oceans/sw_extras/sw_extras.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,3 +927,58 @@ def zmld_boyer(s, t, p):
927927
mldepthptemp_mldindex = presinterp[ix]
928928

929929
return mldepthdens_mldindex, mldepthptemp_mldindex
930+
931+
932+
def o2sol_SP_pt_benson_krause_84(SP, pt):
933+
"""
934+
Calculates the oxygen, O2, concentration expected at equilibrium with air
935+
at an Absolute Pressure of 101325 Pa (sea pressure of 0 dbar) including
936+
saturated water vapor.
937+
938+
This function uses the solubility coefficients derived from the data of
939+
Benson and Krause 1984, as fitted by Garcia and Gordon 1992.
940+
941+
Better in the range:
942+
tF >= t >= 40 degC
943+
0 >= t >= 42 %o.
944+
945+
Parameters
946+
----------
947+
SP : array_like
948+
Practical Salinity
949+
pt : array_like
950+
Potential temperature [℃ (ITS-90)]
951+
952+
Examples
953+
--------
954+
>>> SP = [34.7118, 34.8915, 35.0256, 34.8472, 34.7366, 34.7324]
955+
>>> pt = [28.8099, 28.4392, 22.7862, 10.2262, 6.8272, 4.3236]
956+
>>> o2sol = o2sol_SP_pt_benson_krause_84(SP, pt)
957+
>>> expected = [194.68254317, 195.61350628, 214.65593602, 273.56528327, 295.15807614, 312.95987166]
958+
>>> np.testing.assert_almost_equal(expected, o2sol)
959+
960+
961+
https://aslopubs.onlinelibrary.wiley.com/doi/pdf/10.4319/lo.1992.37.6.1307
962+
963+
"""
964+
SP, pt = list(map(np.asanyarray, (SP, pt)))
965+
966+
S = SP # rename to make eq. identical to the paper and increase readability.
967+
pt68 = pt * 1.00024 # IPTS-68 potential temperature in degC.
968+
969+
Ts = np.log((298.15 - pt68) / (273.15 + pt68))
970+
971+
# The coefficents for Benson and Krause 1984
972+
# from the table 1 of Garcia and Gordon (1992).
973+
A = [5.80871, 3.20291, 4.17887, 5.10006, -9.86643e-2, 3.80369]
974+
B = [-7.01577e-3, -7.70028e-3, -1.13864e-2, -9.51519e-3]
975+
C0 = -2.75915e-7
976+
977+
# Equation 8 from Garcia and Gordon 1992 accoring to Pilson.
978+
lnCo = (
979+
A[0] + A[1]*Ts + A[2]*Ts**2 + A[3]*Ts**3
980+
+ A[4]*Ts**4 + A[5]*Ts**5
981+
+ S * (B[0] + B[1]*Ts + B[2]*Ts**2 + B[3]*Ts**3)
982+
+ C0*S**2
983+
)
984+
return np.exp(lnCo)

0 commit comments

Comments
 (0)