[SciPy-User] integrate.ode sets t0 values outside of my data range

Warren Weckesser warren.weckesser at gmail.com
Thu Aug 7 09:23:43 EDT 2014


On 8/7/14, Daπid <davidmenhur at gmail.com> wrote:
> On 7 August 2014 11:05, Camille <camillechambon at yahoo.fr> wrote:
>
>> Thanks for your answer. Actually, data(t) is a sinusoidal function. Thus
>> I
>> can not extend the interpolation data linearly. I edited my question on
>> StackOverflow accordingly.
>
>
> Note that you are evaluating it very close to the boundary, so the
> interpolation effects will not be so bad. You can check the sensibility
> comparing the results with a purposefully "wrong" interpolation, like the
> same linear interpolation but with the opposite slope; but I bet the
> differences are going to be slim.
>
> If you know your data is sinusoidal, you can use that to make an even
> better estimation of the next value. Essentially, you need to provide the
> ODE solver with a way to estimate the derivatives of your function at any
> point.
>
>
> /David
>

I agree with David.  Use whatever extrapolation method is appropriate
for your function.  The main point is to expect your function to be
evaluated a little bit beyond the final time requested in odeint.

I updated my answer on StackOverflow with a suggestion to use either
the "dopri5" or "dop853" solver of the scipy.integrate.ode class.  It
appears that these solvers do not evaluate your function at times
beyond the requested time.  Check out the SO answer for the sample
code: http://stackoverflow.com/questions/25031966/integrate-ode-sets-t0-values-outside-of-my-data-range

Warren



More information about the SciPy-User mailing list