problem with interp1d
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",
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) 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
"John" == John Hunter <jdhunter@ace.bsd.uchicago.edu> writes:
John> I thought the following code would resample the irregularly John> spaced 't' to the regularly spaced 'newt' but I am getting a John> traceback OK, please ignore me. Because I was using randn to generate the intervals, I was getting non-monotonic x. Duh import scipy import scipy.interpolate t = scipy.cumsum(scipy.rand(100)) # increasing time s = scipy.sin(0.1*2*scipy.pi*t) interp = scipy.interpolate.interp1d(t, s) newt = scipy.arange(min(t), max(t), 0.1) news = interp(newt) from pylab import subplot, show ax = subplot(111) ax.plot(t, s, 'o', newt, news, '-') show()
participants (1)
-
John Hunter