[SciPy-user] Example of how to use B-splines for interpolation
strawman at astraw.com
Sun Jan 29 15:42:07 CST 2006
Thanks for your work on this--it's very useful to me.
I found 2 issues. I'm including a test and a potential fix for the first
issue, which seems to be an end-point problem. Under some circumstances,
the endpoints aren't properly detected. I didn't attempt to comprehend
everything going on in this function, but the patch I made apparently
works. Please review it and apply it if it's acceptable.
The second issue is that the x array cannot be integers (a TypeError
gets raised). There doesn't seem to be any good reason for this (why
can't splines exist over integers?), so I submit that it's also a bug.
Unfortunately, that didn't look as easy for me to fix, so I leave it for
Travis Oliphant wrote:
> This example needs the SVN version of scipy (or you need to get the
> cspline1d_eval function out of SVN):
> I sent a smaller image hoping it would make it to the list...
> from numpy import r_, sin
> from scipy.signal import cspline1d, cspline1d_eval
> x = r_[0:10]
> dx = x-x
> newx = r_[-3:13:0.1] # notice outside the original domain
> y = sin(x)
> cj = cspline1d(y)
> newy = cspline1d_eval(cj, newx, dx=dx,x0=x)
> from pylab import plot
> plot(newx, newy, x, y, 'o')
> Have fun,
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 1568 bytes
Desc: not available
Url : http://www.scipy.net/pipermail/scipy-user/attachments/20060129/63e08825/spline.bin
More information about the SciPy-user