CDAT / cdms

8 stars 10 forks source link

FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated #422

Open yyplanton opened 4 years ago

yyplanton commented 4 years ago

Warnings are raised when selecting a latitudinal range while reading some observational datasets.

Raised when a netCDF file is read: /opt/miniconda3/envs/cdat/lib/python3.7/site-packages/cdms2/fvariable.py:103: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use arr[tuple(seq)] instead of arr[seq]. In the future this will be interpreted as an array index, arr[np.array(seq)], which will result either in an error or a different result. result = result[revlist]

from cdms2 import open as CDMS2open
filename = "precip.mon.mean.nc"
variable = "precip"
ff = CDMS2open(filename)
tab = ff(variable, latitude=(-5, 5))

The preceding code uses CPC Merged Analysis of Precipitation (CMAP) Precipitation Mean (Standard Monthly) (probably raises the same warning with other variables) downloaded from https://psl.noaa.gov/data/gridded/data.cmap.html I encountered the same warning with:

Raised when the same netCDF file is read but a 'dataset' was created with the cdscan utility (e.g., cdscan -x CMAP_precip.xml precip.mon.mean.nc): /opt/miniconda3/envs/cdat/lib/python3.7/site-packages/numpy/ma/core.py:3225: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use arr[tuple(seq)] instead of arr[seq]. In the future this will be interpreted as an array index, arr[np.array(seq)], which will result either in an error or a different result. dout = self.data[indx]

In the case of HadISST1 (HadISST_sst.nc) dataset created with the cdscan utility a second warning is raised: /opt/miniconda3/envs/cdat/lib/python3.7/site-packages/numpy/ma/core.py:3257: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use arr[tuple(seq)] instead of arr[seq]. In the future this will be interpreted as an array index, arr[np.array(seq)], which will result either in an error or a different result. mout = _mask[indx]

jypeter commented 3 years ago

I'm also regularly getting this warning when working with totally unrelated netcdf files. It's annoying because it can hide other useful warnings

I hope this has disappeared in the latest version of cdms2 (I'm still using cdms2 from CDAT 8.0)