0

I'm trying to estimate the vertical wind velocity from vertical pressure velocity. I found metpy.calc.vertical_velocity(omega, pressure, temperature, mixing=0).

https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.vertical_velocity.html

However, there is no documentation on what unit it needs. I gave it Omega in Pa s-1, pressure in Pa, and temperature in K, all in the xarray format. I expect the output to be a xarray too. I got this error: "Cannot convert from 'pascal * second' to 'dimensionless". Any thought why it wants dimensionless variables and how to fix this?

shimaSH
  • 55
  • 10

1 Answers1

1

That error comes from a problem parsing the Udunits-formatted unit string "Pa s-1". The default unit-parser in pint (the unit library used by MetPy) parses this as: Pa * s - 1, which is non-sensical. Luckily, with MetPy 1.0, this should work:

import metpy.calc
import xarray as xr

omega = xr.DataArray([5], attrs={'units': 'Pa s-1'})
pressure = xr.DataArray([50000], attrs={'units': 'Pa'})
temperature = xr.DataArray([283], attrs={'units': 'K'})
metpy.calc.vertical_velocity(omega, pressure, temperature, mixing_ratio=0)

You can currently install metpy 1.0.0rc1 from pip:

pip install --pre metpy

or from conda-forge:

conda install -c conda-forge/label/metpy_rc metpy=1.0.0rc1
DopplerShift
  • 5,472
  • 1
  • 21
  • 20