LUT = np.genfromtxt(\'test.out\', delimiter=\',\', dtype=float)
LUT:
12, 25, 136, 6743
13, 26, 139, 6786
14, 27, 142, 67
Given a list of coordinates coords where you want to interpolate, you can use scipy.spatial.cKDTree to obtain the 2 closest entries of your table that are necessary for the linear interpolation. The code below shows an usage example, already vectorized.
import numpy as np
from scipy.spatial import cKDTree
# inputs
LTU = np.genfromtxt('test.txt', delimiter=',')
coords = ((12.5, 25.5, 137),
(13.5, 26.5, 141),
(14.5, 25.5, 144))
# querying and interpolating
xyz = LTU[:, :3]
val = LTU[:, 3]
del LTU # attempt to clean up memory
tree = cKDTree(xyz)
dist, ind = tree.query(coords, k=2)
d1, d2 = dist.T
v1, v2 = val[ind].T
v = (d1)/(d1 + d2)*(v2 - v1) + v1
print(v)
#[ 6758.73909236 6789.16987298 6790.03575996]