lair.air.meteorology#

Meteorological calculations.

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

Note

It would be nice to be able to wrap these funtions with pint - however, because I input both numpy and xarray arrays, this will not work. Waiting for xarray-contrib/pint-xarray#143 For now, we will assume all inputs are in SI units.

Module Attributes

standard

Standard Atmosphere

Functions

T_from_e(e)

Calculate the temperature from vapor pressure.

hypsometric([Tv, p1, p2, Z1, Z2, deltaz])

Hyposometric equation solver.

ideal_gas_law(solve_for[, p, V, T, m, n, N, ...])

Ideal gas law equation solver.

inv_poisson(p, theta[, p0])

Calculate the temperature from potential temperature.

mixing_ratio(e, p)

Calculate the mixing ratio.

poisson(T, p[, p0])

Calculate the potential temperature.

sat_vapor_pres(T)

Calculate the saturation vapor pressure.

sat_vapor_pres_ice(T)

Calculate the saturation vapor pressure over ice.

virt_T(T, q)

Calculate the virtual temperature.

lair.air.meteorology.standard: dict[str, float] = {'T': <Quantity(288.15, 'kelvin')>, 'p': <Quantity(1013.25, 'hectopascal')>, 'rho': <Quantity(1.225, 'kilogram / meter ** 3')>, 'z': <Quantity(0, 'meter')>}#

Standard Atmosphere

lair.air.meteorology.ideal_gas_law(solve_for, p=None, V=None, T=None, m=None, n=None, N=None, rho=None, alpha=None, R=None)[source]#

Ideal gas law equation solver. Solver attempts to solve for the specified variable using the following forms of the ideal gas law:

pV = nR*T pV = mRT pV = NkbT p = ρRT pα = RT

Input variables must be able to solve for the desired variable using the above equations without intermediate steps. All inputs must be in SI.

p : pressure (Pa) V : volume (m^3) T : temperature (K) m : mass (kg) n : moles (mol) N : number of molecules (#) ρ : density (kg/m^3) α : specific volume (m^3/kg) R : specific gas constant (J/kg/K)

Can be used to solve for pressure, volume, temperature, density, mass, moles, or number of molecules.

lair.air.meteorology.hypsometric(Tv=None, p1=None, p2=None, Z1=None, Z2=None, deltaz=None)[source]#

Hyposometric equation solver.

Z2 - Z1 = Rd * Tv * ln(p1/p2) / g

Input variables must be able to solve for the desired variable using the above equation without intermediate steps. All inputs must be in SI.

Tv : mean virtual temperature of layer (K) p1 : pressure at bottom of layer (Pa) p2 : pressure at top of layer (Pa) Z1 : geopotential height at bottom of layer (m) Z2 : geopotential height at top of layer (m) deltaz : thickness of layer (m)

Can be used to solve for any of the variables in the equation or deltaz.

lair.air.meteorology.virt_T(T: float, q: float) float[source]#

Calculate the virtual temperature.

Parameters:
Tfloat

Temperature in Kelvin.

qfloat

Specific humidity in kg/kg.

Returns:
float

Virtual temperature in Kelvin.

lair.air.meteorology.poisson(T: float, p: float, p0: float = 100000.0) float[source]#

Calculate the potential temperature. (Poission’s equation)

Parameters:
Tfloat

Temperature in Kelvin.

pfloat

Pressure in Pascals.

p0float, optional

Reference pressure in Pascals. Default is 1000 hPa.

Returns:
float

Potential temperature in Kelvin.

lair.air.meteorology.inv_poisson(p: float, theta: float, p0: float = 100000.0) float[source]#

Calculate the temperature from potential temperature. (Inverse Poission’s equation)

Parameters:
pfloat

Pressure in Pascals.

thetafloat

Potential temperature in Kelvin.

p0float, optional

Reference pressure in Pascals. Default is 1000 hPa.

Returns:
float

Temperature in Kelvin.

lair.air.meteorology.sat_vapor_pres(T: float) float[source]#

Calculate the saturation vapor pressure.

Parameters:
Tfloat

Temperature in Kelvin.

Returns:
float

Saturation vapor pressure in Pascals.

lair.air.meteorology.sat_vapor_pres_ice(T: float) float[source]#

Calculate the saturation vapor pressure over ice.

Parameters:
Tfloat

Temperature in Kelvin.

Returns:
float

Saturation vapor pressure over ice in Pascals.

lair.air.meteorology.mixing_ratio(e: float, p: float) float[source]#

Calculate the mixing ratio.

Parameters:
efloat

Vapor pressure in Pascals.

pfloat

Pressure in Pascals.

Returns:
float

Mixing ratio in kg/kg.

lair.air.meteorology.T_from_e(e: float) float[source]#

Calculate the temperature from vapor pressure.

Parameters:
efloat

Vapor pressure in Pascals.

Returns:
float

Temperature in Kelvin.