def average_fft(self, fftlength=None, overlap=<NUM_LIT:0>, window=None):
from gwpy.spectrogram import Spectrogram<EOL>if fftlength is None:<EOL><INDENT>fftlength = self.duration<EOL><DEDENT>if isinstance(fftlength, units.Quantity):<EOL><INDENT>fftlength = fftlength.value<EOL><DEDENT>nfft = int((fftlength * self.sample_rate).decompose().value)<EOL>noverlap = int((overlap * self.sample_rate).decompose().value)<EOL>navg = divmod(self.size-noverlap, (nfft-noverlap))[<NUM_LIT:0>]<EOL>if window is None:<EOL><INDENT>window = '<STR_LIT>'<EOL><DEDENT>if isinstance(window, (str, tuple)):<EOL><INDENT>win = signal.get_window(window, nfft)<EOL><DEDENT>else:<EOL><INDENT>win = numpy.asarray(window)<EOL>if len(win.shape) != <NUM_LIT:1>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>elif win.shape[<NUM_LIT:0>] != nfft:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>win = win.astype(self.dtype)<EOL>scaling = <NUM_LIT:1.> / numpy.absolute(win).mean()<EOL>if nfft % <NUM_LIT:2>:<EOL><INDENT>nfreqs = (nfft + <NUM_LIT:1>) // <NUM_LIT:2><EOL><DEDENT>else:<EOL><INDENT>nfreqs = nfft // <NUM_LIT:2> + <NUM_LIT:1><EOL><DEDENT>ffts = Spectrogram(numpy.zeros((navg, nfreqs), dtype=numpy.complex),<EOL>channel=self.channel, epoch=self.epoch, f0=<NUM_LIT:0>,<EOL>df=<NUM_LIT:1> / fftlength, dt=<NUM_LIT:1>, copy=True)<EOL>idx = <NUM_LIT:0><EOL>for i in range(navg):<EOL><INDENT>idx_end = idx + nfft<EOL>if idx_end > self.size:<EOL><INDENT>continue<EOL><DEDENT>stepseries = self[idx:idx_end].detrend() * win<EOL>fft_ = stepseries.fft(nfft=nfft) * scaling<EOL>ffts.value[i, :] = fft_.value<EOL>idx += (nfft - noverlap)<EOL><DEDENT>mean = ffts.mean(<NUM_LIT:0>)<EOL>mean.name = self.name<EOL>mean.epoch = self.epoch<EOL>mean.channel = self.channel<EOL>return mean<EOL>
Compute the averaged one-dimensional DFT of this `TimeSeries`.

        This method computes a number of FFTs of duration ``fftlength``
        and ``overlap`` (both given in seconds), and returns the mean
        average. This method is analogous to the Welch average method
        for power spectra.

        Parameters
        ----------
        fftlength : `float`
            number of seconds in single FFT, default, use
            whole `TimeSeries`

        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

        Returns
        -------
        out : complex-valued `~gwpy.frequencyseries.FrequencySeries`
            the transformed output, with populated frequencies array
            metadata

        See Also
        --------
        :mod:`scipy.fftpack` for the definition of the DFT and conventions
        used.