Explainers · FFT series · Part 3
Wavelets: which frequency, and when
What the film shows. A fan knocks once every turn. Two different signals, one playing 10 Hz then 25 Hz and the other playing the same thing backwards, have exactly the same FFT spectrum: a spectrum says which frequencies, not when. Short FFTs slid along the signal bring time back, but every one paints the same box in time and frequency: squash one side and the other grows. Wavelets reshape the boxes, thin for fast notes and wide for slow ones. A wavelet is a short burst; multiply it by the signal and add up the area, and the score is high where the two are in step and near zero where they aren't. Slide it along and stretch it, and the scores make a map. On the fan, the hum is a steady band and each knock is a flash, 40 ms apart.
Which frequencies
One answer for the whole record. Anything that comes and goes is averaged away.
Which, and when
A map of frequency against time. Short bursts for fast things, long ones for slow things.
Two signals, one spectrum
The FFT matches a signal against an arrow turning at each frequency, over the whole record:
Play a record backwards and the spectrum's size doesn't change. For a real signal on \(0\le t\le T\), the reversed record \(x(T-t)\) has the transform \(e^{-i2\pi fT}\,\overline{X(f)}\): only the phase moves, so \(|X(f)|\) is identical. The order of events lives only in the phase, and a magnitude spectrum, which is what an analyser shows, throws it away.
That is fine for a steady machine. It isn't fine for something that comes and goes: an impact once per turn, a run-up, a valve that chatters for a second.
First try: short FFTs
Slide a short window \(w\) along the signal and take an FFT of each slice:
That is the spectrogram, and it does bring time back. But the window has one length for every frequency. A short window locates events sharply and blurs frequency; a long one does the opposite. The trade can't be beaten: for any window, the spreads in time and frequency (as standard deviations of the window's energy) obey
with equality only for a Gaussian window (Gabor, 1946).
The idea: a wavelet
A wavelet is a short wave inside a bell. The one used in the film is the Morlet wavelet, a cosine-and-sine arrow under a Gaussian:
Slide it to a time \(b\), stretch it by a scale \(a\), and match it against the signal:
Each scale is a frequency, \(f=\omega_0/(2\pi a)\), and every stretched copy holds the same number of wiggles. So a fast row of the map uses a short burst and a slow row a long one. Every mark on the map has the same area in time and frequency; what changes is its shape.
Try it
The signal, with the wavelet laid over it
How well the wavelet matches, at every time
Set the wavelet to 25 Hz: it matches only in the second half. Set it to 10 Hz: it is two and a half times longer and matches only in the first half. In between it matches neither well.
On a machine: one knock per turn
The film ends on a fan at 1,500 rpm: a 25 Hz hum, and a small knock once per turn that rings a resonance near 400 Hz. One turn takes
On the wavelet map the hum is a steady band and each knock is a flash. At 400 Hz the wavelet is short, so each flash lasts about 5.6 ms (at half height) and the knocks, 40 ms apart, stand out one by one. At 25 Hz the wavelet is long, so the same knock would smear over about 90 ms, but that row pins the hum to 25 ± 5 Hz. A single short-time FFT has to pick one of those two compromises for the whole map.
Derive the tone band, the knock flash, the area of a mark and how to read an amplitude off a map, then size the marks for this fan on a calculator, in Lab lesson 6: Wavelets for engineers.
Reading a wavelet map in practice
Brightness is not amplitude. With the \(1/\sqrt a\) used here, a steady tone of amplitude \(A\) reads \(\tfrac{A}{2}\sqrt{2\pi a}\), so slow rows look brighter than they are. Some tools scale by \(1/a\) instead, which makes equal amplitudes equally bright. Check which one your software uses before comparing rows.
Watch the edges. Near the start and end of a record the long, slow wavelets hang off the end of the data, so the slow rows are unreliable there. Torrence and Compo call this region the cone of influence; good tools shade it.
Where it helps. Anything that changes during the record: impacts and rubs that come once per turn, run-ups and coast-downs, intermittent faults. For a steady machine an ordinary averaged spectrum is still the sharper tool.
Downloads
- wavelets_film.py · the film:
manim -qh wavelets_film.py WaveletsFilm(needs wavelets.py beside it) - wavelets.py · the shared maths, look and mascot, with a numerical check of every claim in the captions
- film.py · an optional film finish: slow camera pushes and vignette
- score.py · a synthesised score, used when the music track isn't there
- wavelets.mp4 · the film, 1080p60 (the music track is not included in the code)
Further reading
- C. Torrence and G. P. Compo (1998). A practical guide to wavelet analysis. Bulletin of the American Meteorological Society, 79(1), 61–78.The best place to start: the Morlet wavelet with ω₀ = 6, normalisation, the cone of influence and significance tests.
- S. Mallat (2009). A Wavelet Tour of Signal Processing, 3rd ed. Academic Press.The full theory: time-frequency tiles, frames and fast wavelet transforms.
- D. Gabor (1946). Theory of communication. Journal of the IEE, 93(26), 429–457.The time-frequency trade-off, and the Gaussian window that meets it exactly.
- Z. K. Peng and F. L. Chu (2004). Application of the wavelet transform in machine condition monitoring and fault diagnostics: a review with bibliography. Mechanical Systems and Signal Processing, 18(2), 199–221.How wavelets have been used on real machines.
- R. B. Randall. Vibration-based Condition Monitoring. Wiley.Time-frequency methods alongside the spectrum, on machines.