[SciPy-User] Understanding the cross-correlation function numpy.correlate & how to use it properly with real and synthetic data

Vincent Schut schut at sarvision.nl
Fri Dec 16 04:45:11 EST 2011


On 12/14/2011 09:14 PM, Rob Newman wrote:
> Hi SciPy gurus,
>
> First up - I am not a physicist, so please be gentle!
>
> I have an array of real data and an array of synthetic data. I am trying to determine the cross-correlation of the two signals and the timeshift that needs to be applied to the real data to best match the synthetic data. I also want to only use the real data later on the script if the cross correlation result is above some level of confidence.
>
> I have read the man page on numpy.correlate, but I am not entirely sure of what that function returns to me, and how I should use it. I have looked at James Battat's website that has a useful script on the discrete correlation function of two functions (https://www.cfa.harvard.edu/~jbattat/computer/python/science/#correlation) but I think his example is more complicated than my needs.
>
> I understand that the correlate function returns an array that is twice the size of both the input arrays minus 1 (when using mode='full'), but what do I need to do to that resulting array to get the correlation value (if there is indeed a value to be returned) and the timeshift that needs to be applied to the real data to match the synthetic data.
>
> Thanks in advance,
> - Rob

Hi,

if you just need to find the time-shift, another approach could be fft 
phase correlation. I have successfully used that to co-register images 
(satellite images) together, but I suppose it would apply in the 1-d 
case as well. Unfortunately I don't have any code ready, but you just 
might want to check some info on the subject on the internet to see if 
it would fit your needs.

Best,
Vincent.




More information about the SciPy-User mailing list