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 FFT
  • rfft / irfft - FFT for real-valued inputs
  • fftfreq - Generate frequency bins
  • fftshift - Shift zero frequency to center
  • stft - Short-Time Fourier Transform
  • convolve / 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.

Loading code editor...

2. Frequency Shifting with fftshift

fftshift rearranges FFT output to place zero-frequency component at the center, which is useful for visualization.

Loading code editor...

3. Inverse FFT and Signal Reconstruction

The inverse FFT transforms frequency domain data back to time domain, allowing for signal filtering and reconstruction.

Loading code editor...

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.

Loading code editor...

5. Short-Time Fourier Transform (STFT)

STFT provides time-frequency analysis by computing FFT over short, overlapping time windows of the signal.

Loading code editor...

6. Convolution and Filtering

Convolution is fundamental to signal filtering and system analysis. It's equivalent to multiplication in the frequency domain.

Loading code editor...
FFT Best Practices
  • Use rfft for 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 fftshift for better visualization of symmetric spectra
  • Consider STFT for analyzing non-stationary signals
  • Always check the frequency axis using fftfreq
Common Applications
Audio Processing
  • Spectrum analysis
  • Pitch detection
  • Audio filtering
Vibration Analysis
  • Machine monitoring
  • Fault detection
  • Modal analysis