From 7f9d46998d74249f9d3f6133d0f4eab2e156bcfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Ri=C3=9Fe?= Date: Thu, 9 Apr 2020 10:07:02 +0200 Subject: [PATCH 1/3] Add note for different behavior of kwargs in 1-d and n-d interpolation --- xarray/core/dataarray.py | 4 +++- xarray/core/dataset.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/xarray/core/dataarray.py b/xarray/core/dataarray.py index 63cba53b689..a17fab383a6 100644 --- a/xarray/core/dataarray.py +++ b/xarray/core/dataarray.py @@ -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. diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index dd1e31cc61a..d811d54847f 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -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. From e86a3beb4ad65aebdec8998468905f93dbfaa9e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Ri=C3=9Fe?= Date: Thu, 9 Apr 2020 10:11:09 +0200 Subject: [PATCH 2/3] Add multi-dimensional extrapolation example --- doc/interpolation.rst | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/interpolation.rst b/doc/interpolation.rst index 63e9a7cd35e..4cf39807e5a 100644 --- a/doc/interpolation.rst +++ b/doc/interpolation.rst @@ -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 From 2bf90d528a3746b4feda29c75a06c1eec939510a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Ri=C3=9Fe?= Date: Tue, 14 Apr 2020 11:15:34 +0200 Subject: [PATCH 3/3] Update whats-new.rst --- doc/whats-new.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 1d00cb369d1..cab886885e8 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -86,6 +86,10 @@ Documentation (:pull:`3935`). By `Spencer Clark `_. - Updated the list of current core developers. (:issue:`3892`) By `Tom Nicholas `_. +- 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 `_. Internal Changes ~~~~~~~~~~~~~~~~