SciPy interp2D for pairs of coordinates

Passing all of your points at once will probably be quite a lot faster than looping over them in Python. You could use scipy.interpolate.griddata:

Z = interpolate.griddata((X_table, Y_table), Z_table, (X, Y), method='cubic')

or one of the scipy.interpolate.BivariateSpline classes, e.g. SmoothBivariateSpline:

itp = interpolate.SmoothBivariateSpline(X_table, Y_table, Z_table)
# NB: choose grid=False to get an (n,) rather than an (n, n) output
Z = itp(X, Y, grid=False)

CloughTocher2DInterpolator also works in a similar fashion, but without the grid=False parameter (it always returns a 1D output).


Try *args and tuple packing/unpacking

points = zip(X, Y)
out = []
for p in points:
    value = f_interp(*p)
    out.append(float(value))

or just

points = zip(X, Y)
out = [float(f_interp(*p)) for p in points]

or just

out = [float(f_interp(*p)) for p in zip(X, Y)]

as a side note, the "magic star" allows zip to be its own inverse!

points = zip(x, y)
x, y   = zip(*points)