Example #1
0
class ImageWidget(QtGui.QWidget):
    def __init__(self, hdu, hmin=150, wmin=400, cmap="gray", scale="zscale", contrast=0.1, parent=None):
        super(imageWidget, self).__init__(parent)

        self.imdisplay = ImageDisplay()
        self.imdisplay.setMinimumHeight(hmin)
        self.imdisplay.setMinimumWidth(wmin)

        # Add FITS display widget with mouse interaction and overplotting

        # Set colormap
        self.imdisplay.setColormap(cmap)

        # Set scale mode for dynamic range
        self.imdisplay.scale = scale
        self.imdisplay.contrast = contrast
        self.imdisplay.aspect = "auto"

        self.loadimage(hdu)

        # Add navigation toolbars for each widget to enable zooming
        self.toolbar = NavigationToolbar2QTAgg(self.imdisplay, self)

        # set up the information panel
        self.infopanel = QtGui.QWidget()

        # add the name of the file
        self.NameLabel = QtGui.QLabel("Filename:")
        self.NameLabel.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.NameValueLabel = QtGui.QLabel(self.name)
        self.NameValueLabel.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Sunken)

        # set up the info panel layout
        infoLayout = QtGui.QGridLayout(self.infopanel)
        infoLayout.addWidget(self.NameLabel, 0, 0, 1, 1)
        infoLayout.addWidget(self.NameValueLabel, 0, 1, 1, 5)

        # Set up the layout
        mainLayout = QtGui.QVBoxLayout()
        mainLayout.addWidget(self.imdisplay)
        mainLayout.addWidget(self.toolbar)
        mainLayout.addWidget(self.infopanel)
        self.setLayout(mainLayout)

    def loadimage(self, hdu, ext=1):
        """Load a new image"""
        if hdu is None:
            self.name = ""
            return
        self.hdu = hdu
        try:
            self.imarr = self.hdu[ext].data
        except:
            raise SaltError("Could not open the data file for %s" % self.image)
        self.imdisplay.loadImage(self.imarr)
        self.imdisplay.drawImage()
        self.name = os.path.basename(hdu._HDUList__file.name)
Example #2
0
class ApplicationWindow(QtGui.QMainWindow):
    """Main application window."""
    def __init__(self,
                 imlist,
                 number,
                 config,
                 target_line_color='g',
                 comparison_line_color='g',
                 target_line_width=2,
                 comparison_line_width=2,
                 distance=5,
                 cmap='gray',
                 scale='zscale',
                 contrast=1.0):
        """Default constructor."""

        # Setup widget
        QtGui.QMainWindow.__init__(self)

        # Set main widget
        self.main = QtGui.QWidget(self)

        # Set window title
        self.setWindowTitle("Slotpreview")

        # Add FITS display widget with mouse interaction and overplotting
        self.imdisplay = ImageDisplay()
        self.imdisplay.setMinimumHeight(150)
        self.imdisplay.setMinimumWidth(400)

        # Set colormap
        self.imdisplay.setColormap(cmap)

        # Set scale mode for dynamic range
        self.imdisplay.scale = scale
        self.imdisplay.contrast = contrast

        # Add navigation toolbars for each widget to enable zooming
        self.toolbar = NavigationToolbar2QT(self.imdisplay, self)

        # Add configuration widget and connect it to the display widget
        self.conf = PhotometryConfigWidget(imdisplay=self.imdisplay,
                                           imlist=imlist,
                                           number=number,
                                           config=config)

        # Set default linewidth and color
        self.conf.setSearchDistance(distance)
        self.conf.setMarkerType('square')
        self.conf.setLineColor('target', target_line_color)
        self.conf.setLineColor('comparison', comparison_line_color)
        self.conf.setLineWidth('target', target_line_width)
        self.conf.setLineWidth('comparison', comparison_line_width)

        # Layout the widgets
        l = QtGui.QVBoxLayout(self.main)
        l.addWidget(self.imdisplay)
        l.addWidget(self.toolbar)
        l.addWidget(self.conf)

        # Set focus to main widget
        self.main.setFocus()

        # Set the main widget as the central widget
        self.setCentralWidget(self.main)

        # Destroy widget on close
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        # Close when config dialog is closed
        self.connect(self.conf, QtCore.SIGNAL('destroyed()'), self,
                     QtCore.SLOT('close()'))
