find time shift between two similar waveforms

前端 未结 6 1720
灰色年华
灰色年华 2020-12-04 11:34

I have to compare two time-vs-voltage waveforms. Because of the peculiarity of the sources of these waveforms, one of them can be a time shifted version of the other.

6条回答
  •  失恋的感觉
    2020-12-04 12:19

    If one is time-shifted by the other, you will see a peak in the correlation. Since calculating the correlation is expensive, it is better to use FFT. So, something like this should work:

    af = scipy.fft(a)
    bf = scipy.fft(b)
    c = scipy.ifft(af * scipy.conj(bf))
    
    time_shift = argmax(abs(c))
    

提交回复
热议问题