FFT Windowing Tutorial
FFT Windowing Tutorial
We need a window for vibration spectrum analysis because Figure 1. This shows a 1,024-point Hanning window applied to 1,024-
point chunk of air handler acceleration.
the beginning does not match the end of the data segment we
are analyzing and because we virtually never have an integer
number of periods of any cyclic information in the signal seg-
ment/chunk. The discrete Fourier transform (DFT) analysis is
really a Fourier series expansion of whatever segment we in-
put. It is considered periodic. Mismatched ends and noninteger
numbers of periods garbles the result. Windows somewhat al-
leviate that garbling but in a complicated way.
Windows are shapes – like a hill, a hump in the center, and
they go to zero at the ends. When you multiply these window
shapes term by term with a segment of data, you force the ends
of the data segment to zero, so at least the ends match the be-
ginning. You cannot really fix the noninteger number of peri-
ods. Figure 1 shows a window application. In Figure 1a we have
a 1,024 value plotted list of acceleration data; in Figure 1b, a
1024 value Hanning window plotted for the same time values.
Figure 1c shows the product of the two. The beginning and ends
certainly match.
I am sure there are more than 100 windows described in the
literature. Figure 2, shows six of them that I happen to use and
will illustrate here: boxcar (or uniform), Hanning, Hamming, Figure 2. Six common window shapes.
Gaussian, Kaiser Bessel, and flat-top (this is very different from
the boxcar or uniform window). Signal analyzers frequently lyzed, which almost never happens without planning. We can
offer five or six to choose from, with variably helpful discus- develop a formula for testing if a sine wave signal component
sions of when to use each. Hanning is the most widely recom- is bin centered as follows. A sine wave is given by Equation 1:
mended. Reference 1 gives 44 and Reference 2 gives eight more;
y = sin 2p ft (1)
these might be the most widely referenced windows papers, but
these authors hadn’t yet heard of the flat-top. Ron Potter 3 gives where f is the frequency in cycles/second (Hz). The period of
about five windows and is famous for an unpublished HP pub- a sine wave P (seconds per cycle) is the reciprocal of the fre-
lication. Potter did have a flat-top in there. Finally, the vener- quency (Equation 2):
able Brüel & Kjær Technical Review published the first fully 1
disclosed flat-top window and a nice version of the Kaiser P= (2)
f
Bessel window.4,5 These two publications are downloadable
from the B&K web site. I read a paper 6 from the 2004 Interna- Since we have to work with digitized data, define:
tional Modal Analysis Conference where the investigator was N = number of samples in data segment being analyzed
working on keeping the side lobes extremely low because of fs = sample rate in samples/second
all the new high-resolution, 24-bit, data-collecting hardware. The time interval between samples h is the reciprocal of the
If you really want to dig into things, Harris7 wrote a difficult sampling rate fs (Equation 3):
64-page article with excellent drawings that I recommend. 1
h= (3)
fs
Defining the Bin-Centered Concept
Non-bin centered or not, an integer number of periods or The signal duration T is given by Equation 4:
cycles in the analyzed data segment is the topic to start with. N
A sine wave component of our signal is bin centered if it has T = Nh = (4)
fs
an integer number of periods in the data segment being ana-
Non-Bin-Centered Effects
Now we are in an excellent position to consider the effects
that those six windows I mentioned help us alleviate (but can-
not really cure) the picket fence and leakage effects of a non-
bin-centered signal on the spectra we compute. In case you are
rusty, I want to review some spectrum fundamentals so you will
know what to expect. I use the acronyms DFT and FFT syn-
onymously. DFT means the discrete Fourier transform, and FFT
means the fast Fourier transform, the calculation procedure
used to calculate the DFT. All signal analyzers and data col-
lectors use an FFT to initially compute and then develope the
spectrum from that result.
The DFT of an N-point signal, sampled at fs gives us a spec-
trum of (N/2 + 1) amplitudes at frequencies from 0 to fs/2. We
frequently call these (N/2 + 1) amplitudes the bin values. The
Df or bin frequency spacing, is 1/T = fs/N. We get a frequency
value starting at f = 0, and values spaced at ∆ f all the way up
to fs/2. There will be N/2 intervals between 0 and fs/2; there-
fore, each interval or space is ∆ f = (fs/2)/(N/2) = fs/N. This is Figure 6. Expanded DFTs, 16.2 Hz, 20% off bin center, six different win-
1/T. The time between samples is 1/fs, and (N)(1/f s) = T. These dows; thin line shows actual tone positioned at 16.2 Hz.
Ak = 2 X k (11a)
Ê Re( X k ) ˆ
j k = tan -1 Á (11b)
Ë - Im( X k ) ˜¯
Ê Re( X k ) ˆ
j k = tan -1 Á (12a)
Ë - Im( X k ) ˜¯
The DFT, which is most economically computed using the
FFT, will compute N Fourier coefficients from a sequence of N
numbers. X0 is the DC or average value; it is real and contains
one value. X N/2 also contains one real value. In between these
two are (N/2 – 1) unique complex values, each containing two
values. The X values from XN/2 + 1 to XN – 1 are not unique but
are complex conjugates of the values from XN/2 – 1 down to X1 .
The values symmetrical about X N/2 are complex conjugate
pairs. Thus for the N values of the sequence, we get N unique
values from the transform.
That is dry and tough. One more DFT concept and then we
proceed, and it is ‘shifted.’ The values past XN/2 can be picked
up as a group and lifted to the other side of zero so that now
instead of having values on either side of the Nyquist value,
X N/2 , be complex conjugate pairs, the values on either side of
zero frequency or X 0 are complex conjugate pairs. In this
method of plotting a DFT we will have positive and negative Figure 12. DFT 1,024 point Hanning window; only three lines; Fs = 1024,
frequencies. This is a common method of plotting a DFT. We So T = 1 sec; Df = 1 Hz.
are used to plotting a spectrum, which is content versus fre-
quency from 0 to the Nyquist frequency, or fs/2. Many people 1Ê 2p n ˆ
w= Á 1 - cos ˜ (13)
not in this business plot the X k’s and use positive and nega- 2Ë N ¯
tive frequencies. That is what I mean by shifted. This is a raised cosine with an average or DC value of 1/2. It
has a period of our window length, 1 second, thus its Df is 1
DFT of a Window Hz. The DFT is going to be a digitized Fourier series of this 1
Now let us look at the DFT magnitude of some windows; the Hz raised cosine with an average value of 1/2 considered peri-
DFT or the X k’s, not the spectrum. I am going to make all these odic and going on forever. Figure 12a shows its time history.
windows 1,024 points long, and I am going to sample them at In Figure 12b, we see its 1,024 value DFT. We see what appears
1,024 samples per second. Therefore, the time duration of each to be a 1 at 0 frequency and a 1/2 at the 1024th value. In Fig-
window will be one second; the Df, which is one over the du- ure 12c, we see the results of shifting the 513th to the 1,024th
ration, will be 1 Hz. We will start with a boxcar window. The value over on the other side of 0. In Figure 12d we expand the
DFT is going to be digitized Fourier series of a boxcar window plot to only slow values from –10 to 10 Hz, which shows a tri-
considered periodic and going on forever. It is a straight line angle with a base from –2 to +2 Hz and an apex of 1 at 0 fre-
with an amplitude of 1. It only has a DC component; it should quency. We get this triangle, because the plotter draws straight
have one line in its DFT with amplitude 1 at frequency equal lines between the values. In Figure 12e, I use the stem plot
to 0. Figure 11 shows this. In Figure 11a, we see the 1,024 ones feature that makes it clear we only have three values; one at 0
as a horizontal line. In Figure 11b, we have the DFT magnitude frequency with an amplitude of 1, and two values of 1/2 at –1
and we see a 1 at 0 frequency. In Figure 11c, I show the shifted and +1 Hz. By Equation 12, these two values of 1/2 would add
DFT magnitude with positive and negative frequencies. We still to 1 when we convert this to a spectrum so the spectrum will
have a 1 at 0 frequency. In Figure 11d, I expand the plot to only have a 0 frequency or DC value of 1 and a 1 Hz value of 1. They
slow values from –10 to 10 Hz, which shows a triangle with a both should be 1/2, but I normalized the DFT plot to make the
base from –1 to 1 Hz and an apex of 1 at 0 frequency; we get largest value 1. The Hanning window has a conveniently
this triangle because the plotter draws straight lines between simple DFT; three numbers. We will soon discuss that the con-
the values. In Figure 11e, I use the stem plot feature that makes volution can be used to apply the window, and a convolution
it clear we only have one value at zero frequency with an am- with just these three numbers made significant economic sense
plitude of 1. in the late 1960s and early ‘70s when the new signal analyzers
Now let us look at the DFT magnitude of a Hanning window. became digital and started using the FFT. Most of the popular
The equation of the Hanning window is Equation 13: windows have simple DFTs for this reason.
Convolution Theorem
The only way I can analyze or explain window effects (that
is, why the window affects leakage, the content in the adjacent
bin, and reduces picket fence errors) is via the convolution
theorem,9 which is difficult. The convolution theorem for us
is: the DFT of the term-by-term product of two digitized time
signals (a digitized time signal is a long list of digitized accel-
eration or velocity values) is equal to the convolution of the
DFTs of each of the signals. If we want the DFT of the product
of two time signals, we can get it by a convolution of the two
individual DFTs. And that is our situation exactly. We want to
understand the DFT of a windowed signal, and we will do it
by looking at the convolution of the DFT of unwindowed sig-
nal and the DFT of the window. So we have to use the convo-
lution.
What is a convolution? It is horribly confusing, important,
Figure 15. 1,024 point flat-top window, DFT, shifted, expanded, semi-
and widely used. It drives most students nuts and still confuses log plot.
me every now and then. The equation is:
q = N -1 For our situation, Y(q) represents the DFT of our un-
X (k ) = Â Y (q )W ( k - q ) (14) windowed data as collected, and W is the DFT of the window.
q =0 X is the DFT of the windowed data that we can convert to the
Conclusion
I hope some of this adds some insight to your understand-
ing of windows. Maybe it will give you enough background to
tackle some of the difficult references. It certainly seems to me
from References 1, 2, and 9, that many bright people have de- Figure 26. DFTs of common windows, shifted, expanded, zero-padded,
voted years to developing windows. All of the figures and cal- linear plot.
References
1. Harris, F. J.. “On the use of Windows for Harmonic Analysis with
the Discrete Fourier Transform,” Proc. IEEE, Vol. 66, No. 1, pp. 51-
83, January 1978.
2. Nuttall, A. H., “Some Windows with Very Good Sidelobe Behavior,”
IEEE Trans. on Acoustics, Speech, and Signal Processing, Vol.
ASSP-29, No. 1, pp. 84-91, February 1981.
3. Potter, R. W., “Compilation of Time Windows and Line Shapes for
Fourier Analysis,” Handout notes from an HP seminar circa 1978
4. Gade, S., and Herlufsen, H., “Use of Weighting Functions in DFT/
FFT Analysis (Part I),” Brüel Kjær Technical Review, No. 3, pp. 1-
28, 1987.
5. Gade, S., and Herlufsen, H., “Use of Weighting Functions in DFT/
FFT Analysis (Part II),” Brüel & Kjær Technical Review, No. 4, pp.
1-35, 1987.
6. Tran, T., Dahl, M., Claesson, I., and Lago, T., “High Accuracy Win-
dows for Today’s 24 Bit ADCs,” IMAC 22, Session 29, Signal Pro-
cessing, Soc. for Experimental Mechs., www.sem.org.
7. Harris, F. J., Trigonometric Transforms, a Unique Introduction to the
FFT, Spectral Dynamics, Inc., San Marcos, CA., October 1977.
8. Gaberson, H. A., “The DFT and the FFT as a Discrete Fourier Se-
ries of Sampled Data,” MFPT Advanced Signal Analysis Course
Notes, Section 2, January 2003.
9. McConnell, K. G., Vibration Testing; Theory and Practice, John
Wiley & Sons, Inc., pp. 266-278, 1995. (Most digital signal process-
ing books cover the convolution theorem, but this one is more di-
rected to our area.)
10. Gaberson, H. A.; “Using the FFT for Filtering, Transient Details, and
Resampling,” Proc. National Technical Training Symposium and
Figure 28. Eight linear spectra from the bearing of a large pump, each 27th Annual Meeting, Vibration Institute, Willowbrook, IL, pp. 127-
analyzed with the indicated window. Note the errors in peak ampli- 136, July 2003.
tudes; the flat-top should be most accurate. 11. UN-SCAN-IT, Silk Scientific Inc., Orem, UT.
12. M ATLAB ® for Windows, Version 5.3, High-Performance Numeric
Computation and Visualization Software, The MathWorks, Inc.,
culations were done with M ATLAB.12 I kept copies of all the little Natick, MA, 1999.
programs used to draw the figures. If you would like copies of
the programs to see how I have done them, let me know. The author can be contacted at: [email protected].