html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue
https://github.com/pydata/xarray/issues/3962#issuecomment-1114752371,https://api.github.com/repos/pydata/xarray/issues/3962,1114752371,IC_kwDOAMm_X85CccVz,26384082,2022-05-02T11:37:48Z,2022-05-02T11:37:48Z,NONE,"In order to maintain a list of currently relevant issues, we mark issues as stale after a period of inactivity

If this issue remains relevant, please comment here or remove the `stale` label; otherwise it will be marked as closed automatically
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,597785475
https://github.com/pydata/xarray/issues/3962#issuecomment-612080638,https://api.github.com/repos/pydata/xarray/issues/3962,612080638,MDEyOklzc3VlQ29tbWVudDYxMjA4MDYzOA==,2448579,2020-04-10T15:32:18Z,2020-04-10T15:32:18Z,MEMBER,"As noted in #3956 `fill_value=""extrapolate""` is what we need for 1D.

> xarray could use the same interpolation function for both 1d and nd.

Not sure if there's a big performance gain. @jhamman implemented these interpolators originally AFAIK. Perhaps he remembers why we use both.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,597785475
https://github.com/pydata/xarray/issues/3962#issuecomment-612077587,https://api.github.com/repos/pydata/xarray/issues/3962,612077587,MDEyOklzc3VlQ29tbWVudDYxMjA3NzU4Nw==,14371165,2020-04-10T15:25:30Z,2020-04-10T15:30:05Z,MEMBER,"Nice find! The documentation doesn't explain that at all currently.

But that solution doesn't work for 1d DataArrays. You have to use this kwargs instead:
````python
kwargs = dict(fill_value=(np.min(da.data), np.max(da.data)))
````
So it still isn't as convenient as I would like it to be. The wrapper function can now be simplified to this however:

````python
import numpy as np
import xarray as xr


def interp(da, coords, extrapolation='clip'):
    """"""
    Linear interpolation that clips the inputs to the coords min and max value.

    Parameters
    ----------
    da : DataArray
        DataArray to interpolate.
    coords : dict
        Coordinates for the interpolated value.
    """"""
    if extrapolation == 'clip':
        if len(da.coords) > 1:
            kwargs = dict(fill_value=None)
        else:
            kwargs = dict(fill_value=(np.min(da.data), np.max(da.data)))
    return da.interp(coords, kwargs=kwargs)


# Create coordinates:
x = np.linspace(1000, 6000, 4)
y = np.linspace(100, 1200, 3)
z = np.linspace(1, 2, 2)

# Create 1D DataArray:
da1 = xr.DataArray(data=2*x, coords=[('x', x)])

# Create 2D DataArray:
X = np.meshgrid(*[x, y], indexing='ij')
data = X[0] * X[1]
da2 = xr.DataArray(data=data, coords=[('x', x), ('y', y)])

# Create 3D DataArray:
X = np.meshgrid(*[x, y, z], indexing='ij')
data = X[0] * X[1] * X[2]
da3 = xr.DataArray(data=data, coords=[('x', x), ('y', y), ('z', z)])

# Attempt to extrapolate:
print(interp(da1, {'x': 7000}))
print(interp(da2, {'x': 7000, 'y': 375}))
print(interp(da3, {'x': 7000, 'y': 375, 'z': 1}))
````

","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,597785475
https://github.com/pydata/xarray/issues/3962#issuecomment-612024066,https://api.github.com/repos/pydata/xarray/issues/3962,612024066,MDEyOklzc3VlQ29tbWVudDYxMjAyNDA2Ng==,2448579,2020-04-10T13:17:36Z,2020-04-10T13:17:36Z,MEMBER,"Scipy will do this for you if you ask it to:

```
da.interp(x=7000, y=375, method=""linear"", kwargs=dict(fill_value=None))
```

See https://github.com/pydata/xarray/pull/3956 . ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,597785475