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/191#issuecomment-60332922,https://api.github.com/repos/pydata/xarray/issues/191,60332922,MDEyOklzc3VlQ29tbWVudDYwMzMyOTIy,377869,2014-10-24T01:19:47Z,2014-10-24T01:19:47Z,NONE,"For what its worth, I wrote this today. Its a long way from being useful but I find it's working well enough to fill gaps in data after a reindex()
``` py
from scipy import interpolate, ndimage
def linterp(data, index, interp_index, order=1):
""""""
Parameters
----------
data: nd-array (cube).
index: index (floats) associated with the cube.
interp_index: float interpolation poing.
Returns
-------
interpolated: nd-array
An interpolated field.
""""""
# Form a cube of the values, which we will imagine is our function f()
cube = np.array(data, dtype=np.float)
# Form a relationship, and this can be non-linear, between slice indexes and
# the ""index"".
m = interpolate.interp1d(index, range(len(index)))
# Form a set of coordinates to sample over - x
y, x = np.mgrid[0:data[0].shape[0], 0:data[0].shape[1]]
z = np.ones_like(y) * m(interp_index)
# Perform the sampling f(x), map coordinates is performing a linear
# interpolation of the coordinates in the cube.
return ndimage.map_coordinates(
cube,
[z, y, x],
order=order,
cval=np.nan)
```
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,38849807