def coherence(self, other, fftlength=None, overlap=None,<EOL>window='<STR_LIT>', **kwargs):
from matplotlib import mlab<EOL>from ..frequencyseries import FrequencySeries<EOL>if self.sample_rate.to('<STR_LIT>') != other.sample_rate.to('<STR_LIT>'):<EOL><INDENT>sampling = min(self.sample_rate.value, other.sample_rate.value)<EOL>if self.sample_rate.value == sampling:<EOL><INDENT>other = other.resample(sampling)<EOL>self_ = self<EOL><DEDENT>else:<EOL><INDENT>self_ = self.resample(sampling)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>sampling = self.sample_rate.value<EOL>self_ = self<EOL><DEDENT>if overlap is None:<EOL><INDENT>overlap = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>overlap = int((overlap * self_.sample_rate).decompose().value)<EOL><DEDENT>if fftlength is None:<EOL><INDENT>fftlength = int(self_.size/<NUM_LIT> + overlap/<NUM_LIT>)<EOL><DEDENT>else:<EOL><INDENT>fftlength = int((fftlength * self_.sample_rate).decompose().value)<EOL><DEDENT>if window is not None:<EOL><INDENT>kwargs['<STR_LIT>'] = signal.get_window(window, fftlength)<EOL><DEDENT>coh, freqs = mlab.cohere(self_.value, other.value, NFFT=fftlength,<EOL>Fs=sampling, noverlap=overlap, **kwargs)<EOL>out = coh.view(FrequencySeries)<EOL>out.xindex = freqs<EOL>out.epoch = self.epoch<EOL>out.name = '<STR_LIT>' % (self.name, other.name)<EOL>out.unit = '<STR_LIT>'<EOL>return out<EOL>
Calculate the frequency-coherence between this `TimeSeries`
        and another.

        Parameters
        ----------
        other : `TimeSeries`
            `TimeSeries` signal to calculate coherence with

        fftlength : `float`, optional
            number of seconds in single FFT, defaults to a single FFT
            covering the full duration

        overlap : `float`, optional
            number of seconds of overlap between FFTs, defaults to the
            recommended overlap for the given window (if given), or 0

        window : `str`, `numpy.ndarray`, optional
            window function to apply to timeseries prior to FFT,
            see :func:`scipy.signal.get_window` for details on acceptable
            formats

        **kwargs
            any other keyword arguments accepted by
            :func:`matplotlib.mlab.cohere` except ``NFFT``, ``window``,
            and ``noverlap`` which are superceded by the above keyword
            arguments

        Returns
        -------
        coherence : `~gwpy.frequencyseries.FrequencySeries`
            the coherence `FrequencySeries` of this `TimeSeries`
            with the other

        Notes
        -----
        If `self` and `other` have difference
        :attr:`TimeSeries.sample_rate` values, the higher sampled
        `TimeSeries` will be down-sampled to match the lower.

        See Also
        --------
        :func:`matplotlib.mlab.cohere`
            for details of the coherence calculator