pyrfu.pyrf.psd module#

pyrfu.pyrf.psd.psd(inp, n_fft: int = 256, n_overlap: int = 128, window: str = 'hamming', d_flag: str = 'constant', scaling: str = 'density')[source]#

Estimate power spectral density using Welch’s method.

Welch’s method [11] computes an estimate of the power spectral density by dividing the data into overlapping segments, computing a modified periodogram for each segment and averaging the periodograms.

Parameters:
  • inp (xarray.DataArray) – Time series of measurement values.

  • n_fft (int, Optional) – Length of the FFT used, if a zero padded FFT is desired. Default to 256.

  • n_overlap (int, Optional) – Number of points to overlap between segments. Default to 128.

  • window (str, Optional) – Desired window to use. It is passed to get_window to generate the window values, which are DFT-even by default. See “get_window” or a list of windows and required parameters. Default Hanning

  • d_flag (str, Optional) – Specifies how to detrend each segment. It is passed as the “type” argument to the”detrend” function. Default to “constant”.

  • scaling (str, Optional) – Selects between computing the power spectral density (‘density’) where Pxx has units of V**2/Hz and computing the power spectrum (“spectrum”) where “Pxx” has units of V**2, if x is measured in V and “fs” is measured in Hz. Default to ‘density’

Returns:

out – Power spectral density or power spectrum of inp.

Return type:

xarray.DataArray

References

[11]

P. Welch, “The use of the fast Fourier transform for the estimation of power spectra: A method based on time averaging over short, modified periodograms”, IEEE Trans. Audio Electroacoust. vol. 15, pp. 70-73, 1967.