-
-
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
Interpolation with multiple mutlidimensional arrays sharing dims fails #4463
Comments
Hi @aulemahal I think you want to interpolate along In [8]: da.interp(t=dx['t'], y=dy, x=dx, method='linear')
Out[8]:
<xarray.DataArray (t: 2, u: 2)>
array([[2., 3.],
[2., 3.]])
Coordinates:
* t (t) int64 10 12
y (u) float64 1.5 2.5
x (t, u) float64 1.5 1.5 1.5 1.5
* u (u) int64 45 55 If not, this fails as |
I think this gives the correct result?
My general thought is that if an axis (like |
Oh! I should have thought of this. The error message is indeed unclear... da.sel(y=dy, x=dx, method='nearest') does work, without the need to explicitly pass the shared dimension |
reopening so that we can fix this. |
I think Let's keep this issue open to track that. |
* Don't eagerly compute dask arrays in localize * Clean up test * Clean up Variable handling * Silence test warning * Use apply_ufunc instead * Add test for #4463 Closes #4463 * complete tests * Add comments * Clear up broadcasting * typing * try a different warning filter * one more fix * types + more duck_array_ops * fixes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Apply suggestions from code review Co-authored-by: Michael Niklas <[email protected]> * Apply suggestions from code review Co-authored-by: Illviljan <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Apply suggestions from code review Co-authored-by: Illviljan <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix * Revert "Apply suggestions from code review" This reverts commit 1b9845d. --------- Co-authored-by: Illviljan <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Michael Niklas <[email protected]>
What happened:
When trying to interpolate a N-D array with 2 other arrays sharing a common (new) dimension and with one (at least) being multidimensional fails. Kinda a complex edge case I agree. Here's a MWE:
So we have
da
a 3D array with dims (t, x, y). We havedy
, containing the values of y along new dimension u. Anddx
containing the values of x along both u and t. We want to interpolate with:As so to have a new array over dims t and u.
What you expected to happen:
I expected (with the dummy data I gave):
But instead it fails with
ValueError: axes don't match array
.Full traceback:
Anything else we need to know?:
It works if
dx
doesn't vary along t. I .e.:da.interp(y=dy, x=dx.isel(t=0, drop=True), method='linear')
works.Environment:
Output of xr.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.8.5 | packaged by conda-forge | (default, Jul 31 2020, 02:39:48)
[GCC 7.5.0]
python-bits: 64
OS: Linux
OS-release: 3.10.0-514.2.2.el7.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_CA.UTF-8
LOCALE: en_CA.UTF-8
libhdf5: 1.10.5
libnetcdf: 4.7.4
xarray: 0.16.2.dev9+gc0399d3
pandas: 1.0.3
numpy: 1.18.4
scipy: 1.4.1
netCDF4: 1.5.3
pydap: None
h5netcdf: None
h5py: 2.10.0
Nio: None
zarr: None
cftime: 1.1.3
nc_time_axis: 1.2.0
PseudoNetCDF: None
rasterio: 1.1.4
cfgrib: None
iris: None
bottleneck: 1.3.2
dask: 2.17.2
distributed: 2.23.0
matplotlib: 3.3.1
cartopy: 0.18.0
seaborn: None
numbagg: None
pint: 0.11
setuptools: 49.6.0.post20200814
pip: 20.2.2
conda: None
pytest: None
IPython: 7.17.0
sphinx: None
The text was updated successfully, but these errors were encountered: