[SciPy-dev] new function regrid for fitpack2

Stefan van der Walt stefan at sun.ac.za
Thu Oct 12 19:38:56 CDT 2006

Hi John

On Fri, Oct 13, 2006 at 12:48:56AM +0100, John Travers wrote:
> > 1. I recently made some changes to the interp2d interface in order to
> >    make the coordinate specification more consistent.  Your patch
> >    simply reverts to the older behaviour.  I don't like this because
> >    it assumes that x values increase with rows and y values with
> >    columns, even though this isn't mentioned anywhere in the
> >    docstrings.  I'm not suggesting that the alternative is better, but
> >    it does make fewer assumptions -- it simply flattens the x and y
> >    inputs and pass them to the fitpack routine (unless x*y != z.size,
> >    in which case it makes up a meshgrid).
> The reason I changed this is because 'regrid' can only take 1d x,y
> arrays which have the same number of points as the respective axis of
> z. Flattening doesn't work here. It probably isn't hard for interp2d
> to take either coordinate arrays, mgrid matrices, meshgrid matrices or
> ogrid arrays and for us to detect which axis they are varying in and
> then get things right for regrid. But as per my note above, when we
> get scattered data working too we can deal with the input issues
> better. In the mean time I think it is better to have just regrid
> working.

Right, the relevant comments in regrid.f for anyone else following:

c given the set of values z(i,j) on the rectangular grid (x(i),y(j)),
c i=1,...,mx;j=1,...,my, subroutine regrid determines a smooth bivar-
c iate spline approximation s(x,y) of degrees kx and ky on the rect-
c angle xb <= x <= xe, yb <= y <= ye.

c  z     : real array of dimension at least (mx*my).
c          before entry, z(my*(i-1)+j) must be set to the data value at
c          the grid point (x(i),y(j)) for i=1,...,mx and j=1,...,my.
c          unchanged on exit.

> > 2. The docstrings were updated to be fairly descriptive, whereas after
> >    patching we'd be back to short, non-descriptive documentation.
> >
> I tried to only remove things that were no longer relevant (like the
> input array format). But if we change as per above, we should
> re-instate your docs. (I don't mean to tred on toes...). I can make
> clearer docstrings for the temporary regrid only interp2d first.

No! Please go ahead and forget about the toes.  I only ask these
questions to make sure that we are on the same page.  I want the
documentation to clearly state exactly what we are doing, so that
there is no confusion on how to use the new interface (I've never seen
a ticket complaining about the detailed level of docstrings ;).

> > I'd also like to see some tests to verify the behaviour of the new
> > interp2d that is *different* from the old version.  It's easier to add
> > it now, while everything is still fresh in our memories.
> Will try and do this tomorrow.

OK, unless someone beats me to it, I will merge the patch tomorrow
morning (ZA time).


More information about the Scipy-dev mailing list