N-dimensional linear interpolation in Python (evaluating an array using a boolean index)
2 answers
scipy.ndimage.map_coordinates is quick and easy;
see the 2d example in
multivariate-spline-interpolation-in-python-scipy .
( map_coordinates( ... order=1 )
this is what you are asking for -
Bilinear_interpolation in 2d, trilinear in 3d ... order=0
is the closest grid point, order=2
or 3 - look (order + 1) ^ d points - slower and smoother.)
Added: as you probably know, numpy rounds float indices before ints:
A = np.eye( 3 ) print A[ 0.1, 0.9 ], A[ 1.1, 2.9 ]
+2
source to share