I use scipy.interpolate.interp2d to create an interpolation function for the surface. Then I have two arrays of real data for which I want to calculate the interpolated points. If I pass two arrays to interp2d , I get an array of all points, not just a pair of points.
My solution is to pin two arrays to a list of coordinate pairs and pass this to the interpolation function in a loop:
f_interp = interpolate.interp2d(X_table, Y_table,Z_table, kind='cubic') co_ords = zip(X,Y) out = [] for i in range(len(co_ords)): X = co_ords[i][0] Y = co_ords[i][1] value = f_interp(X,Y) out.append(float(value))
My question is, is there a better (more elegant, Pythonic?) Way to achieve the same result?
source share