Re: [SciPy-user] Interpolate 1D (2D)
Thanks for your help! But there was still the same problem: /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' I tried it on another system, but there ist the same problem. But there were the same scipy and numpy verions. So, I've updated to the same scipy and numpy version like you. New (or same?) problem: /usr/lib/python2.3/site-packages/scipy/interpolate/interpolate.py in __call__(self, x, y, dx, dy) 62 Output: 63 z - 2-d array of interpolated values of shape (len(y), len(x)). ---> 64 """ 65 x = atleast_1d(x) 66 y = atleast_1d(y) AttributeError: interp2d instance has no attribute 'tck' ?????????????????? Where's the problem? Anybody an idea? Greetings Maik Maik Trömel wrote:
Message: 8 Date: Thu, 7 Sep 2006 23:09:42 +1200 From: "Angus McMorland" <amcmorl@gmail.com> Subject: Re: [SciPy-user] Interpolate 1D To: "SciPy Users List" <scipy-user@scipy.org> Message-ID: <e85f13c40609070409j5fe83995jecb473f07fe9ad5@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1"
Hi Maik,
On 07/09/06, Maik Tr?mel <maik.troemel@maitro.net> wrote:
Hello,
<snip>
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
I've tried your script, and get several different errors, so are you sure that your error messages are coming from this script?
The biggest conceptual jump needed with your script, as it runs on my system, (scipy 0.5.0.2177, numpy 1.0b4.dev3055) is that oldx and oldy need to be the same length as the flattened 'a' - that is an (x,y) pair for each value of a, which itself could also be flat. Here is, I think, a working version:
import scipy.interpolate import numpy
#just some data a = numpy.random.random_sample((4,4)).astype('Float32') oldinds = numpy.indices((4,4)) oldx = oldinds[1].flatten() # because indices[1] is the x values oldy = oldinds[0].flatten() newx = numpy.linspace(0,3,8).astype('Float32') newy = numpy.linspace(0,3,8).astype('Float32')
#interpolation intinst = scipy.interpolate.interp2d(oldx, oldy, a, kind = 'cubic') interpolated = intinst(newx, newy)
#display the result - can ignore if you don't have matplotlib installed import pylab
pylab.subplot(121) pylab.imshow(a,interpolation='nearest') pylab.subplot(122) pylab.imshow(interpolated, interpolation='nearest')
Hi Maik On Fri, Sep 08, 2006 at 09:49:53AM +0200, Maik Trömel wrote:
Thanks for your help! But there was still the same problem:
/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'
This looks like the error that used to be present in older versions of scipy. Are you sure you are running the latest version? It works here, with In [17]: numpy.__version__ Out[17]: '1.0rc1.dev3131' In [18]: scipy.__version__ Out[18]: '0.5.2.dev2190' Regards Stéfan
participants (2)
-
Maik Trömel -
Stefan van der Walt