lair.meteorology#

Meteorological calculations.

Inspired by AOS 330 at UW-Madison with Grant Petty.

Units contract: plain SI in, plain SI out. Inputs are floats, numpy arrays or xarray DataArrays in SI units (K, Pa, m, kg, mol, m^3, J/kg/K, …), and the results are the same kinds of plain numbers in SI units (e.g. hypsometric returns meters, ideal_gas_law("p", ...) returns Pa). The physical constants are used as plain SI floats internally.

pint Quantities (and pint-quantified xarray DataArrays) are accepted for convenience: they are converted to SI magnitudes on the way in (so 850 * units("hPa") becomes 85000.0 and 0 degC becomes 273.15), and the result is still a plain SI number, never a Quantity. Attach units to the result yourself if you want them.

Note

It would be nice to wrap these functions with pint end to end, but numpy and xarray inputs make that awkward. See xarray-contrib/pint-xarray#143

Attributes

Numeric

Scalars, numpy arrays or xarray DataArrays in SI units, as inputs and results

standard

T [K], p [Pa], rho [kg/m^3], z [m]

Functions

T_from_e

Calculate the temperature from vapor pressure.

hypsometric

Solve the hypsometric equation for one variable.

ideal_gas_law

Solve the ideal gas law for one variable.

inv_poisson

Calculate the temperature from the potential temperature.

mixing_ratio

Calculate the mixing ratio.

poisson

Calculate the potential temperature (Poisson's equation).

sat_vapor_pres

Calculate the saturation vapor pressure.

sat_vapor_pres_ice

Calculate the saturation vapor pressure over ice.

virt_T

Calculate the virtual temperature.