integrate.ode sets t0 values outside of my data range
I would like to solve the ODE dy/dt = -2y + data(t), between t=0..3, for y(t=0)=1. I wrote the following code: import numpy as np from scipy.integrate import odeint from scipy.interpolate import interp1d t = np.linspace(0, 3, 4) data = [1, 2, 3, 4] linear_interpolation = interp1d(t, data) def func(y, t0): print 't0', t0 return -2*y + linear_interpolation(t0) soln = odeint(func, 1, t) When I run this code, I get several errors like this: ValueError: A value in x_new is above the interpolation range. odepack.error: Error occurred while calling the Python function named func My interpolation