[SciPy-user] problem with interp1d
John Hunter
jdhunter at ace.bsd.uchicago.edu
Tue Sep 12 10:00:43 EDT 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)
File
"/usr/lib/python2.4/site-packages/scipy/interpolate/interpolate.py",
line 154, in __call__
out_of_bounds = self._check_bounds(x_new)
File
"/usr/lib/python2.4/site-packages/scipy/interpolate/interpolate.py",
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?
Thanks,
JDH
More information about the SciPy-User
mailing list