def plotSmpAndSep(self):
     self.lb5.setVisible(False)
     p = PlotCanvas()
     sep = []
     QMessageBox.information(self, "tip", "开始绘制请稍后...")
     for i in range(3, 30, 3):
         Rm = self.Rms[:i, :]  # 截取前i 个样本
         Rs = self.Rss[:i, :]
         pds = PDS(Rm, Rs)  # 由选取的i 组样本进行DS 建模
         win = self.win
         pds.model(win, self.k)
         Rsun = self.Rss[i:i * 2, :]  # 选取子机上同样n 组未知样本进行DS 预测
         Rmun = self.Rms[i:i * 2, :]
         Rsunp = pds.predict(Rsun)
         sep.append(p.computeSEP(Rmun[:, win:Rsun.shape[1] - win], Rsunp))
     x = range(3, 30, 3)
     p.axes.plot(x,
                 np.array(sep),
                 linewidth=3,
                 color='b',
                 marker='o',
                 markerfacecolor='red',
                 markersize=12)
     p.axes.set_xlabel("样本数目(:组)")
     p.axes.set_ylabel("平均预测标准误差(SEP)")
     p.axes.set_title("样本数量 与 SEP 关系图")
     self.hlayout4.replaceWidget(self.wg, p)
     self.wg = p
     self.lb4.setText("绘制完成")
     pass
 def plotKAndSep(self):
     self.lb5.setVisible(False)
     p = PlotCanvas()
     sep = []
     QMessageBox.information(self, "tip", "开始绘制请稍后...")
     # 样本数量定为当前样本数量
     n = 10
     Rm = self.Rms[:n, :]  # 截取前n 个样本
     Rs = self.Rss[:n, :]
     pds = PDS(Rm, Rs)  # 由选取的i 组样本进行DS 建模
     win = self.win
     Rsun = self.Rss[n:n * 2, :]  # 选取子机上同样n 组未知样本进行PDS 预测
     Rmswin = self.Rms[:, win:Rsun.shape[1] - win]
     Rmun = Rmswin[n:n * 2, :]
     for i in range(1, n + 1):
         pds.model(win, i)
         Rsunp = pds.predict(Rsun)
         sep.append(p.computeSEP(Rmun, Rsunp))
     x = range(1, n + 1)
     p.axes.plot(x,
                 np.array(sep),
                 linewidth=3,
                 color='b',
                 marker='o',
                 markerfacecolor='red',
                 markersize=12)
     p.axes.set_xlabel("主成分个数")
     p.axes.set_ylabel("平均预测标准误差(SEP)")
     p.axes.set_title("主成分个数 与 SEP 关系图")
     self.hlayout4.replaceWidget(self.wg, p)
     self.wg = p
     self.lb4.setText("绘制完成")
     pass
示例#3
0
 def plotSmpAndSep(self):
     self.lb5.setVisible(False)
     p = PlotCanvas()
     sep = []
     self.lb4.setText("绘制中......")
     for i in range(3, 30, 3):
         Rm = self.Rms[:i, :]  # 截取前i 个样本
         Rs = self.Rss[:i, :]
         mlr = MLR(Rs, Rm)  # 由选取的n 组样本进行DS 建模
         mlr.modelling()
         Rsun = self.Rss[i:i * 2, :]  # 选取子机上同样n 组未知样本进行DS 预测
         Rmun = self.Rms[i:i * 2, :]
         Rsunp = np.dot(Rsun, mlr.A)  # A 为得到的转换矩阵,Rsunp 为预测结果
         sep.append(p.computeSEP(Rmun, Rsunp))
     x = range(3, 30, 3)
     p.axes.plot(x,
                 np.array(sep),
                 linewidth=3,
                 color='b',
                 marker='o',
                 markerfacecolor='red',
                 markersize=12)
     p.axes.set_xlabel("样本数目(:组)")
     p.axes.set_ylabel("平均预测标准误差(SEP)")
     p.axes.set_title("样本数量 与 SEP 关系图")
     self.hlayout4.replaceWidget(self.wg, p)
     self.wg = p
     self.lb4.setText("绘制完成")
     pass
 def plotPDS(self):
     pds = PDS(self.Rm, self.Rs)
     # 窗口大小选择
     pds.model(self.win, self.k)  # pds 建模 得到pds.F
     Rsun = self.Rss[:self.n, :]  # 选取子机上同样n 组未知样本进行PDS 预测
     Rsunp = pds.predict(Rsun)  # Rsunp 为预测结果
     win = self.win
     # 舍弃窗口两端
     Rmswin = self.Rms[:, win:Rsun.shape[1] - win]  #Rmswin 源机上去掉两端的光谱
     x = np.arange(1100, 2500, 2)
     xwin = x[win:Rsun.shape[1] - win]
     p = PlotCanvas()
     # 差值
     for i in range(Rsunp.shape[0]):
         y1 = p.averSpec(Rmswin)  # 源机均值光谱
         p.axes.plot(xwin, y1, 'r-', label='源机均值光谱')
         y2 = Rsunp[i, :]  # 从子机预测的光谱
         p.axes.plot(xwin, y2, label='样本' + str(i + 1) + '预测值')
         # 差值
         y = y2 - y1  # 目标机光谱
         p.axes.plot(xwin, y, label='样本' + str(i + 1) + '预测偏差')
     p.axes.legend()
     p.axes.set_title("PDS算法预测结果")
     self.hlayout4.replaceWidget(self.wg, p)
     self.wg = p
     Rmun = Rmswin[:self.n, :]
     sep = p.computeSEP(Rmun, Rsunp)
     self.lb5.setVisible(True)
     self.lb5.setText('%.5f' % sep)
     pass
