Scipy map_ negotiates bilinear interpolation compared to interpolation interpolation and IDL interpolation

I am rewriting colleagues IDL code in python and coming up with some differences that confuse me. According to other SO questions and the conversations I found, if you use scipy.ndimage.interpolation.map_coordinatesand specify order=1, it is assumed that it will be bilinear interpolation. When comparing the results between the IDL code (executed in GDL) and python (map_coordinates), I had different results. Then I tried to use mpl_toolkits.basemap.interp, and got the same result as the IDL code. The following is a simple example showing what is wrong. Can someone help me figure out what I'm doing wrong with map_coordinatesor order=1not bilinearly?

from scipy.ndimage.interpolation import map_coordinates
from mpl_toolkits.basemap import interp
import numpy

in_data = numpy.array([[ 25.89125824,  25.88840675],[ 25.90930748,  25.90640068]], dtype=numpy.float32)

map_coordinates(in_data, [[0.0],[0.125]], order=1, mode='nearest')
# map_coordinates results in "25.89090157"
interp(in_data, numpy.array([0,1]), numpy.array([0,1]), numpy.array([0.0]), numpy.array([0.125]), order=1)
# interp results in "25.89351439", same as GDL "25.8935" when printed

interp, , map_coordinates . , map_coordinates , ? ?

+5
1

map_coordinates (y, x) , (height, width).

from scipy.ndimage.interpolation import map_coordinates
from mpl_toolkits.basemap import interp
import numpy

in_data = numpy.array([[ 25.89125824,  25.88840675],[ 25.90930748,  25.90640068]], dtype=numpy.float32)

print map_coordinates(in_data.T, [[0.0],[0.125]], order=1, mode='nearest')
print interp(in_data, numpy.array([0,1]), numpy.array([0,1]), numpy.array([0.0]), numpy.array([0.125]), order=1)

:

[ 25.89351463]
[ 25.89351439]
+7

All Articles