pangeo-data / xESMF

Universal Regridder for Geospatial Data
http://xesmf.readthedocs.io/
MIT License
189 stars 34 forks source link

TypeError encountered on v0.6 #142

Closed melissaOu closed 2 years ago

melissaOu commented 2 years ago

Has anyone encountered a typeError trying to run regridder? I am testing using version 0.6, I keep getting an int32 related error. I have also tried doing interpolation without xesmf using interp_like() and get the same error so I suspect it may be related. I was using Python v3.7. The regridder does work on version 0.3. My original application contained a much higher resolution, but get the same error with the lower resolution example from the xesmf documentation online:

_import xarray as xr import xesmf as xe ds_in = xe.util.grid_2d( -120, 120, 0.4, -60, 60, 0.3
) ds_out = xe.util.grid_2d(-120, 120, 0.6, -60, 60, 0.4) regridder = xe.Regridder(ds_in, dsout, 'bilinear')

Error: Traceback (most recent call last): File "/export/cpc-lw7-mou/mou/.pycharm_helpers/pydev/_pydevd_bundle/pydevd_exec2.py", line 3, in Exec exec(exp, global_vars, local_vars) File "", line 1, in File "/export/cpc-lw7-mou/mou/gitrepos/snow_obs/venv/lib/python3.10/site-packages/xesmf/frontend.py", line 772, in init super().init(grid_in, grid_out, method, input_dims=input_dims, **kwargs) File "/export/cpc-lw7-mou/mou/gitrepos/snow_obs/venv/lib/python3.10/site-packages/xesmf/frontend.py", line 322, in init self.weights = read_weights(weights, self.n_in, self.n_out) File "/export/cpc-lw7-mou/mou/gitrepos/snow_obs/venv/lib/python3.10/site-packages/xesmf/smm.py", line 69, in read_weights return sps.coo_matrix((S, (row, col)), shape=[n_out, n_in]) File "/export/cpc-lw7-mou/mou/gitrepos/snow_obs/venv/lib/python3.10/site-packages/scipy/sparse/coo.py", line 157, in init idx_dtype = get_index_dtype(maxval=max(self.shape)) File "/export/cpc-lw7-mou/mou/gitrepos/snow_obs/venv/lib/python3.10/site-packages/scipy/sparse/sputils.py", line 153, in get_index_dtype int32min = np.iinfo(np.int32).min File "/export/cpc-lw7-mou/mou/gitrepos/snow_obs/venv/lib/python3.10/site-packages/numpy/core/getlimits.py", line 651, in init self.dtype = numeric.dtype(type(int_type)) TypeError: 'NoneType' object is not callable

huard commented 2 years ago

Hi @melissaOu

You seem to be running Python 3.10, but xESMF is not tested against that version yet. We're testing against 3.6, 3.7 and 3.8. We'll certainly want to add 3.9 to our test suite though.

melissaOu commented 2 years ago

Thanks for the help! I have now tested successfully with Python 3.8 and letting conda select the xesmf version (which ends up being 0.6.2). I think me trying to specify 0.6 was leading to some issues. It also happens to be that with dropping Python down, doing the interpolation with just xarray and interp_like() worked, which it wasn't before. My guess is that the interp_like() and xesmf issues were both related to newer Python version.

huard commented 2 years ago

Excellent, will close the issue and there is a PR ready to test with 3.9 (#144)