Re: [Numpy-discussion] interpolating arrays (?)

Hi Tim, I implemented the below code with good results; and if I go to a C version in the future I'll let you know. As the raw data is integer and a bit coarse at times, it will also help to have a non-linear method. I use a parabolic interpolation for finding centriods of clipped stellar images, but that's still Python too.
With that one comes up with (untested):
def rubberBand(self, y, desiredLength): # Define raw so that raw[0] == 0 and raw[-1] == len(y)-1 and len(raw) == desiredLength raw =arange(desiredLength) * (len(y) - 1) / (float(desiredLength) - 1) jVals = na.clip(na.floor(raw), 0, len(y)-2).astype('i') delta = raw - jVals dy = y[1:] - y[:-1] return na.take(y, jVals) + delta * na.take(dy, jVals)
Hope that's helpful,
quite.
PS, I just realized, these snippets assume a 'import numarray as na' somewhere above. Numeric should also work if the names are adjusted appropriately.
It does. I use Numeric for when arrays are length< 2000, as someone posted some results to that effect a while back. numarray is certainly faster for images. In general, I'm using FFT for ballpark estimation of periodicity, then doing time domain data comparison for more precise alignment. Thanks to Chris, Konrad and Warren as well, Ray

participants (1)
-
RayS