示例#1
0
文件: data.py 项目: hwp-kiel/opencali
    def recalculateIndx2(self):
        log('data.recalculateIndx2:' + self._parent.comboBox_select1.currentText())
        self._parent.tablemodeltreated.beginResetModel()
        colname = self._parent.comboBox_select1.currentText()
        selection = [str(x.text()) for x in self._parent.listWidget_select1.selectedItems()]

        self.indx2.clear()
        if colname == 'None':
            for r in range(self.nrows):
                if self.ignore[r] == 0:
                    self.indx2.append(r)
        elif colname == 'Row':
            for r in range(self.nrows):
                if str(r+1) in selection:
                    self.indx2.append(r)
        elif colname in self.headerd:
            idx = self.headerd.index(colname)
            for r in range(self.nrows):
                if self.descr[r][idx] in selection:
                    self.indx2.append(r)
        elif colname in self.headery:
            idx = self.headery.index(colname)
            for r in range(self.nrows):
                if '{:.1f}'.format(self.yarr[r][idx]) in selection:
                    self.indx2.append(r)

        self._parent.tablemodeltreated.endResetModel()
示例#2
0
    def resetMplPlot(self):
        log('class MyMainWindow: def resetMplPlot')
        if self.tabwidgetmain.currentIndex() != 2:
            return
        ax = self.mpl.canvas.ax
        ax.clear()
        x = self.data.xvector
        for r in range(self.data.nrows):
            if r in self.data.indx2:
                y = self.data.xtreat[r]
                colour = self.data.colour[r]
                label = self.data.label[r]
                if colour == '':
                    colour = 'red'
                    #     self.mpl.canvas.ax.plot(x, y)
                    # else:
                    #     self.mpl.canvas.ax.plot(x, y,  color=colour, label = 'a')
                    #     self.mpl.canvas.ax.le
                    #     plt.legend(handles=[line_up, line_down])
                if label == '':
                    p1, = ax.plot(x, y, color = colour)
                else:
                    p1, = ax.plot(x, y,   label = label, color = colour)
        handles, labels = ax.get_legend_handles_labels()
        ax.legend(handles, labels)

        self.mpl.canvas.draw()
示例#3
0
 def resetPlotSettings(self):
     log('class MyMainWindow: def resetPlotSettings')
     self.comboPlot_ColourBy.clear()
     itms = ['Row']
     for dname in self.data.headerd:
         itms.append(dname)
     for yname in self.data.headery:
         itms.append(yname)
     self.comboPlot_ColourBy.addItems(itms)
示例#4
0
 def loadSamples(self, filename='Donut.csv'):
     log('class MyMainWindow: def loadSamples')
     self.tablemodelraw.beginResetModel()
     self.tablemodeltreated.beginResetModel()
     self.data.loadSamples(path.join(self.ini.paths.samples, filename))
     # self.resetlistWidget_select1()
     self.resetComboSelect1()
     #self.resetPlotSettings()
     self.tablemodelraw.reset()
示例#5
0
 def resetComboSelect1(self):
     log('class MyMainWindow: def resetComboSelect1')
     self.comboBox_select1.clear()
     self.comboPlot_ColourBy.clear()
     itms = ['None', 'Row']
     for dname in self.data.headerd:
         itms.append(dname)
     for yname in self.data.headery:
         itms.append(yname)
     self.comboBox_select1.addItems(itms)
     self.comboPlot_ColourBy.addItems(itms)
示例#6
0
    def resetlistWidget_select1(self):
        # log('class MyMainWindow: def resetlistWidget_select1')
        #print('combo1.: ', self.comboBox_select1.currentText())
        self.comboPlot_ColourBy.setCurrentIndex(self.comboBox_select1.currentIndex())
        self.listWidget_select1.clear()
        currText = self.comboBox_select1.currentText()
        if currText != self.comboBox_select1_seletedItm:
            log('class MyMainWindow: def resetlistWidget_select1-')
            self.comboBox_select1_seletedItm = currText
            itms = []
            if currText == 'Row':
                # itms = [str(i + 1) for i in self.data.indx1]
                for r in range(self.data.nrows):
                    if self.data.ignore[r] == 0:
                        itms.append(str(r+1))
            elif currText in self.data.headerd:
                idx = self.data.headerd.index(currText)
                # itms = [self.data.descr[i][idx] for i in self.data.indx]
                for r in range(self.data.nrows):
                    if self.data.ignore[r] == 0:
                        if not self.data.descr[r][idx] in itms:
                            itms.append(self.data.descr[r][idx])
            elif currText in self.data.headery:
                idx = self.data.headery.index(currText)
                # argsort = np.argsort(self.data.yarr[:, idx])
                sortiert = self.data.yarr[:, idx]
                sortiert.sort()
                for x in sortiert:
                    xstr = '{:.1f}'.format(x)
                    if not xstr in itms:
                        itms.append(xstr)

            # mymin = np.floor(np.nanmin(self.data.yarr[:, idx],axis=0))
            # mymax = np.ceil(np.nanmax(self.data.yarr[:, idx],axis=0))
            # mystep = (mymax-mymin) / 5
            # steps = np.arange(mymin, mymax, mystep, dtype=float )
            # for step in steps:
            #     itms.append(str(step) + ' - ' + str(step + mystep))
            self.listWidget_select1.addItems(itms)
            self.data.recalculateIndx2()
