[SciPy-user] Interpolation using splines
Ewald Zietsman
ewald.zietsman at gmail.com
Tue Sep 26 07:27:42 CDT 2006
Hi all,
I'm trying to fit a cubic spline to a data set. I can't seem to get the
functions in scipy.interpolate (splrep and splev) to work correctly ( I'm
probably being stupid).
When I do the following,
#! /usr/bin/python
from scipy import interpolate
from pylab import *
x = arange(0.0,2.0*pi+pi/4.0,2.0*pi/8.0)
y = sin(x)
tck = interpolate.splrep(x,y,s=0.0)
xnew = arange(0.0,2.0*pi+pi/4.0,pi/50.0)
ynew = interpolate.splev(xnew,tck,der=0.0)
plot(x,y,'x')
plot(xnew,ynew,'r-')
show()
I should get a plot showing a sin curve made of blue x's and a smooth red
line which is the spline. However, the spline seems to be zero except for
one place where it spikes.
I'm using scipy 0.5.0 and matplotlib 0.87.3 with python 2.4.3 on Fedora Core
5.
Any help on this will be appreciated.
-Ewald
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20060926/032e6665/attachment.html
More information about the SciPy-user
mailing list