Python 中的 N 维线性插值(使用基本原理索引评估数组)



假设我有一个带有ar.shape=(n1,...,nN)的 N 维数组ar。是否有一个 python 模块可以允许在基本原理索引上评估ar

例如,让我们假设:ar.shape=(3,4,5) 。然后我正在寻找一个函数f这样做:result=f(ar,[2.3,1.5,3.4])

来自 scipy 文档: scipy.interpolate.griddata :插值非结构化 N 维数据。

scipy.ndimage.map_coordinates既快速又简单;
请参阅下面的清晰 2D 示例Multivariate-spline-interpolation-in-python-scipy.

map_coordinates( ... order=1 ) 是你所要求的——2D Bilinear_interpolation,3D 三线...
order=0 是最近的网格点,order=2或 3 次查看 (order+1)^d 点 — 更慢、更平滑。

补充:您可能知道,numpy 轮次将索引浮动到整数:

A = np.eye( 3 )
print A[ 0.1, 0.9 ], A[ 1.1, 2.9 ]

最新更新