coords要进行插值的坐标列表,您可以
scipy.spatial.cKDTree用来获取表中2个最接近线性插值所必需的条目。下面的代码显示了一个已矢量化的用法示例。
import numpy as npfrom scipy.spatial import cKDTree# inputsLTU = np.genfromtxt('test.txt', delimiter=',')coords = ((12.5, 25.5, 137), (13.5, 26.5, 141), (14.5, 25.5, 144))# querying and interpolatingxyz = LTU[:, :3]val = LTU[:, 3]del LTU # attempt to clean up memorytree = cKDTree(xyz)dist, ind = tree.query(coords, k=2)d1, d2 = dist.Tv1, v2 = val[ind].Tv = (d1)/(d1 + d2)*(v2 - v1) + v1print(v)#[ 6758.73909236 6789.16987298 6790.03575996]
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)