[SciPy-user] problems with splrep,splev

Christian K. ckkart@hoc....
Fri Apr 17 04:14:26 CDT 2009


I am having problems with the spline functions from scipy.interpolate. Reading 
the doc strings I expected the following to work:

from scipy.interpolate import splev,splrep
import numpy as N
x = N.linspace(-4,10,5)
y = x**2
t,c,l = splrep(x,y,xb=0,xe=4)

Traceback (most recent call last):
  File "C:\pythonxy\python\lib\site-packages\scipy\interpolate\fitpack.py", 
line 406, in splrep
    n,c,fp,ier = dfitpack.curfit(task, x, y, w, t, wrk, iwrk, xb, xe, k, s)
error: (xb<=x[0]) failed for 1st keyword xb

Second, I want to fit several curves using the same knots, thus I tried the 

y2 = x**2-3*x+4
t2,c2,l2 = splrep(x,y2,t=t)

Traceback (most recent call last):
  File "C:\pythonxy\python\lib\site-packages\scipy\interpolate\fitpack.py", 
line 418, in splrep
    raise _iermess[ier][1],_iermess[ier][0]
ValueError:     Error on input data

Are those bugs or am I misunderstanding something?

Eventually I would like to morph one spline into another, therefor I want to 
stick with the knots. If anyone has experiences with splines and morphing I 
would be very interested to hear about it.

Regards, Christian

More information about the SciPy-user mailing list