[Numpy-discussion] numpy.correlate with phase offset 1D data series
Mon Mar 3 15:24:49 CST 2008
On Mon, Mar 3, 2008 at 12:57 PM, Ray Schumacher <firstname.lastname@example.org>
> I'm trying to figure out what numpy.correlate does, and, what are people
> using to calculate the phase shift of 1D signals?
> (I coded on routine that uses rfft, conjugate, ratio, irfft, and argmax
> based on a paper by Hongjie Xie "An IDL/ENVI implementation of the FFT Based
> Algorithm for Automatic Image Registration" - but that seems more intensive
> than it could be.)
> In numpy, an identity import numpy from pylab import * l=[1,5,3,8,15,6,7,7,9,10,4]
> c=numpy.correlate(l,l, mode='same') plot(c) peaks at the center, x=5, and
> is symmetric
> when the data is rotated by 2 c=numpy.correlate(l, l[-2:]+l[:-2],
> mode='same') it peaks at x=3
> I was expecting, I guess, that the peak should reflect the x axis shift,
> as in
Interesting. This appears to be a result of the implementation of the
various modes. If you use the 'valid' mode, you'll get 0, as I presume
you'll expect. If you use 'same' or 'full' you'll end of with different
amounts of offset. I imagine that this is due to the way the data is padded.
The offset should be deterministic based on the mode and the size of the
data, so it should be straightforward to compensate for.
> If I use a real time domain signal like
> http://rjs.org/Python/sample.sig fh = open(r'sample.sig','rb') s1 =
> numpy.fromstring(fh.read(), numpy.int32) fh.close()
> an identity like c=numpy.correlate(s1, s1, mode='same') plots like noise.
When I download this, it's full of NaNs. There's either a problem in the way
I downloaded it or in the uploaded file. You didn't by chance upload it as
an ASCII file did you?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion