[SciPy-user] Interpolate 1D

Maik Trömel maik.troemel at maitro.net
Thu Sep 7 06:00:02 EDT 2006


Hello,

scipy.interpolate.fitpack2.InterpolatedUnivariateSpline seems to be a 1d 
interpolation method. I used the Cookbook/Rebinning-Example to 
Interpolate. I don't know if it works with InterpolatedUnivariateSpline.

I also tried out scipy.interpolate.interpolate.interp2d. But I get an 
error. Probably somebody knows what I'm doing wrong. Here's the script:

import scipy.interpolate

#just some data
a = numpy.zeros((4,4), dtype=''Float32') 
oldx= numpy.arange(4)
oldy = numpy.arange(4)
newx = numpy.zeros((4), dtype=''Float32') 
newy =numpy.zeros((4), dtype=''Float32') 
for s in range(8):
    newx[s] =  s * 0.5
    newy[s] =  s * 0.5

#interpolation
intinst = scipy.interpolate.interpolate.interp2d(oldx, oldy, a, kind = 
'cubic')
interpolated = intinst(newx, newy)


And here's the error:
/usr/lib/python2.3/site-packages/scipy/interpolate/interpolate.py in 
__call__(self, x, y, dx, dy)
     62         x = atleast_1d(x)
     63         y = atleast_1d(y)
---> 64         z,ier=fitpack._fitpack._bispev(*(self.tck+[x,y,dx,dy]))
     65         if ier==10: raise ValueError,"Invalid input data"
     66         if ier: raise TypeError,"An error occurred"

AttributeError: interp2d instance has no attribute 'tck'

Thanks for your help.

Greetings Maik






Maik Trömel wrote:
> Date: Tue, 5 Sep 2006 11:29:49 -0400
>
> From: "A. M. Archibald" <peridot.faceted at gmail.com>
> Subject: Re: [SciPy-user] Interpolate 1D
> To: "SciPy Users List" <scipy-user at scipy.org>
> Message-ID:
>     <ce557a360609050829n797be48bv81709ad18bed7e0f at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> On 05/09/06, Maik Tr?mel <maik.troemel at maitro.net> wrote:
>
>> > Hello list,
>> >
>> > when I try to use scipy.interpolate.interpolate.interp1d( olddims[-1],
>> > a, kind='cubic' ) I get an ERROR:
>> >
>> > File
>> > "/usr/lib/python2.3/site-packages/scipy/interpolate/interpolate.py",
>> > line 118, in __init__
>> >     raise NotImplementedError, "Only linear supported for now. Use "\
>> > NotImplementedError: Only linear supported for now. Use fitpack 
>> routines
>> > for other types.
>> >
>> > But under
>> > 
>> http://www.scipy.org/doc/api_docs/scipy.interpolate.interpolate.interp1d.html 
>>
>> > kind = 'cubic' is listed. Whats wrong with the command? Or is cubic 
>> not
>> > implemented yet?
>> >
>> > Thanks for your help!
>>   
>
> It seems not to be implemented, but you can use
> scipy.interpolate.fitpack2.InterpolatedUnivariateSpline to do the same
> thing for splines (of various orders). I think it also provides all
> the handy extras like derivatives and root-finding. It doesn't seem to
> be able to raise exceptions or insert NaNs for out-of-bound values, it
> just extrapolates. But otherwise it seems to be the right tool for the
> job.
>
> A. M. Archibald
>
>
> ------------------------------
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
>
> End of SciPy-user Digest, Vol 37, Issue 3
> *****************************************
>
>



More information about the SciPy-User mailing list