Skip to content

Error using xarray.interp - function signature does not match with scipy.interpn #7414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 4 tasks
Florian1209 opened this issue Jan 4, 2023 · 2 comments
Closed
1 of 4 tasks

Comments

@Florian1209
Copy link

What happened?

I am experiencing an error when using the array.interp function. The error message indicates that the function signature does not match with scipy interpn.

It 's linked to scipy update 1.10.0 (2023/01/03).

What did you expect to happen?

I would interpolate 2D data of numpy float64 : two data lattitudes and longitudes following <xarray.DataArray (row: 32, col: 32)>.
da is a xarray dataset :

Dimensions:  (lat: 721, lon: 1441)
Coordinates:
  * lat      (lat) float64 90.0 89.75 89.5 89.25 ... -89.25 -89.5 -89.75 -90.0
  * lon      (lon) float64 0.0 0.25 0.5 0.75 1.0 ... 359.2 359.5 359.8 360.0
Data variables:
    hgt      (lat, lon) >f4 13.61 13.61 13.61 13.61 ... -29.53 -29.53 -29.53
Attributes:

Minimal Complete Verifiable Example

interpolated_da = da.interp(
        {
            "x": xr.DataArray(x, dims=("x", "y")),
            "y": xr.DataArray(y, dims=("x", "y")),
        }
    )

MVCE confirmation

  • Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
  • Complete example — the example is self-contained, including all data and the text of any traceback.
  • Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
  • New issue — a search of GitHub Issues suggests this is not a duplicate.

Relevant log output

interpolated_da = da.interp(
venv/lib/python3.8/site-packages/xarray/core/dataset.py:3378: in interp
    variables[name] = missing.interp(var, var_indexers, method, **kwargs)
venv/lib/python3.8/site-packages/xarray/core/missing.py:639: in interp
    interped = interp_func(
venv/lib/python3.8/site-packages/xarray/core/missing.py:764: in interp_func
    return _interpnd(var, x, new_x, func, kwargs)
venv/lib/python3.8/site-packages/xarray/core/missing.py:788: in _interpnd
    rslt = func(x, var, xi, **kwargs)
venv/lib/python3.8/site-packages/scipy/interpolate/_rgi.py:654: in interpn
    return interp(xi)
venv/lib/python3.8/site-packages/scipy/interpolate/_rgi.py:336: in __call__
    result = evaluate_linear_2d(self.values,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   ???
E   TypeError: No matching signature found

_rgi_cython.pyx:19: TypeError

Anything else we need to know?

No response

Environment

INSTALLED VERSIONS

commit: None
python: 3.8.10 (default, Nov 14 2022, 12:59:47)
[GCC 9.4.0]
python-bits: 64
OS: Linux
OS-release: 5.4.0-135-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: 1.12.2
libnetcdf: 4.9.0

xarray: 2022.12.0
pandas: 1.5.2
numpy: 1.22.4
scipy: 1.10.0
netCDF4: 1.6.2
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: None
cftime: 1.6.2
nc_time_axis: None
PseudoNetCDF: None
rasterio: 1.3.4
cfgrib: None
iris: None
bottleneck: None
dask: 2022.12.1
distributed: 2022.12.1
matplotlib: 3.6.2
cartopy: None
seaborn: None
numbagg: None
fsspec: 2022.11.0
cupy: None
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: 65.6.3
pip: 22.3.1
conda: None
pytest: 7.2.0
mypy: None
IPython: 8.7.0
sphinx: 5.3.0
None

@Florian1209 Florian1209 added bug needs triage Issue that has not been reviewed by xarray team member labels Jan 4, 2023
@arongergely
Copy link
Contributor

arongergely commented Jan 11, 2023

This breaks the documentation build too, it seems!

Sphinx errors out when it tries to parse https://github.com/pydata/xarray/blob/main/doc/user-guide/interpolation.rst

@arongergely
Copy link
Contributor

Looks like this is the culprit: scipy/scipy#17718
to be fixed in scipy 1.10.1

@keewis keewis added upstream issue and removed needs triage Issue that has not been reviewed by xarray team member labels Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants