def from_timeseries(ts1, ts2, stride, fftlength=None, overlap=None,<EOL>window=None, nproc=<NUM_LIT:1>, **kwargs):
<EOL>if fftlength is None:<EOL><INDENT>fftlength = stride / <NUM_LIT><EOL><DEDENT>nsteps = int(ts1.size // (stride * ts1.sample_rate.value))<EOL>nproc = min(nsteps, nproc)<EOL>if nsteps == <NUM_LIT:0> or nproc == <NUM_LIT:1>:<EOL><INDENT>return _from_timeseries(ts1, ts2, stride, fftlength=fftlength,<EOL>overlap=overlap, window=window, **kwargs)<EOL><DEDENT>def _specgram(queue_, tsa, tsb):<EOL><INDENT>try:<EOL><INDENT>queue_.put(_from_timeseries(tsa, tsb, stride, fftlength=fftlength,<EOL>overlap=overlap, window=window,<EOL>**kwargs))<EOL><DEDENT>except Exception as exc:  <EOL><INDENT>queue_.put(exc)<EOL><DEDENT><DEDENT>stepperproc = int(ceil(nsteps / nproc))<EOL>nsamp = [stepperproc * ts.sample_rate.value * stride for ts in (ts1, ts2)]<EOL>queue = ProcessQueue(nproc)<EOL>processlist = []<EOL>for i in range(nproc):<EOL><INDENT>process = Process(target=_specgram,<EOL>args=(queue, ts1[i * nsamp[<NUM_LIT:0>]:(i + <NUM_LIT:1>) * nsamp[<NUM_LIT:0>]],<EOL>ts2[i * nsamp[<NUM_LIT:1>]:(i + <NUM_LIT:1>) * nsamp[<NUM_LIT:1>]]))<EOL>process.daemon = True<EOL>processlist.append(process)<EOL>process.start()<EOL>if ((i + <NUM_LIT:1>) * nsamp[<NUM_LIT:0>]) >= ts1.size:<EOL><INDENT>break<EOL><DEDENT><DEDENT>data = []<EOL>for process in processlist:<EOL><INDENT>result = queue.get()<EOL>if isinstance(result, Exception):<EOL><INDENT>raise result<EOL><DEDENT>else:<EOL><INDENT>data.append(result)<EOL><DEDENT><DEDENT>for process in processlist:<EOL><INDENT>process.join()<EOL><DEDENT>out = SpectrogramList(*data)<EOL>out.sort(key=lambda spec: spec.epoch.gps)<EOL>return out.join()<EOL>
Calculate the coherence `Spectrogram` between two `TimeSeries`.

    Parameters
    ----------
    timeseries : :class:`~gwpy.timeseries.TimeSeries`
        input time-series to process.
    stride : `float`
        number of seconds in single PSD (column of spectrogram).
    fftlength : `float`
        number of seconds in single FFT.
    overlap : `int`, optiona, default: fftlength
        number of seconds of overlap between FFTs, defaults to no overlap
    window : `timeseries.window.Window`, optional, default: `None`
        window function to apply to timeseries prior to FFT.
    nproc : `int`, default: ``1``
        maximum number of independent frame reading processes, default
        is set to single-process file reading.

    Returns
    -------
    spectrogram : :class:`~gwpy.spectrogram.Spectrogram`
        time-frequency power spectrogram as generated from the
        input time-series.