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 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
def z_from_p(p, lat, geo_strf_dyn_height=0): r"""Calculates height from sea pressure using the 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 ---------- p : array_like pressure [dbar] 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` ] Returns ------- z : array_like height [m] See Also -------- # FIXME: enthalpy_SSO_0_CT25, changed! Examples -------- >>> import gsw >>> p = [10, 50, 125, 250, 600, 1000] >>> lat = 4 >>> gsw.z_from_p(p, lat) array([ -9.94460074, -49.71817465, -124.2728275 , -248.47044828, -595.82618014, -992.0931748 ]) Notes ----- At sea level z = 0, and since z (HEIGHT) is defined to be positive upwards, it follows that while z is positive in the atmosphere, it is NEGATIVE in the ocean. 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. Modifications: 2011-03-26. Trevor McDougall, Claire Roberts-Thomson and Paul Barker. """ X = np.sin(lat * DEG2RAD) sin2 = X ** 2 B = 9.780327 * (1.0 + (5.2792e-3 + (2.32e-5 * sin2)) * sin2) A = -0.5 * gamma * B C = enthalpy_SSO_0_p(p) - geo_strf_dyn_height return -2 * C / (B + np.sqrt(B ** 2 - 4 * A * C))
def z_from_p(p, lat, geo_strf_dyn_height=None): r"""Calculates height from sea pressure using the 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 ---------- p : array_like pressure [dbar] 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` ] Returns ------- z : array_like height [m] See Also -------- # FIXME: enthalpy_SSO_0_CT25, changed! Examples -------- >>> import gsw >>> p = [10, 50, 125, 250, 600, 1000] >>> lat = 4 >>> gsw.z_from_p(p, lat) array([ -9.94460074, -49.71817465, -124.2728275 , -248.47044828, -595.82618014, -992.0931748 ]) Notes ----- At sea level z = 0, and since z (HEIGHT) is defined to be positive upwards, it follows that while z is positive in the atmosphere, it is NEGATIVE in the ocean. 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. Modifications: 2011-03-26. Trevor McDougall, Claire Roberts-Thomson and Paul Barker. """ if not geo_strf_dyn_height: geo_strf_dyn_height = np.zeros(p.shape) X = np.sin(lat * rad) sin2 = X ** 2 B = 9.780327 * (1.0 + (5.2792e-3 + (2.32e-5 * sin2)) * sin2) A = -0.5 * gamma * B C = enthalpy_SSO_0_p(p) - geo_strf_dyn_height z = -2 * C / (B + np.sqrt(B ** 2 - 4 * A * C)) return z