density#
- metpy.calc.density(pressure, temperature, mixing_ratio, molecular_weight_ratio=<Quantity(0.62195691, 'dimensionless')>)[source]#
Calculate density.
This calculation must be given an air parcel’s pressure, temperature, and mixing ratio. The implementation uses the formula outlined in [Hobbs2006] pg.67.
- Parameters:
pressure (
pint.Quantity
) – Total atmospheric pressuretemperature (
pint.Quantity
) – Air temperature (or the virtual temperature if the mixing ratio is set to 0)mixing_ratio (
pint.Quantity
) – Mass mixing ratio (dimensionless)molecular_weight_ratio (
pint.Quantity
or float, optional) – The ratio of the molecular weight of the constituent gas to that assumed for air. Defaults to the ratio for water vapor to dry air. (\(\epsilon\approx0.622\))
- Returns:
pint.Quantity
– Corresponding density of the parcel
Examples
>>> from metpy.calc import density >>> from metpy.units import units >>> density(1000 * units.hPa, 10 * units.degC, 24 * units('g/kg')) <Quantity(1.21307146, 'kilogram / meter ** 3')>
Notes
\[\rho = \frac{\epsilon p\,(1+w)}{R_dT\,(w+\epsilon)}\]Changed in version 1.0: Renamed
mixing
parameter tomixing_ratio