The interpolation function scipy.interpolate.interp1d also works with vector-valued data for interpolation (but not for vector argument values). Thus, as long as x is scalar, you can use it directly.
The following code is a small extension of the example provided in the meager documentation :
>>> from scipy.interpolate import interp1d >>> x = np.linspace(0, 10, 10) >>> y = np.array([np.exp(-x/3.0), 2*x]) >>> f = interp1d(x, y) >>> f(2) array([ 0.51950421, 4. ]) >>> np.array([np.exp(-2/3.0), 2*2]) array([ 0.51341712, 4. ])
Note that 2 is not in the argument vector x , so there is an interpolation error for the first component in y in this example.
silvado
source share