Fast Fourier Transform (FFT) & Signal Processing
Introduction to FFT and Signal Processing
SciPy's FFT module provides efficient implementations of the Fast Fourier Transform and related functions for signal processing. FFT converts signals from time domain to frequency domain, enabling frequency analysis and various signal processing operations.
Key Functions in scipy.fft:
fft/ifft- Forward and inverse FFTrfft/irfft- FFT for real-valued inputsfftfreq- Generate frequency binsfftshift- Shift zero frequency to centerstft- Short-Time Fourier Transformconvolve/correlate- Convolution and correlation
1. Basic FFT Analysis
The FFT transforms a signal from time domain to frequency domain, revealing the frequency components present in the signal.
2. Frequency Shifting with fftshift
fftshift rearranges FFT output to place zero-frequency component at the center, which is useful for visualization.
3. Inverse FFT and Signal Reconstruction
The inverse FFT transforms frequency domain data back to time domain, allowing for signal filtering and reconstruction.
4. Real FFT for Real-valued Signals
For real-valued input signals, rfft is more efficient as it computes only the non-redundant part of the spectrum.
5. Short-Time Fourier Transform (STFT)
STFT provides time-frequency analysis by computing FFT over short, overlapping time windows of the signal.
6. Convolution and Filtering
Convolution is fundamental to signal filtering and system analysis. It's equivalent to multiplication in the frequency domain.
FFT Best Practices
- Use
rfftfor real-valued signals to save computation and memory - Apply appropriate window functions (Hamming, Hanning) to reduce spectral leakage
- Choose FFT length as a power of 2 for optimal performance
- Use
fftshiftfor better visualization of symmetric spectra - Consider STFT for analyzing non-stationary signals
- Always check the frequency axis using
fftfreq
Common Applications
- Spectrum analysis
- Pitch detection
- Audio filtering
- Machine monitoring
- Fault detection
- Modal analysis