Open ks905383 opened 1 year 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!
What happened?
I'm running
ds.interp()
using multi-dimensional new coordinates, usingxarray
's broadcasting to expand the original dataset to new dimensions. In this case, I'm only interpolating on one dimension, but broadcasting out to others.If the dimensions are all numeric (or, presumably, able to be forced to numeric), then this works without an issue. However, if one of the other dimensions is, e.g., populated with string indices (weather station names, model run ids, etc.), then this process fails, even if the dimension on which the interpolating is conducted is purely numeric.
What did you expect to happen?
Here is an example with only numeric dimensions that works as expected:
this produces something like:
as expected.
Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
Anything else we need to know?
I'm pretty sure the issue is in this optimization step.
It calls
_localize()
from missing.py, which callsnp.nanmin()
andnp.nanmax()
on all the coordinates, including the ones that aren't used in the interpolation, but only in the broadcasting.Perhaps a way to fix this would be to have a test in localize for numeric indices, and then only subset the numeric dimensions? (I could see generalizing
_localize()
to other data types may be more trouble than it's worth, especially for unsorted string dimensions...) Or only subset the dimensions used in the interpolation itself? Or, alternatively, having a way to turn off optimizations like this?Environment