Skip to main content
Tweeted twitter.com/StackSignals/status/741288756439863296
Added graph
Source Link
Gilles
  • 3.4k
  • 3
  • 23
  • 29

I am trying to build a Butterworth bandpass filter. My intent is to have a pass band between 250$250\textrm{ Hz}$ and 1000Hz$1000\textrm{ Hz}$. However the plot doesn't look right, as can be seen from the following graph:

enter image description here

Below is my code:

import scipy
import numpy as np
from scipy import signal
import matplotlib.pyplot as plt

#apply bandpass filter
fs = 8000
fso2 = fs/2.
N,Wn = scipy.signal.buttord(wp=[250./fso2,1000./fso2], ws=[200./fso2,1200./fso2],
   gpass=0.1, gstop=30.0)

b, a = signal.butter(N, Wn, 'band', True)
w, h = signal.freqs(b, a, np.logspace(0, 4, 500))
plt.semilogx(w, 20 * np.log10(abs(h)))
plt.title('Butterworth bandpass filter fit to constraints')
plt.xlabel('Frequency [radians / second]')
plt.ylabel('Amplitude [dB]')
plt.grid(which='both', axis='both')
plt.show()

I am trying to build a Butterworth bandpass filter. My intent is to have a pass band between 250 and 1000Hz. However the plot doesn't look right, as can be seen from the following graph:

enter image description here

Below is my code:

import scipy
import numpy as np
from scipy import signal
import matplotlib.pyplot as plt

#apply bandpass filter
fs = 8000
fso2 = fs/2.
N,Wn = scipy.signal.buttord(wp=[250./fso2,1000./fso2], ws=[200./fso2,1200./fso2],
   gpass=0.1, gstop=30.0)

b, a = signal.butter(N, Wn, 'band', True)
w, h = signal.freqs(b, a, np.logspace(0, 4, 500))
plt.semilogx(w, 20 * np.log10(abs(h)))
plt.title('Butterworth bandpass filter fit to constraints')
plt.xlabel('Frequency [radians / second]')
plt.ylabel('Amplitude [dB]')
plt.grid(which='both', axis='both')
plt.show()

I am trying to build a Butterworth bandpass filter. My intent is to have a pass band between $250\textrm{ Hz}$ and $1000\textrm{ Hz}$. However the plot doesn't look right, as can be seen from the following graph:

enter image description here

Below is my code:

import scipy
import numpy as np
from scipy import signal
import matplotlib.pyplot as plt

#apply bandpass filter
fs = 8000
fso2 = fs/2.
N,Wn = scipy.signal.buttord(wp=[250./fso2,1000./fso2], ws=[200./fso2,1200./fso2],
   gpass=0.1, gstop=30.0)

b, a = signal.butter(N, Wn, 'band', True)
w, h = signal.freqs(b, a, np.logspace(0, 4, 500))
plt.semilogx(w, 20 * np.log10(abs(h)))
plt.title('Butterworth bandpass filter fit to constraints')
plt.xlabel('Frequency [radians / second]')
plt.ylabel('Amplitude [dB]')
plt.grid(which='both', axis='both')
plt.show()

I am trying to build a Butterworth bandpass filter. However the plot doesn't look right. My intent is to have a pass band between 250 and 1000 Hz1000Hz. However the plot doesn't look right, as can be seen from the following graph:

enter image description here

Below is my code:

import scipy
import numpy as np
from scipy import signal
import matplotlib.pyplot as plt

#apply bandpass filter
fs = 8000
fso2 = fs/2.
N,Wn = scipy.signal.buttord(wp=[250./fso2,1000./fso2], ws=[200./fso2,1200./fso2],
   gpass=0.1, gstop=30.0)

b, a = signal.butter(N, Wn, 'band', True)
w, h = signal.freqs(b, a, np.logspace(0, 4, 500))
plt.semilogx(w, 20 * np.log10(abs(h)))
plt.title('Butterworth bandpass filter fit to constraints')
plt.xlabel('Frequency [radians / second]')
plt.ylabel('Amplitude [dB]')
plt.grid(which='both', axis='both')
plt.show()

I am trying to build a Butterworth bandpass filter. However the plot doesn't look right. My intent is to have a pass band between 250 and 1000 Hz. Below is my code:

import scipy
import numpy as np
from scipy import signal
import matplotlib.pyplot as plt

#apply bandpass filter
fs = 8000
fso2 = fs/2.
N,Wn = scipy.signal.buttord(wp=[250./fso2,1000./fso2], ws=[200./fso2,1200./fso2],
   gpass=0.1, gstop=30.0)

b, a = signal.butter(N, Wn, 'band', True)
w, h = signal.freqs(b, a, np.logspace(0, 4, 500))
plt.semilogx(w, 20 * np.log10(abs(h)))
plt.title('Butterworth bandpass filter fit to constraints')
plt.xlabel('Frequency [radians / second]')
plt.ylabel('Amplitude [dB]')
plt.grid(which='both', axis='both')
plt.show()

I am trying to build a Butterworth bandpass filter. My intent is to have a pass band between 250 and 1000Hz. However the plot doesn't look right, as can be seen from the following graph:

enter image description here

Below is my code:

import scipy
import numpy as np
from scipy import signal
import matplotlib.pyplot as plt

#apply bandpass filter
fs = 8000
fso2 = fs/2.
N,Wn = scipy.signal.buttord(wp=[250./fso2,1000./fso2], ws=[200./fso2,1200./fso2],
   gpass=0.1, gstop=30.0)

b, a = signal.butter(N, Wn, 'band', True)
w, h = signal.freqs(b, a, np.logspace(0, 4, 500))
plt.semilogx(w, 20 * np.log10(abs(h)))
plt.title('Butterworth bandpass filter fit to constraints')
plt.xlabel('Frequency [radians / second]')
plt.ylabel('Amplitude [dB]')
plt.grid(which='both', axis='both')
plt.show()
Clean up, typos, etc
Source Link
Paul R
  • 3.4k
  • 21
  • 34
Loading
Source Link
MAS
  • 143
  • 1
  • 4
Loading