示例#7
0
    def __init__(self, parent=None):
        super(MyMainWindow, self).__init__(parent)
        deletelogger()
        log('class MyMainWindow: def __init__')
        self.setupUi(self)
        # ---------- class variables ------------------------
        # -- paths --
        self.pathStart = getcwd()
        self.pathParent = path.abspath(path.join(self.pathStart, pardir))
        self.pathSettings = path.join(self.pathParent, 'settings')
        # -- project stuff --
        self.actModelName = ''
        self.ini = Ini()
        # -- data --
        self.data = Data(self)
        self.tablemodelraw = TableModel_Raw(data=self.data, parent=self)
        self.tablemodeltreated = TableModel_Treated(data=self.data, parent=self)
        # -- add matplotlib widget
        self.mpl = MplWidget(self.tab)
        self.mpl.setObjectName("mpl")
        self.horizontalLayout_5.addWidget(self.mpl)
        # --- initializations ------------------------
        self.initIni()
        self.initFileMenu()
        # self.initPerspectives()
        self.initPerspectives()
        self.iniTreeWidgetProject()
        self.initTableRaw()
        self.initTableTreated()
        self.initTabSelect()
        self.initTabWidget()
        self.initComboSelect1()
        self.initlistWidget_select1()
        # self.resetMplPlot()
        self.initTreatments()
        self.initPlotSettings()

        self.comboBox_select1_seletedItm = ''
示例#8
0
 def on_treeWidgetProject_currentItemChanged(self):
     log('class MyMainWindow: def on_treeWidgetProject_currentItemChanged')
     currentitem = self.treeWidgetProject.currentItem()
     if currentitem:
         currnodes = [currentitem]
         currKeys = [currentitem.text(0)]
         currValus = [currentitem.text(1)]
         parentitem1 = currentitem.parent()
         if parentitem1:
             currnodes.append(parentitem1)
             currKeys.append(parentitem1.text(0))
             currValus.append(parentitem1.text(1))
             parentitem2 = parentitem1.parent()
             if parentitem2:
                 currnodes.append(parentitem2)
                 currKeys.append(parentitem2.text(0))
                 currValus.append(parentitem2.text(1))
         # print(currKeys)
         # print(currKeys[-1])
         if currValus[-1] != self.actModelName:
             self.actModelName = currValus[-1]
             # print('self.actModelName changed into: ' + self.actModelName)
             self.loadSamples()
示例#9
0
 def showEvent(self, event):
     log('class MyMainWindow: def showEvent')
     self.onPerspectiveOpenLast()
示例#10
0
    def resetColours(self):
        log('class MyMainWindow: def resetColours(self):')
        colourCriterion = self.comboPlot_ColourBy.currentText()
        print('colourCriterion:',colourCriterion)
        icolour = 0
        self.data.colour = [''] * self.data.nrows
        self.data.label = [''] * self.data.nrows
        if colourCriterion == 'Row':
            for r in range(self.data.nrows):
                if r in self.data.indx2:
                    self.data.colour[r] = self.coloursY[icolour % len(self.coloursY)]
                    icolour += 1
        elif colourCriterion in self.data.headerd:
            idx = self.data.headerd.index(colourCriterion)
            key = []
            for r in range(self.data.nrows):
                if r in self.data.indx2:
                    if not self.data.descr[r][idx] in key:
                        key.append(self.data.descr[r][idx])
                        self.data.label[r] = self.data.descr[r][idx]
                    self.data.colour[r] = self.coloursY[
                        key.index(self.data.descr[r][idx]) % len(self.coloursY)]
        elif colourCriterion in self.data.headery:
            idx = self.data.headery.index(colourCriterion)
            argsort = np.argsort(self.data.yarr[:, idx])
             # get min and max
            ymin = 1000000000
            ymax = -ymin
            # find min and max
            for r in range(self.data.nrows):
                if r in self.data.indx2:
                    if self.data.yarr[r,idx] > ymax:
                        ymax = self.data.yarr[r,idx]
                    if self.data.yarr[r,idx] < ymin:
                        ymin = self.data.yarr[r,idx]
            ymin = np.floor(ymin)  # np.floor(np.nanmin(self.data.yarr[:, idx],axis=0))
            ymax = np.ceil(ymax)   # np.ceil(np.nanmax(self.data.yarr[:, idx],axis=0))
            ystep = (ymax-ymin)/len(self.coloursY)
            ysteps = np.arange(ymin, ymax, ystep)
            labels = []
            for r in range(self.data.nrows):
                if r in self.data.indx2:
                    y = self.data.yarr[r,idx]
                    isdone = False
                    for i in range(len(ysteps)):
                        y0 = ysteps[i]

                        if y>11:
                            print(y)

                        if y <= y0 + ystep:
                            if not isdone:
                                isdone = True
                                ystr = str(y0) + ' - ' + str(y0 + ystep)
                                self.data.colour[r] = self.coloursY[i]
                                if not ystr in labels:
                                    labels.append(ystr)
                                    self.data.label[r] = ystr


        self.tablemodeltreated.reset()
        self.resetMplPlot()
示例#11
0
 def onListWidget_select1_changed(self):
     log('class MyMainWindow: def onListWidget1 changed')
     self.listWidgetPlot_ColourBy.setCurrentRow(1)
示例#12
0
 def formatTableView_treated(self):
     log('class MyMainWindow: def formatTableView_treated')
     self.tableView_treated.setColumnWidth(0, 38)
     self.tableView_treated.setColumnHidden(1, True)
     self.tableView_treated.setColumnHidden(2, False)
     self.tableView_treated.setColumnHidden(3, False)
示例#13
0
 def formatTableView_raw(self):
     log('class MyMainWindow: def formatTableView_raw')
     self.tableView_raw.setColumnWidth(0, 38)
     self.tableView_raw.setColumnWidth(1, 38)
     self.tableView_raw.setColumnHidden(2, True)
     self.tableView_raw.setColumnHidden(3, True)