def autocorrfunc(freq, power):
tbin = <NUM_LIT:1.> / (<NUM_LIT> * np.max(freq)) * <NUM_LIT>  <EOL>time = np.arange(-len(freq) / <NUM_LIT> + <NUM_LIT:1>, len(freq) / <NUM_LIT> + <NUM_LIT:1>) * tbin<EOL>multidata = False<EOL>if len(np.shape(power)) > <NUM_LIT:1>:<EOL><INDENT>multidata = True<EOL><DEDENT>if multidata:<EOL><INDENT>N = len(power)<EOL>autof = np.zeros((N, len(freq)))<EOL>for i in range(N):<EOL><INDENT>raw_autof = np.real(np.fft.ifft(power[i]))<EOL>mid = int(len(raw_autof) / <NUM_LIT>)<EOL>autof[i] = np.hstack([raw_autof[mid + <NUM_LIT:1>:], raw_autof[:mid + <NUM_LIT:1>]])<EOL><DEDENT>assert(len(time) == len(autof[<NUM_LIT:0>]))<EOL><DEDENT>else:<EOL><INDENT>raw_autof = np.real(np.fft.ifft(power))<EOL>mid = int(len(raw_autof) / <NUM_LIT>)<EOL>autof = np.hstack([raw_autof[mid + <NUM_LIT:1>:], raw_autof[:mid + <NUM_LIT:1>]])<EOL>assert(len(time) == len(autof))<EOL><DEDENT>return time, autof<EOL>
Calculate autocorrelation function(s) for given power spectrum/spectra.


Parameters
----------
freq : numpy.ndarray
    1 dimensional array of frequencies.
power : numpy.ndarray
    2 dimensional power spectra, 1st axis units, 2nd axis frequencies.


Returns
-------
time : tuple
    1 dim numpy.ndarray of times.
autof : tuple
    2 dim numpy.ndarray; autocorrelation functions, 1st axis units,
    2nd axis times.