Avoid PyWavelets and scipy. ssqueezepy's (disclaimer, am author) scales='auto'
is motivated similar to MATLAB's cwtfilterbank
, and wavelets can be cached, inspected, and reused.
import numpy as np
from ssqueezepy import Wavelet, cwt
from ssqueezepy.utils import make_scales, cwt_scalebounds
from ssqueezepy.visuals import plot, imshow
# configure
signal_length = 4096
wavelet = Wavelet('morlet')
# make scales
min_scale, max_scale = cwt_scalebounds(wavelet, signal_length)
scales = make_scales(signal_length, scaletype='log', nv=8,
min_scale=min_scale, max_scale=max_scale)
# make filterbank
fbank = wavelet(scale=scales)
# take CWT
np.random.seed(0)
x = np.random.randn(signal_length)
Wx, _ = cwt(x, wavelet, scales=scales)
# visualize
plot(fbank.T, show=1, title="CWT filterbank")
imshow(Wx, title="|CWT(x)|", abs=1)