[SciPy-user] spline problem

Peter Bienstman Peter.Bienstman at ugent.be
Fri Sep 7 09:07:28 EDT 2007


Hi,

I'm trying to do spline interpolation of my data. When I try the final example 
of http://www.scipy.org/Cookbook/Interpolation, everything works fine. 
However, as soon as I adapt it to use my own data, I get this

Traceback (most recent call last):
  File "test.py", line 26, in ?
    tckp,u = splprep([x,y],s=s,k=k,nest=-1,quiet=0)
  File "/usr/lib64/python2.4/site-packages/scipy/interpolate/fitpack.py", line 
223, in splprep
    nest,wrk,iwrk,per)
SystemError: error return without exception set

This is on a core duo, with the latest scipy.

Here is the code:

===============

from numpy import *

from scipy.interpolate import splprep, splev

x = array([10807., 10806, 10808, 10810, 10812, 10814, 10817, 10821, 10825,
       10830, 10835, 10839, 10842, 10846, 10849, 10851, 10853, 10855,
       10855, 10855, 10854, 10852, 10851, 10847, 10844, 10841, 10839,
       10837, 10837, 10835, 10835, 10835, 10837, 10838, 10841, 10843,
       10845, 10847, 10848, 10847, 10846, 10843, 10838, 10833, 10825,
       10819, 10809, 10801, 10791, 10782, 10774, 10759, 10749, 10738,
       10729, 10721, 10714, 10706, 10701, 10696, 10693, 10691, 10693,
       10693, 10693, 10698, 10699, 10704, 10670, 10682, 10690, 10696, 10696])
y = array([272., 272, 272, 272, 272, 273, 274, 279, 279, 281, 282, 284, 284,
       284, 284, 286, 285, 288, 289, 289, 291, 296, 300, 305, 313, 324,
       334, 343, 351, 357, 362, 367, 372, 376, 379, 381, 383, 383, 383,
       383, 382, 381, 381, 381, 383, 387, 391, 398, 403, 411, 416, 421,
       426, 430, 433, 434, 431, 424, 416, 404, 390, 377, 365, 354, 345,
       338, 332, 329, 325, 325, 323, 317, 317])

# spline parameters
s=3.0 # smoothness parameter
k=2 # spline order
nest=-1 # estimate of number of knots needed (-1 = maximal)

# find the knot points
tckp,u = splprep([x,y],s=s,k=k,nest=-1,quiet=0)

# evaluate spline, including interpolated points
xnew,ynew = splev(linspace(0,1,400),tckp)

import pylab
data,=pylab.plot(x,y,'bo-',label='data')
fit,=pylab.plot(xnew,ynew,'r-',label='fit')
pylab.legend()
pylab.xlabel('x')
pylab.ylabel('y')

pylab.show()

Thanks!

Peter

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: not available
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20070907/9b86c3cd/attachment.sig>


More information about the SciPy-User mailing list