def cross_correlation2(fft1, fft2, maxlag, dt, Nfft):
    corr = np.zeros(fft1.shape, dtype=np.complex64)
    corr = (np.conj(fft1) * fft2)
    ncorr = np.zeros(shape=Nfft, dtype=np.complex64)
    ncorr[:(Nfft // 2)] = np.mean(corr, axis=0)
    ncorr[((- (Nfft // 2)) + 1):] = np.flip(np.conj(ncorr[1:(Nfft // 2)]), axis=0)
    ncorr[0] = complex(0, 0)
    ncorr = np.fft.ifftshift(scipy.fftpack.ifft(ncorr, Nfft, axis=0))
    print(ncorr.real, ncorr.imag)
    tcorr = (np.arange((((- Nfft) // 2) + 1), (Nfft // 2)) * dt)
    ind = np.where((np.abs(tcorr) <= maxlag))[0]
    ncorr = ncorr[ind]
    return ncorr
def cross_correlation2(fft1, fft2, maxlag, dt, Nfft):
    corr = np.zeros(fft1.shape, dtype=np.complex64)
    corr = (np.conj(fft1) * fft2)
    ncorr = np.zeros(shape=Nfft, dtype=np.complex64)
    ncorr[:(Nfft // 2)] = np.mean(corr, axis=0)
    ncorr[((- (Nfft // 2)) + 1):] = np.flip(np.conj(ncorr[1:(Nfft // 2)]), axis=0)
    ncorr[0] = complex(0, 0)
    ncorr = np.fft.ifftshift(scipy.fftpack.ifft(ncorr, Nfft, axis=0))
    print(ncorr.real, ncorr.imag)
    tcorr = (np.arange((((- Nfft) // 2) + 1), (Nfft // 2)) * dt)
    ind = np.where((np.abs(tcorr) <= maxlag))[0]
    ncorr = ncorr[ind]
    return ncorr