def welch(timeseries, segmentlength, noverlap=None, **kwargs):
    """Calculate a PSD of this `TimeSeries` using Welch's method.
    """
    # calculate PSD
    freqs, psd_ = scipy.signal.welch(
        timeseries.value,
        noverlap=noverlap,
        fs=timeseries.sample_rate.decompose().value,
        nperseg=segmentlength,
        **kwargs
    )
    # generate FrequencySeries and return
    unit = scale_timeseries_unit(
        timeseries.unit,
        kwargs.get('scaling', 'density'),
    )
    return FrequencySeries(
        psd_,
        unit=unit,
        frequencies=freqs,
        name=timeseries.name,
        epoch=timeseries.epoch,
        channel=timeseries.channel,
    )
def welch ( timeseries , segmentlength , noverlap = None , ** kwargs ) : freqs , psd_ = scipy . signal . welch ( timeseries . value , noverlap = noverlap , fs = timeseries . sample_rate . decompose ( ) . value , nperseg = segmentlength , ** kwargs ) unit = scale_timeseries_unit ( timeseries . unit , kwargs . get ( 'scaling' , 'density' ) , ) return FrequencySeries ( psd_ , unit = unit , frequencies = freqs , name = timeseries . name , epoch = timeseries . epoch , channel = timeseries . channel , )
Calculate a PSD of this `TimeSeries` using Welch's method.