issues: 1169750048
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1169750048 | I_kwDOAMm_X85FuPgg | 6360 | Multidimensional `interpolate_na()` | 5797727 | open | 0 | 4 | 2022-03-15T14:27:46Z | 2023-09-28T11:51:20Z | NONE | Is your feature request related to a problem?I think that having a way to run a multidimensional interpolation for filling missing values would be awesome. The code snippet below create a data and show the problem I am having now. If the data has some orientation, we couldn't simply interpolate dimensions separately. ```python import xarray as xr import numpy as np n = 30 x = xr.DataArray(np.linspace(0,2np.pi,n),dims=['x']) y = xr.DataArray(np.linspace(0,2np.pi,n),dims=['y']) z = (np.sin(x)*xr.ones_like(y)) mask = xr.DataArray(np.random.randint(0,1+1,(n,n)).astype('bool'),dims=['x','y']) kw = dict(add_colorbar=False) fig,ax = plt.subplots(1,3,figsize=(11,3)) z.plot(ax=ax[0],kw) z.where(mask).plot(ax=ax[1],kw) z.where(mask).interpolate_na('x').plot(ax=ax[2],**kw) ``` I tried to use advanced interpolation for that, but it doesn't look like the best solution. ```python zs = z.where(mask).stack(k=['x','y']) zs = zs.where(np.isnan(zs),drop=True) xi,yi = zs.k.x.drop('k'),zs.k.y.drop('k') zi = z.interp(x=xi,y=yi) fig,ax = plt.subplots() z.where(mask).plot(ax=ax,kw) ax.scatter(xi,yi,c=zi,kw,linewidth=1,edgecolor='k') ``` returns Describe the solution you'd likeSimply Describe alternatives you've consideredI could extract the data to Additional contextNo response |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/6360/reactions", "total_count": 11, "+1": 9, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 2 } |
13221727 | issue |