Skip to content

Commit

Permalink
rename lfunctions that calculate lapse rate from dt_ to lapse_
Browse files Browse the repository at this point in the history
  • Loading branch information
Osamu Miyawaki committed Nov 14, 2023
1 parent 373e4b2 commit 85afef0
Showing 1 changed file with 58 additions and 11 deletions.
69 changes: 58 additions & 11 deletions src/metpy/calc/thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def dry_lapse(pressure, temperature, reference_pressure=None, vertical_dim=0):
return temperature * (pressure / reference_pressure)**mpconsts.kappa


def dt_standard(p, t, params):
def lapse_standard(p, t, params):
r"""
Compute the AMS moist adiabatic lapse rate in pressure coordinates.
Expand Down Expand Up @@ -285,7 +285,7 @@ def dt_standard(p, t, params):
return frac / p


def dt_pseudoadiabatic(p, t, params):
def lapse_pseudoadiabatic(p, t, params):
r"""
Compute the AMS pseudoadiabatic lapse rate in pressure coordinates.
Expand Down Expand Up @@ -314,7 +314,7 @@ def dt_pseudoadiabatic(p, t, params):
return frac / p


def dt_reversible(p, t, params):
def lapse_reversible(p, t, params):
r"""
Compute the AMS reversible lapse rate in pressure coordinates.
Expand Down Expand Up @@ -345,7 +345,40 @@ def dt_reversible(p, t, params):
return frac / p


def dt_so13(p, t, params):
def lapse_r24(p, t, params):
r"""
Compute the Risi et al. (2024) entraining lapse rate in pressure coordinates.
Parameters
----------
p : `float`
pressure [Pa]
t : `float`
temperature [K]
params : `dict`
'ep0': scalar, entrainment rate [m**-1]
'rh0': scalar, ambient relative humidity [unitless]
Returns
-------
dT/dp : `float`
lapse rate in pressure coordinates
"""
rs = saturation_mixing_ratio._nounit(p, t)
qs = specific_humidity_from_mixing_ratio(rs)
frac = ((mpconsts.nounit.Rd * t + mpconsts.nounit.Lv * qs
+ params['ep0'] * qs * mpconsts.nounit.Lv * (1 - params['rh0'])
* mpconsts.nounit.Rd * t / mpconsts.nounit.g)
/ (mpconsts.nounit.Cp_d
+ (mpconsts.nounit.Lv**2 * qs * mpconsts.nounit.epsilon
/ (mpconsts.nounit.Rd * t**2))))
return frac / p


def lapse_so13(p, t, params):
r"""
Compute the Singh & O'Gorman (2013) entraining lapse rate in pressure coordinates.
Expand Down Expand Up @@ -385,7 +418,7 @@ def dt_so13(p, t, params):
return frac / p


def dt_r14(p, t, params):
def lapse_r14(p, t, params):
r"""
Compute the Romps (2014) entraining lapse rate in pressure coordinates.
Expand Down Expand Up @@ -449,19 +482,21 @@ def select_dt(lapse_type):
"""
if lapse_type == 'standard':
dt = dt_standard
dt = lapse_standard
elif lapse_type == 'pseudoadiabatic':
dt = dt_pseudoadiabatic
dt = lapse_pseudoadiabatic
elif lapse_type == 'reversible':
dt = dt_reversible
dt = lapse_reversible
elif lapse_type == 'r24':
dt = lapse_r24
elif lapse_type == 'so13':
dt = dt_so13
dt = lapse_so13
elif lapse_type == 'r14':
dt = dt_r14
dt = lapse_r14
else:
raise ValueError('Specified lapse_type is not supported. '
'Choose from standard, pseudoadiabatic, reversible, '
'so13, or r14.')
'r24, so13, or r14.')
return dt


Expand Down Expand Up @@ -537,13 +572,17 @@ def moist_lapse(pressure, temperature, reference_pressure=None,
'standard' for simplified pseudoadiabatic process
'pseudoadiabatic' for pseudoadiabatic moist process
'reversible' for reversible moist process
'r24' for Risi et al. (2024);
'so13' for Singh and O'Gorman (2013); doi.org/10.1002/grl.50796
'r14' for Romps (2014); doi.org/10.1175/JCLI-D-14-00255.1
More info: glossary.ametsoc.org/wiki/Adiabatic_lapse_rate
params : `dict` or None, optional
External parameters used for the some lapse_types
Required parameters:
For 'r24':
'ep0': scalar, entrainment rate [m**-1],
'rh0': scalar, ambient relative humidity [unitless],}
For 'so13':
'ep0': scalar, entrainment constant [unitless],
'rh0': scalar, ambient relative humidity [unitless],}
Expand Down Expand Up @@ -1202,13 +1241,17 @@ def parcel_profile(pressure, temperature, dewpoint, lapse_type='standard', param
'standard' for simplified pseudoadiabatic process
'pseudoadiabatic' for pseudoadiabatic moist process
'reversible' for reversible moist process
'r24' for Risi et al. (2024);
'so13' for Singh and O'Gorman (2013); doi.org/10.1002/grl.50796
'r14' for Romps (2014); doi.org/10.1175/JCLI-D-14-00255.1
More info: glossary.ametsoc.org/wiki/Adiabatic_lapse_rate
params : `dict` or None, optional
External parameters used for the some lapse_types
Required parameters:
For 'r24':
'ep0': entrainment rate [m**-1],
'rh0': ambient relative humidity [unitless],
For 'so13':
'ep0': entrainment constant [unitless],
'rh0': ambient relative humidity [unitless],
Expand Down Expand Up @@ -1307,13 +1350,17 @@ def parcel_profile_with_lcl(pressure, temperature, dewpoint,
'standard' for simplified pseudoadiabatic process
'pseudoadiabatic' for pseudoadiabatic moist process
'reversible' for reversible moist process
'r24' for Risi et al. (2024);
'so13' for Singh and O'Gorman (2013); doi.org/10.1002/grl.50796
'r14' for Romps (2014); doi.org/10.1175/JCLI-D-14-00255.1
More info: glossary.ametsoc.org/wiki/Adiabatic_lapse_rate
params : `dict` or None, optional
External parameters used for the some lapse_types
Required parameters:
For 'r24':
'ep0': entrainment rate [m**-1],
'rh0': ambient relative humidity [unitless],
For 'so13':
'ep0': entrainment constant [unitless],
'rh0': ambient relative humidity [unitless],
Expand Down

0 comments on commit 85afef0

Please sign in to comment.