# [SciPy-user] spline interpolation

Christian Kristukat ckkart at hoc.net
Thu Nov 9 20:54:49 CST 2006

Robert Kern wrote:
> Jordan Dawe wrote:
>> I've been looking at scipy's interpolation routines and I can't make
>> heads or tails of them.  I just want to do a spline interp1d like matlab
>> does.  Is there any way to do this?
>
> I don't know exactly what features you want from Matlab's interp1d, but you
> probably want scipy.interpolate.UnivariateSpline.

I just noticed that UnivariateSpline.derivatives() seems to be broken:

import numpy as N
from scipy.interpolate import UnivariateSpline as spline
x=N.arange(10,dtype=float)
y=x**2
a=N.linspace(2,5,100)
sp=spline(x,y)
b=sp(a)
der=sp.derivatives(a)

fails with:

0-th dimension must be fixed to 8 but got 4
---------------------------------------------------------------------------
dfitpack.error                                     Traceback (most recent call last)

/mnt/home/ck/<console>

/usr/local/lib/python2.4/site-packages/scipy/interpolate/fitpack2.py in
derivatives(self, x)
179     def derivatives(self, x):
180         """ Return all derivatives of the spline at the point x."""
--> 181         d,ier = dfitpack.spalde(*(self._eval_args+(x,)))
182         assert ier==0,`ier`
183         return d

error: failed in converting 2nd argument `c' of dfitpack.spalde to C/Fortran array

Christian