示例#1
0
    def __init__(self,
                 data,
                 x=None,
                 plugin=None,
                 mpl_kwargs={
                     'width': 8,
                     'height': 2
                 },
                 parent=None):
        super(DialogPlotEffect, self).__init__(parent)
        self.ui = Ui_DialogPlotEffect()
        self.ui.setupUi(self)

        self.data = data

        # Setup MPL containers
        self.mpl_orig = _MplCanvas(subplot=111, **mpl_kwargs)
        self.mpl_orig.fig.canvas.setMinimumSize(100, 200)
        self.mpl_orig.fig.canvas.setSizePolicy(
            _QtWidgets.QSizePolicy.Expanding, _QtWidgets.QSizePolicy.Minimum)

        self.mpl_affected = _MplCanvas(subplot=111, **mpl_kwargs)
        self.mpl_affected.fig.canvas.setMinimumSize(100, 200)
        self.mpl_affected.fig.canvas.setSizePolicy(
            _QtWidgets.QSizePolicy.Expanding, _QtWidgets.QSizePolicy.Minimum)

        # Show(), although not needed, enables mpl-tight_layout
        # to work later on
        self.show()

        self.ui.verticalLayout.insertWidget(1, self.mpl_orig, stretch=1)
        self.ui.verticalLayout.insertWidget(1, self.mpl_orig.toolbar)

        self.ui.verticalLayout.insertWidget(3, self.mpl_affected)
        self.ui.verticalLayout.insertWidget(3, self.mpl_affected.toolbar)

        # Plugin that brings functionality to PlotEffect
        self.plugin = plugin

        # Signal emited when something changes in the plugin widget
        self.plugin.changed.connect(self.widget_changed)

        # Setup indep. variable
        if x is None:
            self.x = _np.linspace(0, data.shape[0], self.data.shape[0])
        else:
            self.x = x

        self.make_orig_plots(self.data)

        if self.plugin is not None:
            self.ui.verticalLayout.insertWidget(8, plugin)

        self.show()
        self.widget_changed()
        self.mpl_orig.draw()
        self.mpl_affected.draw()

        self.ui.pushButtonOk.clicked.connect(self.accept)
        self.ui.pushButtonCancel.clicked.connect(self.reject)
示例#2
0
    def __init__(self, data, x=None, plugin=None, parent=None):
        super(DialogPlotEffectFuture, self).__init__(parent)
        self.ui = Ui_DialogPlotEffect()
        self.ui.setupUi(self)

        self.data = data

        # Setup MPL containers
        self.mpl_orig = _MplCanvas(subplot=111)
        self.mpl_affected = _MplCanvas(subplot=111)

        # Show(), although not needed, enables mpl-tight_layout
        # to work later on
        self.show()

        self.ui.verticalLayout.insertWidget(1, self.mpl_orig)
        self.ui.verticalLayout.insertWidget(1, self.mpl_orig.toolbar)

        self.ui.verticalLayout.insertWidget(3, self.mpl_affected)
        self.ui.verticalLayout.insertWidget(3, self.mpl_affected.toolbar)

        # Plugin that brings functionality to PlotEffect
        self.plugin = plugin

        # Signal emited when something changes in the plugin widget
        self.plugin.changed.connect(self.widget_changed)

        # Setup indep. variable
        if x is None:
            self.x = _np.linspace(0, data.shape[0], self.data.shape[0])
        else:
            self.x = x

        # If data is a list (assumed to be a list of ndarrays),
        # plot each item in list
        if isinstance(data, _np.ndarray):
            try:
                self.mpl_orig.ax.plot(self.x, data)
            except:
                self.mpl_orig.ax.plot(self.x, data.T)
        elif isinstance(data, list):
            for d in data:
                try:
                    self.mpl_orig.ax.plot(self.x, d)
                except:
                    self.mpl_orig.ax.plot(self.x, d.T)

        self.plot_labels()

        if self.plugin is not None:
            self.ui.verticalLayout.insertWidget(8, plugin)

        self.show()
        self.widget_changed()
        self.mpl_orig.draw()
        self.mpl_affected.draw()

        self.ui.pushButtonOk.clicked.connect(self.accept)
        self.ui.pushButtonCancel.clicked.connect(self.reject)
