[SciPy-User] 1 dimensional interpolation of vectors
Tue Mar 15 14:23:47 CDT 2011
On Tue, Mar 15, 2011 at 1:33 PM, Michael Hull <email@example.com>wrote:
> Sorry for the confusing title!
> Firstly, thanks for all the great work on numpy and scipy, its very
> What I have is an array of time recordings of various properties. If
> have recordings of prop1,prop2,prop3,prop4.... propN, and for each
> recording, I have the values at millisecond time intervals, stored in
> a 2 dimensional array.
> The properties are not linked, what I am trying to do is to find the
> value at say t=2.4ms, i.e. a non integer millisecond, by linearly
> interpolating between the two time points 2ms and 3ms.
> I can do this in one dimension using scipy.interpolate.interp1d for
> each property, but what I would like to do is get an entire row in one
> go,, because the number of properties is
> pretty large.
> I can write this myself, but I was wondering if there was already
> something built in?
interp1d can take a 2D array for the y value. For example,
In : x = array([0.0, 1.0, 2.0, 3.0])
In : y = array([[1.0, 0.0, 0.5, 10.5],[-4, 2, 2, 0]])
In : func = interp1d(x, y)
In : func(0.5)
Out: array([ 0.5, -1. ])
In : func(1.1)
Out: array([ 0.05, 2. ])
In : func(2.75)
Out: array([ 8. , 0.5])
So if you have a 2D array of measurements--one row for each "prop"--you can
use interp1d without a loop. If each property is a column, you can use the
'axis=0' keyword argument in interp1d, or transpose the array.
> Many thanks
> SciPy-User mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-User