I'm looking for a way to partially reconstruct branches of a wavelet decomposition, such that the sum would recreate the original signal. This could be achieved in MATLAB using:
DATA = [0,1,2,3,4,5,6,7,8,9] N_LEVELS = 2; WAVELET_NAME = 'db4'; [C,L] = wavedec(DATA, N_LEVELS, WAVELET_NAME); A2 = wrcoef('a', C, L, WAVELET_NAME, 2); D2 = wrcoef('d', C, L, WAVELET_NAME, 2); D1 = wrcoef('d', C, L, WAVELET_NAME, 1); A2+D2+D1 ans = 0.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000
I'd like to achieve the same using
pywt, but I'm not sure how to go about this.
pywt.waverec function creates a full reconstruction, but doesn't have a level parameter for partial reconstruction.
pywt.upcoef function does what I need for a single level but I'm not sure how to expand this for multiple levels:
>>> import pywt >>> data = [1,2,3,4,5,6] >>> (cA, cD) = pywt.dwt(data, 'db2', 'smooth') >>> n = len(data) >>> pywt.upcoef('a', cA, 'db2', take=n) + pywt.upcoef('d', cD, 'db2', take=n) array([ 1., 2., 3., 4., 5., 6.])