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-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