def crossspec(data, tbin, Df=None, units=False, pointProcess=False):
N = len(data)<EOL>if units is True:<EOL><INDENT>freq, POW = powerspec(data, tbin, Df=Df, units=True)<EOL>freq_com, CPOW = compound_powerspec(data, tbin, Df=Df)<EOL>assert(len(freq) == len(freq_com))<EOL>assert(np.min(freq) == np.min(freq_com))<EOL>assert(np.max(freq) == np.max(freq_com))<EOL>CRO = <NUM_LIT:1.> / (<NUM_LIT:1.> * N * (N - <NUM_LIT:1.>)) * (CPOW - <NUM_LIT:1.> * N * POW)<EOL>assert(len(freq) == len(CRO))<EOL><DEDENT>else:<EOL><INDENT>freq, DATA = calculate_fft(data, tbin)<EOL>T = tbin * len(freq)<EOL>df = freq[<NUM_LIT:1>] - freq[<NUM_LIT:0>]<EOL>if Df is not None:<EOL><INDENT>cut = int(Df / df)<EOL>freq = freq[cut:]<EOL><DEDENT>CRO = np.zeros((N, N, len(freq)), dtype=complex)<EOL>for i in range(N):<EOL><INDENT>for j in range(i + <NUM_LIT:1>):<EOL><INDENT>tempij = DATA[i] * DATA[j].conj()<EOL>if Df is not None:<EOL><INDENT>tempij = movav(tempij, Df, df)[cut:]<EOL><DEDENT>CRO[i, j] = tempij<EOL>CRO[j, i] = CRO[i, j].conj()<EOL><DEDENT><DEDENT>assert(len(freq) == len(CRO[<NUM_LIT:0>, <NUM_LIT:0>]))<EOL>if pointProcess:<EOL><INDENT>CRO *= <NUM_LIT:1.> / T * <NUM_LIT>  <EOL><DEDENT><DEDENT>return freq, CRO<EOL>
Calculate (smoothed) cross spectra of data.
If `units`=True, cross spectra are averaged across units.
Note that averaging is done on cross spectra rather than data.

Cross spectra are normalized by the length T of the time series -> no
scaling with T.

If pointProcess=True, power spectra are normalized by the length T of the
time series.


Parameters
----------
data : numpy.ndarray, 
    1st axis unit, 2nd axis time
tbin : float, 
    binsize in ms
Df : float/None, 
    window width of sliding rectangular filter (smoothing),
    None -> no smoothing
units : bool, 
    average cross spectrum
pointProcess : bool, 
    if set to True, cross spectrum is normalized to signal length T


Returns
-------
freq : tuple
    numpy.ndarray of frequencies
CRO : tuple
    if `units`=True: 1 dim numpy.ndarray; frequency series
    if `units`=False:3 dim numpy.ndarray; 1st axis first unit,
        2nd axis second unit, 3rd axis frequency


Examples
--------    
>>> crossspec(np.array([analog_sig1, analog_sig2]), tbin, Df=Df)
Out[1]: (freq,CRO)
>>> CRO.shape
Out[2]: (2,2,len(analog_sig1))

>>> crossspec(np.array([analog_sig1, analog_sig2]), tbin, Df=Df, units=True)
Out[1]: (freq,CRO)
>>> CRO.shape
Out[2]: (len(analog_sig1),)