def compute_normalised_by_order(self, ap, n, aa) -> ApproximationErrorCode: """ Generates normalised transfer function prioritising the fixed order """ # Computing needed constants zeros, poles, gain = ss.cheb2ap(n, aa) wa, aa, wp, ap = self.get_norm_template() self.h_aux = ss.ZerosPolesGain(zeros, poles, gain) return ApproximationErrorCode.OK
my_N = [2, 3, 4] #Orden de mis Filtros. # Diseño de los Filtros: # --------------------------------------------------------------------------- # N = 2: # Filtro Chebyshev Tipo I: z1, p1, k1 = sig.cheb1ap(my_N[0], eps) NUM1, DEN1 = sig.zpk2tf(z1, p1, k1) tf_ch1 = tf(NUM1, DEN1) # Filtro Chebyshev Tipo II o Chebyshev Inverso: z2, p2, k2 = sig.cheb2ap(my_N[0], alfa_min) NUM2, DEN2 = sig.zpk2tf(z2, p2, k2) tf_ch2 = tf(NUM2, DEN2) analyze_sys([tf_ch1, tf_ch2], ['Cheby Tipo I Orden 2', 'Cheby Tipo II o Inverso Orden 2']) # --------------------------------------------------------------------------- # N = 3: # Filtro Chebyshev Tipo I: z1, p1, k1 = sig.cheb1ap(my_N[1], eps) NUM1, DEN1 = sig.zpk2tf(z1, p1, k1) tf_ch1 = tf(NUM1, DEN1)
z, p, k = sig.buttap(this_order) eps = np.sqrt(10**(this_ripple / 10) - 1) num, den = sig.zpk2tf(z, p, k) num, den = sig.lp2lp(num, den, eps**(-1 / this_order)) z, p, k = sig.tf2zpk(num, den) elif aprox_name == 'Chebyshev1': z, p, k = sig.cheb1ap(this_order, this_ripple) elif aprox_name == 'Chebyshev2': z, p, k = sig.cheb2ap(this_order, this_ripple) elif aprox_name == 'Bessel': z, p, k = sig.besselap(this_order, norm='mag') elif aprox_name == 'Cauer': z, p, k = sig.ellipap(this_order, this_ripple, this_att) num, den = sig.zpk2tf(z, p, k) all_sys.append(sig.TransferFunction(num, den)) filter_names.append(aprox_name + '_ord_' + str(this_order) + '_rip_' + str(this_ripple) + '_att_' + str(this_att))
filter_names = [] analog_filters_names = [] digital_filters_names = [] if aprox_name == 'Butterworth': z, p, k = sig.buttap(order2analyze) elif aprox_name == 'Chebyshev1': z, p, k = sig.cheb1ap(order2analyze, ripple) elif aprox_name == 'Chebyshev2': z, p, k = sig.cheb2ap(order2analyze, ripple) elif aprox_name == 'Bessel': z, p, k = sig.besselap(order2analyze, norm='mag') elif aprox_name == 'Cauer': z, p, k = sig.ellipap(order2analyze, ripple, attenuation) num, den = sig.zpk2tf(z, p, k) # Desnormalizamos para wc num, den = sig.lp2lp(num, den, 2 * np.pi * fc) my_analog_filter = sig.TransferFunction(num, den)
all_sys = [] filter_names = [] for ii in orders2analyze: if aprox_name == 'Butterworth': z,p,k = sig.buttap(ii) elif aprox_name == 'Chebyshev1': z,p,k = sig.cheb1ap(ii, ripple) elif aprox_name == 'Chebyshev2': z,p,k = sig.cheb2ap(ii, ripple) elif aprox_name == 'Bessel': z,p,k = sig.besselap(ii, norm='mag') elif aprox_name == 'Cauer': z,p,k = sig.ellipap(ii, ripple, attenuation) num, den = sig.zpk2tf(z,p,k) all_sys.append(sig.TransferFunction(num,den)) filter_names.append(aprox_name + '_ord_' + str(ii))
analog=True) z, p, k = sig.cheb1ap(this_order, alfa_max) elif aprox_name == 'Chebyshev2': if force_order > 0: this_order = force_order else: this_order, _ = sig.cheb2ord(omega_p, omega_s, alfa_max, alfa_min, analog=True) z, p, k = sig.cheb2ap(this_order, alfa_min) elif aprox_name == 'Bessel': if force_order > 0: this_order = force_order else: this_order = besselord(omega_p, omega_s, alfa_max, alfa_min, omega_d, max_pc_delay) z, p, k = sig.besselap(this_order, norm='mag') elif aprox_name == 'Cauer': if force_order > 0: this_order = force_order