[SciPy-user] interp1d problem

Ben Webber b.webber@uea.ac...
Mon Nov 3 09:00:05 CST 2008


In CDAT I have been trying to use the interp1d class from the
scipy.interpolate package to interpolate 3-dimensional oceanographic data
along the time axis using cubic splines. This works fine for 1 or 2
dimensional data but fails for 3 dimensional data. However, using linear
interpolation works no matter what the dimensions. I have tried to simplify
the problem as much as possible and have created the following simplified

import scipy
from scipy.interpolate import interp1d

test_array = [[[2,6],[10,7]],[[4,8],[12,9]],[[2,6],[10,7]],[[4,8],[12,9]]]
test_array = scipy.array(test_array)

test_axis = scipy.array(range(0,31,10))
myInterp = interp1d(test_axis,test_array,kind='cubic',axis = 0)
#-----------------fails here----------------------

new_axis = scipy.array(range(0,31))
new_data = myInterp(new_axis)

If kind is specified as 'linear' this script works. However, with kind as
'cubic', I get the following error:

Traceback (most recent call last):
  File "cubic_interp.py", line 11, in <module>
    myInterp = interp1d(timeax_array,theta_array,kind = 'cubic',axis = 0)
line 235, in __init__
    self._spline = splmake(x,oriented_y,order=order)
line 697, in splmake
    coefs = func(xk, yk, order, conds, B)
line 431, in _find_smoothest
    return dot(tmp, yk)
ValueError: objects are not aligned

The shape of the array is (4,2,2). The time axis is length 4, so it should
work. Can anybody explain this error?


Ben Webber
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20081103/ceee78cb/attachment.html 

More information about the SciPy-user mailing list