class imageWidget(QtGui.QWidget):
    def __init__(self,
                 imarr,
                 y1=None,
                 y2=None,
                 nrows=1,
                 nsteps=100,
                 hmin=150,
                 wmin=400,
                 name=None,
                 cmap='Gray',
                 scale='zscale',
                 contrast=0.1,
                 parent=None):
        super(imageWidget, self).__init__(parent)

        self.y1 = y1
        self.y2 = y2
        self.x1 = 0
        self.x2 = len(imarr[0])
        self.nrows = nrows
        self.nsteps = nsteps

        # Add FITS display widget with mouse interaction and overplotting
        self.imdisplay = ImageDisplay()
        self.imdisplay.setMinimumHeight(hmin)
        self.imdisplay.setMinimumWidth(wmin)

        # Set colormap
        self.imdisplay.setColormap(cmap)

        # Set scale mode for dynamic range
        self.imdisplay.scale = scale
        self.imdisplay.contrast = contrast
        self.imdisplay.aspect = 'auto'
        self.imdisplay.loadImage(imarr)
        self.imdisplay.drawImage()
        self.y1line, = self.imdisplay.axes.plot([self.x1, self.x2],
                                                [self.y1, self.y1],
                                                ls='-',
                                                color='#00FF00')
        self.y2line, = self.imdisplay.axes.plot([self.x1, self.x2],
                                                [self.y2, self.y2],
                                                ls='-',
                                                color='#00FF00')

        # Add navigation toolbars for each widget to enable zooming
        self.toolbar = NavigationToolbar2QTAgg(self.imdisplay, self)

        # set up the information panel
        self.infopanel = QtGui.QWidget()

        # add the name of the file
        self.NameLabel = QtGui.QLabel("Filename:")
        self.NameLabel.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.NameValueLabel = QtGui.QLabel("%s" % name)
        self.NameValueLabel.setFrameStyle(QtGui.QFrame.Panel
                                          | QtGui.QFrame.Sunken)

        # add the rows that are extracted
        self.y1Label = QtGui.QLabel("Y1:")
        self.y1Label.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.y1ValueEdit = QtGui.QLineEdit("%6i" % self.y1)
        self.y2Label = QtGui.QLabel("Y2:")
        self.y2Label.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.y2ValueEdit = QtGui.QLineEdit("%6i" % self.y2)
        self.updateButton = QtGui.QPushButton("Update")
        self.updateButton.clicked.connect(self.updatesection)

        # add the update for automatically updating it
        self.nrLabel = QtGui.QLabel("nrows:")
        self.nrLabel.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.nrValueEdit = QtGui.QLineEdit("%5i" % self.nrows)
        self.nsLabel = QtGui.QLabel("nsteps:")
        self.nsLabel.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.nsValueEdit = QtGui.QLineEdit("%6i" % self.nsteps)
        self.nextButton = QtGui.QPushButton("Next")
        self.nextButton.clicked.connect(self.nextsection)

        # set up the info panel layout
        infoLayout = QtGui.QGridLayout(self.infopanel)
        infoLayout.addWidget(self.NameLabel, 0, 0, 1, 1)
        infoLayout.addWidget(self.NameValueLabel, 0, 1, 1, 5)
        infoLayout.addWidget(self.y1Label, 1, 0, 1, 1)
        infoLayout.addWidget(self.y1ValueEdit, 1, 1, 1, 1)
        infoLayout.addWidget(self.y2Label, 1, 2, 1, 1)
        infoLayout.addWidget(self.y2ValueEdit, 1, 3, 1, 1)
        infoLayout.addWidget(self.updateButton, 1, 4, 1, 1)
        infoLayout.addWidget(self.nrLabel, 2, 0, 1, 1)
        infoLayout.addWidget(self.nrValueEdit, 2, 1, 1, 1)
        infoLayout.addWidget(self.nsLabel, 2, 2, 1, 1)
        infoLayout.addWidget(self.nsValueEdit, 2, 3, 1, 1)
        infoLayout.addWidget(self.nextButton, 2, 4, 1, 1)

        # Set up the layout
        mainLayout = QtGui.QVBoxLayout()
        mainLayout.addWidget(self.imdisplay)
        mainLayout.addWidget(self.toolbar)
        mainLayout.addWidget(self.infopanel)
        self.setLayout(mainLayout)

    def updatesection(self):
        self.y1 = int(self.y1ValueEdit.text())
        self.y2 = int(self.y2ValueEdit.text())
        self.y1line.set_ydata([self.y1, self.y1])
        self.y2line.set_ydata([self.y2, self.y2])
        self.imdisplay.draw()
        self.emit(QtCore.SIGNAL("regionChange(int,int)"), self.y1, self.y2)

    def nextsection(self):
        self.nrows = int(self.nrValueEdit.text())
        self.nsteps = int(self.nsValueEdit.text())
        self.y1 = self.y1 + self.nsteps
        self.y2 = self.y1 + self.nrows
        self.y1ValueEdit.setText('%6i' % self.y1)
        self.y2ValueEdit.setText('%6i' % self.y2)
        self.updatesection()