示例#5
0
 def plotWinAndSep(self):
     self.lb5.setVisible(False)
     p = PlotCanvas()
     sep = []
     QMessageBox.information(self, "tip", "开始绘制请稍后...")
     # 样本数量定为当前样本数量
     n = self.n
     Rm = self.Rms[:n, :]  # 截取前n 个样本
     Rs = self.Rss[:n, :]
     sks = Shenks(Rm, Rs)  # 由选取的n 组样本进行sks 建模.
     Rsun = self.Rss[n:n * 2, :]  # 选取子机上同样n 组未知样本进行sks 预测
     for i in range(1, 21):
         win = i
         sks.model(win)
         Rsunp = sks.predict(Rsun)
         xnew = sks.xnew
         Rmswin = self.Rms[:, win:Rsun.shape[1] - win]
         Rmswin = Rmswin[:, :xnew.shape[0]]
         Rmun = Rmswin[n:n * 2, :]
         sep.append(p.computeSEP(Rmun, Rsunp))
     x = range(1, 21)
     p.axes.plot(x,
                 np.array(sep),
                 linewidth=3,
                 color='b',
                 marker='o',
                 markerfacecolor='red',
                 markersize=12)
     p.axes.set_xlabel("窗口大小")
     p.axes.set_ylabel("平均预测标准误差(SEP)")
     p.axes.set_title("窗口大小 与 SEP 关系图")
     self.hlayout4.replaceWidget(self.wg, p)
     self.wg = p
     self.lb4.setText("绘制完成")
     pass
