In Python, I'm trying to construct a routine that interpolates in vector-valued data in a multi-dimensional (5+) parameter space. i.e. I have a function that takes a number of input variables and returns a number of output variables. At the moment, there is one call for each element of the vector. The data is in a columned file, so I retrieve it with
import numpy
[x_data,y_data,f1_data,f2_data] = numpy.loadtxt('data',unpack=True)
Then, I instantiate individual interpolators using SciPy's functions, like
from scipy import interpolate
f1 = interpolate.LinearNDInterpolator((x_data,y_data),f1_data)
f2 = interpolate.LinearNDInterpolator((x_data,y_data),f2_data)
...
Now, when I make the interpolation call, I have to interpolate for each value f1, f2, etc. even though really it should be achievable as one operation. And I'm guessing that making one interpolation should be faster than making 5 or more.
Is there a way to construct a vector- (or array-) valued interpolator?
I tried constructing the interpolator with
f = interpolate.LinearNDInterpolator((x_data,y_data),(f1_data,f2_data,...))
but it returns the error
ValueError: different number of values and points
I've also read this question and answer but it's about a vector-valued function of a scalar, which can apparently be handled by interp1d.