Frequency Domain Filtering

Frequency domain filtering is another (perhaps better) way to eliminate noise. Noise is unwanted high-frequency content in sampled data. Applying a lowpass filter to the noisy data allows low-frequency components to remain unchanged while high frequencies are smoothed or attenuated. Construct a filter function by entering the following step-by-step commands:

  1. Create a floating point array using FINDGEN which sets each element to the value of its subscript and stores it in the variable Y by entering:
  2. y=[FINDGEN(100),FINDGEN(100)-100]

  3. Next, make the last 99 elements of Y a mirror image of the first 99 elements:
  4. y[101:199]=REVERSE(y[0:98])

  5. Now, create a variable filter to hold the filter function based on Y:
    gssig05.gif
  6. filter=1.0/(1+(y/40)^10)

  7. Finally, plot:
  8. IPLOT, filter

    The next step applies the filter to the NOISY data. To filter data in the frequency domain, we multiply the Fast Fourier transform (FFT) of the data by the frequency response of a filter and then apply an inverse Fourier transform to return the data to the spatial domain.

  9. Now we can use a lowpass filter on the NOISY data set and store the filtered data in the variable lowpass by entering:
  10. lowpass = FFT(FFT(noisy,1)*filter,-1)

  11. Then plot the filtered data:
    gssig06.gif
  12. IPLOT, lowpass

      
      
      
      
      
      
      
      
      
      
      
    

    Note
    Your plots may look slightly different due to the random number generator.

The same filter function can be used as a high-pass filter (allowing only the high frequency or noise components through).

  1. To accomplish this, enter:
  2. highpass = FFT(FFT(noisy,1)*(1.0-filter),-1)

  3. Then plot the result:
    gssig07.gif
  4. IPLOT, highpass