Skip to content

Instantly share code, notes, and snippets.

View cwyenberg's full-sized avatar

Chris Wyenberg cwyenberg

View GitHub Profile
@cwyenberg
cwyenberg / CorrFns.py
Created May 18, 2020 18:57
Python autocorrelation functions; 1D and 2D exploiting FFT identity for speedup, one vanilla 1D not using FFT
import numpy as np
def auto_corr(data, normalize=True):
# Performs an autocorrelation on data
# Note that for data size n_data, we autocorrelate to 2*n_data-1 points
# (i.e. this returns a larger array than passed)
n_data = data.shape[0] # Number of data points in the input data
n_ac = 2*n_data-1 # Autocorrelation array size