pactools.utils.spectrum.Spectrum

class pactools.utils.spectrum.Spectrum(block_length=1024, fft_length=None, step=None, wfunc=<function hamming>, fs=1.0, donorm=True)[source]

Spectral estimator following Welch’s method

Parameters
block_lengthint

Length of each signal block, on which we estimate the spectrum

fft_lengthint or None

Length of FFT, should be greater or equal to block_length. If None, it is set to block_length

stepint or None

Step between successive blocks If None, it is set to half the block length (i.e. 0.5 overlap)

wfuncfunction

Function used to compute the weitghting window on each block. Examples: np.ones, np.hamming, np.bartlett, np.blackman, …

fsfloat

Sampling frequency

donormboolean

If True, the amplitude is normalized

__init__(self, block_length=1024, fft_length=None, step=None, wfunc=<function hamming at 0x7fd5ecd21d30>, fs=1.0, donorm=True)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(self[, block_length, fft_length, …])

Initialize self.

check_params(self)

main_frequency(self)

Extract the frequency of the maximum in the spectrum

periodogram(self, signals[, hold, mean_psd])

Computes the estimation (in dB) for each epoch in a signal

plot(self[, title, fscale, labels, fig, …])

plots the power spectral density warning: the plot will only appear after plt.show()