Skip to content

Commit f72be8d

Browse files
authored
Merge pull request #207 from DocOtak/geo_strf_steric_height
Add geo_strf_steric_height function
2 parents 42645a7 + 5116ea3 commit f72be8d

File tree

6 files changed

+67
-0
lines changed

6 files changed

+67
-0
lines changed

gsw/geostrophy.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from .conversions import z_from_p
1010

1111
__all__ = ['geo_strf_dyn_height',
12+
'geo_strf_steric_height',
1213
'distance',
1314
'f',
1415
'geostrophic_velocity',
@@ -105,6 +106,52 @@ def geo_strf_dyn_height(SA, CT, p, p_ref=0, axis=0, max_dp=1.0,
105106
return dh
106107

107108

109+
@match_args_return
110+
def geo_strf_steric_height(SA, CT, p, p_ref=0, axis=0, max_dp=1.0, interp_method="pchip"):
111+
"""
112+
Steric height anomaly as a function of pressure.
113+
114+
Parameters
115+
----------
116+
SA : array-like
117+
Absolute Salinity, g/kg
118+
CT : array-like
119+
Conservative Temperature (ITS-90), degrees C
120+
p : array-like
121+
Sea pressure (absolute pressure minus 10.1325 dbar), dbar
122+
p_ref : float or array-like, optional
123+
Reference pressure, dbar
124+
axis : int, optional, default is 0
125+
The index of the pressure dimension in SA and CT.
126+
max_dp : float
127+
If any pressure interval in the input p exceeds max_dp, the dynamic
128+
height will be calculated after interpolating to a grid with this
129+
spacing.
130+
interp_method : string {'mrst', 'pchip', 'linear'}
131+
Interpolation algorithm.
132+
133+
Returns
134+
-------
135+
steric_height : array
136+
This is the integral of specific volume anomaly with respect
137+
to pressure, from each pressure in p to the specified
138+
reference pressure, divided by the global mean surface value of
139+
gravitational acceleration, 9.7963 m s^-2. (see page 46 of Griffies, 2004)
140+
It is not exactly the height of an isobaric surface above a
141+
geopotential surface, but is an exact geostrophic streamfunction.
142+
143+
References
144+
----------
145+
Griffies, S. M., 2004: Fundamentals of Ocean Climate Models. Princeton,
146+
NJ: Princeton University Press, 518 pp + xxxiv.
147+
148+
"""
149+
return (
150+
geo_strf_dyn_height(SA, CT, p, p_ref, axis=axis, max_dp=max_dp, interp_method=interp_method)
151+
/ 9.7963
152+
)
153+
154+
108155
def unwrap(lon, centered=True, copy=True):
109156
"""
110157
Unwrap a sequence of longitudes or headings in degrees.

gsw/tests/geo_strf_steric_height.npy

1.18 KB
Binary file not shown.

gsw/tests/test_check_functions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
# Substitute new check values for the pchip interpolation version.
3535
cv.geo_strf_dyn_height = np.load(os.path.join(root_path,'geo_strf_dyn_height.npy'))
36+
cv.geo_strf_steric_height = np.load(os.path.join(root_path,'geo_strf_steric_height.npy'))
3637
cv.geo_strf_velocity = np.load(os.path.join(root_path,'geo_strf_velocity.npy'))
3738

3839
cf = Bunch()

gsw/tests/test_geostrophy.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,15 @@ def test_dyn_height_mrst():
113113
strf = gsw.geo_strf_dyn_height(SA, CT, p, p_ref=pr, interp_method='mrst')
114114

115115
assert_allclose(strf, cv.geo_strf_dyn_height, rtol=0, atol=cv.geo_strf_dyn_height_ca)
116+
117+
def test_steric_height_mrst():
118+
"""
119+
Tests the MRST-PCHIP interpolation method.
120+
"""
121+
p = cv.p_chck_cast
122+
CT = cv.CT_chck_cast
123+
SA = cv.SA_chck_cast
124+
pr = cv.pr
125+
strf = gsw.geo_strf_steric_height(SA, CT, p, p_ref=pr, interp_method='mrst')
126+
127+
assert_allclose(strf, cv.geo_strf_steric_height, rtol=0, atol=cv.geo_strf_steric_height_ca)

gsw/tests/test_xarray.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242

4343
# Substitute new check values for the pchip interpolation version.
4444
cv.geo_strf_dyn_height = np.load(os.path.join(root_path,'geo_strf_dyn_height.npy'))
45+
cv.geo_strf_steric_height = np.load(os.path.join(root_path,'geo_strf_steric_height.npy'))
4546
cv.geo_strf_velocity = np.load(os.path.join(root_path,'geo_strf_velocity.npy'))
4647

4748
for name in ['SA_chck_cast', 't_chck_cast', 'p_chck_cast']:

gsw/tests/write_geo_npyfiles.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
cv.pr)
2626
np.save('geo_strf_dyn_height.npy', dyn_height)
2727

28+
steric_height = gsw.geo_strf_steric_height(cv.SA_chck_cast,
29+
cv.CT_chck_cast,
30+
cv.p_chck_cast,
31+
cv.pr)
32+
np.save('geo_strf_steric_height.npy', steric_height)
33+
2834
lon = cv.long_chck_cast
2935
lat = cv.lat_chck_cast
3036
p = cv.p_chck_cast

0 commit comments

Comments
 (0)