def coherence(freq, power, cross):
N = len(power)<EOL>coh = np.zeros(np.shape(cross))<EOL>for i in range(N):<EOL><INDENT>for j in range(N):<EOL><INDENT>coh[i, j] = cross[i, j] / np.sqrt(power[i] * power[j])<EOL><DEDENT><DEDENT>assert(len(freq) == len(coh[<NUM_LIT:0>, <NUM_LIT:0>]))<EOL>return freq, coh<EOL>
Calculate frequency resolved coherence for given power- and crossspectra.


Parameters
----------
freq : numpy.ndarray
    Frequencies, 1 dim array.
power : numpy.ndarray
    Power spectra, 1st axis units, 2nd axis frequencies.
cross : numpy.ndarray, 
    Cross spectra, 1st axis units, 2nd axis units, 3rd axis frequencies.


Returns
-------
freq: tuple
    1 dim numpy.ndarray of frequencies.
coh: tuple
    ndim 3 numpy.ndarray of coherences, 1st axis units, 2nd axis units,
    3rd axis frequencies.