Conversion functions

Conversions involving temperature, salinity, entropy, pressure, and height.

Those most commonly used probably include:

  • gsw.CT_from_t()

  • gsw.SA_from_SP()

  • gsw.SP_from_C()

  • gsw.p_from_z()

  • gsw.z_from_p()

gsw.conversions.CT_from_enthalpy(SA, h, p)[source]

Calculates the Conservative Temperature of seawater, given the Absolute Salinity, specific enthalpy, h, and pressure p. The specific enthalpy input is the one calculated from the computationally-efficient expression for specific volume in terms of SA, CT and p (Roquet et al., 2015).

Parameters
SAarray-like

Absolute Salinity, g/kg

harray-like

Specific enthalpy, J/kg

parray-like

Sea pressure (absolute pressure minus 10.1325 dbar), dbar

Returns
CTarray-like, deg C

Conservative Temperature ( ITS-90)

gsw.conversions.CT_from_entropy(SA, entropy)[source]

Calculates Conservative Temperature with entropy as an input variable.

Parameters
SAarray-like

Absolute Salinity, g/kg

entropyarray-like

Specific entropy, J/(kg*K)

Returns
CTarray-like, deg C

Conservative Temperature (ITS-90)

gsw.conversions.CT_from_pt(SA, pt)[source]

Calculates Conservative Temperature of seawater from potential temperature (whose reference sea pressure is zero dbar).

Parameters
SAarray-like

Absolute Salinity, g/kg

ptarray-like

Potential temperature referenced to a sea pressure, degrees C

Returns
CTarray-like, deg C

Conservative Temperature (ITS-90)

gsw.conversions.CT_from_rho(rho, SA, p)[source]

Calculates the Conservative Temperature of a seawater sample, for given values of its density, Absolute Salinity and sea pressure (in dbar), using the computationally-efficient expression for specific volume in terms of SA, CT and p (Roquet et al., 2015).

Parameters
rhoarray-like

Seawater density (not anomaly) in-situ, e.g., 1026 kg/m^3.

SAarray-like

Absolute Salinity, g/kg

parray-like

Sea pressure (absolute pressure minus 10.1325 dbar), dbar

Returns
CTarray-like, deg C

Conservative Temperature (ITS-90)

CT_multiplearray-like, deg C

Conservative Temperature (ITS-90)

gsw.conversions.CT_from_t(SA, t, p)[source]

Calculates Conservative Temperature of seawater from in-situ temperature.

Parameters
SAarray-like

Absolute Salinity, g/kg

tarray-like

In-situ temperature (ITS-90), degrees C

parray-like

Sea pressure (absolute pressure minus 10.1325 dbar), dbar

Returns
CTarray-like, deg C

Conservative Temperature (ITS-90)

gsw.conversions.C_from_SP(SP, t, p)[source]

Calculates conductivity, C, from (SP,t,p) using PSS-78 in the range 2 < SP < 42. If the input Practical Salinity is less than 2 then a modified form of the Hill et al. (1986) formula is used for Practical Salinity. The modification of the Hill et al. (1986) expression is to ensure that it is exactly consistent with PSS-78 at SP = 2.

Parameters
SParray-like

Practical Salinity (PSS-78), unitless

tarray-like

In-situ temperature (ITS-90), degrees C

parray-like

Sea pressure (absolute pressure minus 10.1325 dbar), dbar

Returns
Carray-like, mS/cm

conductivity

gsw.conversions.SA_from_SP(SP, p, lon, lat)[source]

Calculates Absolute Salinity from Practical Salinity. Since SP is non-negative by definition, this function changes any negative input values of SP to be zero.

Parameters
SParray-like

Practical Salinity (PSS-78), unitless

parray-like

Sea pressure (absolute pressure minus 10.1325 dbar), dbar

lonarray-like

Longitude, -360 to 360 degrees

latarray-like

Latitude, -90 to 90 degrees

Returns
SAarray-like, g/kg

