Open XavierTolza 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!
Is your feature request related to a problem?
Hello all. First, thanks for this amazing library!
I'm working with unstructured data ( points that are not in a grid ), and I want to interpolate them onto a regular grid. However, it seems it is not directly supported by xarray and I have to manually call scipy's
griddata
. This is annoying because:It seems the problem is encoutered by some other people as a google search on
xarray interp irregular data
yields to some results:Searching for issues related to this topic led me to this single issue https://github.com/pydata/xarray/issues/5281 where the user uses directly scipy's griddata to interpolate.
Here is a sample script to reproduce and illustrate the problem:
I get the following value for
z
:And it looks like so:
So we can see
z
is correctly annotated and we've got the x and y value for each point, but I still cannot interpolate on a regular grid:It raises the following error:
Describe the solution you'd like
It would be nice to allow a direct unstructured interpolation if variables are correctly annotated (I supposed it's done with panda's multi indexes?)
This could be done using Scipy's griddata
A check could be added in interp function to see if the user wants to interpolate on sub-dimensions (i'm not sure if the name is appropriate), and if so, using griddata instead of the other interpolation methods.
Describe alternatives you've considered
Alternative solutions could be to use only scipy grid data by hand, but that would be sad.
Additional context
No response