Skip to content

Commit

Permalink
Merge pull request GliderToolsCommunity#39 from dhruvbalwada/add_spice
Browse files Browse the repository at this point in the history
fixed spice calculations
  • Loading branch information
dhruvbalwada authored Jan 16, 2021
2 parents 221091e + 2d5be11 commit 08c4dde
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions glidertools/physics.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,51 @@ def pad_nan(a):
)

return n2


# compute spice
def spice0(salt_PSU, temp_C, pres_db, lat, lon):
"""
Calculate spiciness from glider measurements of salinity and temperature.
Parameters
----------
salt_PSU : array, dtype=float, shape=[n, ]
practical salinty
temp_C : array, dtype=float, shape=[n, ]
temperature in deg C
pres_db : array, dtype=float, shape=[n, ]
pressure in decibar
lat : array, dtype=float, shape=[n, ]
latitude in degrees north
lon : array, dtype=float, shape=[n, ]
longitude in degrees east
Returns
-------
potential_density : array, dtype=float, shape=[n, ]
Note
----
Using seawater.dens does not yield the same results as this function. We
get very close results to what the SeaGlider Basestation returns with this
function. The difference of this function with the basestation is on
average ~ 0.003 kg/m3
"""
import gsw
salt_abs = gsw.SA_from_SP(salt_PSU, pres_db, lon, lat)
cons_temp = gsw.CT_from_t(salt_abs, temp_C, pres_db)

spice0 = gsw.spiciness0(salt_abs, cons_temp)

spice0 = transfer_nc_attrs(
getframe(),
temp_C,
spice0,
'spiciness0',
units=' ',
comment='',
standard_name='spiciness0',
)
return spice0

0 comments on commit 08c4dde

Please sign in to comment.