Regarding Custom Wavelets and Wavelet.wavefun()

96 views
Skip to first unread message

Susmit Agrawal

unread,
Mar 4, 2021, 1:38:20 AM3/4/21
to PyWavelets
I have been playing around with the library, and I had a few questions regarding the `wavefun` function:

1. What exactly is the "levels" parameter to the function?

2. In one of my tests, I used the following code:
```
import matplotlib.pyplot as plt
import pywt
import numpy as np


fig = plt.figure()
fig.subplots_adjust(hspace=0.2, wspace=0.2, bottom=.02, left=.06,
right=.97, top=.94)

dec_lo, dec_hi, rec_lo, rec_hi = np.random.normal(0.0, 0.5, (4, 2)).tolist()
print(dec_lo, ' ', dec_hi, ' ', rec_lo, ' ', rec_hi)
filter_bank = [dec_lo, dec_hi, rec_lo, rec_hi]
wavelet = pywt.Wavelet(name="myWavelet", filter_bank=filter_bank)

phi, psi, _, _, x = wavelet.wavefun(level=5)

color = 'red'
ax = fig.add_subplot(1, 2, 1)
ax.set_title(wavelet.name + " phi")
ax.plot(x, phi, color)
ax.set_xlim(min(x), max(x))

ax = fig.add_subplot(1, 2, 2)
ax.set_title(wavelet.name + " psi")
ax.plot(x, psi, color)
ax.set_xlim(min(x), max(x))

plt.show()

```

Basically, I plot for random values of the lowpass and highpass filter coefficients. One of the runs gave me the plot below:
myplot.png
My question is, are the functions in the plot actually Scaling and Wavelet functions, or just random functions generated by `wavefun()`?
Reply all
Reply to author
Forward
0 new messages