[SciPy-user] odeint for calculating trajectories

Rob Clewley rob.clewley@gmail....
Thu Feb 12 12:16:22 CST 2009

> Is there a good way to use scipy.integrate.odeint to calculate trajectories
> from an observed velocity field? I know you can do this when you have an
> analytic expression for dx/dt, but in this case I have a spatial grid of
> values for dx/dt.  The only way I've come up with is to make the function
> passed to odeint something that will interpolate fromt the grid to the given
> point.

I don't think odeint is the right tool for this job - there is no ODE
integration to do if you do not have an explicit function for the
vector field. You should think of it purely as an interpolation
problem. You have (t,x) values and (t, dx/dt) values, so this defines
a piecewise quadratic function which has continuous *second*
derivative everywhere (i.e. the trajectory smoothly agrees at your
mesh points). I would use the polynomial interpolation classes that
were recently added to scipy by Anne Archibald (search this list for
details about it). You pass it your arrays of values and you get back
a function that smoothly interpolates through your points. This is the
most accurate trajectory that you can derive from this finite mesh


More information about the SciPy-user mailing list