示例#3
0
    def setup(self, parent=None):

        # Generic load/init designer-based GUI
        # super(DialogAbstractFactorization, self).__init__(parent) ### EDIT ###

        self.ui = Ui_Dialog()  ### EDIT ###
        self.ui.setupUi(self)  ### EDIT ###

        self.ui.pushButtonNext.clicked.connect(self.advance)
        self.ui.pushButtonPrev.clicked.connect(self.advance)
        self.ui.pushButtonGoTo.clicked.connect(self.advance)
        self.ui.pushButtonCancel.clicked.connect(self.reject)
        self.ui.pushButtonOk.clicked.connect(self.accept)
        self.ui.pushButtonClear.clicked.connect(self.clear)
        self.ui.pushButtonApply.clicked.connect(self.applyCheckBoxes)
        self.ui.pushButtonScript.clicked.connect(self.runScript)

        self._first_factor_visible = 0
        self._num_factor_visible = 6

        self.ui.lcdSelectedFactors.display(0)
        self.ui.lcdMaxFactors.display(self.max_factors())

        self.factorWins = []
        self.factorLabelCheckBoxes = [
            self.ui.checkBox, self.ui.checkBox_2, self.ui.checkBox_3,
            self.ui.checkBox_4, self.ui.checkBox_5, self.ui.checkBox_6
        ]

        for count in range(self._num_factor_visible):
            self.factorWins.append(_MplCanvas(subplot=211))
            self.factorWins[count].ax[0].axis('Off')
            if self._mpl_v1:
                self.factorWins[count].ax[1].hold('Off')

        self.ui.gridLayout.addWidget(self.factorWins[0], 1, 0)
        self.ui.gridLayout.addWidget(self.factorWins[1], 1, 1)
        self.ui.gridLayout.addWidget(self.factorWins[2], 1, 2)

        self.ui.gridLayout.addWidget(self.factorWins[3], 3, 0)
        self.ui.gridLayout.addWidget(self.factorWins[4], 3, 1)
        self.ui.gridLayout.addWidget(self.factorWins[5], 3, 2)

        self.reconCurrent = _MplCanvas(subplot=211)
        self.reconCurrent.ax[0].axis('Off')
        if self._mpl_v1:
            self.reconCurrent.ax[1].hold('Off')

        self.reconRemainder = _MplCanvas(subplot=211)
        self.reconRemainder.ax[0].axis('Off')
        if self._mpl_v1:
            self.reconRemainder.ax[1].hold('Off')

        self.ui.verticalLayout_3.insertWidget(1, self.reconCurrent)
        self.ui.verticalLayout_3.insertWidget(-1, self.reconRemainder)

        for count in range(self._num_factor_visible):
            self.factorLabelCheckBoxes[count].setText('Keep: ' + str(count))
    def setup(self, parent = None):

        # Generic load/init designer-based GUI
        # super(DialogAbstractFactorization, self).__init__(parent) ### EDIT ###

        self.ui = Ui_Dialog() ### EDIT ###
        self.ui.setupUi(self)     ### EDIT ###

        self.ui.pushButtonNext.clicked.connect(self.advance)
        self.ui.pushButtonPrev.clicked.connect(self.advance)
        self.ui.pushButtonGoTo.clicked.connect(self.advance)
        self.ui.pushButtonCancel.clicked.connect(self.reject)
        self.ui.pushButtonOk.clicked.connect(self.accept)
        self.ui.pushButtonClear.clicked.connect(self.clear)
        self.ui.pushButtonApply.clicked.connect(self.applyCheckBoxes)
        self.ui.pushButtonScript.clicked.connect(self.runScript)

        self._first_factor_visible = 0
        self._num_factor_visible = 6

        self.ui.lcdSelectedFactors.display(0)
        self.ui.lcdMaxFactors.display(self.max_factors())

        self.factorWins = []
        self.factorLabelCheckBoxes = [self.ui.checkBox,
                                  self.ui.checkBox_2,
                                  self.ui.checkBox_3,
                                  self.ui.checkBox_4,
                                  self.ui.checkBox_5,
                                  self.ui.checkBox_6]

        for count in range(self._num_factor_visible):
            self.factorWins.append(_MplCanvas(subplot=211))
            self.factorWins[count].ax[0].axis('Off')
            self.factorWins[count].ax[1].hold('Off')

        self.ui.gridLayout.addWidget(self.factorWins[0],1,0)
        self.ui.gridLayout.addWidget(self.factorWins[1],1,1)
        self.ui.gridLayout.addWidget(self.factorWins[2],1,2)

        self.ui.gridLayout.addWidget(self.factorWins[3],3,0)
        self.ui.gridLayout.addWidget(self.factorWins[4],3,1)
        self.ui.gridLayout.addWidget(self.factorWins[5],3,2)

        self.reconCurrent = _MplCanvas(subplot=211)
        self.reconCurrent.ax[0].axis('Off')
        self.reconCurrent.ax[1].hold('Off')

        self.reconRemainder = _MplCanvas(subplot=211)
        self.reconRemainder.ax[0].axis('Off')
        self.reconRemainder.ax[1].hold('Off')


        self.ui.verticalLayout_3.insertWidget(1,self.reconCurrent)
        self.ui.verticalLayout_3.insertWidget(-1,self.reconRemainder)

        for count in range(self._num_factor_visible):
            self.factorLabelCheckBoxes[count].setText('Keep: ' + str(count))
