def _from_timeseries(ts1, ts2, stride, fftlength=None, overlap=None,<EOL>window=None, **kwargs):
<EOL>if ts1.sample_rate.to('<STR_LIT>') != ts2.sample_rate.to('<STR_LIT>'):<EOL><INDENT>sampling = min(ts1.sample_rate.value, ts2.sample_rate.value)<EOL>if ts1.sample_rate.value == sampling:<EOL><INDENT>ts2 = ts2.resample(sampling)<EOL><DEDENT>else:<EOL><INDENT>ts1 = ts1.resample(sampling)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>sampling = ts1.sample_rate.value<EOL><DEDENT>if fftlength is None:<EOL><INDENT>fftlength = stride<EOL><DEDENT>if overlap is None:<EOL><INDENT>overlap = <NUM_LIT:0><EOL><DEDENT>nstride = int(stride * sampling)<EOL>nsteps = int(ts1.size // nstride)<EOL>nfreqs = int(fftlength * sampling // <NUM_LIT:2> + <NUM_LIT:1>)<EOL>out = Spectrogram(zeros((nsteps, nfreqs)), epoch=ts1.epoch, dt=stride,<EOL>f0=<NUM_LIT:0>, df=<NUM_LIT:1>/fftlength, copy=True, unit='<STR_LIT>')<EOL>if not nsteps:<EOL><INDENT>return out<EOL><DEDENT>for step in range(nsteps):<EOL><INDENT>idx = nstride * step<EOL>idx_end = idx + nstride<EOL>stepseries1 = ts1[idx:idx_end]<EOL>stepseries2 = ts2[idx:idx_end]<EOL>stepcoh = stepseries1.coherence(stepseries2, fftlength=fftlength,<EOL>overlap=overlap, window=window,<EOL>**kwargs)<EOL>out.value[step] = stepcoh.value<EOL><DEDENT>return out<EOL>
Generate a time-frequency coherence
    :class:`~gwpy.spectrogram.Spectrogram` from a pair of
    :class:`~gwpy.timeseries.TimeSeries`.

    For each `stride`, a PSD :class:`~gwpy.frequencyseries.FrequencySeries`
    is generated, with all resulting spectra stacked in time and returned.