示例#6
0
    def setupUi(self, graph):
        graph.setObjectName("graph")
        graph.resize(985, 693)
        self.centralwidget = QtWidgets.QWidget(graph)
        self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
        self.label_3 = QtWidgets.QLabel(self.centralwidget)
        self.gridLayout.addWidget(self.label_3, 0, 0, 1, 1)
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.gridLayout.addWidget(self.label, 1, 0, 1, 1)
        self.win = PlotCanvas(self.centralwidget)
        self.gridLayout.addWidget(self.win, 3, 0, 4, 3)
        self.gridLayout.addWidget(self.win.scroll, 5, 0, 6, 3)
        self.gridLayout.addWidget(self.win.scroll2, 3, 0, 4, 3)
        #self.gridLayout.addWidget(self.win.scroll3, 3,0,4,3)
        self.toolBarArea = NavigationToolbar(self.win,
                                             self.centralwidget,
                                             coordinates=True)

        self.win.mpl_connect('pick_event', self.onpick1)
        self.listcol = QtWidgets.QLineEdit(self.centralwidget)
        self.gridLayout.addWidget(self.listcol, 0, 1, 1, 2)

        self.listrows = QtWidgets.QLineEdit(self.centralwidget)
        self.gridLayout.addWidget(self.listrows, 1, 1, 1, 2)

        self.hafe = QtWidgets.QHBoxLayout(self.centralwidget)
        self.submit = QtWidgets.QPushButton(self.centralwidget)
        self.hafe.addWidget(self.submit)
        self.filterlist = QtWidgets.QLineEdit(self.centralwidget)
        self.hafe.addWidget(self.filterlist)

        self.submit.clicked.connect(self.filter)
        self.gridLayout.addItem(self.hafe, 2, 1, 1, 2)
        self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
        self.gridLayout.addItem(self.verticalLayout, 0, 3, 3, 1)
        self.getgraph_b()
        self.verticalLayout2 = QtWidgets.QVBoxLayout(self.centralwidget)
        self.gridLayout.addItem(self.verticalLayout2, 3, 3, 1, 0)
        self.getlist()

        graph.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(graph)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 985, 31))
        self.menuFile = QtWidgets.QMenu(self.menubar)
        graph.setMenuBar(self.menubar)
        self.actionOpen = QtWidgets.QAction(graph)
        self.menuFile.addAction(self.actionOpen)
        self.menubar.addAction(self.menuFile.menuAction())
        self.actionOpen.triggered.connect(self.file_open)
        saveFile = QtWidgets.QAction("&Save File", self)
        saveFile.triggered.connect(self.file_save)
        self.menuFile.addAction(saveFile)

        self.retranslateUi(graph)
        self.creatdateselect()
        self.comboBox3.setVisible(False)
        QtCore.QMetaObject.connectSlotsByName(graph)
示例#7
0
    def setupUi(self, mainwindow):
        # Call setup of super class
        super().setupUi(mainwindow)

        # Get last filename from settings file and fill table
        lastFile = self.settings.value("lastDataFile")
        if lastFile is not None:
            self.fillTableWithDataFromFile(lastFile)

        # Initialize plotting canvas
        plotCanvas = PlotCanvas(parent=self.plotPlaceholder)
示例#8
0
    def plot(self):
        p = PlotCanvas(dpi=75)
        data = self.data
        matdata = data[self.cbx.currentText()]
        arrdata = np.array(matdata.__getitem__("data")[0][0])
        x = np.arange(1100, 2500, 2)
        for i in range(arrdata.shape[0]):
            y = arrdata[i]
            p.axes.plot(x, y, 'r-')
        p.axes.set_title(self.cbx.currentText()+ "80组玉米样本光谱")
        self.hlayout3.replaceWidget(self.wg1, p)
        self.wg1 = p

        # 绘制均值光谱
        p2 = PlotCanvas(dpi=75)
        y = p2.averSpec(arrdata)
        p2.axes.plot(x, y, 'r-')
        p2.axes.set_title(self.cbx.currentText())
        self.hlayout3.replaceWidget(self.wg2, p2)
        self.wg2 = p2
示例#9
0
 def __init__(self):
     super(Gui2Ros, self).__init__()
     self.setupUi(self)
     self.map = 'indoor1'
     self.comboBox_maps.currentIndexChanged.connect(self.initplot)
     self.button_run.clicked.connect(self.startrun)
     self.close_flag = False
     self.local_pose = PoseStamped()
     self.local_vel = Twist()
     self.m = PlotCanvas(self, self.map)
     self.m.move(180, 0)
     self.flag = 0
 def plotDiff(self):
     p = PlotCanvas()
     x = range(1100, 2500, 2)
     offset = 0.5
     for i in range(self.n):
         y = self.Rm[i, :] + offset * i  # 源机光谱
         p.axes.plot(x, y, label='样本' + str(i + 1) + '(Master)')
         y = self.Rs[i, :] + offset * i  # 目标机光谱
         p.axes.plot(x, y, label='样本' + str(i + 1) + '(Slaver)')
     p.axes.legend()
     p.axes.set_title("两台仪器样本光谱对比(offset:" + str(offset) + ")")
     self.hlayout4.replaceWidget(self.wg, p)
     self.wg = p
     pass
 def setupUi(self, graph):
     graph.setObjectName("graph")
     graph.resize(985, 693)
     self.centralwidget = QtWidgets.QWidget(graph)
     self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
     self.label_3 = QtWidgets.QLabel(self.centralwidget)
     self.gridLayout.addWidget(self.label_3, 0, 0, 1, 1)
     self.label = QtWidgets.QLabel(self.centralwidget)
     self.gridLayout.addWidget(self.label, 1, 0, 1, 1)
     self.win = PlotCanvas(self.centralwidget)
     self.gridLayout.addWidget(self.win, 3, 0, 4, 3)
     self.gridLayout.addWidget(self.win.scroll, 6, 0, 6, 3)
     self.gridLayout.addWidget(self.win.scroll2, 3, 0, 4, 3)
     self.gui_winlist()
     self.gui_filter()
     self.gui_graphtree()
     self.gui_tab(graph)
     self.gui_slotsig(graph)