示例#5
0
    def setup(self, limit_to=None, parent=None):
        """
        Basic UI setup
        """

        # Generic start to any pyQT program

        super(SciPlotUI, self).__init__(parent)
        self.ui = Ui_Plotter()
        self.ui.setupUi(self)
        self.setSizePolicy(_QSizePolicy.Expanding, _QSizePolicy.Expanding)

        # Global "data" i.e., title, x-label, y-label, etc
        self._global_data = _DataGlobal()

        # MPL plot widget
        self.mpl_widget = _MplCanvas(height=6, dpi=100)

        # Hold is deprecated in MPL2
        if not self._mpl_v2:
            self.mpl_widget.ax.hold(True)

        # Insert MPL widget and toolbar
        self.ui.verticalLayout.insertWidget(0, self.mpl_widget)
        self.ui.verticalLayout.insertWidget(0, self.mpl_widget.toolbar)
        self.updateAxisParameters()
        self.mpl_widget.draw()

        # Insert TabWidget
        self.ui.modelTabWidget = _QTabWidget()
        self.ui.verticalLayout.insertWidget(-1, self.ui.modelTabWidget)

        # Setup what tabs are available:
        self._tabAvailability(limit_to)
        for count in self._to_setup:
            count()

        # SIGNALS AND SLOTS

        # Global labels
        self.ui.lineEditTitle.editingFinished.connect(
            self.updateLabelsFromLineEdit)
        self.ui.lineEditXLabel.editingFinished.connect(
            self.updateLabelsFromLineEdit)
        self.ui.lineEditYLabel.editingFinished.connect(
            self.updateLabelsFromLineEdit)

        # Non-tracked (not saved) properties
        self.ui.comboBoxAspect.currentIndexChanged.connect(self.axisAspect)
        self.ui.comboBoxAxisScaling.currentIndexChanged.connect(
            self.axisScaling)
        self.ui.checkBoxAxisVisible.stateChanged.connect(self.axisVisible)
        self.ui.lineEditXLimMin.editingFinished.connect(self.axisLimits)
        self.ui.lineEditXLimMax.editingFinished.connect(self.axisLimits)
        self.ui.lineEditYLimMin.editingFinished.connect(self.axisLimits)
        self.ui.lineEditYLimMax.editingFinished.connect(self.axisLimits)

        # Actions
        self.ui.pushButtonClearAll.pressed.connect(self.clearAll)
        self.ui.pushButtonDefaultView.pressed.connect(self.defaultView)
示例#6
0
    def setup(self, limit_to=None, parent=None):
        """
        Basic UI setup
        """

        # Generic start to any pyQT program
        
        
        super(SciPlotUI, self).__init__(parent)
        self.ui = Ui_Plotter()
        self.ui.setupUi(self)
        self.setSizePolicy(_QSizePolicy.Expanding,
                           _QSizePolicy.Expanding)

        # Global "data" i.e., title, x-label, y-label, etc
        self._global_data = _DataGlobal()

        # MPL plot widget
        self.mpl_widget = _MplCanvas(height=6, dpi=100)

        # Hold is deprecated in MPL2
        if not self._mpl_v2:
            self.mpl_widget.ax.hold(True)

        # Insert MPL widget and toolbar
        self.ui.verticalLayout.insertWidget(0, self.mpl_widget)
        self.ui.verticalLayout.insertWidget(0, self.mpl_widget.toolbar)
        self.updateAxisParameters()
        self.mpl_widget.draw()

        # Insert TabWidget
        self.ui.modelTabWidget = _QTabWidget()
        self.ui.verticalLayout.insertWidget(-1, self.ui.modelTabWidget)

        # Setup what tabs are available:
        self._tabAvailability(limit_to)
        for count in self._to_setup:
            count()

        # SIGNALS AND SLOTS
        
        # Global labels
        self.ui.lineEditTitle.editingFinished.connect(self.updateLabelsFromLineEdit)
        self.ui.lineEditXLabel.editingFinished.connect(self.updateLabelsFromLineEdit)
        self.ui.lineEditYLabel.editingFinished.connect(self.updateLabelsFromLineEdit)

        # Non-tracked (not saved) properties
        self.ui.comboBoxAspect.currentIndexChanged.connect(self.axisAspect)
        self.ui.comboBoxAxisScaling.currentIndexChanged.connect(self.axisScaling)
        self.ui.checkBoxAxisVisible.stateChanged.connect(self.axisVisible)
        self.ui.lineEditXLimMin.editingFinished.connect(self.axisLimits)
        self.ui.lineEditXLimMax.editingFinished.connect(self.axisLimits)
        self.ui.lineEditYLimMin.editingFinished.connect(self.axisLimits)
        self.ui.lineEditYLimMax.editingFinished.connect(self.axisLimits)
        
        # Actions
        self.ui.pushButtonClearAll.pressed.connect(self.clearAll)
        self.ui.pushButtonDefaultView.pressed.connect(self.defaultView)
