mixing_ratio#
- metpy.calc.mixing_ratio(partial_press, total_press, molecular_weight_ratio=0.6219569100577033)[source]#
Calculate the mixing ratio of a gas.
This calculates mixing ratio 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:
partial_press (
pint.Quantity
) – Partial pressure of the constituent gastotal_press (
pint.Quantity
) – Total air pressuremolecular_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
– The (mass) mixing ratio, dimensionless (e.g. Kg/Kg or g/g)
Examples
>>> from metpy.calc import mixing_ratio >>> from metpy.units import units >>> mixing_ratio(25 * units.hPa, 1000 * units.hPa).to('g/kg') <Quantity(15.9476131, 'gram / kilogram')>
See also
Notes
This function is a straightforward implementation of the equation given in many places, such as [Hobbs1977] pg.73:
\[r = \epsilon \frac{e}{p - e}\]Changed in version 1.0: Renamed
part_press
,tot_press
parameters topartial_press
,total_press