DISEÑO Y COMPARACIÓN DE FILTROS PASO BAJO EN PYTHON

DISEÑO Y COMPARACIÓN DE FILTROS EN PYTHON

En el siguiente codigo corresponde a la comparacion de los diferentes tipos de filtros.Butterwoth Chevyshev,  eliptico y ademas los filtros optimos algoritmo de parks-mcclellan y el algoritmo de minimos cuadrados. 

#INTRODUCIR EN LA CONSOLA %matplotlib auto PARA PODER MOSTRAR LA GRAFICA EN UNA VENTANA
import numpy as np
import matplotlib.pyplot as plt
from scipy import signal
N=8
riple_paso=1;
riple_stop=30;
wc=0.5
WR=1.1*wc
bandaspm=np.array([0,0.5*wc,0.5*1.1*wc,0.5*1]);
bandas=np.array([0,wc,1.1*wc,1]);
valorespm=np.array([1,0]);
valores=np.array([1,1,0,0]);
#FILTROS
num_butter,deno_butter=signal.butter(N,0.5);
num_cheby1,deno_cheby1=signal.cheby1(N,riple_paso,wc);
num_cheby2,deno_cheby2=signal.cheby2(N,riple_stop,wc);
num_ellip,deno_ellip=signal.ellip(N,riple_paso,riple_stop,wc);
num_firpm=signal.remez(53,bandaspm,valorespm);
num_firls=signal.firls(53,bandas,valores);
"RESPUESTA EN FRECUENCIA DE FILTROS"
w_butter, h_butter = signal.freqz(num_butter,deno_butter);
w_cheby1, h_cheby1 = signal.freqz(num_cheby1,deno_cheby1);
w_cheby2, h_cheby2 = signal.freqz(num_cheby2,deno_cheby2);
w_ellip, h_ellip   = signal.freqz(num_ellip,deno_ellip);
w_firpm,h_firpm    = signal.freqz(num_firpm,1);
w_firls,h_firls    = signal.freqz(num_firls,1);
"GRAFICOS DE RESPUESTA EN MAGNITUD"
plt.plot(w_butter, 20 * np.log10(abs(h_butter)),label="butter")
plt.plot(w_cheby1, 20 * np.log10(abs(h_cheby1)),label="chebychey1")
plt.plot(w_cheby2, 20 * np.log10(abs(h_cheby2)),label="chebychey2")
plt.plot(w_ellip, 20 * np.log10(abs(h_ellip)),label="eliptico")
plt.plot(w_firpm,20*np.log10(abs(h_firpm)),label="parks_mcclellian")
plt.plot(w_firls,20*np.log10(abs(h_firls)),label="minimos cuadrados")
plt.ylim(-50, 1);
plt.xlim(0,np.pi);
plt.legend(loc='upper left',bbox_to_anchor=(0, 0.2))
plt.grid('on')

En este ejemplo se ha tomado como la frecuencia de corte (wc=0.5$\pi$).









0 Comentarios