title: Denoising a signal with Pywavelet?
body: <p>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 ?</p>
  
  <p><a href="https://www.dropbox.com/s/mpmq0w257h5gik9/front1.txt?dl=0" rel="nofollow">here is a text file with signal datas</a></p>
  
  <pre><code>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)
  </code></pre>