signal.correlate(): calculate linear cross correlation np.percentile(): calculate percentile here np.interp()