issues: 1692523672
This data as json
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | active_lock_reason | draft | pull_request | body | reactions | performed_via_github_app | state_reason | repo | type |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1692523672 | I_kwDOAMm_X85k4dyY | 7807 | Interpolation on unstructured data/irregular grid | 16798775 | open | 0 | 1 | 2023-05-02T14:22:15Z | 2023-05-02T14:23:54Z | NONE | 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 It seems the problem is encoutered by some other people as a google search on 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: ```python from xarray import DataArray import numpy as np import matplotlib.pyplot as plt Sample 1000 uniform points in [-1,1]Thus, those points are unstructuredx, y = points = np.random.uniform(-1, 1, (2, 1000)) x, y = points = DataArray( points, coords=dict( variable=list("XY"), point=np.arange(1000), x=("point", x), y=("point", y) ), dims=("variable", "point"), ) Compute a dummy "function"z = np.sqrt(x2 + y2) print(z) We now have a function sampled on unstructured pointsfig, ax = plt.subplots(1, 1) ax.scatter(x, y, c=z) ax.set_xlabel("x") ax.set_ylabel("y") ax.set_aspect(1) plt.show()
So we can see Describe the solution you'd likeIt 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 consideredAlternative solutions could be to use only scipy grid data by hand, but that would be sad. Additional contextNo response |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/7807/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
13221727 | issue |