def saveCoeffs(self): """ Read out coefficients table and save the values to filter 'coeffs' and 'zpk' dicts. Is called when clicking the <Save> button, triggers a recalculation and replot of all plot widgets. """ if self.DEBUG: print("=====================\nInputCoeffs.saveCoeffs") coeffs = [] num_rows, num_cols = self.tblCoeff.rowCount(), self.tblCoeff.columnCount() if self.DEBUG: print("Tbl rows / cols:", num_rows, num_cols) # if num_cols > 1: # IIR for col in range(num_cols): rows = [] for row in range(num_rows): item = self.tblCoeff.item(row, col) if item: if item.text() != "": rows.append(simple_eval(item.text())) else: rows.append(0.0) # rows.append(float(item.text()) if item else 0.) coeffs.append(rows) fb.fil[0]["N"] = num_rows - 1 save_fil(fb.fil[0], coeffs, "ba", __name__) if self.DEBUG: print("Coeffs - ZPK:", fb.fil[0]["zpk"]) print("Coeffs - b,a:", fb.fil[0]["ba"]) print("Coeffs updated!") self.sigFilterDesigned.emit() # -> input_all -> pyFDA -> pltAll.updateAll()
def save(self, fil_dict, arg): """ Convert between poles / zeros / gain, filter coefficients (polynomes) and second-order sections and store all available formats in the passed dictionary 'fil_dict'. """ pyfda_lib.save_fil(fil_dict, arg, frmt, __name__) try: # has the order been calculated by a "min" filter design? fil_dict['N'] = self.N # yes, update filterbroker except AttributeError: pass self.storeEntries()
def save(self, fil_dict, arg): """ Convert poles / zeros / gain to filter coefficients (polynomes) and the other way round """ pyfda_lib.save_fil(fil_dict, arg, frmt, __name__) if self.F_SBC is not None: # has the order been calculated by a "min" filter design? fil_dict['N'] = self.N # yes, update filterbroker if np.isscalar(self.F_SBC): # HP or LP - a single corner frequency fil_dict['F_C'] = self.F_SBC / 2. else: # BP or BS - two corner frequencies fil_dict['F_C'] = self.F_SBC[0] / 2. fil_dict['F_C2'] = self.F_SBC[1] / 2
def save(self, fil_dict, arg): """ Store results of filter design in the global filter dictionary. Corner frequencies calculated for minimum filter order are also stored in the dictionary to allow for a smooth manual filter design. """ pyfda_lib.save_fil(fil_dict, arg, frmt, __name__) if self.F_PBC is not None: # has corner frequency been calculated? fil_dict['N'] = self.N # yes, update filterbroker if np.isscalar(self.F_PBC): # HP or LP - a single corner frequency fil_dict['F_PB'] = self.F_PBC / 2. else: # BP or BS - two corner frequencies fil_dict['F_PB'] = self.F_PBC[0] / 2. fil_dict['F_PB2'] = self.F_PBC[1] / 2.
def saveZPK(self): """ Read out table and save the values to the filter PZ dict """ if self.DEBUG: print("=====================\nInputPZ.saveZPK") zpk = [] num_rows = self.tblPZ.rowCount() if self.DEBUG: print("nrows:",num_rows) #iterate over both columns for col in range(2): rows = [] for row in range(num_rows): item = self.tblPZ.item(row, col) if item: if item.text() != "": rows.append(simple_eval(item.text())) else: rows.append(0.) zpk.append(rows) zpk.append(simple_eval(self.ledGain.text())) # append k factor to zpk fb.fil[0]["N"] = num_rows save_fil(fb.fil[0], zpk, 'zpk', __name__) # save & convert to 'ba' if self.chkNorm.isChecked(): # set gain factor k (zpk[2]) in such a way that the max. filter # gain remains unchanged [w, H] = freqz(fb.fil[0]['ba'][0], fb.fil[0]['ba'][1]) # (bb, aa) zpk[2] = zpk[2] * self.Hmax_last / max(abs(H)) save_fil(fb.fil[0], zpk, 'zpk', __name__) # save with new gain ' if __name__ == '__main__': self.showZPK() # only needed for stand-alone test self.sigFilterDesigned.emit() if self.DEBUG: print("ZPK - coeffs:", fb.fil[0]['ba']) print("ZPK - zpk:", fb.fil[0]['zpk']) print("ZPK updated!")
def save(self, fil_dict, arg): """ Convert between poles / zeros / gain, filter coefficients (polynomes) and second-order sections and store all available formats in the global database. """ pyfda_lib.save_fil(fil_dict, arg, frmt, __name__) if self.F_PBC is not None: # has corner frequency been calculated? fil_dict['N'] = self.N # yes, update filterbroker # print("====== cheby1.save ========\nF_PBC = ", self.F_PBC, type(self.F_PBC)) # print("F_PBC vor", self.F_PBC, type(self.F_PBC)) if np.isscalar(self.F_PBC): # HP or LP - a single corner frequency fil_dict['F_C'] = self.F_PBC / 2. else: # BP or BS - two corner frequencies fil_dict['F_C'] = self.F_PBC[0] / 2. fil_dict['F_C2'] = self.F_PBC[1] / 2.
def save(self, fil_dict, arg): """ Store results of filter design in the global filter dictionary. Corner frequencies calculated for minimum filter order are also stored in the dictionary to allow for a smooth manual filter design. """ pyfda_lib.save_fil(fil_dict, arg, frmt, __name__) if self.F_PBC is not None: # has corner frequency been calculated? fil_dict['N'] = self.N # yes, update filterbroker if np.isscalar(self.F_PBC): # HP or LP - a single corner frequency fil_dict['F_PB'] = self.F_PBC / 2. else: # BP or BS - two corner frequencies fil_dict['F_PB'] = self.F_PBC[0] / 2. fil_dict['F_PB2'] = self.F_PBC[1] / 2. fil_dict['A_PB2'] = self.A_PB fil_dict['A_SB2'] = self.A_SB