I want to extract the higher frequency component from a signal composed of different frequency components by using the pywt package in python. How do I do this correctly?
In order to extract the high frequency components from a signal, I tried to use the pywt.dwt functionality for discrete wavelet transform. My code and explanations of what it does can be found here: https://github.com/EstebanHess/WaveletTransform_with_pywt/blob/master/Extract_High_Freqs.ipynb
Since I did not know how to directly reconstruct the higher frequency components of a signal I reconstructed them indirectly: I extracted the lower frequencies and subtracted them from the original signal in order to obtain the higher frequencies. However, the reconstructed lower frequency components are longer than the original signal and need to be sliced in order to have the same length before they can be subtracted from the original signal. Correct slicing can be obtained by trial and error or by visual inspection in the case of a simple illustrative example as in my notebook. But how would I know how to select the correct part of the reconstructed low frequency component in the case of real data? Or is it possible to directly reconstruct the higher frequency component? If so, how?