Denoising a signal with Pywavelet?

亡梦爱人 提交于 2019-12-24 00:34:09

问题


I need to denoise a signal. I tried to denoise it with savgol_filter but it result in loosing singularities in the signal. In order to denoise and keep singularities i tried to use wavelet transform, wavelet thresholding and inverse wavelet transform but i didn't succeed. Does someone know how to use wavelet denoising ?

here is a text file with signal datas

import numpy as np
from matplotlib import pyplot as plt
from scipy.signal import savgol_filter
import pywt





def readSignal(nomFichier, N):  
    x=np.zeros((N), dtype=float)
    y=np.zeros((N), dtype=float)
    fichier=open(nomFichier,"r")
    for k in range(N):
        l=fichier.readline()  
        l=l.split(' \t\t\t ',1)
        l2=l[1].split(' \n',1)
        l[1]=l2[0]
        x[k]=float(l[0])
        y[k]=float(l[1])
    fichier.close()

    return x, y


nomFichier='front1.txt'
N=1509
x, y=readSignal(nomFichier, N)
#y=savgol_filter(y, 51, 3)
#cA, cD=pywt.dwt(y, 'db1')
#cA=pywt.thresholding.hard(cA, 400)
#y=pywt.idwt(cA,cD,'db1', 'sp1')
plt.plot(x,y)
plt.show(block=False)

来源:https://stackoverflow.com/questions/33636117/denoising-a-signal-with-pywavelet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!