Spectrum Analysis Tools - contains tools to estimate Power Spectral Densities using methods based on Fourier transform, Parametric methods or eigenvalues analysis
npx @tessl/cli install tessl/pypi-spectrum@0.9.0A comprehensive Python library for spectral analysis providing various methods for power spectral density (PSD) estimation, parametric spectral analysis, and signal processing utilities. The package includes 174+ functions and 35+ classes across 24+ modules, covering parametric methods, eigenvalue-based methods, non-parametric methods, and extensive signal processing tools.
pip install spectrumimport spectrumCommon patterns for specific functionality:
from spectrum import *
# or
from spectrum import pburg, pyule, pmusic, speriodogramimport spectrum
import numpy as np
# Generate test signal
N = 1024
noise = np.random.randn(N)
signal = np.sin(2 * np.pi * 0.1 * np.arange(N)) + 0.1 * noise
# Parametric PSD estimation using Burg method
p = spectrum.pburg(signal, order=15)
p.plot()
# Non-parametric PSD estimation using periodogram
psd = spectrum.speriodogram(signal, NFFT=512)
# Eigenvalue-based method (MUSIC)
music = spectrum.pmusic(signal, IP=15, NSIG=2)
music.plot()
# Auto-regressive parameter estimation
ar_params, noise_var, _ = spectrum.aryule(signal, order=10)
# Window function generation
window = spectrum.create_window(64, 'hamming')The spectrum package follows a modular design with several key architectural patterns:
ParametricSpectrum for AR, ARMA, and eigenvalue methodsFourierSpectrum for periodogram and correlogram methodsThis design provides consistent interfaces across different estimation methods while maintaining flexibility for specialized applications in spectral analysis, system identification, and digital signal processing.
Auto-regressive parameter estimation and PSD computation using various algorithms including Yule-Walker, Burg, covariance, and modified covariance methods.
def aryule(X, order, norm='biased', allow_singularity=True): ...
def arburg(X, order, criteria=None): ...
def arcovar(x, order): ...
def modcovar(x, order): ...
class pyule(data, order, NFFT=None, sampling=1., scale_by_freq=False): ...
class pburg(data, order, criteria=None, NFFT=None, sampling=1., scale_by_freq=False): ...
class pcovar(data, order, NFFT=None, sampling=1., scale_by_freq=False): ...
class pmodcovar(data, order, NFFT=None, sampling=1., scale_by_freq=False): ...Auto-regressive moving average parameter estimation and PSD computation for combined AR-MA models and pure MA models.
def arma_estimate(X, P, Q, lag): ...
def ma(X, Q, M): ...
def arma2psd(A=None, B=None, rho=1., T=1., NFFT=4096, sides='default', norm=False): ...
class parma(data, P, Q, lag, NFFT=None, sampling=1., scale_by_freq=False): ...
class pma(data, Q, M, NFFT=None, sampling=1., scale_by_freq=False): ...High-resolution spectral estimation using eigenvalue decomposition including MUSIC, eigenvector, and minimum variance methods.
def music(X, IP, NSIG=None, NFFT=4096, threshold=None, criteria='aic', verbose=False): ...
def ev(X, IP, NSIG=None, NFFT=4096, threshold=None, criteria='aic', verbose=False): ...
def minvar(X, order, sampling=1., NFFT=4096): ...
class pmusic(data, IP, NSIG=None, NFFT=None, sampling=1., scale_by_freq=False): ...
class pev(data, IP, NSIG=None, NFFT=None, sampling=1., scale_by_freq=False): ...
class pminvar(data, order, NFFT=None, sampling=1., scale_by_freq=False): ...Classical spectral estimation techniques including periodogram, Welch's method, correlogram, and multi-taper methods.
def speriodogram(x, NFFT=None, detrend=True, sampling=1., scale_by_freq=True, window='hamming', axis=0): ...
def WelchPeriodogram(data, NFFT=None, sampling=1., **kargs): ...
def pmtm(x, NW=None, k=None, NFFT=None, e=None, v=None, method="adapt", show=False): ...
class Periodogram(data, sampling=1., NFFT=None, window='hamming', detrend='mean', scale_by_freq=True): ...
class pcorrelogram(data, sampling=1., lag=-1, window='hamming', NFFT=None, scale_by_freq=True, detrend=None): ...
class MultiTapering(Spectrum): ...Linear prediction analysis and conversion between different parameter representations (AR coefficients, reflection coefficients, line spectral frequencies).
def LEVINSON(r, order=None, allow_singularity=False): ...
def lpc(x, N=None): ...
def ac2poly(data): ...
def poly2ac(poly, efinal): ...
def rc2poly(kr, r0=None): ...Comprehensive collection of window functions for signal processing applications with visualization and analysis tools.
def create_window(N, name=None, **kargs): ...
def enbw(data): ...
class Window(N, name=None, **kargs): ...
def window_hamming(N): ...
def window_hanning(N): ...
def window_kaiser(N, beta=8.6): ...
def window_blackman(N, alpha=0.16): ...
def window_gaussian(N, alpha=2.5): ...Correlation analysis, signal generation, and essential signal processing utilities for spectral analysis applications.
def CORRELATION(x, y=None, maxlags=None, norm='unbiased'): ...
def xcorr(x, y=None, maxlags=None, norm='biased'): ...
def chirp(t, f0=0., t1=1., f1=100., form='linear', phase=0): ...
def morlet(lb, ub, n): ...
def pow2db(x): ...
def db2pow(xdb): ...
def nextpow2(x): ...Correlation and Signal Processing
Linear algebra utilities, model selection criteria, transfer function analysis, and mathematical tools supporting spectral analysis.
def CHOLESKY(A, B, method='scipy'): ...
def pascal(n): ...
def corrmtx(x_input, m, method='autocorrelation'): ...
def AIC(N, rho, k): ...
def MDL(N, rho, k): ...
def FPE(N, rho, k=None): ...
class Criteria(name, N): ...
def tf2zp(b, a): ...
def zp2tf(z, p, k): ...