Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion doc/interpolation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,14 @@ Additional keyword arguments can be passed to scipy's functions.

# fill 0 for the outside of the original coordinates.
da.interp(x=np.linspace(-0.5, 1.5, 10), kwargs={'fill_value': 0.0})
# extrapolation
# 1-dimensional extrapolation
da.interp(x=np.linspace(-0.5, 1.5, 10), kwargs={'fill_value': 'extrapolate'})
# multi-dimensional extrapolation
da = xr.DataArray(np.sin(0.3 * np.arange(12).reshape(4, 3)),
[('time', np.arange(4)),
('space', [0.1, 0.2, 0.3])])

da.interp(time=4, space=np.linspace(-0.1, 0.5, 10), kwargs={'fill_value': None})


Advanced Interpolation
Expand Down
4 changes: 4 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ Documentation
(:pull:`3935`). By `Spencer Clark <https://github.com/spencerkclark>`_.
- Updated the list of current core developers. (:issue:`3892`)
By `Tom Nicholas <https://github.com/TomNicholas>`_.
- Add example for multi-dimensional extrapolation and note different behavior
of ``kwargs`` in :py:meth:`Dataset.interp` and :py:meth:`DataArray.interp`
for 1-d and n-d interpolation (:pull:`3956`).
By `Matthias Riße <https://github.com/risebell>`_.

Internal Changes
~~~~~~~~~~~~~~~~
Expand Down
4 changes: 3 additions & 1 deletion xarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,9 @@ def interp(
first. If True, x has to be an array of monotonically increasing
values.
kwargs: dictionary
Additional keyword passed to scipy's interpolator.
Additional keyword arguments passed to scipy's interpolator. Valid
options and their behavior depend on if 1-dimensional or
multi-dimensional interpolation is used.
``**coords_kwargs`` : {dim: coordinate, ...}, optional
The keyword arguments form of ``coords``.
One of coords or coords_kwargs must be provided.
Expand Down
4 changes: 3 additions & 1 deletion xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2570,7 +2570,9 @@ def interp(
coordinates are assumed to be an array of monotonically increasing
values.
kwargs: dictionary, optional
Additional keyword passed to scipy's interpolator.
Additional keyword arguments passed to scipy's interpolator. Valid
options and their behavior depend on if 1-dimensional or
multi-dimensional interpolation is used.
**coords_kwargs : {dim: coordinate, ...}, optional
The keyword arguments form of ``coords``.
One of coords or coords_kwargs must be provided.
Expand Down