Absolute Salinity

gsw.conversions.SA_from_Sstar(Sstar, p, lon, lat)[source]

Calculates Absolute Salinity from Preformed Salinity.

Parameters
Sstararray-like

Preformed Salinity, g/kg

parray-like

Sea pressure (absolute pressure minus 10.1325 dbar), dbar

lonarray-like

Longitude, -360 to 360 degrees

latarray-like

Latitude, -90 to 90 degrees

Returns
SAarray-like, g/kg

Absolute Salinity

gsw.conversions.SA_from_rho(rho, CT, p)[source]

Calculates the Absolute Salinity of a seawater sample, for given values of its density, Conservative Temperature and sea pressure (in dbar). This function uses the computationally-efficient 75-term expression for specific volume in terms of SA, CT and p (Roquet et al., 2015).

Parameters
rhoarray-like

Seawater density (not anomaly) in-situ, e.g., 1026 kg/m^3.

CTarray-like

Conservative Temperature (ITS-90), degrees C

parray-like

Sea pressure (absolute pressure minus 10.1325 dbar), dbar

Returns
SAarray-like, g/kg

Absolute Salinity.

gsw.conversions.SP_from_C(C, t, p)[source]

Calculates Practical Salinity, SP, from conductivity, C, primarily using the PSS-78 algorithm. Note that the PSS-78 algorithm for Practical Salinity is only valid in the range 2 < SP < 42. If the PSS-78 algorithm produces a Practical Salinity that is less than 2 then the Practical Salinity is recalculated with a modified form of the Hill et al. (1986) formula. The modification of the Hill et al. (1986) expression is to ensure that it is exactly consistent with PSS-78 at SP = 2. Note that the input values of conductivity need to be in units of mS/cm (not S/m).

Parameters
Carray-like

Conductivity, mS/cm

tarray-like

In-situ temperature (ITS-90), degrees C

parray-like

Sea pressure (absolute pressure minus 10.1325 dbar), dbar

Returns
SParray-like, unitless

Practical Salinity on the PSS-78 scale

gsw.conversions.SP_from_SA(SA, p, lon, lat)[source]

Calculates Practical Salinity from Absolute Salinity.

Parameters
SAarray-like

Absolute Salinity, g/kg

parray-like

Sea pressure (absolute pressure minus 10.1325 dbar), dbar

lonarray-like

Longitude, -360 to 360 degrees

latarray-like

Latitude, -90 to 90 degrees

Returns
SParray-like, unitless

Practical Salinity (PSS-78)

gsw.conversions.SP_from_SK(SK)[source]

Calculates Practical Salinity from Knudsen Salinity.

Parameters
SKarray-like

Knudsen Salinity, ppt

Returns
SParray-like, unitless

Practical Salinity (PSS-78)

gsw.conversions.SP_from_SR(SR)[source]

Calculates Practical Salinity from Reference Salinity.

Parameters
SRarray-like

Reference Salinity, g/kg

Returns
SParray-like, unitless

Practical Salinity (PSS-78)

gsw.conversions.SP_from_Sstar(Sstar, p, lon, lat)[source]

Calculates Practical Salinity from Preformed Salinity.

Parameters
Sstararray-like

Preformed Salinity, g/kg

parray-like

Sea pressure (absolute pressure minus 10.1325 dbar), dbar

lonarray-like

Longitude, -360 to 360 degrees

latarray-like

Latitude, -90 to 90 degrees

Returns
SParray-like, unitless

Practical Salinity (PSS-78)

gsw.conversions.SR_from_SP(SP)[source]

Calculates Reference Salinity from Practical Salinity.

Parameters
SParray-like

Practical Salinity (PSS-78), unitless

Returns
SRarray-like, g/kg

Reference Salinity

gsw.conversions.Sstar_from_SA(SA, p, lon, lat)[source]

Converts Preformed Salinity from Absolute Salinity.

Parameters
SAarray-like

