-
from metpy.calc import vapor_pressure
vapor_pressure(988 * units.hPa, 18 * units('g/kg')).to('hPa') The above example works but when |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
MetPy functions' outputs, where possible, preserve the type of the inputs. So if you provide a Pint To help, we do provide our own helpers to work with units inside of vapor_pressure(my_dataset["pressure"], my_dataset["mixing_ratio"]).metpy.convert_units('hPa') Check out the xarray with MetPy Tutorial on the docs for more info! |
Beta Was this translation helpful? Give feedback.
MetPy functions' outputs, where possible, preserve the type of the inputs. So if you provide a Pint
Quantity
(which is what988 * units.hPa
returns), that is what you'll get back. With that comes all of the functionality associated withQuantity
s, like theQuantity.to()
method for converting units. If instead you provide aDataArray
, you will get one back, along with the methods accessible to those.To help, we do provide our own helpers to work with units inside of
DataArray
s, egDataArray.metpy.convert_units()
,Check out the xarray with MetPy Tutorial on the docs for more info!