ajdawson / windspharm

A Python library for spherical harmonic computations on vector winds.
http://ajdawson.github.io/windspharm
MIT License
82 stars 36 forks source link

ValueError: rollaxis: axis (3) must be >=0 and < 2 #88

Closed winash12 closed 6 years ago

winash12 commented 6 years ago

I am getting the above error for a netCDF file with this ordering of dimensions - time,lat,lev,lon

and in my code I have this order -

uwnd, uwnd_info = prep_data(uwnd850, 'tyzx') vwnd, vwnd_info = prep_data(vwnd850, 'tyzx')

Traceback (most recent call last): File "monsoon_index.py", line 86, in uwnd, uwnd_info = prep_data(uwnd850, 'tyzx') File "/usr/local/lib/python3.5/dist-packages/windspharm-1.5.1-py3.5.egg/windspharm/tools.py", line 97, in prep_data pdata, intorder = __order_dims(data, dimorder) File "/usr/local/lib/python3.5/dist-packages/windspharm-1.5.1-py3.5.egg/windspharm/tools.py", line 35, in __order_dims d = np.rollaxis(d, lonpos) File "/usr/lib/python3/dist-packages/numpy/core/numeric.py", line 1450, in rollaxis raise ValueError(msg % ('axis', axis, n)) ValueError: rollaxis: axis (3) must be >=0 and < 2

So line 86 is this line - uwnd, uwnd_info = prep_data(uwnd850, 'tyzx')

ajdawson commented 6 years ago

What is the shape of the array uwnd850 as reported by the uwnd850.shape attribute?

winash12 commented 6 years ago

It is 73,144.

ajdawson commented 6 years ago

Then you are telling prep_data it has 4 dimensions (t, y, z, x) when it only has 2... What are you expecting will happen? If the data array is already just lat-lon then you don't need to call prep_data.