Dewpoint and Mixing RatioΒΆ

Notebook

The goal of this notebook is to show an example using the units support in MetPy. In this example, we calculate the dewpoint, corresponding to a fixed value of mixing ratio, at two different surface pressure values.

# First import our calculation functions, as well as unit support
import metpy.calc as mcalc
from metpy.units import units
# Create a test value of mixing ratio in grams per kilogram
mixing = 10 * units('g/kg')
print(mixing)
10.0 gram / kilogram
# Now throw that value with units into the function to calculate
# the corresponding vapor pressure, given a surface pressure of 1000 mb
e = mcalc.vapor_pressure(1000. * units.mbar, mixing)
print(e)
15825.67178529092 gram * millibar / kilogram
# Take the odd units and force them to millibars
print(e.to(units.mbar))
15.82567178529092 millibar
# Take the raw vapor pressure and throw into the dewpoint function
td = mcalc.dewpoint(e)
print(td)
13.856458659577921 degC
# Which can of course be converted to Farenheit
print(td.to('degF'))
56.94162598724023 degF
# Now do the same thing for 850 mb, approximately the pressure of Denver
e = mcalc.vapor_pressure(850. * units.mbar, mixing)
print(e.to(units.mbar))
13.451821017497283 millibar
# And print the corresponding dewpoint
td = mcalc.dewpoint(e)
print(td, td.to('degF'))
11.378824018637602 degC 52.48188363354765 degF