def welch(timeseries, segmentlength, noverlap=None, scheme=None, **kwargs):
from pycbc.psd import welch as pycbc_welch<EOL>kwargs.setdefault('<STR_LIT>', '<STR_LIT>')<EOL>if scheme is None:<EOL><INDENT>scheme = null_context()<EOL><DEDENT>with scheme:<EOL><INDENT>pycbc_fseries = pycbc_welch(timeseries.to_pycbc(copy=False),<EOL>seg_len=segmentlength,<EOL>seg_stride=segmentlength-noverlap,<EOL>**kwargs)<EOL><DEDENT>fseries = FrequencySeries.from_pycbc(pycbc_fseries, copy=False)<EOL>fseries.name = timeseries.name<EOL>fseries.override_unit(scale_timeseries_unit(<EOL>timeseries.unit, scaling='<STR_LIT>'))<EOL>return fseries<EOL>
Calculate a PSD using Welch's method with a mean average

    Parameters
    ----------
    timeseries : `~gwpy.timeseries.TimeSeries`
        input `TimeSeries` data.

    segmentlength : `int`
        number of samples in single average.

    noverlap : `int`
        number of samples to overlap between segments, defaults to 50%.

    scheme : `pycbc.scheme.Scheme`, optional
        processing scheme in which to execute FFT, default: `None`

    **kwargs
        other keyword arguments to pass to :func:`pycbc.psd.welch`

    Returns
    -------
    spectrum : `~gwpy.frequencyseries.FrequencySeries`
        average power `FrequencySeries`

    See also
    --------
    pycbc.psd.welch