示例#7
0
    def __init__(self, sgl_color_widget_list = None, parent = None, **kwargs):
        super(widgetCompositeColor, self).__init__(parent)
        ## Double check the spellings
        self._img_defaults = {'showcbar':False, 'axison':True}
        self.ui = Ui_CompositeColor_Form()
        self.ui.setupUi(self)

        # Initialize underlying data
        self.initData(sgl_color_widget_list)
        self.external_plots = []

        # Create stand-in image data
        self.data.grayscaleimage = _np.dot(_np.ones([100,1]),_np.linspace(1,100,100)[None,:])
        self.data.set_x(_np.linspace(1,400,self.data.xlen))
        self.data.set_y(_np.linspace(1,400,self.data.ylen))
        
        winextent = (self.data.x.min(), self.data.x.max(), self.data.y.min(), self.data.y.max())

        # Instantiate mpl widget
        self.mpl = _MplCanvas(**kwargs)
        self.mpl.cbar = None  # Monkey patch on a cbar object

        # Background color-related
        # Get all MPL named colors
        color_list = ['black', 'white', 'CUSTOM', 'red', 'green', 'blue',
                      'magenta', 'cyan', 'yellow']
        color_list.extend(sorted(set(_mpl.colors.cnames.keys()) - set(color_list)))
        self.ui.comboBoxBGColor.addItems(color_list)
        self.ui.comboBoxBGColor.setCurrentIndex(color_list.index('black'))
        
        # Emission/Absorption mode settings
        self.ui.comboBoxColorMode.setCurrentIndex(0)  # Emission mode is default

        # Create stand-in image data
        self.createImg(img = self.data.image, xunits = self.data.xunits,
                              yunits = self.data.yunits,
                              extent = winextent)
        self.mpl.fig.tight_layout()

        # Insert mpl widget into this widget
        self.ui.verticalLayout.insertWidget(0,self.mpl,_QtCore.Qt.AlignHCenter)
        self.ui.verticalLayout.insertWidget(0,self.mpl.toolbar, _QtCore.Qt.AlignHCenter)

        self.popimage = widgetPopSpectrumGS(self)
        self.ui.verticalLayout.insertWidget(1, self.popimage, _QtCore.Qt.AlignLeft)
        self.popimage.ui.pushButtonPop.pressed.connect(lambda: self.createImg_Ext(img = self.data.image,
                                                                                  showcbar=False,
                                                                                  extent=self.data.winextent, 
                                                                                  xunits=self.data.xunits,
                                                                                  yunits=self.data.yunits,
                                                                                  parent=parent))
        self.popimage.ui.pushButtonGSPop.setEnabled(False)
        self.popimage.ui.pushButtonSpectrum.setEnabled(False)
        self.ui.comboBoxBGColor.setEnabled(False)
        self.ui.comboBoxBGColor.setVisible(False)  # Broken -- don't know if it will ever work
        self.ui.labelBGColor.setVisible(False)  # Broken
        self.ui.comboBoxColorMode.currentIndexChanged.connect(self.changeMode)
示例#8
0
    def __init__(self, parent=None, **kwargs):
        super(widgetBWImg, self).__init__(parent)
        self.ui = Ui_BWImage_Form()
        self.ui.setupUi(self)

        # Initialize underlying data
        self.initData()

        # Stand-in image data
        self.data.grayscaleimage = _np.dot(_np.ones([100, 1]),
                                           _np.linspace(1, 100, 100)[None, :])
        self.data.set_x(_np.linspace(1, 400, self.data.xlen))
        self.data.set_y(_np.linspace(1, 400, self.data.ylen))

        # Calculate extent of image
        winextent = (self.data.x.min(), self.data.x.max(), self.data.y.min(),
                     self.data.y.max())

        # MPL canvas
        self.mpl = _MplCanvas(**kwargs)
        self.mpl.cbar = None  # Monkey patch on a cbar object

        # Create stand-image plot
        self.createImg(img=self.data.image,
                       xunits=self.data.xunits,
                       yunits=self.data.yunits,
                       extent=winextent,
                       showcbar=True,
                       axison=True)
        self.mpl.fig.tight_layout()

        # Insert canvas widget into this widget
        self.ui.verticalLayout.insertWidget(0, self.mpl,
                                            _QtCore.Qt.AlignHCenter)
        self.ui.verticalLayout.insertWidget(0, self.mpl.toolbar,
                                            _QtCore.Qt.AlignHCenter)

        # SIGNAL & SLOTS
        self.ui.checkBoxFixed.stateChanged.connect(self.checkBoxFixed)
        self.ui.checkBoxCompress.stateChanged.connect(self.checkBoxCompress)
        self.ui.checkBoxRemOutliers.stateChanged.connect(
            self.checkBoxRemOutliers)
        self.ui.spinBoxStdDevs.valueChanged.connect(
            self.spinBoxOutliersChanged)
        self.ui.lineEditMin.editingFinished.connect(self.textEditMinMaxSet)
        self.ui.lineEditMax.editingFinished.connect(self.textEditMinMaxSet)
示例#9
0
    def __init__(self, sgl_color_widget_list=None, parent=None, **kwargs):
        super(widgetCompositeColor, self).__init__(parent)
        self.ui = Ui_CompositeColor_Form()
        self.ui.setupUi(self)

        # Initialize underlying data
        self.initData(sgl_color_widget_list)

        # Create stand-in image data
        self.data.grayscaleimage = _np.dot(_np.ones([100, 1]),
                                           _np.linspace(1, 100, 100)[None, :])
        self.data.set_x(_np.linspace(1, 400, self.data.xlen))
        self.data.set_y(_np.linspace(1, 400, self.data.ylen))
        winextent = (self.data.x.min(), self.data.x.max(), self.data.y.min(),
                     self.data.y.max())

        # Instantiate mpl widget
        self.mpl = _MplCanvas(**kwargs)
        self.mpl.cbar = None  # Monkey patch on a cbar object

        # Create stand-in image data
        self.createImg(img=self.data.image,
                       xunits=self.data.xunits,
                       yunits=self.data.yunits,
                       extent=winextent,
                       showcbar=False,
                       axison=True)
        self.mpl.fig.tight_layout()

        # Insert mpl widget into this widget
        self.ui.verticalLayout.insertWidget(0, self.mpl,
                                            _QtCore.Qt.AlignHCenter)
        self.ui.verticalLayout.insertWidget(0, self.mpl.toolbar,
                                            _QtCore.Qt.AlignHCenter)

        # SIGNALS & SLOTS
        self.ui.checkBoxFixed.stateChanged.connect(self.checkBoxFixed)
        self.ui.checkBoxCompress.stateChanged.connect(self.checkBoxCompress)
        self.ui.checkBoxRemOutliers.stateChanged.connect(
            self.checkBoxRemOutliers)
        self.ui.spinBoxStdDevs.valueChanged.connect(
            self.spinBoxOutliersChanged)
示例#10
0
    def __init__(self, parent = None, **kwargs):
        super().__init__(parent)
        self.win = Ui_Blank()
        self.win.setupUi(self)
        self.win.gridLayout.setEnabled(False)
        
        self._img_defaults = {'showcbar': True, 'axison': True}

        self.gsinfo = widgetGrayScaleInfoBar(parent=self)
        
        self.colormode = widgetColorMode(parent=self)
        self.colormode.ui.comboBoxColorMode.setCurrentIndex(1)
        self.colormode.ui.comboBoxColormap.setVisible(True)
        self.colormode.ui.labelColormap.setVisible(True)
        self.colormode.ui.comboBoxFGColor.setVisible(False)
        self.colormode.ui.comboBoxBGColor.setVisible(False)
        self.colormode.ui.comboBoxColorMode.setVisible(False)
        self.colormode.ui.labelBGColor.setVisible(False)
        self.colormode.ui.labelFGColor.setVisible(False)
        self.colormode.ui.labelColorMode.setVisible(False)

        self.popimage = widgetPopSpectrumGS(parent=self)
        self.popimage.ui.pushButtonGSPop.setVisible(False)

        self.ui = self.gsinfo.ui  # Alias

        self.win.horizLayout = _QHBoxLayout()
        self.win.horizLayout.setContentsMargins(2,2,2,2)

        self.win.verticalLayout.insertLayout(0, self.win.horizLayout)
        
        self.win.horizLayout.insertWidget(0, self.gsinfo, _QtCore.Qt.AlignHCenter)
        self.win.horizLayout.insertWidget(0, self.colormode, _QtCore.Qt.AlignBottom)

        # Initialize underlying data
        self.initData()
        self.external_plots = []

        # Stand-in image data
        self.data.grayscaleimage = _np.dot(_np.ones([100,1]),_np.linspace(1,100,100)[None,:])
        self.data.set_x(_np.linspace(1,400,self.data.xlen))
        self.data.set_y(_np.linspace(1,400,self.data.ylen))
        
        # Calculate extent of image
        winextent = (self.data.x.min(), self.data.x.max(), self.data.y.min(), self.data.y.max())

        # MPL canvas
        self.mpl = _MplCanvas(**kwargs)
        self.mpl.cbar = None  # Monkey patch on a cbar object
        
        # Create stand-image plot
        self.createImg(img=self.data.image, xunits=self.data.xunits,
                       yunits=self.data.yunits,
                       extent=winextent,
                       cmap=self.colormode.ui.comboBoxColormap.currentText())
        self.mpl.fig.tight_layout()
        
        # Insert canvas widget into this widget
        self.win.verticalLayout.insertWidget(0,self.mpl,_QtCore.Qt.AlignCenter)
        self.win.verticalLayout.insertWidget(0,self.popimage,_QtCore.Qt.AlignCenter)
        self.win.verticalLayout.insertWidget(0,self.mpl.toolbar, _QtCore.Qt.AlignHCenter)

        # # SIGNAL & SLOTS
        self.ui.checkBoxFixed.stateChanged.connect(self.checkBoxFixed)
        self.ui.checkBoxRemOutliers.stateChanged.connect(self.checkBoxRemOutliers)
        self.ui.spinBoxStdDevs.editingFinished.connect(self.checkBoxRemOutliers)
        
        # New
        self.ui.comboBoxAboveMax.currentIndexChanged.connect(self.comboBoxCompress)
        self.ui.comboBoxBelowMin.currentIndexChanged.connect(self.comboBoxCompress)
        self.ui.spinBoxMax.editingFinished.connect(self.spinBoxMinMaxSet)
        self.ui.spinBoxMin.editingFinished.connect(self.spinBoxMinMaxSet)
        self.colormode.ui.comboBoxColormap.currentIndexChanged.connect(self.checkBoxFixed)
        self.popimage.ui.pushButtonPop.pressed.connect(lambda: self.createImg_Ext(img=self.data.image,
                                                      cmap=self.colormode.ui.comboBoxColormap.currentText(),
                                                      showcbar=True,
                                                      extent=self.data.winextent,
                                                      xunits=self.data.xunits,
                                                      yunits=self.data.yunits,
                                                      parent=parent))
示例#11
0
    def __init__(self, data=None, parent=None):

        # Generic load/init designer-based GUI
        super(DialogSVD, self).__init__(parent)  ### EDIT ###

        self.ui = Ui_Dialog()  ### EDIT ###
        self.ui.setupUi(self)  ### EDIT ###

        self.ui.pushButtonNext.clicked.connect(self.advance)
        self.ui.pushButtonPrev.clicked.connect(self.advance)
        self.ui.pushButtonGoTo.clicked.connect(self.advance)
        self.ui.pushButtonCancel.clicked.connect(self.reject)
        self.ui.pushButtonOk.clicked.connect(self.accept)
        self.ui.pushButtonClear.clicked.connect(self.clear)
        self.ui.pushButtonApply.clicked.connect(self.applyCheckBoxes)
        self.ui.pushButtonScript.clicked.connect(self.runScript)

        self.firstSV = 0
        self.spanSV = 6

        self.Mlen = 0
        self.Nlen = 0
        self.Olen = 0

        self.data = _np.zeros([self.Mlen, self.Nlen, self.Olen])

        self.selected_svs = set()
        self.ui.lcdSelectedFactors.display(len(self.selected_svs))

        self.svWins = []
        self.svLabelCheckBoxes = [
            self.ui.checkBox, self.ui.checkBox_2, self.ui.checkBox_3,
            self.ui.checkBox_4, self.ui.checkBox_5, self.ui.checkBox_6
        ]

        for count in range(self.spanSV):
            self.svWins.append(_MplCanvas(subplot=211))
            self.svWins[count].ax[0].axis('Off')
            self.svWins[count].ax[1].hold('Off')

        self.ui.gridLayout.addWidget(self.svWins[0], 1, 0)
        self.ui.gridLayout.addWidget(self.svWins[1], 1, 1)
        self.ui.gridLayout.addWidget(self.svWins[2], 1, 2)

        self.ui.gridLayout.addWidget(self.svWins[3], 3, 0)
        self.ui.gridLayout.addWidget(self.svWins[4], 3, 1)
        self.ui.gridLayout.addWidget(self.svWins[5], 3, 2)

        self.reconCurrent = _MplCanvas(subplot=211)
        self.reconCurrent.ax[0].axis('Off')
        self.reconCurrent.ax[1].hold('Off')

        self.reconRemainder = _MplCanvas(subplot=211)
        self.reconRemainder.ax[0].axis('Off')
        self.reconRemainder.ax[1].hold('Off')

        self.ui.verticalLayout_3.insertWidget(1, self.reconCurrent)
        self.ui.verticalLayout_3.insertWidget(4, self.reconRemainder)

        for count in range(self.spanSV):
            self.svLabelCheckBoxes[count].setText('Keep: ' + str(count))

        if data is not None:
            self.data = data
            if data.ndim == 3:
                self.Mlen, self.Nlen, self.Olen = data.shape
                self.reconCurrent.ax[0].imshow(_np.mean(data, axis=-1),
                                               interpolation='none',
                                               origin='lower')
                self.reconCurrent.draw()

                data = data.reshape([-1, self.Olen])

                self.svddata = self.SvdData()
                self.svddata.orig_shape = [self.Mlen, self.Nlen, self.Olen]
                self.svddata.U, self.svddata.S, self.svddata.Vh = _svd(
                    data, full_matrices=False)

                self.maxsvs = self.svddata.S.size

                self.ui.lcdMaxFactors.display(self.maxsvs)
                self.ui.spinBoxGoTo.setMaximum(self.maxsvs)

                self.updateCurrentRemainder()

                #print('U: {}, S: {}, Vh: {}'.format(self.svddata.U.shape, self.svddata.S.shape, self.svddata.Vh.shape))

                self.updateSVPlots()
示例#12
0
    def __init__(self, parent=None, **kwargs):
        super(widgetSglColor, self).__init__(parent)
        self.ui = Ui_SglColorImage_Form()
        self.math = widgetColorMath()
        self.ui.setupUi(self)
        for color in self.COLORMAP_ORDER:
            self.ui.comboBox.addItem(color)

        # Initialize data
        self.initData()
        self.data.colormap = self.COLORMAPS[self.ui.comboBox.currentText()]
        self.external_plots = []

        # Create stand-in imahe
        self.data.grayscaleimage = _np.dot(_np.ones([100, 1]),
                                           _np.linspace(1, 100, 100)[None, :])
        self.data.set_x(_np.linspace(1, 400, self.data.xlen))
        self.data.set_y(_np.linspace(1, 400, self.data.ylen))

        # Instantiate MPL widget
        self.mpl = _MplCanvas(**kwargs)
        self.mpl.cbar = None  # Monkey patch on a cbar object

        self.createImg(img=self.data.image,
                       xunits=self.data.xunits,
                       yunits=self.data.yunits,
                       extent=self.data.winextent,
                       showcbar=False,
                       axison=False)

        self.mpl.fig.tight_layout()

        # Embed MPL widget into this widget
        self.ui.horizontalLayoutGainImg.addWidget(self.mpl)
        self.ui.verticalLayoutMain.insertWidget(1, self.mpl.toolbar,
                                                _QtCore.Qt.AlignVCenter)
        self.ui.verticalLayoutMain.addWidget(self.math)

        # SIGNALS & SLOTS
        self.ui.comboBox.currentIndexChanged.connect(self.changeColor)
        self.math.ui.lineEditMin.editingFinished.connect(
            self.textEditMinMaxSet)
        self.math.ui.lineEditMax.editingFinished.connect(
            self.textEditMinMaxSet)
        self.ui.gainSlider.valueChanged.connect(self.gainSliderChanged)
        self.ui.pushButtonGain1.pressed.connect(self.gain1)
        self.math.ui.checkBoxFixed.stateChanged.connect(self.checkBoxFixed)
        self.math.ui.checkBoxCompress.stateChanged.connect(
            self.checkBoxCompress)

        self.ui.pushButtonPop.pressed.connect(
            lambda: self.createImg_Ext(img=self.data.image,
                                       showcbar=False,
                                       extent=self.data.winextent,
                                       xunits=self.data.xunits,
                                       yunits=self.data.yunits))

        self.ui.pushButtonGSPop.pressed.connect(
            lambda: self.createImg_Ext(img=self.data.imageGS,
                                       showcbar=True,
                                       extent=self.data.winextent,
                                       xunits=self.data.xunits,
                                       yunits=self.data.yunits))
示例#13
0
    def __init__(self, data=None, parent = None):

        # Generic load/init designer-based GUI
        super(DialogSVD, self).__init__(parent) ### EDIT ###

        self.ui = Ui_Dialog() ### EDIT ###
        self.ui.setupUi(self)     ### EDIT ###

        self.ui.pushButtonNext.clicked.connect(self.advance)
        self.ui.pushButtonPrev.clicked.connect(self.advance)
        self.ui.pushButtonGoTo.clicked.connect(self.advance)
        self.ui.pushButtonCancel.clicked.connect(self.reject)
        self.ui.pushButtonOk.clicked.connect(self.accept)
        self.ui.pushButtonClear.clicked.connect(self.clear)
        self.ui.pushButtonApply.clicked.connect(self.applyCheckBoxes)
        self.ui.pushButtonScript.clicked.connect(self.runScript)

        self.firstSV = 0
        self.spanSV = 6

        self.Mlen = 0
        self.Nlen = 0
        self.Olen = 0

        self.data = _np.zeros([self.Mlen, self.Nlen, self.Olen])

        self.selected_svs = set()
        self.ui.lcdSelectedFactors.display(len(self.selected_svs))

        self.svWins = []
        self.svLabelCheckBoxes = [self.ui.checkBox,
                                  self.ui.checkBox_2,
                                  self.ui.checkBox_3,
                                  self.ui.checkBox_4,
                                  self.ui.checkBox_5,
                                  self.ui.checkBox_6]

        for count in range(self.spanSV):
            self.svWins.append(_MplCanvas(subplot=211))
            self.svWins[count].ax[0].axis('Off')
            self.svWins[count].ax[1].hold('Off')

        self.ui.gridLayout.addWidget(self.svWins[0],1,0)
        self.ui.gridLayout.addWidget(self.svWins[1],1,1)
        self.ui.gridLayout.addWidget(self.svWins[2],1,2)

        self.ui.gridLayout.addWidget(self.svWins[3],3,0)
        self.ui.gridLayout.addWidget(self.svWins[4],3,1)
        self.ui.gridLayout.addWidget(self.svWins[5],3,2)

        self.reconCurrent = _MplCanvas(subplot=211)
        self.reconCurrent.ax[0].axis('Off')
        self.reconCurrent.ax[1].hold('Off')

        self.reconRemainder = _MplCanvas(subplot=211)
        self.reconRemainder.ax[0].axis('Off')
        self.reconRemainder.ax[1].hold('Off')


        self.ui.verticalLayout_3.insertWidget(1,self.reconCurrent)
        self.ui.verticalLayout_3.insertWidget(4,self.reconRemainder)

        for count in range(self.spanSV):
            self.svLabelCheckBoxes[count].setText('Keep: ' + str(count))

        if data is not None:
            self.data = data
            if data.ndim == 3:
                self.Mlen, self.Nlen, self.Olen = data.shape
                self.reconCurrent.ax[0].imshow(_np.mean(data, axis=-1),interpolation='none', origin='lower')
                self.reconCurrent.draw()

                data = data.reshape([-1, self.Olen])

                self.svddata = self.SvdData()
                self.svddata.orig_shape = [self.Mlen, self.Nlen, self.Olen]
                self.svddata.U, self.svddata.S, self.svddata.Vh = _svd(data, full_matrices=False)

                self.maxsvs = self.svddata.S.size

                self.ui.lcdMaxFactors.display(self.maxsvs)
                self.ui.spinBoxGoTo.setMaximum(self.maxsvs)

                self.updateCurrentRemainder()

               #print('U: {}, S: {}, Vh: {}'.format(self.svddata.U.shape, self.svddata.S.shape, self.svddata.Vh.shape))

                self.updateSVPlots()
