def p_from_z(z, lat, geo_strf_dyn_height=0): r"""Calculates sea pressure from height using computationally-efficient 48-term expression for density, in terms of SA, CT and p (McDougall et al., 2011). Dynamic height anomaly, geo_strf_dyn_height, if provided, must be computed with its pr=0 (the surface.) Parameters ---------- z : array_like height [m] lat : array_like latitude in decimal degrees north [-90..+90] geo_strf_dyn_height : float, optional dynamic height anomaly [ m :sup:`2` s :sup:`-2` ] The reference pressure (p_ref) of geo_strf_dyn_height must be zero (0) dbar. Returns ------- p : array_like pressure [dbar] See Also -------- #FIXME: specvol_SSO_0_CT25, enthalpy_SSO_0_CT25, changed! Examples -------- >>> import gsw >>> z = [-10., -50., -125., -250., -600., -1000.] >>> lat = 4. >>> gsw.p_from_z(z, lat) array([ 10.05521794, 50.2711751, 125.6548857, 251.23284504, 602.44050752, 1003.07609807]) >>> z = [9.94460074, 49.71817465, 124.2728275, 248.47044828, 595.82618014, ... 992.0931748] >>> gsw.p_from_z(z, lat) array([ 10., 50., 125., 250., 600., 1000.]) Notes ----- Height (z) is NEGATIVE in the ocean. Depth is -z. Depth is not used in the gibbs library. References ---------- .. [1] IOC, SCOR and IAPSO, 2010: The international thermodynamic equation of seawater - 2010: Calculation and use of thermodynamic properties. Intergovernmental Oceanographic Commission, Manuals and Guides No. 56, UNESCO (English), 196 pp. .. [2] McDougall T.J., P.M. Barker, R. Feistel and D.R. Jackett, 2011: A computationally efficient 48-term expression for the density of seawater in terms of Conservative Temperature, and related properties of seawater. .. [3] Moritz (2000) Goedetic reference system 1980. J. Geodesy, 74, 128-133. .. [4] Saunders, P. M., 1981: Practical conversion of pressure to depth. Journal of Physical Oceanography, 11, 573-574. Modifications: 2010-08-26. Trevor McDougall, Claire Roberts-Thomson and Paul Barker. 2011-03-26. Trevor McDougall, Claire Roberts-Thomson and Paul Barker """ X = np.sin(lat * DEG2RAD) sin2 = X ** 2 gs = 9.780327 * (1.0 + (5.2792e-3 + (2.32e-5 * sin2)) * sin2) # get the first estimate of p from Saunders (1981) c1 = 5.25e-3 * sin2 + 5.92e-3 p = -2 * z / ((1 - c1) + np.sqrt((1 - c1) * (1 - c1) + 8.84e-6 * z)) df_dp = db2Pascal * specvol_SSO_0_p(p) # Initial value for f derivative. f = (enthalpy_SSO_0_p(p) + gs * (z - 0.5 * gamma * (z ** 2)) - geo_strf_dyn_height) p_old = p p = p_old - f / df_dp p_mid = 0.5 * (p + p_old) df_dp = db2Pascal * specvol_SSO_0_p(p_mid) p = p_old - f / df_dp # After this one iteration through this modified Newton-Raphson iterative # procedure, the remaining error in p is at computer machine precision, # being no more than 1.6e-10 dbar. return p
def specvol_anom(SA, CT, p): r"""Calculates specific volume anomaly from Absolute Salinity, Conservative Temperature and pressure. It uses the computationally-efficient 48-term expression for density as a function of SA, CT and p (McDougall et al., 2011). The reference value of Absolute Salinity is SSO and the reference value of Conservative Temperature is equal to 0 degrees C. Parameters ---------- SA : array_like Absolute Salinity [g/kg] CT : array_like Conservative Temperature [:math:`^\circ` C (ITS-90)] p : array_like sea pressure [dbar] Returns ------- specvol_anom : array_like specific volume anomaly [m**3/kg] See Also -------- TODO Notes ----- The 48-term equation has been fitted in a restricted range of parameter space, and is most accurate inside the "oceanographic funnel" described in McDougall et al. (2011). The GSW library function "infunnel(SA,CT,p)" is available to be used if one wants to test if some of one's data lies outside this "funnel". Examples -------- TODO References ---------- .. [1] IOC, SCOR and IAPSO, 2010: The international thermodynamic equation of seawater - 2010: Calculation and use of thermodynamic properties. Intergovernmental Oceanographic Commission, Manuals and Guides No. 56, UNESCO (English), 196 pp. See Eqn. (3.7.3). .. [2] McDougall T.J., P.M. Barker, R. Feistel and D.R. Jackett, 2011: A computationally efficient 48-term expression for the density of seawater in terms of Conservative Temperature, and related properties of seawater. Modifications: 2011-03-24. Paul Barker and Trevor McDougall. """ SA = np.maximum(SA, 0) """This function calculates specvol_anom using the computationally- efficient 48-term expression for density in terms of SA, CT and p. If one wanted to compute specvol_anom from SA, CT, and p with the full TEOS-10 Gibbs function, the following lines of code will enable this. pt = pt_from_CT(SA, CT) t = pt_from_t(SA, pt, 0, p) specvol_anom = specvol_anom_t_exact(SA, t, p) or call the following, it is identical to the lines above. specvol_anom = specvol_anom_CT_exact(SA, CT, p) """ return (v_hat_numerator(SA, CT, p) / v_hat_denominator(SA, CT, p) - specvol_SSO_0_p(p))
def specvol_anom(SA, CT, p): r"""Calculates specific volume anomaly from Absolute Salinity, Conservative Temperature and pressure. It uses the computationally-efficient 48-term expression for density as a function of SA, CT and p (McDougall et al., 2011). The reference value of Absolute Salinity is SSO and the reference value of Conservative Temperature is equal to 0 degrees C. Parameters ---------- SA : array_like Absolute Salinity [g/kg] CT : array_like Conservative Temperature [:math:`^\circ` C (ITS-90)] p : array_like sea pressure [dbar] Returns ------- specvol_anom : array_like specific volume anomaly [m**3/kg] See Also -------- TODO Notes ----- The 48-term equation has been fitted in a restricted range of parameter space, and is most accurate inside the "oceanographic funnel" described in McDougall et al. (2011). The GSW library function "infunnel(SA,CT,p)" is available to be used if one wants to test if some of one's data lies outside this "funnel". Examples -------- TODO References ---------- .. [1] IOC, SCOR and IAPSO, 2010: The international thermodynamic equation of seawater - 2010: Calculation and use of thermodynamic properties. Intergovernmental Oceanographic Commission, Manuals and Guides No. 56, UNESCO (English), 196 pp. See Eqn. (3.7.3). .. [2] McDougall T.J., P.M. Barker, R. Feistel and D.R. Jackett, 2011: A computationally efficient 48-term expression for the density of seawater in terms of Conservative Temperature, and related properties of seawater. Modifications: 2011-03-24. Paul Barker and Trevor McDougall. """ SA = np.maximum(SA, 0) sqrtSA = np.sqrt(SA) args = SA, CT, p, sqrtSA """This function calculates specvol_anom using the computationally- efficient 48-term expression for density in terms of SA, CT and p. If one wanted to compute specvol_anom from SA, CT, and p with the full TEOS-10 Gibbs function, the following lines of code will enable this. pt = pt_from_CT(SA, CT) t = pt_from_t(SA, pt, 0, p) specvol_anom = specvol_anom_t_exact(SA, t, p) or call the following, it is identical to the lines above. specvol_anom = specvol_anom_CT_exact(SA, CT, p) """ return (v_hat_numerator(*args) / v_hat_denominator(*args) - specvol_SSO_0_p(p))
def p_from_z(z, lat, geo_strf_dyn_height=0): r"""Calculates sea pressure from height using computationally-efficient 48-term expression for density, in terms of SA, CT and p (McDougall et al., 2011). Dynamic height anomaly, geo_strf_dyn_height, if provided, must be computed with its pr=0 (the surface.) Parameters ---------- z : array_like height [m] lat : array_like latitude in decimal degrees north [-90..+90] geo_strf_dyn_height : float, optional dynamic height anomaly [ m :sup:`2` s :sup:`-2` ] The reference pressure (p_ref) of geo_strf_dyn_height must be zero (0) dbar. Returns ------- p : array_like pressure [dbar] See Also -------- #FIXME: specvol_SSO_0_CT25, enthalpy_SSO_0_CT25, changed! Examples -------- >>> import gsw >>> z = [-10., -50., -125., -250., -600., -1000.] >>> lat = 4. >>> gsw.p_from_z(z, lat) array([ 10.05521794, 50.2711751, 125.6548857, 251.23284504, 602.44050752, 1003.07609807]) >>> z = [9.94460074, 49.71817465, 124.2728275, 248.47044828, 595.82618014, ... 992.0931748] >>> gsw.p_from_z(z, lat) array([ 10., 50., 125., 250., 600., 1000.]) Notes ----- Height (z) is NEGATIVE in the ocean. Depth is -z. Depth is not used in the gibbs library. References ---------- .. [1] IOC, SCOR and IAPSO, 2010: The international thermodynamic equation of seawater - 2010: Calculation and use of thermodynamic properties. Intergovernmental Oceanographic Commission, Manuals and Guides No. 56, UNESCO (English), 196 pp. .. [2] McDougall T.J., P.M. Barker, R. Feistel and D.R. Jackett, 2011: A computationally efficient 48-term expression for the density of seawater in terms of Conservative Temperature, and related properties of seawater. .. [3] Moritz (2000) Goedetic reference system 1980. J. Geodesy, 74, 128-133. .. [4] Saunders, P. M., 1981: Practical conversion of pressure to depth. Journal of Physical Oceanography, 11, 573-574. Modifications: 2010-08-26. Trevor McDougall, Claire Roberts-Thomson and Paul Barker. 2011-03-26. Trevor McDougall, Claire Roberts-Thomson and Paul Barker """ X = np.sin(lat * rad) sin2 = X ** 2 gs = 9.780327 * (1.0 + (5.2792e-3 + (2.32e-5 * sin2)) * sin2) # get the first estimate of p from Saunders (1981) c1 = 5.25e-3 * sin2 + 5.92e-3 p = -2 * z / ((1 - c1) + np.sqrt((1 - c1) * (1 - c1) + 8.84e-6 * z)) df_dp = db2Pascal * specvol_SSO_0_p(p) # Initial value for f derivative. f = (enthalpy_SSO_0_p(p) + gs * (z - 0.5 * gamma * (z ** 2)) - geo_strf_dyn_height) p_old = p p = p_old - f / df_dp p_mid = 0.5 * (p + p_old) df_dp = db2Pascal * specvol_SSO_0_p(p_mid) p = p_old - f / df_dp # After this one iteration through this modified Newton-Raphson iterative # procedure, the remaining error in p is at computer machine precision, # being no more than 1.6e-10 dbar. return p