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
Scalars, numpy arrays or xarray DataArrays in SI units, as inputs and results |
|
T [K], p [Pa], rho [kg/m^3], z [m] |
Functions
Calculate the temperature from vapor pressure. |
|
Solve the hypsometric equation for one variable. |
|
Solve the ideal gas law for one variable. |
|
Calculate the temperature from the potential temperature. |
|
Calculate the mixing ratio. |
|
Calculate the potential temperature (Poisson's equation). |
|
Calculate the saturation vapor pressure. |
|
Calculate the saturation vapor pressure over ice. |
|
Calculate the virtual temperature. |