Home | Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]

Using Windows


The smearing or leakage effect mentioned previously is a direct consequence of the definition of the Discrete Fourier Transform and of the fact that a finite time sample of a signal often does not include an integral number of some of the frequency components in the signal. The effect of this truncation can be reduced by increasing the length of the time sequence or by employing a windowing algorithm. IDL's HANNING function computes two windows which are widely used in signal processing: the Hanning window and the Hamming window.

Hanning Window

The Hanning window is defined as:

The resulting vector is multiplied element-by-element with the sampled signal vector before applying the FFT. For example, the following IDL command computes the Hanning window and then applies the FFT function:

v_n = FFT(HANNING(N)*U) 

The power spectrum of the Hanning windowed signal shows the mitigation of the truncation effect (see the figure below).

Enter the following commands at the IDL prompt to create the plot:

; Compute time sequence data: 
@sigprc01 
; F = [0.0, 1.0/(N*delt), ... , 1.0/(2.0*delt)]: 
F = FINDGEN(N/2+1) / (N*delt)	 
v_n = FFT(HANNING(N)*U) 
; Create a log-log plot of power spectrum: 
PLOT, F, ABS(v_n(0:N/2))^2, YTITLE='Power Spectrum', $ 
   /YLOG, YRANGE=[1.0e-8,1.0], YSTYLE=1, YMARGIN=[4,4], $ 
   XTITLE='Frequency in cycles / second', /XLOG, $ 
   XRANGE=[1.0,1.0/(2.0*delt)], XSTYLE=1, $ 
   TITLE='Power Spectrum of u(k) with Hanning Window ' $ 
   +'(solid)!Cand without Window (dashed)' 
; Overplot without window: 
OPLOT, F, ABS((FFT(U))(0:N/2))^2, LINESTYLE=2 

Alternately, you can run the following batch file to create the plot:

@sigprc06 

See Running the Example Code if IDL does not find the batch file.

Hamming Window

The Hamming window is defined as:

The resulting vector is multiplied element-by-element with the sampled signal vector before applying the FFT. For example, the following IDL command computes the Hamming window and then applies the FFT function:

v_m = FFT(HANNING(N, ALPHA=0.56)*U) 

The power spectrum of the Hamming windowed signal shows the mitigation of the truncation effect (see the figure below).

Enter the following commands at the IDL prompt to create the plot:

; Compute time sequence data. 
@sigprc01 
; F = [0.0, 1.0/(N*delt), ... , 1.0/(2.0*delt)]: 
F = FINDGEN(N/2+1) / (N*delt)	 
v_m = FFT(HANNING(N, ALPHA=0.54)*U) 
; Create log-log plot of power spectrum: 
PLOT, F, ABS(v_m(0:N/2))^2, YTITLE='Power Spectrum', $ 
   /YLOG, YRANGE=[1.0e-8,1.0], YSTYLE=1, YMARGIN=[4,4], $ 
   XTITLE='Frequency in cycles / second', $ 
   /XLOG, XRANGE=[1.0,1.0/(2.0*delt)], XSTYLE=1, $ 
   TITLE='Power Spectrum of u(k) with Hamming Window' 
   +'!C(solid) and without Window (dashed)' 
; Overplot without window: 
OPLOT, F, ABS((FFT(U))(0:N/2))^2, LINESTYLE=2 

Alternately, you can run the following batch file to create the plot:

@sigprc07 

See Running the Example Code if IDL does not find the batch file.


Home | Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]