[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: zonal means
Martin Schultz <mgs@io.harvard.edu> writes:
>
> Q: ... And does anyone have an idea why CONGRID screws up ?
First, CONGRID uses a different form of interpolation compared to
REBIN. REBIN will find the simple average of array cells that are
collapsed, while CONGRID can be set to perform an interpolation. It's
not clear to me that these are the same.
Also, CONGRID() has a subtle bug in its implementation, at least from
the point of view of a physicist :-) Essentially, CONGRID attempts to
interpolate to the pixel *corners*, not their centers. This becomes a
problem at the edges of the array; one "extra" row and column appears
at the far edges.
At some point the IDL folks tried to fix CONGRID by adding the
MINUS_ONE keyword, which removes those extra pieces. Unfortunately
that doesn't solve the problem, if you are trying to be precise, since
you lose one row and column. RSI support seems to have confirmed my
report of this problem.
The proper solution is to interpolate to the pixel centers. I have a
modified version of CONGRID on my IDL web page called CMCONGRID,
http://astrog.physics.wisc.edu/~craigm/idl/idl.html
which does just that. CMCONGRID is a drop in replacement for CONGRID.
Use it just like CONGRID, except that you also need to set the keyword
HALF_HALF to enable the pixel-center interpolation.
Craig
--
--------------------------------------------------------------------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@astrog.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
--------------------------------------------------------------------------