Using IDL: Signal Processing 
Depending on the application, there are many ways to display spectral data, the result of the (forward) FFT function.
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 * d) to (N/2)/(N * d) cycles per second.

Example Code Type @sigprc03 at the IDL prompt to run the batch file that creates this display. The source code is located in sigprc03 , in the examples/doc/signal directory. See Running the Example Code if IDL does not find the batch file. 
IDL's FFT function always returns a single or doubleprecision complex array with the same dimensions as the input argument. In the case of a forward FFT performed on a onedimensional vector of N real values, the result is an Nelement 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 the case. For a real valued time sequence, half of the information in the frequency sequence is redundant. Specifically:
; 1 redundant value: IMAGINARY(v(0)) = 0.0 ; 1 redundant value: IMAGINARY(v(N/2)) = 0.0
and
; for m=1 to N/21, N2 redundant values: v(Nm) = CONJ(v(m))
so that exactly N of the single or doubleprecision 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 realvalued 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 * d), the Nyquist frequency. This vector of positive frequencies is generated in IDL with the following command:
; f = [0.0, 1.0/(N*delt), ... , 1.0/(2.0*delt)] F = FINDGEN(N/2+1)/(N*delt)
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 onetoone 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 arctangent (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.

Example Code Type @sigprc04 at the IDL prompt to run the batch file that creates this display. The source code is located in sigprc04 , in the examples/doc/signal directory. See Running the Example Code if IDL 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 semilogarithmic 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.
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.
Example Code Type @sigprc05 at the IDL prompt to run the batch file that creates this display. The source code is located in sigprc05 , in the examples/doc/signal directory. See Running the Example Code if IDL does not find the batch file. 
IDL Online Help (June 16, 2005)