I'm trying to work out the octave/voice range I should be passing when using the pyWavelet continuous wavelet transform. For this, as a play, I'm reproducing some of the pyWavelet examples from the documentation. I'm using a Ricker wavelet instead of the Gaussian's first derivative. But I don't think it makes any difference in my findings. The example in the first from the "Continuous Wavelet Transform" chapter
import pywt
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(512)
y = np.sin(2*np.pi*x/32)
coef, freqs=pywt.cwt(y,np.arange(1,129),'gaus1')
plt.matshow(coef)
plt.show()
In one case, I turn y into a dirac function where y[256]=1, the rest of the array being 0. When I look at the wavelet coefficients for the scales 8/16/32/64, I get the following results and more importantly, I can see a series of spikes which obviously affect my results. Wavelet coefficients for a dirac at scales 8/16/32/64 Wavelet coefficients for the pyWavelet example at scales 8/16/32/64
I guess there might be something I missed.
Is there a way to set the scale correctly or maybe there are some limitations on the input signal? Anyone could explain why I have those stripes?
I can't explain what is wrong with
pywt
or how to use it correctly in this case. Maybe some numerical issues (maybe pywt convert to float32?).However, I managed to get clean signals but with
scipy
, "dirac delta" with ricker wavelets:You may want to write an issue on
pywt
github about this and add comparison with scipy.