def showCoeffs(self): """ Create table from filter coeff dict """ coeffs = fb.fil[0]['ba'] self.tblCoeff.setVisible(self.chkCoeffList.isChecked()) self.tblCoeff.setRowCount(max(np.shape(coeffs))) self.tblCoeff.setColumnCount(2) if self.DEBUG: print("=====================\nInputCoeffs.showCoeffs") print("Coeffs:\n",coeffs) print ("shape", np.shape(coeffs)) print ("len", len(coeffs)) print("ndim", np.ndim(coeffs)) self.tblCoeff.setHorizontalHeaderLabels(["b", "a"]) for col in range(2): for row in range(np.shape(coeffs)[1]): item = self.tblCoeff.item(row, col) # copy content of zpk to corresponding table field, rounding # as specified and removing the brackets of complex arguments if item: item.setText(str(cround(coeffs[col][row])).strip('()')) else: self.tblCoeff.setItem(row,col,QtGui.QTableWidgetItem( str(cround(coeffs[col][row])).strip('()'))) self.tblCoeff.resizeColumnsToContents() self.tblCoeff.resizeRowsToContents()
def load_entries(self): """ Update all entries from filter dict, create table from filter zpk dict, overwriting all previous entries. """ if fb.fil[0]['ft'] == 'FIR': self.cmbFilterType.setCurrentIndex(0) # set to "FIR" else: self.cmbFilterType.setCurrentIndex(1) # set to "IIR" zpk = fb.fil[0]['zpk'] n_digits = int(self.spnRound.text()) self.ledGain.setVisible(self.chkPZList.isChecked()) self.lblGain.setVisible(self.chkPZList.isChecked()) self.tblPZ.setVisible(self.chkPZList.isChecked()) if self.chkNorm.isChecked(): [w, H] = freqz(fb.fil[0]['ba'][0], fb.fil[0]['ba'][1]) # (bb, aa) self.Hmax_last = max(abs(H)) # store current max. filter gain if not np.isfinite(self.Hmax_last) or self.Hmax_last > 1e4: self.Hmax_last = 1. if not np.isfinite(zpk[2]): zpk[2] = 1. self.ledGain.setText(str(cround(zpk[2], n_digits))) self.tblPZ.setVisible(self.chkPZList.isChecked()) self.tblPZ.setRowCount(max(len(zpk[0]), len(zpk[1]))) logger.debug("load_entries - pz:\n" "Shape = %s\n" "Len = %d\n" "NDim = %d\n\n" "ZPK = %s" % (np.shape(zpk), len(zpk), np.ndim(zpk), pformat(zpk))) self.tblPZ.setColumnCount(2) self.tblPZ.setHorizontalHeaderLabels(["Z", "P"]) for col in range(2): for row in range(len(zpk[col])): logger.debug("Len Row = %d" % len(zpk[col])) item = self.tblPZ.item(row, col) # copy content of zpk to corresponding table field, rounding # as specified and removing the brackets of complex arguments if item: # does item exist? item.setText( str(cround(zpk[col][row], n_digits)).strip('()')) else: # no construct it self.tblPZ.setItem( row, col, QTableWidgetItem( str(cround(zpk[col][row], n_digits)).strip('()'))) self.tblPZ.resizeColumnsToContents() self.tblPZ.resizeRowsToContents()
def load_entries(self): """ Create table from filter coeff dict """ coeffs = fb.fil[0]['ba'] num_rows = max(np.shape(coeffs)) q_coeff = fb.fil[0]['q_coeff'] self.ledQuantI.setText(str(q_coeff['QI'])) self.ledQuantF.setText(str(q_coeff['QF'])) self.cmbQQuant.setCurrentIndex( self.cmbQQuant.findText(q_coeff['quant'])) self.cmbQOvfl.setCurrentIndex(self.cmbQOvfl.findText(q_coeff['ovfl'])) # check whether filter is FIR and only needs one column if fb.fil[0]['ft'] == 'FIR': # and np.all(fb.fil[0]['zpk'][1]) == 0: num_cols = 1 self.tblCoeff.setColumnCount(1) self.tblCoeff.setHorizontalHeaderLabels(["b"]) self.cmbFilterType.setCurrentIndex(0) # set to "FIR" else: num_cols = 2 self.tblCoeff.setColumnCount(2) self.tblCoeff.setHorizontalHeaderLabels(["b", "a"]) self.cmbFilterType.setCurrentIndex(1) # set to "IIR" self.tblCoeff.setVisible(self.chkCoeffList.isChecked()) self.tblCoeff.setRowCount(num_rows) self.tblCoeff.setColumnCount(num_cols) # create index strings for column 0, starting with 0 idx_str = [str(n) for n in range(num_rows)] self.tblCoeff.setVerticalHeaderLabels(idx_str) logger.debug( "load_entries - coeffs:\n" "Shape = %s\n" "Len = %d\n" "NDim = %d\n\n" "Coeffs = %s" % (np.shape(coeffs), len(coeffs), np.ndim(coeffs), pformat(coeffs))) for col in range(num_cols): for row in range(np.shape(coeffs)[1]): item = self.tblCoeff.item(row, col) # copy content of zpk to corresponding table field, rounding # as specified and removing the brackets of complex arguments if item: item.setText(str(cround(coeffs[col][row])).strip('()')) else: self.tblCoeff.setItem( row, col, QTableWidgetItem( str(cround(coeffs[col][row])).strip('()'))) self.tblCoeff.resizeColumnsToContents() self.tblCoeff.resizeRowsToContents()
def load_entries(self): """ Create table from filter zpk dict, overwriting all previous entries. """ zpk = fb.fil[0]['zpk'] n_digits = int(self.spnRound.text()) self.ledGain.setVisible(self.chkPZList.isChecked()) self.lblGain.setVisible(self.chkPZList.isChecked()) self.tblPZ.setVisible(self.chkPZList.isChecked()) if self.chkNorm.isChecked(): [w, H] = freqz(fb.fil[0]['ba'][0], fb.fil[0]['ba'][1]) # (bb, aa) self.Hmax_last = max(abs(H)) # store current max. filter gain if not np.isfinite(self.Hmax_last) or self.Hmax_last > 1e4: self.Hmax_last = 1. if not np.isfinite(zpk[2]): zpk[2] = 1. self.ledGain.setText(str(cround(zpk[2], n_digits))) self.tblPZ.setVisible(self.chkPZList.isChecked()) self.tblPZ.setRowCount(max(len(zpk[0]), len(zpk[1]))) if self.DEBUG: print("=====================\nInputPZ.load_entries") print("ZPK:\n", zpk) print("shape", np.shape(zpk)) print("len", len(zpk)) print("ndim", np.ndim(zpk)) self.tblPZ.setColumnCount(2) self.tblPZ.setHorizontalHeaderLabels(["Z", "P"]) for col in range(2): for row in range(len(zpk[col])): logger.debug("Len Row = %d" % len(zpk[col])) item = self.tblPZ.item(row, col) # copy content of zpk to corresponding table field, rounding # as specified and removing the brackets of complex arguments if item: # does item exist? item.setText( str(cround(zpk[col][row], n_digits)).strip('()')) else: # no construct it self.tblPZ.setItem( row, col, QtGui.QTableWidgetItem( str(cround(zpk[col][row], n_digits)).strip('()'))) self.tblPZ.resizeColumnsToContents() self.tblPZ.resizeRowsToContents()
def showZPK(self): """ Create table from filter zpk dict, overwriting all previous entries. """ zpk = fb.fil[0]['zpk'] n_digits = int(self.spnRound.text()) self.ledGain.setVisible(self.chkPZList.isChecked()) self.lblGain.setVisible(self.chkPZList.isChecked()) self.tblPZ.setVisible(self.chkPZList.isChecked()) if self.chkNorm.isChecked(): [w, H] = freqz(fb.fil[0]['ba'][0], fb.fil[0]['ba'][1]) # (bb, aa) self.Hmax_last = max(abs(H)) # store current max. filter gain self.ledGain.setText(str(cround(zpk[2], n_digits))) self.tblPZ.setVisible(self.chkPZList.isChecked()) self.tblPZ.setRowCount(max(len(zpk[0]),len(zpk[1]))) if self.DEBUG: print("=====================\nInputPZ.showZPK") print("ZPK:\n",zpk) print ("shape", np.shape(zpk)) print ("len", len(zpk)) print("ndim", np.ndim(zpk)) self.tblPZ.setColumnCount(2) self.tblPZ.setHorizontalHeaderLabels(["Z", "P"]) for col in range(2): for row in range(len(zpk[col])): if self.DEBUG: print("Len Row:", len(zpk[col])) item = self.tblPZ.item(row, col) # copy content of zpk to corresponding table field, rounding # as specified and removing the brackets of complex arguments if item: # does item exist? item.setText(str(cround(zpk[col][row], n_digits)).strip('()')) else: # no construct it self.tblPZ.setItem(row,col,QtGui.QTableWidgetItem( str(cround(zpk[col][row], n_digits)).strip('()'))) self.tblPZ.resizeColumnsToContents() self.tblPZ.resizeRowsToContents()