Scipy map_coordinates bilinear interpolation compared to interp and IDL interpolate

梦想的初衷 提交于 2019-12-05 11:34:58
HYRY

When use map_coordinates, you need transpose the array or change you coordinates to (y, x) format, because the shape of the array is (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)

This will output:

[ 25.89351463]
[ 25.89351439]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!