Absolute Salinity, g/kg

parray-like

Sea pressure (absolute pressure minus 10.1325 dbar), dbar

lonarray-like

Longitude, -360 to 360 degrees

latarray-like

Latitude, -90 to 90 degrees

Returns
Sstararray-like, g/kg

Preformed Salinity

gsw.conversions.Sstar_from_SP(SP, p, lon, lat)[source]

Calculates Preformed Salinity from Absolute Salinity. Since SP is non-negative by definition, this function changes any negative input values of SP to be zero.

Parameters
SParray-like

Practical Salinity (PSS-78), unitless

parray-like

Sea pressure (absolute pressure minus 10.1325 dbar), dbar

lonarray-like

Longitude, -360 to 360 degrees

latarray-like

Latitude, -90 to 90 degrees

Returns
Sstararray-like, g/kg

Preformed Salinity

gsw.conversions.adiabatic_lapse_rate_from_CT(SA, CT, p)[source]

Calculates the adiabatic lapse rate of sea water from Conservative Temperature.

Parameters
SAarray-like

Absolute Salinity, g/kg

CTarray-like

Conservative Temperature (ITS-90), degrees C

parray-like

Sea pressure (absolute pressure minus 10.1325 dbar), dbar

Returns
adiabatic_lapse_ratearray-like, K/Pa

adiabatic lapse rate

gsw.conversions.deltaSA_from_SP(SP, p, lon, lat)[source]

Calculates Absolute Salinity Anomaly from Practical Salinity. Since SP is non-negative by definition, this function changes any negative input values of SP to be zero.

Parameters
SParray-like

Practical Salinity (PSS-78), unitless

parray-like

Sea pressure (absolute pressure minus 10.1325 dbar), dbar

lonarray-like

Longitude, -360 to 360 degrees

latarray-like

Latitude, -90 to 90 degrees

Returns
deltaSAarray-like, g/kg

Absolute Salinity Anomaly

gsw.conversions.entropy_from_pt(SA, pt)[source]

Calculates specific entropy of seawater as a function of potential temperature.

Parameters
SAarray-like

Absolute Salinity, g/kg

ptarray-like

Potential temperature referenced to a sea pressure, degrees C

Returns
entropyarray-like, J/(kg*K)

specific entropy

gsw.conversions.entropy_from_t(SA, t, p)[source]

Calculates specific entropy of seawater from in-situ temperature.

Parameters
SAarray-like

Absolute Salinity, g/kg

tarray-like

In-situ temperature (ITS-90), degrees C

parray-like

Sea pressure (absolute pressure minus 10.1325 dbar), dbar

Returns
entropyarray-like, J/(kg*K)

specific entropy

gsw.conversions.p_from_z(z, lat, geo_strf_dyn_height=0, sea_surface_geopotential=0)[source]

Calculates sea pressure from height using computationally-efficient 75-term expression for density, in terms of SA, CT and p (Roquet et al., 2015). Dynamic height anomaly, geo_strf_dyn_height, if provided, must be computed with its p_ref = 0 (the surface). Also if provided, sea_surface_geopotental is the geopotential at zero sea pressure. This function solves Eqn.(3.32.3) of IOC et al. (2010) iteratively for p.

Parameters
zarray-like

Depth, positive up, m

latarray-like

Latitude, -90 to 90 degrees

geo_strf_dyn_heightarray-like
dynamic height anomaly, m^2/s^2

Note that the reference pressure, p_ref, of geo_strf_dyn_height must be zero (0) dbar.

sea_surface_geopotentialarray-like

geopotential at zero sea pressure, m^2/s^2

Returns
parray-like, dbar

sea pressure ( i.e. absolute pressure - 10.1325 dbar )

gsw.conversions.pt0_from_t(SA, t, p)[source]

