obspy.signal.cross_correlation.xcorr_max

xcorr_max(fct, abs_max=True)[source]

Return shift and value of the maximum of the cross-correlation function.

Parameters
  • fct (ndarray) – Cross-correlation function e.g. returned by correlate.

  • abs_max (bool) – Determines if the largest value of the correlation function is returned, independent of it being positive (correlation) or negative (anti-correlation). Defaults to True. If False the maximum returned is positive only.

Returns

shift, value - Shift and value of maximum of cross-correlation.

Example

>>> fct = np.zeros(101)
>>> fct[50] = -1.0
>>> xcorr_max(fct)
(0, -1.0)
>>> fct[50], fct[60] = 0.0, 1.0
>>> xcorr_max(fct)
(10, 1.0)
>>> fct[60], fct[40] = 0.0, -1.0
>>> xcorr_max(fct)
(-10, -1.0)
>>> fct[60], fct[40] = 0.5, -1.0
>>> xcorr_max(fct, abs_max=True)
(-10, -1.0)
>>> xcorr_max(fct, abs_max=False)
(10, 0.5)
>>> xcorr_max(fct[:-1], abs_max=False)
(10.5, 0.5)