scipy.ndimage.map_coordinates is used to interpolate the grid values of the background mode and rms to the entire image.
Default this is done using bilinear interpolation.
For that case much faster solutions are available.
One of the answers to this SO question includes these four lines of code:
f = interp.interp1d(y, im, kind='linear')
temp = f(new_y)
f = interp.interp1d(x, temp.T, kind='linear')
new_im = f(new_x).T
This is more than three times faster than scipy.ndimage.map_coordinates for linear interpolation.
scipy.ndimage.zoom should also be an option for speedup, but even after extensive tweaking of the zoom parameters I could not produce the exact same output as map_coordinates. My bad.
(One might want to retain the option to apply other interpolation orders, I do not see its use, not accommodated for here)
scipy.ndimage.map_coordinates
is used to interpolate the grid values of the background mode and rms to the entire image. Default this is done using bilinear interpolation. For that case much faster solutions are available.One of the answers to this SO question includes these four lines of code:
This is more than three times faster than
scipy.ndimage.map_coordinates
for linear interpolation.scipy.ndimage.zoom
should also be an option for speedup, but even after extensive tweaking of thezoom
parameters I could not produce the exact same output asmap_coordinates
. My bad.(One might want to retain the option to apply other interpolation orders, I do not see its use, not accommodated for here)