Description
What happened?
Extrapolation does not seem to be working on 2D data arrays. The area outside the input grid is NaN in the interpolated data when using kwargs={"fill_value": None}
as arguments to the interp
function (the extrapolation does work when using scipy.interpolate.interpn
and passing fill_value=None
along with bounds_error=False
).
This figure shows the example data arrays from the code snippet provided here:
What did you expect to happen?
Area outside the input grid filled with extrapolated data.
Minimal Complete Verifiable Example
import xarray as xr
da = xr.DataArray(
data=[[1, 2, 3], [3, 4, 5]],
coords=dict(y=[0, 1], x=[10, 20, 30]),
dims=("y", "x")
)
dai = da.interp(x=[25, 30, 35], y=[0, 1], kwargs={"fill_value": None})
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
No response
Anything else we need to know?
No response
Environment
INSTALLED VERSIONS
commit: None
python: 3.7.12 | packaged by conda-forge | (default, Oct 26 2021, 06:08:53)
[GCC 9.4.0]
python-bits: 64
OS: Linux
OS-release: 5.13.0-1031-gcp
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: C.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: 1.12.0
libnetcdf: 4.7.4
xarray: 0.20.2
pandas: 1.3.5
numpy: 1.19.5
scipy: 1.7.3
netCDF4: 1.5.8
pydap: None
h5netcdf: None
h5py: 3.7.0
Nio: None
zarr: 2.11.3
cftime: 1.6.0
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: None
dask: 2022.02.0
distributed: None
matplotlib: 3.5.2
cartopy: None
seaborn: 0.11.2
numbagg: None
fsspec: 2022.5.0
cupy: None
pint: 0.18
sparse: None
setuptools: 59.8.0
pip: 22.1.1
conda: 4.12.0
pytest: 7.1.2
IPython: 7.33.0
sphinx: None