[SciPy-user] intepolate.interp2d why X==Y?[SEC=UNCLASSIFIED]

Scott Collis s.collis@bom.gov...
Tue Mar 25 22:51:52 CDT 2008

Hello Scipy-users,
I've often scanned the mailing lists for tidbits and answers.. But now I
have a question of my own. 

I am regridding data from various sources onto a common grid. These
grids are non square and interpolate.interp2d requires X==Y to create a
interplolated object.

I have modified the code and removed the condition:
       self.x, self.y, self.z = map(ravel, map(array, [x, y, z]))
        if not map(rank, [self.x, self.y, self.z]) == [1,1,1]:
            raise ValueError("One of the input arrays is not 1-d.")
 -->       #if len(self.x) != len(self.y):
 -->       #    raise ValueError("x and y must have equal lengths")
        if len(self.z) == len(self.x) * len(self.y):
            self.x, self.y = meshgrid(x,y)
            self.x, self.y = map(ravel, [self.x, self.y])
        if len(self.z) != len(self.x):
            raise ValueError("Invalid length for input z")

and it -seems- to be working

Is the check there only for the case when X and Y are declared pointwise
(ie len(x)=len(y)=len(z)) rather than gridwise (len(x)*len(y)=len(x))


It seems grids over 100x100 seem to kill it..

if anyone has any other suggestions for re-gridding please let me know..
(I may just end up writing my own quick nearest neighbour algorithm
instead of using splines like interp2d)


Dr Scott Collis
National Meteorological & Oceanographic Centre
Australian Bureau of Meteorology
Mb: 0412177550

More information about the SciPy-user mailing list