示例#12
0
    def plotShenks(self):
        win = self.win
        sks = Shenks(self.Rm, self.Rs)
        # 窗口大小选择
        sks.model(win)  # sks 建模
        xnew = sks.xnew  # 由一元二次模型校正后的波长
        ynew = sks.ynew  # 由校正后波长插值后的吸光度
        Rsun = self.Rss[:self.n, :]  # 选取子机上同样n 组未知样本进行Sks预测
        Rsunp = sks.predict(Rsun)
        x = np.arange(1100, 2500, 2)
        # 舍弃窗口两端
        xnew = sks.xnew  # 由校正模型  校正后的 波长
        Rmswin = self.Rms[:, win:Rsun.shape[1] - win]

        p = PlotCanvas()
        y1 = p.averSpec(Rmswin)  # 源机均值光谱
        y1 = y1[:xnew.shape[0]]  # Rmswin 源机上去掉多余波长的光谱
        # 差值
        for i in range(Rsunp.shape[0]):
            p.axes.plot(xnew, y1, 'r-', label='源机均值光谱')
            y2 = Rsunp[i]  # 从子机预测的光谱
            p.axes.plot(xnew, y2, label='样本' + str(i + 1) + '预测值')
            # 差值
            y = y2 - y1  # 目标机光谱
            p.axes.plot(xnew, y, label='样本' + str(i + 1) + '预测偏差')
        p.axes.legend()
        p.axes.set_title("Shenk's算法预测结果")
        self.hlayout4.replaceWidget(self.wg, p)
        self.wg = p

        Rmswin = Rmswin[:, :xnew.shape[0]]
        Rmun = Rmswin[:self.n, :]
        sep = p.computeSEP(Rmun, Rsunp)
        self.lb5.setVisible(True)
        self.lb5.setText('%.5f' % sep)
        pass
示例#13
0
 def plotDS(self):
     p = PlotCanvas()
     mlr = MLR(self.Rs, self.Rm)  # 由选取的n 组样本进行DS 建模
     mlr.modelling()
     Rsun = self.Rss[:self.n, :]  # 选取子机上同样n 组未知样本进行DS 预测
     Rsunp = np.dot(Rsun, mlr.A)  # A 为得到的转换矩阵,Rsunp 为预测结果
     x = np.arange(1100, 2500, 2)
     for i in range(Rsunp.shape[0]):
         y1 = p.averSpec(self.Rms)  # 源机均值光谱
         p.axes.plot(x, y1, 'r-', label='源机均值光谱')
         y2 = Rsunp[i, :]  # 从子机预测的光谱
         p.axes.plot(x, y2, label='样本' + str(i + 1) + '预测值')
         # 差值
         y = y2 - y1  # 目标机光谱
         p.axes.plot(x, y, label='样本' + str(i + 1) + '预测偏差')
     p.axes.legend()
     p.axes.set_title("DS算法预测结果")
     self.hlayout4.replaceWidget(self.wg, p)
     self.wg = p
     Rmun = self.Rms[:self.n, :]
     sep = p.computeSEP(Rmun, Rsunp)
     self.lb5.setVisible(True)
     self.lb5.setText('%.5f' % sep)
     pass
示例#14
0
 def on_stocktree_dclicked_cb(self, item, column):
     canvas = PlotCanvas(title=item.text(0))
     canvas.setStock(item.text(0))
     idx = self.stockTab.addTab(canvas, item.text(0))
     self.stockTab.setCurrentIndex(idx)
示例#15
0
文件: xtd_ui.py 项目: songkk/XTDrone
 def initplot(self):
     self.map = self.comboBox_maps.currentText()
     self.m = PlotCanvas(self, map=self.map)
     self.m.move(170, 0)