Skip to content

Verify results of vapor_pressure results #2984

Answered by dcamron
Marston asked this question in Q&A
Discussion options

You must be logged in to vote

MetPy functions' outputs, where possible, preserve the type of the inputs. So if you provide a Pint Quantity (which is what 988 * units.hPa returns), that is what you'll get back. With that comes all of the functionality associated with Quantitys, like the Quantity.to() method for converting units. If instead you provide a DataArray, 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 DataArrays, eg DataArray.metpy.convert_units(),

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!

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@dcamron
Comment options

@Marston
Comment options

Answer selected by dopplershift
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants