Пример #1
0
    def show_data(self, s):
        file_name = s.text()
        self.data_dict = ut.ibw2dict(self.current_dir + '/' + file_name)

        e_sc = self.data_dict['E_axis'][1] - self.data_dict['E_axis'][0]
        a_sc = self.data_dict['A_axis'][1] - self.data_dict['A_axis'][0]
        e_rg = self.data_dict['E_axis'][-1] - self.data_dict['E_axis'][0]
        a_rg = self.data_dict['A_axis'][-1] - self.data_dict['A_axis'][0]
        e_str = self.data_dict['E_axis'][0]
        a_str = self.data_dict['A_axis'][0]
        e_end = self.data_dict['E_axis'][-1]
        a_end = self.data_dict['A_axis'][-1]

        self.ui.base_wd.plt_i.setRange(xRange=[e_str, e_end],
                                       yRange=[a_str, a_end],
                                       update=True,
                                       padding=0)
        self.ui.base_wd.plt_i.getViewBox().setLimits(xMin=e_str,
                                                     xMax=e_end,
                                                     yMin=a_str,
                                                     yMax=a_end)
        self.ui.base_wd.plt_iv.setImage(self.data_dict['data'],
                                        pos=[e_str, a_str],
                                        scale=[e_sc, a_sc])

        self.ui.base_wd.plt_iv.ui.roiBtn.hide()
        self.ui.base_wd.plt_iv.ui.menuBtn.hide()
Пример #2
0
 def refresh_wnd(self, s):
     try:
         if str(s.objectName()) in self.opened_wd_names:
             self.data_dict = ut.ibw2dict(self.current_dir + '/' +
                                          str(s.objectName()))
         elif str(s.objectName()) in self.opened3D_wd_names:
             self.data3D_dict = ut.read_bin_multi_region(
                 self.current_dir,
                 str(s.objectName())[:-4])
     except AttributeError as e:
         print('Error: {}'.format(e))
Пример #3
0
    def show_data(self, s):
        print('show data')
        file_name = s.text()
        self.data_dict = ut.ibw2dict(self.current_dir + '/' + file_name)

        e_sc = self.data_dict['E_axis'][1] - self.data_dict['E_axis'][0]
        a_sc = self.data_dict['A_axis'][1] - self.data_dict['A_axis'][0]
        e_str = self.data_dict['E_axis'][0]
        a_str = self.data_dict['A_axis'][0]
        self.base_wd.plt_i.setRange(xRange=[self.data_dict['E_axis'][0], self.data_dict['E_axis'][-1]], \
                            yRange=[self.data_dict['A_axis'][0], self.data_dict['A_axis'][-1]], update=True, padding = 0)

        self.base_wd.plt_i.getViewBox().setLimits(xMin= e_str, xMax = self.data_dict['E_axis'][-1],\
                                          yMin=self.data_dict['A_axis'][0], yMax=self.data_dict['A_axis'][-1])

        self.base_wd.plt_iv.setImage(
            self.data_dict['data'],
            pos=[self.data_dict['E_axis'][0], self.data_dict['A_axis'][0]],
            scale=[e_sc, a_sc])
        #        self.base_wd.plt_iv.ui.histogram.hide()
        self.base_wd.plt_iv.ui.roiBtn.hide()
        self.base_wd.plt_iv.ui.menuBtn.hide()
Пример #4
0
    def get_data(self, s):
        file_name = s.text()
        self.data_dict = ut.ibw2dict(self.current_dir + '/' + file_name)

        MDIWindow.count = MDIWindow.count + 1
        sub = QMdiSubWindow()

        sub.plt_i = pg.PlotItem(labels={
            'bottom': ('slits', 'degrees'),
            'left': ('Kin. Energy', 'eV')
        })
        sub.plt_iv = pg.ImageView(view=sub.plt_i)
        sub.setWidget(sub.plt_iv)
        sub.setWindowTitle(file_name)
        self.mdi.addSubWindow(sub)
        sub.show()

        e_sc = self.data_dict['E_axis'][1] - self.data_dict['E_axis'][0]
        a_sc = self.data_dict['A_axis'][1] - self.data_dict['A_axis'][0]
        e_str = self.data_dict['E_axis'][0]
        a_str = self.data_dict['A_axis'][0]
        e_end = self.data_dict['E_axis'][-1]
        a_end = self.data_dict['A_axis'][-1]
        sub.plt_i.setRange(xRange=[self.data_dict['E_axis'][0], self.data_dict['E_axis'][-1]], \
                            yRange=[self.data_dict['A_axis'][0], self.data_dict['A_axis'][-1]], update=True, padding = 0)

        sub.plt_i.getViewBox().setLimits(xMin= e_str, xMax = self.data_dict['E_axis'][-1],\
                                          yMin=self.data_dict['A_axis'][0], yMax=self.data_dict['A_axis'][-1])

        sub.plt_iv.setImage(
            self.data_dict['data'],
            pos=[self.data_dict['E_axis'][0], self.data_dict['A_axis'][0]],
            scale=[e_sc, a_sc])

        sub.plt_iv.ui.roiBtn.clicked.connect(lambda status, a_s = a_str,a_e = a_end,e_s = e_str,e_e = e_end, e_w = e_sc*10, a_w = a_sc*10, iv = sub.plt_iv:\
                                                 self.add_lin_ROI(status, a_s, a_e, e_s, e_e, e_w, a_w, iv))
Пример #5
0
    def get_data(self, s):
        file_name = s.text()
        MDIWindow.count = MDIWindow.count + 1
        sub = QMdiSubWindow()
        sub.resize(600, 600)
        sub.setWindowTitle(file_name)
        sub.setObjectName(file_name)
        if 'ibw' in file_name:
            self.opened_wd_names.append(file_name)
            self.data_dict = ut.ibw2dict(self.current_dir + '/' + file_name)
        elif 'zip' in file_name:
            self.opened3D_wd_names.append(file_name)
            self.data3D_dict = ut.read_bin_multi_region(
                self.current_dir, file_name[:-4])

        e_sc = self.data_dict['E_axis'][1] - self.data_dict['E_axis'][0]
        a_sc = self.data_dict['A_axis'][1] - self.data_dict['A_axis'][0]
        e_rg = self.data_dict['E_axis'][-1] - self.data_dict['E_axis'][0]
        a_rg = self.data_dict['A_axis'][-1] - self.data_dict['A_axis'][0]

        e_str = self.data_dict['E_axis'][0]
        a_str = self.data_dict['A_axis'][0]
        e_end = self.data_dict['E_axis'][-1]
        a_end = self.data_dict['A_axis'][-1]

        gr_v = pg.GraphicsView()
        l = pg.GraphicsLayout()
        gr_v.setCentralWidget(l)
        sub.setWidget(gr_v)
        self.ui.mdi.addSubWindow(sub)
        sub.show()

        p1 = l.addPlot(x=[1, 2],
                       y=[1, 2],
                       name="Plot1",
                       title="EDC",
                       pen="r",
                       row=0,
                       col=0)
        #       label1 = pg.LabelItem(justify='right')
        #        p1.addItem(label1)

        plt_i = pg.PlotItem(labels={
            'left': ('slits', 'degrees'),
            'bottom': ('Kin. Energy', 'eV')
        })
        plt_i.setRange(xRange=[e_str, e_end],
                       yRange=[a_str, a_end],
                       update=True,
                       padding=0)

        vb = plt_i.getViewBox()
        vb.setLimits(xMin=e_str, xMax=e_end, yMin=a_str, yMax=a_end)
        vb.setMouseMode(vb.RectMode)

        l.addItem(plt_i, row=1, col=0)
        img_i = pg.ImageItem(self.data_dict['data'], border=None)
        qrect = vb.viewRect()
        img_i.setRect(qrect)
        vb.addItem(img_i)
        vb.autoRange()
        #        vb.invertX()
        vb.invertY()
        hist = pg.HistogramLUTItem(image=img_i)

        l.addItem(hist, row=0, col=1)

        p2 = l.addPlot(x=[1, 2],
                       y=[2, 1],
                       name="Plot2",
                       title="MDC",
                       pen="g",
                       row=1,
                       col=1)
        #        label2 = pg.LabelItem(justify='left')
        #        plt_i.addItem(label2)

        # cross hair
        vLine = pg.InfiniteLine(angle=90, movable=False)
        hLine = pg.InfiniteLine(angle=0, movable=False)
        p1.addItem(vLine, ignoreBounds=False)
        p1.addItem(hLine, ignoreBounds=False)

        vb1 = p1.vb

        pcv = plt_i.addLine(x=e_end, pen='r')
        pch = plt_i.addLine(y=a_str, pen='r')

        def onMouseMoved(point):
            p = vb.mapSceneToView(point)
            pcv.setValue(p.x())
            pch.setValue(p.y())
            #            print(p.x(), p.y())

            hROI = pg.ROI((e_str, p.y()), size=(e_rg, 5 * a_sc))
            vb.addItem(hROI)
            hROI.hide()
            sl, co = hROI.getArrayRegion(self.data_dict['data'],
                                         img_i,
                                         returnMappedCoords=True)
            sl_sum = np.sum(sl, axis=1)
            p1.setXLink(plt_i)
            p1.plot(x=co[0, :, 0], y=sl_sum, clear=True)
            p1.setTitle('EDC, angle ={:.2f}'.format(p.y()))

            vROI = pg.ROI((p.x(), a_str), size=(5 * e_sc, a_rg))
            vb.addItem(vROI)
            vROI.hide()
            slc, coo = vROI.getArrayRegion(self.data_dict['data'],
                                           img_i,
                                           returnMappedCoords=True)
            sl_sum = np.sum(slc, axis=0)
            p2.invertY()
            p2.setYLink(plt_i)
            p2.plot(y=coo[1, 0, :], x=sl_sum, clear=True)
            p2.setTitle('MDC, energy ={:.2f}'.format(p.x()))

        #            label2.setText("{}-{}".format(p.x(), p.y()))

        img_i.scene().sigMouseMoved.connect(onMouseMoved)
