コード例 #1
0
 def normalize(self):
     param = TemplateParameters(wa=self.denormalized_template.wp /
                                self.denormalized_template.wa,
                                wp=1,
                                alpha_p=self.denormalized_template.alpha_p,
                                alpha_a=self.denormalized_template.alpha_a)
     self.normalized_template = \
         LowPassTemplate(param=param,
                         n_min=self.denormalized_template.n_min, n_max=self.denormalized_template.n_max,
                         q_max=self.denormalized_template.q_max,
                         denorm_degree=self.denormalized_template.denorm_degree)
コード例 #2
0
ファイル: gui_stage_1.py プロジェクト: rocioparra/TC_TP4_G4
    def calculate_new_filter_cb(self):
        if (not self.is_filter_type_set
            ) or self.approximation_type_name == "Approximation type":
            return
        nmin = 0
        nmax = 25
        if self.n_options_name == "N min y max":
            nmin = int(self.nmin_value.get())
            nmax = int(self.nmin_value.get())
        elif self.n_options_name == "N fijo":
            nmin = int(self.nfijo_value.get())
            nmax = int(self.nfijo_value.get())

        Qmax = 200
        if len(self.qmax_value.get()):
            Qmax = float(self.qmax_value.get())

        template_parameters_list = []
        for key in self.template_parameters_input:
            if self.template_parameters_input[key][0].get():
                template_parameters_list.append(
                    float(self.template_parameters_input[key][0].get()))
            else:
                template_parameters_list.append(None)
            print(self.template_parameters_input[key][0].get())

        template_parameters_list_to_send = TemplateParameters(
            *template_parameters_list)

        normal = 1
        dn = self.normalizacion.get()
        if (dn == "Desnormalizado"):
            normal = 0

        auxTup = self.m.add_filter(self.filter_type_name.get(), self.approximation_type_name.get(), \
                          template_parameters_list_to_send, nmin, nmax, Qmax, normal)

        if auxTup[1] == -1:  #si hubo error
            messagebox.showinfo("Error", auxTup[0])
        else:
            new_filter_input = []
            new_filter_input.append(
                IntVar())  # guarda si esta seleccionado o no
            new_filter_input.append(auxTup[0])  # nombre
            new_filter_input.append(auxTup[1])  # filter index
            new_filter_input.append(
                Checkbutton(self.existing_filters_frame,
                            variable=new_filter_input[0],
                            text=new_filter_input[1],
                            state='normal'))
            new_filter_input[3].pack(side=TOP, fill='x')
            self.filters_input.append(new_filter_input)
コード例 #3
0
 def get_parameter_list():
     return TemplateParameters(wa=True, wp=True, alpha_a=True, alpha_p=True)
コード例 #4
0
 def get_parameter_list():
     return TemplateParameters(wrg=True, tau=True, tol=True)
コード例 #5
0
ファイル: test_approx.py プロジェクト: rocioparra/TC_TP4_G4
import numpy
import math
from group_delay import group_delay


# m = Model()
# s, id = m.add_filter("Band-pass", "Inverse Chebyshev", [500, 100, 200, 1, 20], 1, 25, 100, 50)
# #m.f.auto_stage_decomposition(.1, 15)
# print(s)
# m.get_plot(id, "Step response", False)


tau = 10e-3
w_rg = 600
tolerance = 0.20
params = TemplateParameters(wrg=w_rg, tau=tau, tol=tolerance)
template = GroupDelayTemplate(param=params, q_max=100, n_min=1, n_max=25)
f = GroupDelay(template=template, approx="Bessel")
f.calculate_pzkn()
tf = f.calculate_tf(f.denormalized_poles, f.denormalized_zeros, f.denormalized_k)

[w, mag, pha] = signal.bode(tf)
plt.semilogx(w, -mag)
plt.grid(b=True)
plt.show()
print(tf.num/tf.den[0])
print(tf.den/tf.den[0])

gd = -numpy.diff(pha)/numpy.diff(w)*math.pi/180
w = numpy.delete(w, 0)