-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Multi-dimensional extrapolation doesn't work #6617
Comments
try If I'm understanding the purpose of that example correctly that's a documentation bug, and we would welcome a PR to fix it. |
You're right, thanks for the help. It seems that orthogonal dimensions are now interpolated independently by calling SciPy's The documentation should be adapted to use @keewis's approach. I'd suggest including an example combining "advanced interpolation" and extrapolation, such as the one below: da = xr.DataArray(
np.sin(0.3 * np.arange(20).reshape(5, 4)),
[("x", np.arange(5)), ("y", [0.1, 0.2, 0.3, 0.4])],
)
x = xr.DataArray([0.5, 1.5, 2.5, 3.5], dims="z")
y = xr.DataArray([0.15, 0.25, 0.35, 0.45], dims="z") Without extrapolation: da.interp(x=x, y=y)
With extrapolation: da.interp(x=x, y=y, kwargs={'fill_value': None})
|
The current version of xarray tries to call scipy's interp1d whenever possible, and kwargs used in the user guide should reflect this. Fixes pydata#6617
* Fix kwargs used for extrapolation in docs The current version of xarray tries to call scipy's interp1d whenever possible, and kwargs used in the user guide should reflect this. Fixes #6617 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add extended summary for interp methods The extended summaries for Dataset.interp and DataArray.interp explain how the scipy interpolator is selected * Update interp_like extended summary Explains how the scipy interpolator is chosen, similarly as done in Dataset.interp and DataArray.interp * Add the "polynomial" option to interp(_like) When scipy.interpolate.interp1d is called, it is possible to interpolate with the polynomial method if the `order` kwarg is provided. Co-authored-by: Louis Stenger <louis.stenger@epfl.ch> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
What happened?
I am trying to interpolate and extrapolate a two dimensional DataArray. Passing the
kwargs=dict(fill_value=None)
argument toDataArray.interp
still returnsnan
values.The MCVE is taken from the documentation guide on interpolation. (Note that the documentation also shows
nan
values.)What did you expect to happen?
I expected the routine to extrapolate the data when "out-of-bounds" coordinates were provided.
Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
Anything else we need to know?
This is my first issue, I hope I didn't forget something! Thank you for the amazing package!
Environment
The text was updated successfully, but these errors were encountered: