how to make a rolling wavelet across array with axis =1 using pywavelets

133 views Asked by At

Im trying to create a rolling wavelet across a array where the row is the rolling window and i want to threshold it by using the max of the window row, but i cant seem to get the code to work: There seems to be a problem with the rolling threshold as if i use a static threshold it works.. here is the code and the data following . whats am i doing wrong as i spent ages trying to figure it out to no avail.. Can anyone help ?


    def lowpassfilter1(signal, thres = 0.11, wavelet="db2",level =3):
        leng = int((signal.shape[1]))
        thresh = thres * np.nanmax(signal, axis=1)
        coeff = pywt.wavedec(signal, wavelet, mode="per", level=level,axis=1) # ca2,cd2,cd
        coeff[1:] = (pywt.threshold(i, value=thresh, mode="soft" ) for i in coeff[1:])
        reconstructed_signal = pywt.waverec(coeff, wavelet, mode="per",axis=1)
        res = [i[-1] for i in reconstructed_signal]
        return res

[[1.48310006 1.48313999 1.48318005 1.48324001 1.48324001 1.48318005
  1.48313999 1.48310006 1.48310006 1.48313999 1.48318005 1.48324001]
 [1.48313999 1.48310006 1.48313999 1.48318005 1.48318005 1.48313999
  1.48310006 1.48313999 1.48313999 1.48310006 1.48313999 1.48318005]
 [1.48318005 1.48313999 1.48310006 1.48313999 1.48313999 1.48310006
  1.48313999 1.48318005 1.48318005 1.48313999 1.48310006 1.48313999]
0

There are 0 answers