Sie sind auf Seite 1von 4

19.02.

2012

Displa ing FFT Results

Using IDL: Signal Processing

Displa ing FFT Results


Depending on the application, there are many ways to display spectral data, the result of the (forward) FFT function. Real and Imaginar Components The most direct way is to plot the real and imaginary parts of the spectrum as a function of frequency index or as a function of the corresponding frequencies. The following figure displays the real and imaginary parts of the spectrum v(m) of the sampled signal u(k ) for frequencies from (N/2 1)/(N * ) to (N/2)/(N * ) cycles per second. Figure 6-2: Real and Imaginar Parts of the Sample Signal Figure 6-2: Real and Imaginary Parts of the Sample Signal

E ample Code Type @ i p c 3at the IDL prompt to run the batch file that creates this display. The source code is sgr0 located in s g r 0 , in the e a p e / o / i n ldirectory. See Running the Example Code if IDL ipc3 mlsdcsga does not find the batch file.

IDL's FFT function always returns a single- or double-precision complex array with the same dimensions as the input argument. In the case of a forward FFT performed on a one-dimensional vector of N real values, the result is an N-element vector of complex quantities, which takes 2N real values to represent. It would seem that there is twice as much information in the spectral data as there is in the time sequence data. This is not
idlastro.gsfc.nasa.gov/idl_html_help/Displa ing_FFT_Results.html 1/4

19.02.2012

Displa ing FFT Results

the case. For a real valued time sequence, half of the information in the frequency sequence is redundant. Specifically:
;1rdnatvle eudn au: IAIAYv0)=00 MGNR(() . ;1rdnatvle eudn au: IAIAYvN2)=00 MGNR((/) .

and
;frm1t N21 N2rdnatvle: o = o /-, - eudn aus vNm =CN(() (-) OJvm)

so that exactly N of the single- or double-precision values used to represent the frequency spectrum are redundant. This redundancy is evident in the previous figure. Notice that the real part of the spectrum is an even function (symmetric about zero), and the imaginary part of the spectrum is an odd function (antisymmetric about zero). This is always the case for the spectra of real-valued time sequences. Because of the redundancy in such spectra, it is common to display only half of the spectrum of a real time sequence. That is, only the spectral values with frequency indices from 0 to N/2, which correspond to frequencies from 0 to 1/(2 * ), the Nyquist frequency. This vector of positive frequencies is generated in IDL with the following command:
;f=[.,10(*et,..,10(.*et] 00 ./Ndl) . ./20dl) F=FNGNN21/Ndl) IDE(/+)(*et

Magnitude and Phase It is also common to display the magnitude and phase of the spectrum, which have physical significance, as opposed to the real and imaginary parts of the spectrum, which do not have physical significance. Since there is a one-to-one correspondence between a complex number and its magnitude and phase, no information is lost in the transformation from a complex spectrum to its magnitude and phase. In IDL, the magnitude is easily determined with the absolute value (ABS) function, and the phase with the arc-tangent (ATAN) function. By one widely used convention, the magnitude of the spectrum is plotted in decibels (dB) and the phase is plotted in degrees, against frequency on a logarithmic scale. The magnitude and phase of our sample signal are plotted in the same data space, shown in the figure below. Fgr 63 Mgiue(oi Ln)adPae(ahdLn) iue -: antd Sld Ie n hs Dse ie o teSml Sga f h ape inl Figure 6-3: Magnitude (Solid LIne) and Phase (Dashed Line) of the Sample Signal

idlastro.gsfc.nasa.gov/idl_html_help/Displa ing_FFT_Results.html

2/4

19.02.2012

Displa ing FFT Results

E ample Code Type @ i p c 4at the IDL prompt to run the batch file that creates this display. The source code is sgr0 located in s g r 0 , in the e a p e / o / i n ldirectory. See Running the Example Code if IDL ipc4 mlsdcsga does not find the batch file.

Using a logarithmic scale for the frequency axis has the advantage of spreading out the lower frequencies, while higher frequencies are crowded together. Note that the spectrum at zero frequency (DC) is lost completely on a semi-logarithmic plot. The previous figure shows the strong frequency components at 2.8, 6.25, and 11.0 cycles/second as peaks in the magnitude plot, and as discontinuities in the phase plot. The magnitude peak at 6.25 cycles/second is a narrow spike, as would be expected from the pure sine wave component at that frequency in the time data sequence. The peaks at 2.8 and 11.0 cycles/second are more spread out, due to an effect known as smearing or leakage. This effect is a direct result of the definition of the DFT and is not due to any inaccuracy in the FFT. Smearing is reduced by increasing the length of the time sequence, or by choosing a sample size which includes an integral number of cycles of the frequency component of interest. There are an integral number of cycles of the 6.25 cycles/second component in the time sequence used for this example, which is why the peak at that frequency is sharper. The apparent discontinuity in the phase plot at around 7.45 cycles/second is an anomaly known as phase wrapping. It is a result of resolving the phase from the real and imaginary parts of the spectrum with the arctangent function (ATAN), which returns principal values between 180 and +180 degrees. Po er Spectrum Finally, for many applications, the phase information is not useful. For these, it is often customary to plot the power spectrum, which is the square of the magnitude of the complex spectrum. The resulting plot is shown in the figure below. Fgr 64 P e Setu o teSml Sga iue -: o r pcrm f h ape inl Figure 6-4: Power Spectrum of the Sample Signal

E ample Code Type @ i p c 5at the IDL prompt to run the batch file that creates this display. The source code is sgr0 located in s g r 0 , in the e a p e / o / i n ldirectory. See Running the Example Code if IDL ipc5 mlsdcsga does not find the batch file.
idlastro.gsfc.nasa.gov/idl_html_help/Displa ing_FFT_Results.html 3/4

19.02.2012

Displa ing FFT Results

ILOln Hl (ac 0,20) D nie ep Mrh 6 07

idlastro.gsfc.nasa.gov/idl_html_help/Displa ing_FFT_Results.html

4/4

Das könnte Ihnen auch gefallen