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

prep_data occur TypeError: unhashable type: 'list' #120

Open xigrug opened 3 years ago

xigrug commented 3 years ago

I use xarray to read netcdf data

import xarray as xr from windspharm.xarray import VectorWind from windspharm.tools import prep_data, recover_data, order_latdim from windspharm.examples import example_data_path nc = xr.open_dataset('era5/era5_3d_201906070809.nc') uwnd = nc.u uwnd, uwnd_info = prep_data(uwnd, 'tzyx')

<xarray.DataArray 'u' (time: 4, level: 22, latitude: 721, longitude: 1440)> [91365120 values with dtype=float32] Coordinates:

  • longitude (longitude) float32 0.0 0.25 0.5 0.75 ... 359.25 359.5 359.75
  • latitude (latitude) float32 90.0 89.75 89.5 89.25 ... -89.5 -89.75 -90.0
  • level (level) int32 1 2 3 5 7 10 20 30 ... 400 500 600 700 850 925 1000
  • time (time) datetime64[ns] 2019-06-01 2019-07-01 2019-08-01 2019-09-01 Attributes: units: m s**-1 long_name: U component of wind standard_name: eastward_wind

the error message are as following:

uwnd, uwnd_info = prep_data(uwnd, 'tzyx')
  File "/g3/liuchong/software/anaconda3/lib/python3.8/site-packages/windspharm/tools.py", line 97, in prep_data
    pdata, intorder = __order_dims(data, dimorder)
  File "/g3/liuchong/software/anaconda3/lib/python3.8/site-packages/windspharm/tools.py", line 35, in __order_dims
    d = np.rollaxis(d, lonpos)
  File "<__array_function__ internals>", line 5, in rollaxis
  File "/g3/liuchong/software/anaconda3/lib/python3.8/site-packages/numpy/core/numeric.py", line 1274, in rollaxis
    return a.transpose(axes)
  File "/g3/liuchong/software/anaconda3/lib/python3.8/site-packages/xarray/core/dataarray.py", line 2036, in transpose
    dims = tuple(utils.infix_dims(dims, self.dims))
  File "/g3/liuchong/software/anaconda3/lib/python3.8/site-packages/xarray/core/utils.py", line 724, in infix_dims
    if set(dims_supplied) ^ set(dims_all):
**TypeError: unhashable type: 'list'**

how to fix this? Thanks

Nuist0186 commented 1 year ago

hello, have you solved the problem?