示例#14
0
    def __init__(self, parent=None):
        super(MainWindowMosaic, self).__init__(parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.setupListWidget()

        self.ui.spinBoxIntercept.setValue(self.frequency_calib['Intercept'])
        self.ui.spinBoxSlope.setValue(self.frequency_calib['Slope'])
        self.ui.spinBoxProbe.setValue(self.frequency_calib['Probe'])
        self.ui.spinBoxCalibWL.setValue(self.frequency_calib['Calib_WL'])
        self.ui.spinBoxCenterWL.setValue(self.frequency_calib['Center_WL'])

        # Internal data
        self.init_internals()

        self.mpl = _MplCanvas(parent=self)
        self.ui.verticalLayoutMPL.insertWidget(0, self.mpl,
                                               _QtCore.Qt.AlignCenter)
        self.ui.verticalLayoutMPL.insertWidget(0, self.mpl.toolbar,
                                               _QtCore.Qt.AlignHCenter)

        # SIGNALS AND SLOTS
        self.ui.actionAddFromHDF.triggered.connect(self.addDataset)
        self.ui.pushButtonAddDataset.pressed.connect(self.addDataset)

        self.ui.actionSaveToHDF5.triggered.connect(self.save)

        self.ui.sliderFreq.valueChanged.connect(self.updateSlider)
        self.ui.sliderFreq.sliderReleased.connect(self.updateMosaicImage)

        self.ui.lineEditPix.editingFinished.connect(self.lineEditPixChange)

        self.ui.spinBoxMRows.editingFinished.connect(self.updateParams)
        self.ui.spinBoxNCols.editingFinished.connect(self.updateParams)
        self.ui.comboBoxRowCol.currentIndexChanged.connect(self.updateParams)
        self.ui.checkBoxFlipH.stateChanged.connect(self.updateParams)
        self.ui.checkBoxFlipV.stateChanged.connect(self.updateParams)
        self.ui.checkBoxTranspose.stateChanged.connect(self.updateParams)
        self.ui.spinBoxStartRow.editingFinished.connect(self.updateParams)
        self.ui.spinBoxStartCol.editingFinished.connect(self.updateParams)
        self.ui.spinBoxEndRow.editingFinished.connect(self.updateParams)
        self.ui.spinBoxEndCol.editingFinished.connect(self.updateParams)

        # ! Currently, cannot save compress in HDF5
        self.ui.checkBoxCompress.setEnabled(False)
        # self.ui.checkBoxCompress.stateChanged.connect(self.updateParams)

        self.ui.spinBoxSlope.editingFinished.connect(self.updateFrequency)
        self.ui.spinBoxIntercept.editingFinished.connect(self.updateFrequency)
        self.ui.spinBoxProbe.editingFinished.connect(self.updateFrequency)
        self.ui.spinBoxCalibWL.editingFinished.connect(self.updateFrequency)
        self.ui.spinBoxCenterWL.editingFinished.connect(self.updateFrequency)

        # self.ui.spinBoxXStepSize.editingFinished.connect(self.updateSpace)
        # self.ui.spinBoxYStepSize.editingFinished.connect(self.updateSpace)

        self.ui.pushButtonMoveUp.pressed.connect(self.promote_demote_list_item)
        self.ui.pushButtonMoveDown.pressed.connect(
            self.promote_demote_list_item)
        self.ui.pushButtonDeleteDataset.pressed.connect(self.deleteDataset)

        self.ui.listWidgetDatasets.reordered.connect(self.list_reordered)

        # Close event
        self.ui.closeEvent = self.closeEvent
        self.ui.actionExit.triggered.connect(self.closeEvent)
示例#15
0
    def __init__(self, data, x=None, plugin=None, parent=None):
        super(DialogPlotEffectFuture, self).__init__(parent)
        self.ui = Ui_DialogPlotEffect()
        self.ui.setupUi(self)

        self.data = data
        
        # Setup MPL containers
        self.mpl_orig = _MplCanvas(subplot=111)        
        self.mpl_affected = _MplCanvas(subplot=111)
        
        # Show(), although not needed, enables mpl-tight_layout 
        # to work later on
        self.show()
        
        self.ui.verticalLayout.insertWidget(1, self.mpl_orig)
        self.ui.verticalLayout.insertWidget(1, self.mpl_orig.toolbar)
        
        self.ui.verticalLayout.insertWidget(3, self.mpl_affected)
        self.ui.verticalLayout.insertWidget(3, self.mpl_affected.toolbar)

        # Plugin that brings functionality to PlotEffect
        self.plugin = plugin
        
        
        # Signal emited when something changes in the plugin widget
        self.plugin.changed.connect(self.widget_changed)
            
        # Setup indep. variable
        if x is None:
            self.x = _np.linspace(0,data.shape[0],self.data.shape[0])
        else:
            self.x = x
        
        # If data is a list (assumed to be a list of ndarrays),
        # plot each item in list
        if isinstance(data, _np.ndarray):
            try:
                self.mpl_orig.ax.plot(self.x,data)
            except:
                self.mpl_orig.ax.plot(self.x,data.T)
        elif isinstance(data, list):
            for d in data:
                try:
                    self.mpl_orig.ax.plot(self.x,d)
                except:
                    self.mpl_orig.ax.plot(self.x,d.T)
                
            
        self.plot_labels()
                
        if self.plugin is not None:
            self.ui.verticalLayout.insertWidget(8, plugin)
        
        self.show()
        self.widget_changed()
        self.mpl_orig.draw()
        self.mpl_affected.draw()

        self.ui.pushButtonOk.clicked.connect(self.accept)
        self.ui.pushButtonCancel.clicked.connect(self.reject)