def __init__(self, R1, R2, fp, fs, gpass, gstop, ftype, btype): """ Variables init """ Filter.__init__(self, fp, fs, gpass, gstop, ftype, btype) self.R1 = R1 self.R2 = R2 self.units = Units() """ TEST DATA FOR CHEBY """ #self.gpass = 1.5 #self.ord = 4 #self.wn = np.pi * 100000.0 """ TEST DATA FOR BUTTER """ #self.ord = 5 #self.wn = 100000.0 if ftype == 'butter': self.alpha = self.alpha() elif ftype in ('cheby1', 'cheby2'): self.E = self.epsilon() self.gamma = self.gamma() self.a = self.a_help_var() self.a_ = self.a_prim_help_var() print("gamma ", self.gamma) print("epsilon ", self.E) print("a", self.a) print("a_ ", self.a_) #Frequency to pulsation self.wn = self.wn * np.pi * 2
def to_physical_unit(window, values, dx, to_c): unit = Units(dx=dx, to_c=to_c) for key, conv in convs: em_key = 'em_{}'.format(key) em_val = float(values[em_key]) value = conv(unit).reverse(em_val) window[key].Update(value=value)
def to_emses_unit(window, values, dx, to_c): unit = Units(dx=dx, to_c=to_c) for key, conv in convs: em_key = 'em_{}'.format(key) physical_val = float(values[key]) value = conv(unit).trans(physical_val) window[em_key].Update(value=value)
def apply(self, inp, convkey, window): unit = Units(convkey.dx, convkey.to_c) for key, applyer in self.applyers.items(): if not self.exceptors[key](inp, unit): continue try: value = applyer(inp, unit) except KeyError: continue window[key].Update(value=value)
def save(self, filename, inp, values): dx = float(values['dx']) to_c = float(values['em_c']) unit = Units(dx=dx, to_c=to_c) convkey = UnitConversionKey(dx=dx, to_c=to_c) for saver, exceptor in zip(self.savers, self.exceptors): if exceptor(inp, values, unit): saver(inp, values, unit) inp.save(filename, convkey=convkey)