Notch Filter: Definition, How It Works, and Examples
notch filter is a signal processing tool that removes or reduces a very narrow range of frequencies from a signal while leaving others mostly unchanged. It is often used to eliminate unwanted noise or interference at a specific frequency, like the 60 Hz hum from electrical power lines.How It Works
A notch filter works like a very selective gate that blocks out a tiny band of frequencies while letting all other frequencies pass through. Imagine you are listening to music but there is a single annoying beep at one pitch. The notch filter acts like a sound-proof wall that only blocks that beep's pitch, so the rest of the music sounds normal.
Technically, it creates a deep dip or "notch" in the frequency response at the unwanted frequency. This notch is very narrow, so frequencies just above or below it are mostly unaffected. This precision makes notch filters ideal for removing specific interference without harming the overall signal.
Example
import numpy as np import matplotlib.pyplot as plt from scipy.signal import iirnotch, filtfilt fs = 1000 # Sampling frequency in Hz f0 = 60 # Frequency to remove (notch frequency) Q = 30 # Quality factor (controls notch width) # Create a sample signal: 5 Hz sine wave + 60 Hz noise T = 1.0 t = np.linspace(0, T, int(fs*T), endpoint=False) signal = np.sin(2*np.pi*5*t) + 0.5*np.sin(2*np.pi*60*t) # Design notch filter b, a = iirnotch(f0, Q, fs) # Apply notch filter filtered_signal = filtfilt(b, a, signal) # Plot results plt.figure(figsize=(10, 6)) plt.plot(t, signal, label='Original Signal') plt.plot(t, filtered_signal, label='Filtered Signal', linestyle='--') plt.xlabel('Time [seconds]') plt.ylabel('Amplitude') plt.title('Notch Filter Removing 60 Hz Noise') plt.legend() plt.grid(True) plt.show()
When to Use
Use a notch filter when you need to remove a very specific frequency from a signal without affecting other parts. Common cases include:
- Removing electrical hum at 50 or 60 Hz from audio or sensor data.
- Eliminating narrowband interference in communication signals.
- Cleaning biomedical signals like ECG or EEG from power line noise.
Because notch filters target a narrow frequency range, they are perfect when the noise frequency is known and stable.
Key Points
- A notch filter removes a narrow band of frequencies from a signal.
- It is highly selective, affecting only the unwanted frequency.
- Commonly used to remove power line interference (50/60 Hz).
- Implemented using digital or analog filter designs.
- Quality factor (Q) controls the width of the notch.