-
-
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
DataArrayResample.interpolate and passing kwargs #8762
Comments
import xarray as xr
import pandas as pd
import numpy as np Reproduce the bugExample taken from DataArray.resample, adapted to name the dimension xda = xr.DataArray(
np.linspace(0, 11, num=12),
coords={"valid_time":
pd.date_range(
"1999-12-15",
periods=12,
freq=pd.DateOffset(months=1),
)
},
)
print(xda) try:
data_per_day = xda.resample(valid_time="1D").interpolate("polynomial")
except ValueError as err:
assert str(err) == "order is required when method=polynomial" try:
data_per_day = xda.resample(valid_time="1D").interpolate(kind="polynomial", order=3)
except TypeError as err:
assert (
str(err) == "Resample.interpolate() got an unexpected keyword argument 'order'"
) Technical AnalysisFirst error message
Source: https://github.com/pydata/xarray/blob/main/xarray/core/missing.py#L153 It seems that the Second error message:
Check https://docs.xarray.dev/en/stable/generated/xarray.core.resample.DataArrayResample.interpolate.html Source: https://github.com/pydata/xarray/blob/main/xarray/core/resample.py#L143-L171 We can see that the function signature only allows for a single It uses interp1d.
|
@etienneschalk Thank you for adding much more detail 🙇 |
* add order for polynomial, fixes #8762 * add bugfixes in whats_new.rst, fixes #8762 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix typo * Update xarray/core/resample.py setdefault "bounds_error", and not forcing it. Thanks @dcherian Co-authored-by: Deepak Cherian <dcherian@users.noreply.github.com> * chore(test) : polynomial resample * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix(setdefault) : change dict to arg * fix(test) : polynomial interpolate tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * chore(test) : add comment using interp1d for polynomial * Update xarray/tests/test_groupby.py * Update doc/whats-new.rst * Update whats-new.rst * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Deepak Cherian <dcherian@users.noreply.github.com>
* add order for polynomial, fixes #8762 * add bugfixes in whats_new.rst, fixes #8762 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix typo * Update xarray/core/resample.py setdefault "bounds_error", and not forcing it. Thanks @dcherian Co-authored-by: Deepak Cherian <dcherian@users.noreply.github.com> * chore(test) : polynomial resample * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix(setdefault) : change dict to arg * fix(test) : polynomial interpolate tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * chore(test) : add comment using interp1d for polynomial * Update xarray/tests/test_groupby.py * Update doc/whats-new.rst * Update whats-new.rst * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Deepak Cherian <dcherian@users.noreply.github.com>
What is your issue?
The docs here state that it is possible to use
polynomial
interpolation when resampling.If you try this though:
You get the following:
The docs here state that you need to pass in order, how is this possible?
If you then try:
You get:
How can the order be specified? Thank you in advance.
The text was updated successfully, but these errors were encountered: