-
Hello! I'm trying to use the metpy.calc.ccl functionality and keep getting this traceback: Traceback (most recent call last): File ~\anaconda3\envs\MetPy\lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec File c:\users\cjsen\desktop\upper air profiles - working\winndex data grabber.py:104 File ~\anaconda3\envs\MetPy\lib\site-packages\metpy\xarray.py:1328 in wrapper File ~\anaconda3\envs\MetPy\lib\site-packages\metpy\units.py:325 in wrapper File ~\anaconda3\envs\MetPy\lib\site-packages\metpy\calc\thermo.py:574 in ccl File ~\anaconda3\envs\MetPy\lib\site-packages\pint\facets\numpy\quantity.py:238 in getitem IndexError: index -1 is out of bounds for axis 0 with size 0 As far as I can tell, my arrays for Pressure, Temperature, and Dewpoint are all fine. If I set "which = 'all'", the IndexError drops but it returns an empty array that looks like this: (<Quantity([], 'millibar')>, <Quantity([], 'degree_Celsius')>, <Quantity([], 'degree_Celsius')>) I'm just super lost at this point and am hoping someone here can point me in the right direction! I've attached my current code with the only change being the file path on line 41. I can gladly provide more information if needed. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Can you share the source data so we can try to reproduce? My best guess right now is that you're triggering a corner case that we missed. |
Beta Was this translation helpful? Give feedback.
-
Hi @Cjseng, I am sorry for the late response -- but the issue is due to the fact MetPy implicitly assumes that the
to
I believe MetPy should have better specifications for these functions and provide more useful error messages when things go astray. I will submit an issue shortly. |
Beta Was this translation helpful? Give feedback.
Hi @Cjseng, I am sorry for the late response -- but the issue is due to the fact MetPy implicitly assumes that the
pressure
array is in descending order (such that it mimics the real atmosphere, from ground to TOA). To make your code work, you only need to changeto
I believe MetPy should have better specifications for these functions and provide more useful error messages …