def crosscorrfunc(freq, cross):
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(cross)) > <NUM_LIT:1>:<EOL><INDENT>multidata = True<EOL><DEDENT>if multidata:<EOL><INDENT>N = len(cross)<EOL>crossf = np.zeros((N, N, len(freq)))<EOL>for i in range(N):<EOL><INDENT>for j in range(N):<EOL><INDENT>raw_crossf = np.real(np.fft.ifft(cross[i, j]))<EOL>mid = int(len(raw_crossf) / <NUM_LIT>)<EOL>crossf[i, j] = np.hstack(<EOL>[raw_crossf[mid + <NUM_LIT:1>:], raw_crossf[:mid + <NUM_LIT:1>]])<EOL><DEDENT><DEDENT>assert(len(time) == len(crossf[<NUM_LIT:0>, <NUM_LIT:0>]))<EOL><DEDENT>else:<EOL><INDENT>raw_crossf = np.real(np.fft.ifft(cross))<EOL>mid = int(len(raw_crossf) / <NUM_LIT>)<EOL>crossf = np.hstack([raw_crossf[mid + <NUM_LIT:1>:], raw_crossf[:mid + <NUM_LIT:1>]])<EOL>assert(len(time) == len(crossf))<EOL><DEDENT>return time, crossf<EOL>
Calculate crosscorrelation function(s) for given cross spectra.


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


Returns
-------
time : tuple
    1 dim numpy.ndarray of times.
crossf : tuple
    3 dim numpy.ndarray, crosscorrelation functions,
    1st axis first unit, 2nd axis second unit, 3rd axis times.