code: def welch(timeseries, segmentlength, noverlap=None, **kwargs):
      
      # 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,
      )
docs: Calculate a PSD of this `TimeSeries` using Welch's method.