-
-
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 coordinates out of bound. #2197
Comments
This is a good point -- the current code only really makes sense when interpolating to a higher frequency, e.g., daily -> hourly. I do think going to higher frequencies is the main use-case for interpolation, but I don't think it needs to raise errors in this case. At the least, it would be OK to fill in the invalid values with NaN. I think the fix might be as simple as setting xarray/xarray/core/resample.py Line 202 in cf19528
xarray/xarray/core/resample.py Line 341 in cf19528
Any interest in putting together a pull request? |
Also with oversampling we have the same problem (2007-02-02 02:00:00 is out of bound): import numpy as np
import pandas as pd
import xarray as xr
time = np.arange('2007-01-01 00:00:00', '2007-02-02 00:00:00', dtype='datetime64[ns]')
arr = xr.DataArray(
np.arange(time.size), coords=[time,], dims=('time',), name='data'
)
resampler = arr.resample(time='3h', base=2, label='right')
resampler
DatetimeIndex(['2007-01-01 02:00:00', '2007-01-01 05:00:00',
'2007-01-01 08:00:00', '2007-01-01 11:00:00',
'2007-01-01 14:00:00', '2007-01-01 17:00:00',
'2007-01-01 20:00:00', '2007-01-01 23:00:00',
'2007-01-02 02:00:00', '2007-01-02 05:00:00',
...
'2007-01-31 23:00:00', '2007-02-01 02:00:00',
'2007-02-01 05:00:00', '2007-02-01 08:00:00',
'2007-02-01 11:00:00', '2007-02-01 14:00:00',
'2007-02-01 17:00:00', '2007-02-01 20:00:00',
'2007-02-01 23:00:00', '2007-02-02 02:00:00'],
dtype='datetime64[ns]', name='time', length=257, freq='3H') The fix is really very easy, I can try to make pull request. |
Code Sample, a copy-pastable example if possible
Problem description
It raise an error if I try to interpolate. If time range is exactly a month, then it works:
The problem for the interpolation seems to be that the resampler contains indices out bound ('2007-03-31'). It is ok for the aggregations, but it doesn't work with the interpolation.
Expected Output
Output of
xr.show_versions()
xarray: 0.10.3
pandas: 0.22.0
numpy: 1.14.3
scipy: 1.1.0
netCDF4: 1.3.1
h5netcdf: None
h5py: None
Nio: None
zarr: None
bottleneck: None
cyordereddict: None
dask: 0.17.4
distributed: None
matplotlib: 2.2.2
cartopy: 0.16.0
seaborn: None
setuptools: 39.2.0
pip: 10.0.1
conda: None
pytest: 3.5.1
IPython: 6.4.0
sphinx: 1.7.4
The text was updated successfully, but these errors were encountered: