[SciPy-User] Inconsistent conventions in scipy.interpolate

Pauli Virtanen pav@iki...
Tue Oct 30 15:39:33 CDT 2012


30.10.2012 12:08, Armando Serrano Lombillo kirjoitti:
> I've recently been catched by the fact that
> scipy.interpolate.interp2d(x, y, z) expects z.shape=(len(y), len(x))
> while scipy.interpolate.RectBivariateSpline(x, y, z) expects
> z.shape=(len(x), len(y)). I find this inconsistency quite annoying and
> error prone, is there a reason for it?

No reason I'm aware of. The "transposed" convention comes from how
meshgrid and probably ultimately comes from image processing or so,
whereas the other convention is more natural for Numpy.

I would suggest avoiding using interp2d --- use RectBivariateSpline if
you want to fit splines to rectangular array data,
Smooth/LSQBivariateSpline if you want to do spline fitting to scattered
data, and griddata for scattered data interpolation.

-- 
Pauli Virtanen



More information about the SciPy-User mailing list