Open wilson0028 opened 9 months ago
Thanks for opening your first issue here at xarray! Be sure to follow the issue template! If you have an idea for a solution, we would really welcome a Pull Request with proposed changes. See the Contributing Guide for more. It may take us a while to respond here, but we really value your contribution. Contributors like you help make xarray better. Thank you!
Not sure what's causing this, but confirm I can reproduce. Any ideas?
Simpler repro (no datetime, no resample) - but I don't know why it happens, either.
import xarray as xr
data1 = xr.DataArray([np.nan,1], dims='x', coords={'x': [0, 6]})
data2 = data1.astype('float32')
target = [0, 6]
data1.interp(x=target)
data2.interp(x=target)
Ok this is a scipy problem - do you want to raise a issue in scipy?
import scipy as sp
import numpy as np
xi = np.array([0, 6])
yi = np.array([np.nan, 1])
sp.interpolate.interp1d(xi, yi, kind="linear")(xi)
sp.interpolate.interp1d(xi, yi.astype(np.float32), kind="linear")(xi)
(the xarray question here is - why do we choose to interpolate using scipy and not numpy?)
Issue now posted on scipy repo: https://github.com/scipy/scipy/issues/20152
From the scipy documentation, "We note that scipy.interpolate does not support interpolation with missing data. Two popular ways of representing missing data are using masked arrays of the numpy.ma library, and encoding missing values as not-a-number, NaN."
If scipy does not support interpolation of missing data, by extension xarray does not also?
What happened?
Depending on the data type, interpolate gives different results
What did you expect to happen?
The example code outputs two arrays which are pasted below. The first array end with a one while the seconds array, which is based on the float32 dataset, has all NaN. I was expecting each array to have 6 NaNs and one numerical value.
[nan nan nan nan nan nan 1.] [nan nan nan nan nan nan nan]
Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
No response
Anything else we need to know?
No response
Environment