Exemple #1
0
    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()
Exemple #2
0
    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()