[SciPy-user] problem with interp1d

John Hunter jdhunter at ace.bsd.uchicago.edu
Tue Sep 12 09:00:43 CDT 2006

I thought the following code would resample  the irregularly spaced
't' to the regularly spaced 'newt' but I am getting a traceback

import scipy
import scipy.interpolate
t = scipy.cumsum(scipy.randn(100)) # increasing time
s = scipy.sin(2*scipy.pi*t)
interp = scipy.interpolate.interp1d(t, s)
newt = scipy.arange(min(t), max(t), 0.1)
news = interp(newt)

> python tst.py
Traceback (most recent call last):
  File "tst.py", line 7, in ?
    news = interp(newt)
  line 154, in __call__
    out_of_bounds = self._check_bounds(x_new)
  line 208, in _check_bounds
    raise ValueError, " A value in x_new is below the"\
ValueError:  A value in x_new is below the interpolation range.

In [2]: scipy.__version__
Out[2]: '0.5.2.dev2196'

Any ideas?

More information about the SciPy-user mailing list