Thermodynamic Calculations

metpy.calc.thermo

metpy.calc.thermo.potential_temperature(pressure, temperature)

Calculate the potential temperature.

Uses the Poisson equation to calculation the potential temperature given pressure and temperature.

Parameters:
  • pressure (array_like) – The total atmospheric pressure in mb
  • temperature (array_like) – The temperature in Kelvin
Returns:

The potential temperature corresponding to the the temperature and pressure.

Return type:

array_like

See also

dry_lapse()

Notes

Formula:

\[\Theta = T (P_0 / P)^\kappa\]

Examples

>>> metpy.calc.potential_temperature(800., 273.)
290.9814150577374
metpy.calc.thermo.dry_lapse(pressure, temperature, starting_pressure=1000.0)

Calculate the temperature at a level assuming only dry processes operating from the starting point.

This function lifts a parcel starting at temperature and starting_pressure to the level given by pressure, conserving potential temperature.

Parameters:
  • pressure (array_like) – The atmospheric pressure level of interest in mb
  • temperature (array_like) – The starting temperature in Kelvin
  • starting_pressure (array_like) – The pressure at the starting point. Defaults to P0 (1000 mb).
Returns:

The resulting parcel temperature, in Kelvin, at level pressure

Return type:

array_like

See also

moist_lapse()
Calculate parcel temperature assuming liquid saturation processes
parcel_profile()
Calculate complete parcel profile

potential_temperature()

metpy.calc.thermo.moist_lapse(pressure, temperature)

Calculate the temperature at a level assuming liquid saturation processes operating from the starting point.

This function lifts a parcel starting at temperature this is calculating moist pseudo-adiabats. The starting pressure should be the first item in the pressure array.

Parameters:
  • pressure (array_like) – The atmospheric pressure level of interest in mb
  • temperature (array_like) – The starting temperature in Kelvin
Returns:

The temperature corresponding to the the starting temperature and pressure levels, with the shape determined by numpy broadcasting rules.

Return type:

array_like

See also

dry_lapse()
Calculate parcel temperature assuming dry adiabatic processes
parcel_profile()
Calculate complete parcel profile

Notes

This function is implemented by integrating the following differential equation:

\[\frac{dT}{dP} = \frac{1}{P} \frac{R_d T + L_v r_s} {C_{pd} + \frac{L_v^2 r_s \epsilon}{R_d T^2}}\]

This equation comes from [1].

References

[1]Bakhshaii, A. and R. Stull, 2013: Saturated Pseudoadiabats–A Noniterative Approximation. J. Appl. Meteor. Clim., 52, 5-15.
metpy.calc.thermo.lcl(pressure, temperature, dewpt, max_iters=50, eps=0.01)

Calculate the lifted condensation level (LCL) using from the starting point.

The starting state for the parcel is defined by temperature, dewpoint, and pressure.

Parameters:
  • pressure (array_like) – The starting atmospheric pressure in mb
  • temperature (array_like) – The starting temperature in Kelvin
  • dewpt (array_like) – The dew point in Kelvin
Returns:

The LCL in mb.

Return type:

array_like

Other Parameters:
 
  • max_iters (int, optional) – The maximum number of iterations to use in calculation, defaults to 50.
  • eps (float, optional) – The desired absolute error in the calculated value, defaults to 1e-2.

See also

parcel_profile()

Notes

This function is implemented using an iterative approach to solve for the LCL. The basic algorithm is: 1. Find the dew point from the LCL pressure and starting mixing ratio 2. Find the LCL pressure from the starting temperature and dewpoint 3. Iterate until convergence

The function is guaranteed to finish by virtue of the maxIters counter.

metpy.calc.thermo.parcel_profile(pressure, temperature, dewpt)

Calculate the profile a parcel takes through the atmosphere, lifting from the starting point.

The parcel starts at temperature, and dewpt, lifed up dry adiabatically to the LCL, and then moist adiabatically from there. pressure specifies the pressure levels for the profile.

Parameters:
  • pressure (array_like) – The atmospheric pressure in mb. The first entry should be the starting point pressure.
  • temperature (array_like) – The temperature in Kelvin
  • dewpt (array_like) – The dew point in Kelvin
Returns:

The parcel temperatures at the specified pressure levels.

Return type:

array_like

metpy.calc.thermo.vapor_pressure(pressure, mixing)

Calculate water vapor (partial) pressure

Given total pressure and water vapor mixing ratio, calculates the partial pressure of water vapor.

Parameters:
  • pressure (array_like) – total atmospheric pressure
  • mixing (array_like) – dimensionless mass mixing ratio
Returns:

The ambient water vapor (partial) pressure in the same units as pressure.

Return type:

array_like

metpy.calc.thermo.saturation_vapor_pressure(temperature)

Calculate the saturation water vapor (partial) pressure

Parameters:temperature (array_like) – The temperature in degrees Celsius.
Returns:The saturation water vapor (partial) presure in mb.
Return type:array_like

Notes

Instead of temperature, dewpoint may be used in order to calculate the actual (ambient) water vapor (partial) pressure.

The formula used is that from Bolton 1980 [2] for T in degrees Celsius:

\[6.112 e^\frac{17.67T}{T + 243.5}\]

References

[2]Bolton, D., 1980: The Computation of Equivalent Potential Temperature. Mon. Wea. Rev., 108, 1046-1053.
metpy.calc.thermo.dewpoint_rh(temperature, rh)

Calculate the ambient dewpoint given air temperature and relative humidity.

Parameters:
  • temperature (array_like) – Temperature in degrees Celsius
  • rh (array_like) – Relative humidity expressed as a ratio in the range [0, 1]
Returns:

The dew point temperature in degrees Celsius, with the shape of the result being determined using numpy’s broadcasting rules.

Return type:

array_like

metpy.calc.thermo.dewpoint(e)

Calculate the ambient dewpoint given the vapor pressure.

Parameters:e (array_like) – Water vapor partial pressure in mb
Returns:Dew point temperature in degrees Celsius.
Return type:array_like

Notes

This function inverts the Bolton 1980 [3] formula for saturation vapor pressure to instead calculate the temperature. This yield the following formula for dewpoint in degrees Celsius:

\[T = \frac{243.5 log(e / 6.112)}{17.67 - log(e / 6.112)}\]

References

[3]Bolton, D., 1980: The Computation of Equivalent Potential Temperature. Mon. Wea. Rev., 108, 1046-1053.
metpy.calc.thermo.mixing_ratio(part_press, tot_press)

Calculates the mixing ratio of gas given its partial pressure and the total pressure of the air.

There are no required units for the input arrays, other than that they have the same units.

Parameters:
  • part_press (array_like) – Partial pressure of the constituent gas
  • tot_press (array_like) – Total air pressure
Returns:

The (mass) mixing ratio, unitless (e.g. Kg/Kg or g/g)

Return type:

array_like

See also

vapor_pressure()