apollon.signal.spectral module

spectral.py (c) Michael Blaß 2016

Provide easy access to frequency spectra obtained by the DFT.

Classes:
_Spectrum_Base Utility class _Spectrum Representation of a frequency spectrum
Functions:
fft Easy to use discrete fourier transform
class apollon.signal.spectral.Spectrogram(inp: numpy.ndarray, fps: int, window: str, n_perseg: int, hop_size: int, n_fft: int = None)

Bases: object

Compute a spectrogram from an one-dimensional input signal.

abs()

Return the magnitude spectrogram.

bins
centroid(power=True)
d_frq
d_time
extract()
flux(subband=False)
fps
frqs
hop_size
inp_size
n_fft
n_overlap
n_perseg
params()
plot(cmap: str = 'nipy_spectral', log_frq: float = None, low: float = None, high: float = None, figsize: tuple = (14, 6), cbar: bool = True) → tuple

Plot the spectrogram in dB scaling. The 0-frequency component is ommitted in plots.

Parameters:
  • cmap (str) –
  • log_frq (float) – plot it in log domain, centered on log_frq Hz.
  • cbar (bool) –
  • figsize (tuple) –
Returns:

Tuple (fig, ax)

power()

Return the power spectrogram.

shape
times
window
class apollon.signal.spectral.Spectrum(inp: numpy.ndarray, fps: int, n_fft: int = None, window: str = None)

Bases: apollon.signal.spectral._Spectrum_Base

abs()

Return magnitude spectrum.

centroid(power=True)
extract()
params() → dict
phase()

Return phase spectrum.

power()

Retrun power spectrum.

apollon.signal.spectral.fft(sig, window=None, n_fft=None)

Return the Discrete Fourier Transform for real input.

Params:
sig (array-like) Input time domain signal n_fft (int) FFT length window (str) Name of window function
Returns:(ndarray) FFT bins.
Raises:AttributeError
apollon.signal.spectral.stft(inp: numpy.ndarray, fps: int, window: str = 'hanning', n_perseg: int = 512, hop_size: int = None, n_fft: int = None) → apollon.signal.spectral.Spectrogram

Perform Short Time Fourier Transformation of inp

inp is assumed to be an one-dimensional array of real values.

Parameters:
  • inp (ndarray) –
  • fps (int) –
  • window (str) –
  • n_perseg (int) –
  • hop_size (int) –
  • n_fft (int) –
Returns:

(Spectrogram)