Calculates potential temperature with reference pressure, p_ref = 0 dbar. The present routine is computationally faster than the more general function “gsw_pt_from_t(SA,t,p,p_ref)” which can be used for any reference pressure value. This subroutine calls “gsw_entropy_part(SA,t,p)”, “gsw_entropy_part_zerop(SA,pt0)” and “gsw_gibbs_pt0_pt0(SA,pt0)”.

Parameters
SAarray-like

Absolute Salinity, g/kg

tarray-like

In-situ temperature (ITS-90), degrees C

parray-like

Sea pressure (absolute pressure minus 10.1325 dbar), dbar

Returns
pt0array-like, deg C

potential temperature with reference sea pressure (p_ref) = 0 dbar.

gsw.conversions.pt_from_CT(SA, CT)[source]

Calculates potential temperature (with a reference sea pressure of zero dbar) from Conservative Temperature. This function uses 1.5 iterations through a modified Newton-Raphson (N-R) iterative solution procedure, starting from a rational-function-based initial condition for both pt and dCT_dpt.

Parameters
SAarray-like

Absolute Salinity, g/kg

CTarray-like

Conservative Temperature (ITS-90), degrees C

Returns
ptarray-like, deg C

potential temperature referenced to a sea pressure of zero dbar (ITS-90)

gsw.conversions.pt_from_entropy(SA, entropy)[source]

Calculates potential temperature with reference pressure p_ref = 0 dbar and with entropy as an input variable.

Parameters
SAarray-like

Absolute Salinity, g/kg

entropyarray-like

Specific entropy, J/(kg*K)

Returns
ptarray-like, deg C

potential temperature with reference sea pressure (p_ref) = 0 dbar.

gsw.conversions.pt_from_t(SA, t, p, p_ref)[source]

Calculates potential temperature with the general reference pressure, p_ref, from in-situ temperature, t. This function calls “gsw_entropy_part” which evaluates entropy except for the parts which are a function of Absolute Salinity alone. A faster gsw routine exists if p_ref is indeed zero dbar. This routine is “gsw_pt0_from_t(SA,t,p)”.

Parameters
SAarray-like

Absolute Salinity, g/kg

tarray-like

In-situ temperature (ITS-90), degrees C

parray-like

Sea pressure (absolute pressure minus 10.1325 dbar), dbar

p_refarray-like

Reference pressure, dbar

Returns
ptarray-like, deg C

potential temperature with reference pressure, p_ref, on the ITS-90 temperature scale

gsw.conversions.t90_from_t68(t68)[source]

ITS-90 temperature from IPTS-68 temperature

This conversion should be applied to all in-situ data collected between 1/1/1968 and 31/12/1989.

gsw.conversions.t_from_CT(SA, CT, p)[source]

Calculates in-situ temperature from the Conservative Temperature of seawater.

Parameters
SAarray-like

Absolute Salinity, g/kg

CTarray-like

Conservative Temperature (ITS-90), degrees C

parray-like

Sea pressure (absolute pressure minus 10.1325 dbar), dbar

Returns
tarray-like, deg C

in-situ temperature (ITS-90)

gsw.conversions.z_from_p(p, lat, geo_strf_dyn_height=0, sea_surface_geopotential=0)[source]

Calculates height from sea pressure using the computationally-efficient 75-term expression for specific volume in terms of SA, CT and p (Roquet et al., 2015). Dynamic height anomaly, geo_strf_dyn_height, if provided, must be computed with its p_ref = 0 (the surface). Also if provided, sea_surface_geopotental is the geopotential at zero sea pressure. This function solves Eqn.(3.32.3) of IOC et al. (2010).

Parameters
parray-like

Sea pressure (absolute pressure minus 10.1325 dbar), dbar

latarray-like

Latitude, -90 to 90 degrees

geo_strf_dyn_heightarray-like
dynamic height anomaly, m^2/s^2

Note that the reference pressure, p_ref, of geo_strf_dyn_height must be zero (0) dbar.

sea_surface_geopotentialarray-like

geopotential at zero sea pressure, m^2/s^2

Returns
zarray-like, m

height