Digital Band Pass Butterworth Filter in Python
In this article, we are going to discuss how to design a Digital Low Pass Butterworth Filter using Python. The Butterworth filter is a type of signal processing filter designed to have a frequency response as flat as possible in the pass band. Let us take the below specifications to design the filter and observe the Magnitude, Phase & Impulse Response of the Digital Butterworth Filter.
What is Digital Bandpass Filter?
A band-pass filter is a filter that passes frequencies within a range and rejects frequencies outside that range.
How it’s different from Highpass & Lowpass:
The main difference can be spotted by observing the magnitude response of the Band Pass Filter. The passband of the filter is of a specific range, which means that the only signal’s within this range can be passed by the Bandpass filter. Any signal which doesn’t fall within the specified range is rejected by the filter.
The specifications are as follows:
- Sampling rate of 40 kHz
- Pass band edge frequencies are 1400 Hz & 2100 Hz
- Stop band edge frequencies are 1050 Hz & 2450 Hz
- Pass band ripple of 0.4 dB
- Minimum stop band attenuation of 50 dB
We will plot the magnitude, phase, and impulse response of the filter.
Before starting, first, we will create a user-defined function to convert the edge frequencies, we are defining it as convert() method.
Now below are the steps:
Step 1: Importing all the necessary libraries.
Step 2: Define variables with the given specifications of the filter.
Step 3: Building the filter using signal.buttord() function.
Step 4: Plotting the Magnitude Response.
Step 5: Plotting the Impulse Response.
Step 6: Plotting the Phase Response.
Below is the complete program based on the above approach:
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course