Example #4
0
class imageWidget(QtGui.QWidget):

    def __init__(self, imarr, y1=None, y2=None, nrows=1, nsteps=100, hmin=150, wmin=400,
                 name=None, cmap='Gray', scale='zscale', contrast=0.1, parent=None):
        super(imageWidget, self).__init__(parent)

        self.y1 = y1
        self.y2 = y2
        self.x1 = 0
        self.x2 = len(imarr[0])
        self.nrows = nrows
        self.nsteps = nsteps

        # Add FITS display widget with mouse interaction and overplotting
        self.imdisplay = ImageDisplay()
        self.imdisplay.setMinimumHeight(hmin)
        self.imdisplay.setMinimumWidth(wmin)

        # Set colormap
        self.imdisplay.setColormap(cmap)

        # Set scale mode for dynamic range
        self.imdisplay.scale = scale
        self.imdisplay.contrast = contrast
        self.imdisplay.aspect = 'auto'
        self.imdisplay.loadImage(imarr)
        self.imdisplay.drawImage()
        self.y1line, = self.imdisplay.axes.plot([self.x1, self.x2], [self.y1, self.y1], ls='-', color='#00FF00')
        self.y2line, = self.imdisplay.axes.plot([self.x1, self.x2], [self.y2, self.y2], ls='-', color='#00FF00')

        # Add navigation toolbars for each widget to enable zooming
        self.toolbar = NavigationToolbar2QTAgg(self.imdisplay, self)

        # set up the information panel
        self.infopanel = QtGui.QWidget()

        # add the name of the file
        self.NameLabel = QtGui.QLabel("Filename:")
        self.NameLabel.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.NameValueLabel = QtGui.QLabel("%s" % name)
        self.NameValueLabel.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Sunken)

        # add the rows that are extracted
        self.y1Label = QtGui.QLabel("Y1:")
        self.y1Label.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.y1ValueEdit = QtGui.QLineEdit("%6i" % self.y1)
        self.y2Label = QtGui.QLabel("Y2:")
        self.y2Label.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.y2ValueEdit = QtGui.QLineEdit("%6i" % self.y2)
        self.updateButton = QtGui.QPushButton("Update")
        self.updateButton.clicked.connect(self.updatesection)

        # add the update for automatically updating it
        self.nrLabel = QtGui.QLabel("nrows:")
        self.nrLabel.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.nrValueEdit = QtGui.QLineEdit("%5i" % self.nrows)
        self.nsLabel = QtGui.QLabel("nsteps:")
        self.nsLabel.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.nsValueEdit = QtGui.QLineEdit("%6i" % self.nsteps)
        self.nextButton = QtGui.QPushButton("Next")
        self.nextButton.clicked.connect(self.nextsection)

        # set up the info panel layout
        infoLayout = QtGui.QGridLayout(self.infopanel)
        infoLayout.addWidget(self.NameLabel, 0, 0, 1, 1)
        infoLayout.addWidget(self.NameValueLabel, 0, 1, 1, 5)
        infoLayout.addWidget(self.y1Label, 1, 0, 1, 1)
        infoLayout.addWidget(self.y1ValueEdit, 1, 1, 1, 1)
        infoLayout.addWidget(self.y2Label, 1, 2, 1, 1)
        infoLayout.addWidget(self.y2ValueEdit, 1, 3, 1, 1)
        infoLayout.addWidget(self.updateButton, 1, 4, 1, 1)
        infoLayout.addWidget(self.nrLabel, 2, 0, 1, 1)
        infoLayout.addWidget(self.nrValueEdit, 2, 1, 1, 1)
        infoLayout.addWidget(self.nsLabel, 2, 2, 1, 1)
        infoLayout.addWidget(self.nsValueEdit, 2, 3, 1, 1)
        infoLayout.addWidget(self.nextButton, 2, 4, 1, 1)

        # Set up the layout
        mainLayout = QtGui.QVBoxLayout()
        mainLayout.addWidget(self.imdisplay)
        mainLayout.addWidget(self.toolbar)
        mainLayout.addWidget(self.infopanel)
        self.setLayout(mainLayout)

    def updatesection(self):
        self.y1 = int(self.y1ValueEdit.text())
        self.y2 = int(self.y2ValueEdit.text())
        self.y1line.set_ydata([self.y1, self.y1])
        self.y2line.set_ydata([self.y2, self.y2])
        self.imdisplay.draw()
        self.emit(QtCore.SIGNAL("regionChange(int,int)"), self.y1, self.y2)

    def nextsection(self):
        self.nrows = int(self.nrValueEdit.text())
        self.nsteps = int(self.nsValueEdit.text())
        self.y1 = self.y1 + self.nsteps
        self.y2 = self.y1 + self.nrows
        self.y1ValueEdit.setText('%6i' % self.y1)
        self.y2ValueEdit.setText('%6i' % self.y2)
        self.updatesection()
