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.
In [1]:
# First import our calculation functions, as well as unit support
import metpy.calc as mcalc
from metpy.units import units
In [2]:
# Create a test value of mixing ratio in grams per kilogram
mixing = 10 * units('g/kg')
print(mixing)
In [3]:
# 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)
In [4]:
# Take the odd units and force them to millibars
print(e.to(units.mbar))
In [5]:
# Take the raw vapor pressure and throw into the dewpoint function
td = mcalc.dewpoint(e)
print(td)
In [6]:
# Which can of course be converted to Farenheit
print(td.to('degF'))
In [7]:
# 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))
In [8]:
# And print the corresponding dewpoint
td = mcalc.dewpoint(e)
print(td, td.to('degF'))