PyWavelets / pywt

PyWavelets - Wavelet Transforms in Python
http://pywavelets.readthedocs.org
MIT License
2.04k stars 470 forks source link

Omitting detail signals won't produce same result as approximate signal #594

Open fozba opened 3 years ago

fozba commented 3 years ago

Hello everyone. My knowledge about wavelets is limited (I am a beginner). When I try to omit the detail signals and reconstruct the signal only with the approximate signal, I don't obtain the same signal with approximate signal. Here is the code which will provide a much better explanation of the situation:

coeffs = pywt.wavedec(pressure, 'db1', level=5)
for idx in range(2, len(coeffs)):
    coeffs[idx]= np.zeros(len(coeffs[idx]))
y = pywt.waverec(coeffs, 'db1')

After this, plotting just the approximate signal and the reconstructed signal by setting detail signals to zero:

plt.plot(coeffs[0])
plt.plot(time, y)

Yields these two plots respectively: approx omitteddetails

As you can see, reconstructed signal is not "smooth" as the approximate signal itself. Is there a way to omit the detail signals and just keep the "smooth" approximate signal? I put this question here because I believe this feature is not supposed to work like this.