Example #5
0
class ApplicationWindow(QtGui.QMainWindow):
    """Main application window."""

    def __init__(self, imlist, number, config,
                target_line_color='g', comparison_line_color='g',
                target_line_width=2, comparison_line_width=2,
                distance=5, cmap='gray', scale='zscale', contrast=1.0):
        """Default constructor."""

        # Setup widget
        QtGui.QMainWindow.__init__(self)

        # Set main widget
        self.main = QtGui.QWidget(self)

        # Set window title
        self.setWindowTitle("Slotpreview")

        # Add FITS display widget with mouse interaction and overplotting
        self.imdisplay = ImageDisplay()
        self.imdisplay.setMinimumHeight(150)
        self.imdisplay.setMinimumWidth(400)

        # Set colormap
        self.imdisplay.setColormap(cmap)

        # Set scale mode for dynamic range
        self.imdisplay.scale=scale
        self.imdisplay.contrast=contrast

        # Add navigation toolbars for each widget to enable zooming
        self.toolbar=NavigationToolbar2QTAgg(self.imdisplay,self)

        # Add configuration widget and connect it to the display widget
        self.conf = PhotometryConfigWidget(imdisplay=self.imdisplay, imlist=imlist, number=number, config=config)

        # Set default linewidth and color
        self.conf.setSearchDistance(distance)
        self.conf.setMarkerType('square')
        self.conf.setLineColor('target', target_line_color)
        self.conf.setLineColor('comparison', comparison_line_color)
        self.conf.setLineWidth('target', target_line_width)
        self.conf.setLineWidth('comparison', comparison_line_width)

        # Layout the widgets
        l = QtGui.QVBoxLayout(self.main)
        l.addWidget(self.imdisplay)
        l.addWidget(self.toolbar)
        l.addWidget(self.conf)

        # Set focus to main widget
        self.main.setFocus()

        # Set the main widget as the central widget
        self.setCentralWidget(self.main)

        # Destroy widget on close
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        # Close when config dialog is closed
        self.connect(self.conf, QtCore.SIGNAL('destroyed()'), self, QtCore.SLOT('close()'))