Replies: 5 comments 3 replies
-
What version of MetPy are you using? This looks like the problem: Looking at how you're calling the function, you're providing 5 positional arguments but the function only takes Note this is for MetPy v1.6 here: https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.vorticity.html |
Beta Was this translation helpful? Give feedback.
-
Yes you are correct - https://github.com/Unidata/MetPy/blob/main/tests/calc/test_kinematics.py#L70 and I am using 1.6. If I use GFS data with just the positional arguments with u and v it's fine. Here I am using mock up data. My version of the mock is taken from https://github.com/Unidata/MetPy/blob/main/conftest.py#L169 Now I get this error.
|
Beta Was this translation helpful? Give feedback.
-
`from metpy.units import check_units def main():
u850 = xr.open_dataset('gfs.t12z.pgrb2.0p25.f000', engine='cfgrib',backend_kwargs={'filter_by_keys':{'typeOfLevel': 'isobaricInhPa', 'shortName': 'u', 'level': 850}}) main()` This is how I invoke the GFS data to load the u850 array. I am not sure where the CRS information is stored in the GFS file. Regarding your suggestion to add these 2 methods -
these should be invoked on the xarray objects after they have been instantiated like this
But that will be problematic because the error I reported is thrown when the object is instantiated. This test case works - https://github.com/Unidata/MetPy/blob/main/tests/calc/test_kinematics.py#L70 and uses 2d arrays. Just not sure what is the CRS they are using. ` |
Beta Was this translation helpful? Give feedback.
-
I am submitting a PR that uses the vorticity function. Therefore I need to submit a unit test case with mock data that replicates the GFS data. The data can be constant but it needs to be of a sufficient spatial scale so that the voriticity makes physical sense. ` crs = pyproj.CRS(4326)
main()` Yes you are right with this code I am getting this error
|
Beta Was this translation helpful? Give feedback.
-
@DanielAdriaansen I got it to work eventually - contrived maybe but does work - `import xarray as xr def setUpData():
|
Beta Was this translation helpful? Give feedback.
-
I am trying to get a geographic vorticity test case going and I get the following error. But first the example code
`
import xarray as xr
import numpy as np
import metpy.calc as mpcalc
from metpy.units import units
import pyproj
import sys
def main():
setUpData()
def setUpData():
main()`
I get this error -
File "/home/winash12/testpython/test_rot_inv.py", line 28, in setUpData vort = mpcalc.vorticity(u,v,longitude,latitude,crs) File "/usr/local/lib/python3.9/dist-packages/metpy/calc/tools.py", line 1032, in wrapper bound_args = newsig.bind(*args, **kwargs) File "/usr/lib/python3.9/inspect.py", line 3062, in bind return self._bind(args, kwargs) File "/usr/lib/python3.9/inspect.py", line 2988, in _bind raise TypeError( TypeError: too many positional arguments
Beta Was this translation helpful? Give feedback.
All reactions