Esempio n. 1
0
 def __get_annotationparam(self, title, subtitle):
     param = AnnotationParam(_("Annotation"), icon="annotation.png")
     if title is not None:
         param.title = title
     if subtitle is not None:
         param.subtitle = subtitle
     return param
Esempio n. 2
0
 def __get_annotationparam(self, title, subtitle):
     param = AnnotationParam(_("Annotation"), icon="annotation.png")
     if title is not None:
         param.title = title
     if subtitle is not None:
         param.subtitle = subtitle
     return param
Esempio n. 3
0
    def loadData(self):
        self.trainingData = self.dataController.loadSampleData()
        import logic.dimreduce.paa as PAA

        p = PAA.paa()
        data = p.process(self.trainingData["PIR"][:], 100)

        r = np.array(range(len(data))).reshape(len(data), 1)
        s = np.array(data).reshape(len(data), 1)
        rs = np.hstack((s, s))
        print rs
        import logic.featurex.kmeans as km

        k = km.kmeans()
        labels = k.process(rs, 2)
        print labels
        self.plot.add_item(make.curve(range(0, len(data)), data))
        from guiqwt.styles import AnnotationParam

        i = 0
        i_beg = 0
        i_end = 0
        while i < len(labels):
            cur = labels[i_end]

            if i < len(labels) - 1:
                if labels[i_end + 1] != cur:
                    i_end = i
                    from guiqwt.annotations import AnnotatedRectangle

                    param = AnnotationParam()
                    param.title = str(labels[int(i_beg)])
                    param.show_computations = False

                    anno = AnnotatedRectangle(r[int(i_beg)], 0.5, r[int(i_end)], 0.2, param)  # TODO: y axis scaling
                    self.plot.add_item(anno)
                    i_beg = i_end
                    print "s1"
                else:
                    i_end = i
                    print "s2"
                print "s3"
            print "s4", i_end, len(labels)
            i += 1
        # param = AnnotationParam()
        # param.title = "alright"
        # param.show_computations = False

        ##anno = AnnotatedRectangle(0., 1., 1.5, 0.5, param)
        # anno.set_style("plot", "shape/drag")
        # anno.set_style("shape/drag/fill/color", "white")
        # self.plot.add_item(anno)
        # self.rangeSelection = make.range(-2, 2)
        # disp0 = make.range_info_label(self.rangeSelection, 'BR', u"x = %.1f +- %.1f cm",
        #                              title="Range infos")
        # self.plot.add_item(self.rangeSelection)
        # self.plot.add_item(disp0)
        self.plot.replot()
Esempio n. 4
0
 def setup_widget(self, title):
     self.plot = plt.CurvePlot(self, title=title,
                               xunit='Hz', yunit='dB')
     self.curve_item = make.curve([], [])
     # set color to magenta
     color = QtGui.QColor(QtCore.Qt.magenta)
     color.setAlpha(150)
     self.curve_item.setPen(QtGui.QPen(color))
     self.curve_item.setBrush(QtGui.QBrush(color))
     self.plot.add_item(self.curve_item)
     a_param = AnnotationParam()
     a_param.title = 'Peak Value'
     self.peak_item = AnnotatedPoint(annotationparam=a_param)
     self.plot.add_item(self.peak_item)
     self.plot.set_antialiasing(True)
     self.plot.setCanvasBackground(QtCore.Qt.darkBlue)
     vlayout = QtWidgets.QVBoxLayout()
     vlayout.addWidget(self.plot)
     self.setLayout(vlayout)
     self.update_curve()
    def process(self):
        params = {}
        for i in range(self.tableWidget.rowCount()):
            a = self.tableWidget.item(i, 0)
            b = self.tableWidget.item(i, 1)
            params[str(a.text())] = int(b.text())
        print "params", params
        outpN = self.tableWidget.item(0, 0)
        #params = {"none": "none", "output_length": outpN}


        r = np.array(range(len(self.dc.dimrecprocData))).reshape(len(self.dc.dimrecprocData), 1)
        s = np.array(self.dc.dimrecprocData).reshape(len(self.dc.dimrecprocData), 1)
        rs = np.hstack((s, s))

        labels = self.fec.extractFeature(rs, params)
        print labels
        self.plot.del_all_items()
        self.plot.replot()
        self.plot.add_item(
            make.curve(range(0, len(self.dc.dimrecprocData)), self.dc.dimrecprocData))

        from guiqwt.styles import AnnotationParam

        i = 0
        i_beg = 0
        i_end = 0
        while i < len(labels):
            cur = labels[i_end]

            if i < len(labels) - 1:
                if labels[i_end + 1] != cur:
                    i_end = i
                    from guiqwt.annotations import AnnotatedRectangle

                    param = AnnotationParam()
                    param.title = str(labels[int(i_beg)])
                    param.show_computations = False

                    anno = AnnotatedRectangle(r[int(i_beg)], self.dc.dimrecprocData[int(i_beg)], int(i_end), self.dc.dimrecprocData[r[int(i_end)]], param) #TODO: y axis scaling
                    self.plot.add_item(anno)
                    i_beg = i_end
                    print "s1"
                else:
                    i_end = i
                    print "s2"
                print "s3"
            print "s4", i_end, len(labels)
            i += 1

        self.rangeSelection = make.range(-2, 2)
        disp0 = make.range_info_label(self.rangeSelection, 'BR', u"x = %.1f +- %.1f cm",
                                      title="Range infos")
        #self.plot.add_item(self.rangeSelection)
        #self.plot.add_item(disp0)
        #self.dc.setCurrentDataFlowObject(self.flowData)
        self.dc.featureexData = self.flowData
        self.dc.setCurrentLabels(labels)
        print(self.dc.setCurrentLabels)
        #ToDo: Check that following line, make property in data controller
        self.dc.dimrecprocData = rs
        self.plot.replot()
        self.currentdata = np.reshape(labels, (-1, 1))