def crossCorrelate(t, s, lag=0):

    t_mean = np.mean(t)
    s_mean = np.mean(s)
    t_std = np.std(t)
    s_std = np.std(s)
    len_t = len(t)

    t_norm = [((x - t_mean)/(t_std * len_t)) for x in t]
    s_norm = [((y - s_mean)/s_std) for y in s]

    if lag == 0:
        xcorr = np.correlate(t_norm, s_norm)
    elif lag != 0:
        xcorr = np.correlate(t_norm, s_norm, mode=2)[len_t - 1 + lag]

    return xcorr
Calculate the cross-correlation of two timeseries, s and t.
dataset/ETHPy150Open CGATOxford/cgat/CGAT/Timeseries/__init__.py/crossCorrelate