interpolate using quadratic returns nan
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
What happened?
When using a multiple dimensions xarray (like time, x and y), the quadratic function is not working anymore with interpolate, it returns only nan. slinear is ok. quadratic is only ok when using only a dimension (like only a lat/lon value).
What did you expect to happen?
No response
Minimal Complete Verifiable Example
import xarray as xr
ds = xr.tutorial.load_dataset("ersstv5")
# Generate a subset
subset = ds['sst'].isel(time=slice(0,10),lat=slice(20,40),lon=slice(20,40))
## Plot images
subset.plot(col="time",col_wrap=6)
# Interpolate with quadratic
subset_quadratic = subset.resample(time='10D').interpolate('quadratic')
## subset_quadratic is now full of NaN
subset_quadratic.plot(col="time",col_wrap=6)
# Working with only time dimension
subset_quadratic = subset.isel(lat=0,lon=0).resample(time='10D').interpolate('quadratic')
subset_quadratic.plot()
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.
- Recent environment — the issue occurs with the latest version of xarray and its dependencies.
Relevant log output
No response
Anything else we need to know?
No response
Environment
xarray: 2024.5.0
pandas: 2.1.4
numpy: 1.26.4
scipy: 1.13.0
netCDF4: None
pydap: None
h5netcdf: 1.3.0
h5py: 3.11.0
zarr: 2.18.0
cftime: None
nc_time_axis: None
iris: None
bottleneck: None
dask: 2024.5.0
distributed: 2024.5.0
matplotlib: 3.8.4
cartopy: None
seaborn: 0.13.2
numbagg: None
fsspec: 2024.3.1
cupy: None
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: 69.5.1
pip: 24.0
conda: None
pytest: None
mypy: None
IPython: 8.24.0
sphinx: 7.3.7
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the reported xarray tutorial example with subset.resample(time='10D').interpolate('quadratic'), comparing multidimensional output with the one-dimensional case. Trace the resample/interpolate entry points to identify where quadratic interpolation produces NaN across lat and lon, then add a regression test showing valid multidimensional results.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100