Пример #6
0
    def get_data(self, s):
        print('get data')
        if isinstance(s, QMdiSubWindow) and str(
                s.objectName()) in self.opened_wd_names:
            sub = self.mdi.currentSubWindow()
            self.data_dict = ut.ibw2dict(self.current_dir + '/' +
                                         str(s.objectName()))
        elif isinstance(s, QListWidgetItem):
            file_name = s.text()
            self.opened_wd_names.append(file_name)
            MDIWindow.count = MDIWindow.count + 1
            sub = QMdiSubWindow()
            sub.resize(550, 550)
            sub.setWindowTitle(file_name)
            sub.setObjectName(file_name)
            self.data_dict = ut.ibw2dict(self.current_dir + '/' + file_name)
        else:
            print(isinstance(s, QMdiSubWindow), isinstance(s, QListWidgetItem))
            print(type(s))
            return
        e_sc = self.data_dict['E_axis'][1] - self.data_dict['E_axis'][0]
        a_sc = self.data_dict['A_axis'][1] - self.data_dict['A_axis'][0]
        e_rg = self.data_dict['E_axis'][-1] - self.data_dict['E_axis'][0]
        a_rg = self.data_dict['A_axis'][-1] - self.data_dict['A_axis'][0]

        e_str = self.data_dict['E_axis'][0]
        a_str = self.data_dict['A_axis'][0]
        e_end = self.data_dict['E_axis'][-1]
        a_end = self.data_dict['A_axis'][-1]
        print(e_str, a_str)
        print(e_end, a_end)
        print(e_rg, a_rg)
        print(e_sc, a_sc)

        gr_v = pg.GraphicsView()
        l = pg.GraphicsLayout()
        gr_v.setCentralWidget(l)
        sub.setWidget(gr_v)
        self.mdi.addSubWindow(sub)
        sub.show()

        p1 = l.addPlot(x=[1, 2],
                       y=[1, 2],
                       name="Plot1",
                       title="EDC",
                       pen="r",
                       row=0,
                       col=0)
        #       label1 = pg.LabelItem(justify='right')
        #        p1.addItem(label1)

        plt_i = pg.PlotItem(labels={
            'left': ('slits', 'degrees'),
            'bottom': ('Kin. Energy', 'eV')
        })
        plt_i.setRange(xRange=[e_str, e_end],
                       yRange=[a_str, a_end],
                       update=True,
                       padding=0)

        vb = plt_i.getViewBox()
        vb.setLimits(xMin=e_str, xMax=e_end, yMin=a_str, yMax=a_end)

        l.addItem(plt_i, row=1, col=0)
        img_i = pg.ImageItem(self.data_dict['data'], border=None)
        qrect = vb.viewRect()
        img_i.setRect(qrect)
        vb.addItem(img_i)
        vb.autoRange()
        #        vb.invertX()
        vb.invertY()

        p2 = l.addPlot(x=[1, 2],
                       y=[2, 1],
                       name="Plot2",
                       title="MDC",
                       pen="g",
                       row=1,
                       col=1)
        #        label2 = pg.LabelItem(justify='left')
        #        plt_i.addItem(label2)

        # cross hair
        vLine = pg.InfiniteLine(angle=90, movable=False)
        hLine = pg.InfiniteLine(angle=0, movable=False)
        p1.addItem(vLine, ignoreBounds=False)
        p1.addItem(hLine, ignoreBounds=False)

        vb1 = p1.vb

        pcv = plt_i.addLine(x=e_end, pen='r')
        pch = plt_i.addLine(y=a_str, pen='r')

        #        lROI = pg.ROI(((e_str+e_end)/2,a_str), size=(5*e_sc,a_rg))
        #        vb.addItem(lROI)
        #        slice, coor = lROI.getArrayRegion(self.data_dict['data'], img_i ,returnMappedCoords = True)

        #        print('slice')
        #        sl_sum=np.sum(slice, axis=0)
        #        print(sl_sum[0:10])
        #        print(type(slice), slice.shape)
        #        print(type(coor), coor.shape)
        #        print(coor[1,0,0:10])
        #        p2.invertY()
        #        p2.setYLink(plt_i)
        #        p2.plot(y=coor[1,0,:], x=sl_sum)

        def onMouseMoved(point):
            p = vb.mapSceneToView(point)
            pcv.setValue(p.x())
            pch.setValue(p.y())
            #            print(p.x(), p.y())

            hROI = pg.ROI((e_str, p.y()), size=(e_rg, 5 * a_sc))
            vb.addItem(hROI)
            hROI.hide()
            sl, co = hROI.getArrayRegion(self.data_dict['data'],
                                         img_i,
                                         returnMappedCoords=True)
            sl_sum = np.sum(sl, axis=1)
            p1.setXLink(plt_i)
            p1.plot(x=co[0, :, 0], y=sl_sum, clear=True)

            vROI = pg.ROI((p.x(), a_str), size=(5 * e_sc, a_rg))
            vb.addItem(vROI)
            vROI.hide()
            slc, coo = vROI.getArrayRegion(self.data_dict['data'],
                                           img_i,
                                           returnMappedCoords=True)
            sl_sum = np.sum(slc, axis=0)
            p2.invertY()
            p2.setYLink(plt_i)
            p2.plot(y=coo[1, 0, :], x=sl_sum, clear=True)


#            label2.setText("{}-{}".format(p.x(), p.y()))

        img_i.scene().sigMouseMoved.connect(onMouseMoved)