A lightweight, fully invertible wavelet transform toolkit for Python — implement time-frequency filterbanks, run forward/inverse transforms, and visualize scalograms with ease.
- Abstract FilterBank base class with pluggable implementations:
LinearFilterBank(linear-scale center frequencies)DyadicFilterBank(dyadic/power-of-two scales)
- FFT-based forward and inverse transforms with overlap-add handling
- frame operator normalization built in to assist the dual-frame inverse
- Scalogram plotting (log-power over time–frequency)
- Four canonical mother wavelets:
Morlet,Cauchy,MexicanHat,DoG
- Pure Python, minimal dependencies (
numpy,scipy,matplotlib)
Install directly from GitHub (no PyPI publish required):
pip install git+https://github.com/aphoffmann/invertiblewavelets.gitimport numpy as np
import matplotlib.pyplot as plt
from invertiblewavelets import LinearFilterBank, DyadicFilterBank, Transform, Morlet
# 1. Create a test signal
fs = 1000 # sampling rate [Hz]
N = 10_000
t = np.arange(N)/fs
data = np.sin(2*np.pi*100*t)
# 2. Create a Filterbank
fb = LinearFilterBank(
wavelet=Morlet(fc=1, fb=100),
fs=fs,
N=N,
b = 1/10,
real=False
)
fb_dyadic = DyadicFilterBank(
wavelet=Morlet(fc=1, fb=100),
fs=fs,
N = N,
s_max = 1/10,
real=False
)
# 3. Build the Transform with the filterbank
xfm = Transform(fb.Wfreq)
# 4. Forward
xfm.forward(data, mode='full')
# 5. Plot scalogram
xfm.scalogram(coeffs, title="Demo Scalogram")
plt.show()
# 6. Inverse
reconstructed = xfm.inverse(coeffs, mode='full', Lx = N)
# 7. Print RMSE
print(np.sqrt(np.mean((data-reconstructed)**2)))