예제 #1
0
 def show_layout_details(self):
     text = QwtText(
       "plotLayout().canvasRect():\n%r\n\n"
       "canvas().geometry():\n%r\n\n"
       "plotLayout().scaleRect(QwtPlot.yLeft):\n%r\n\n"
       "axisWidget(QwtPlot.yLeft).geometry():\n%r\n\n"
       "plotLayout().scaleRect(QwtPlot.yRight):\n%r\n\n"
       "axisWidget(QwtPlot.yRight).geometry():\n%r\n\n"
       "plotLayout().scaleRect(QwtPlot.xBottom):\n%r\n\n"
       "axisWidget(QwtPlot.xBottom).geometry():\n%r\n\n"
       "plotLayout().scaleRect(QwtPlot.xTop):\n%r\n\n"
       "axisWidget(QwtPlot.xTop).geometry():\n%r\n\n"
           % (self.plotLayout().canvasRect().getCoords(),
              self.canvas().geometry().getCoords(),
              self.plotLayout().scaleRect(QwtPlot.yLeft).getCoords(),
              self.axisWidget(QwtPlot.yLeft).geometry().getCoords(),
              self.plotLayout().scaleRect(QwtPlot.yRight).getCoords(),
              self.axisWidget(QwtPlot.yRight).geometry().getCoords(),
              self.plotLayout().scaleRect(QwtPlot.xBottom).getCoords(),
              self.axisWidget(QwtPlot.xBottom).geometry().getCoords(),
              self.plotLayout().scaleRect(QwtPlot.xTop).getCoords(),
              self.axisWidget(QwtPlot.xTop).geometry().getCoords(),
              )
                    )
     text.setFont(QFont('Courier New'))
     text.setColor(Qt.blue)
     self.marker.setLabel(text)
예제 #2
0
 def trackerText(self, pos):
     x, y = self.plot.invTransform(QwtPlot.xBottom, pos.x()), self.plot.invTransform(QwtPlot.yLeft, pos.y())
     if self.track:
         text = self.track(x, y)
         if text is not None:
             return text
     if self.label:
         text = QwtText(self.label % dict(x=x, y=y))
         text.setColor(self.color)
         return text
     return QwtText()
예제 #3
0
 def _set_rt_x_axis_labels(self):
     # todo: refactor as helper
     a = QwtScaleDraw()
     # render tic labels in modfied format:
     label = lambda self, v: QwtText(formatSeconds(v))
     a.label = new.instancemethod(label, self.widget.plot, QwtScaleDraw)
     self.widget.plot.setAxisScaleDraw(self.widget.plot.xBottom, a)
예제 #4
0
 def label(self, value ):
     """ Function used to create the text of each label
     used to draw the axis.
     """
     try:
         dt = datetime.fromtimestamp( value )
         return QwtText( '%s' % dt.strftime( '%H:%M:%S' ) )
     except:
         pass
예제 #5
0
 def _set_ts_x_axis_labels(self, data):
     # todo: refactor as helper
     all_ts = [tsi for ts in data for tsi in ts.x]
     pos = find_datetime_split_pos(all_ts)
     a = QwtScaleDraw()
     # render tic labels in modfied format:
     label = lambda self, v, pos=pos: QwtText(format_datetime_value(pos, v)) # QwtText(str(v))
     a.label = new.instancemethod(label, self.widget.plot, QwtScaleDraw)
     self.widget.plot.setAxisScaleDraw(self.widget.plot.xBottom, a)
예제 #6
0
 def show_layout_details(self):
     text = QwtText(
         "plotLayout().canvasRect():\n%r\n\n"
         "canvas().geometry():\n%r\n\n"
         "plotLayout().scaleRect(QwtPlot.yLeft):\n%r\n\n"
         "axisWidget(QwtPlot.yLeft).geometry():\n%r\n\n"
         "plotLayout().scaleRect(QwtPlot.yRight):\n%r\n\n"
         "axisWidget(QwtPlot.yRight).geometry():\n%r\n\n"
         "plotLayout().scaleRect(QwtPlot.xBottom):\n%r\n\n"
         "axisWidget(QwtPlot.xBottom).geometry():\n%r\n\n"
         "plotLayout().scaleRect(QwtPlot.xTop):\n%r\n\n"
         "axisWidget(QwtPlot.xTop).geometry():\n%r\n\n" % (
             self.plotLayout().canvasRect().getCoords(),
             self.canvas().geometry().getCoords(),
             self.plotLayout().scaleRect(QwtPlot.yLeft).getCoords(),
             self.axisWidget(QwtPlot.yLeft).geometry().getCoords(),
             self.plotLayout().scaleRect(QwtPlot.yRight).getCoords(),
             self.axisWidget(QwtPlot.yRight).geometry().getCoords(),
             self.plotLayout().scaleRect(QwtPlot.xBottom).getCoords(),
             self.axisWidget(QwtPlot.xBottom).geometry().getCoords(),
             self.plotLayout().scaleRect(QwtPlot.xTop).getCoords(),
             self.axisWidget(QwtPlot.xTop).geometry().getCoords(),
         ))
     text.setFont(QFont('Courier New'))
     text.setColor(Qt.blue)
     self.marker.setLabel(text)
예제 #7
0
 def trackerText(self, pos):
     pos = self.invTransform(pos)
     band = self.rubberBand()
     if band == self.HLineRubberBand:
         label = '%.3f' % pos.y()
     elif band == self.VLineRubberBand:
         label = '%.3f' % pos.x()
     else:
         label = '%i, %.3f' % (
             pos.x(),
             pos.y(),
         )
     return QwtText(label)
예제 #8
0
    def __init__(self, c_callback=None):
        super(MzPlotter, self).__init__("m/z", "I")

        self.c_callback = c_callback

        widget = self.widget

        # inject mofified behaviour of wigets plot attribute:
        widget.plot.__class__ = MzPlot
        widget.plot.register_c_callback(self.handle_c_pressed)
        self.setHalfWindowWidth(0.05)
        self.centralMz = None

        # todo: refactor as helper
        a = QwtScaleDraw()
        label = lambda self, x : QwtText("%s" % x)
        a.label = new.instancemethod(label, widget.plot, QwtScaleDraw)
        widget.plot.setAxisScaleDraw(widget.plot.xBottom, a)

        self.pm = PlotManager(widget)
        self.pm.add_plot(widget.plot)
        self.curve = make.curve([], [], color='b', curvestyle="Sticks")
        # inject modified behaviour:
        self.curve.__class__ = ModifiedCurveItem

        self.widget.plot.add_item(self.curve)

        t = self.pm.add_tool(MzSelectionTool)
        self.pm.set_default_tool(t)
        t.activate()

        marker = Marker(label_cb=widget.plot.label_info,\
                        constraint_cb=widget.plot.on_plot)
        marker.attach(self.widget.plot)

        line   = make.segment(0, 0, 0, 0)
        line.__class__ = ModifiedSegment
        line.setVisible(0)

        setupCommonStyle(line, marker)

        label = make.info_label("TR", [MzCursorInfo(marker, line)], title=None)
        label.labelparam.label = ""

        self.marker = marker
        self.label = label
        self.line = line
예제 #9
0
 def addPlotBorder(self, border_pen, label, label_color=None, bg_brush=None):
     # make plot items for image frame
     # make curve for image borders
     (l0, l1), (m0, m1) = self.image.getExtents()
     self._border_pen = QPen(border_pen)
     self._image_border.show()
     self._image_border.setData([l0, l0, l1, l1, l0], [m0, m1, m1, m0, m0])
     self._image_border.setPen(self._border_pen)
     self._image_border.setZ(self.image.z() + 1 if self._z_markers is None else self._z_markers)
     if label:
         self._image_label.show()
         self._image_label_text = text = QwtText(" %s " % label)
         text.setColor(label_color)
         text.setBackgroundBrush(bg_brush)
         self._image_label.setValue(l1, m1)
         self._image_label.setLabel(text)
         self._image_label.setLabelAlignment(Qt.AlignRight | Qt.AlignVCenter)
         self._image_label.setZ(self.image.z() + 2 if self._z_markers is None else self._z_markers)
예제 #10
0
    def __init__(self, rangeSelectionCallback = None):
        super(RtPlotter, self).__init__("RT", "I")

        self.rangeSelectionCallback = rangeSelectionCallback

        widget = self.widget
        widget.plot.__class__ = RtPlot

        # todo: refactor as helper
        a = QwtScaleDraw()
        # render tic labels in modfied format:
        label = lambda self, v: QwtText(formatSeconds(v))
        a.label = new.instancemethod(label, widget.plot, QwtScaleDraw)
        widget.plot.setAxisScaleDraw(widget.plot.xBottom, a)

        #a.label = new.instancemethod(label, widget.plot, QwtScaleDraw)

        self.pm = PlotManager(widget)
        self.pm.add_plot(widget.plot)

        t = self.pm.add_tool(RtSelectionTool)
        self.addTool(RtSelectionTool)
        self.pm.set_default_tool(t)

        marker = Marker(label_cb=self.widget.plot.label_info,\
                        constraint_cb=self.widget.plot.on_plot)
        marker.rts = [0]
        setupStyleRtMarker(marker)
        marker.attach(self.widget.plot)
        self.marker = marker

        label = make.info_label("T", [RtCursorInfo(marker)], title=None)
        label.labelparam.label = ""
        self.label=label

        self.minRTRangeSelected = None
        self.maxRTRangeSelected = None
예제 #11
0
 def show_layout_details(self):
     text = ("plotLayout().canvasRect():\n%r\n\n"
             "canvas().geometry():\n%r\n\n"
             "plotLayout().scaleRect(QwtPlot.yLeft):\n%r\n\n"
             "axisWidget(QwtPlot.yLeft).geometry():\n%r\n\n"
             "plotLayout().scaleRect(QwtPlot.yRight):\n%r\n\n"
             "axisWidget(QwtPlot.yRight).geometry():\n%r\n\n"
             "plotLayout().scaleRect(QwtPlot.xBottom):\n%r\n\n"
             "axisWidget(QwtPlot.xBottom).geometry():\n%r\n\n"
             "plotLayout().scaleRect(QwtPlot.xTop):\n%r\n\n"
             "axisWidget(QwtPlot.xTop).geometry():\n%r\n\n" % (
                 self.plotLayout().canvasRect().getCoords(),
                 self.canvas().geometry().getCoords(),
                 self.plotLayout().scaleRect(QwtPlot.yLeft).getCoords(),
                 self.axisWidget(QwtPlot.yLeft).geometry().getCoords(),
                 self.plotLayout().scaleRect(QwtPlot.yRight).getCoords(),
                 self.axisWidget(QwtPlot.yRight).geometry().getCoords(),
                 self.plotLayout().scaleRect(QwtPlot.xBottom).getCoords(),
                 self.axisWidget(QwtPlot.xBottom).geometry().getCoords(),
                 self.plotLayout().scaleRect(QwtPlot.xTop).getCoords(),
                 self.axisWidget(QwtPlot.xTop).geometry().getCoords(),
             ))
     self.marker.setLabel(
         QwtText.make(text, family="Courier New", color=Qt.blue))
예제 #12
0
 def label(self, float_val):
     if float_val < 1.0:
         return QwtText("")
     dt = datetime.datetime.fromordinal(int(float_val))
     txt = str(dt).split(" ")[0]
     return QwtText(txt)
예제 #13
0
 def _trackHistCoordinates(self, x, y):
     self._wlab_histpos.setText((DataValueFormat + " %d") % (x, y) if x is not None else self._wlab_histpos_text)
     return QwtText()
예제 #14
0
    def __init__(self, image, parent, imgman, name=None, save=False):
        QFrame.__init__(self, parent)
        self.setFrameStyle(QFrame.StyledPanel | QFrame.Raised)
        # init state
        self.image = image
        self._imgman = imgman
        self._currier = PersistentCurrier()
        self._control_dialog = None
        # create widgets
        self._lo = lo = QHBoxLayout(self)
        lo.setContentsMargins(0, 0, 0, 0)
        lo.setSpacing(2)
        # raise button
        self._wraise = QToolButton(self)
        lo.addWidget(self._wraise)
        self._wraise.setIcon(pixmaps.raise_up.icon())
        self._wraise.setAutoRaise(True)
        self._can_raise = False
        QObject.connect(self._wraise, SIGNAL("clicked()"), self._raiseButtonPressed)
        self._wraise.setToolTip("""<P>Click here to raise this image above other images. Hold the button down briefly to
      show a menu of image operations.</P>""")
        # center label
        self._wcenter = QLabel(self)
        self._wcenter.setPixmap(pixmaps.center_image.pm())
        self._wcenter.setToolTip(
            "<P>The plot is currently centered on (the reference pixel %d,%d) of this image.</P>" % self.image.referencePixel())
        lo.addWidget(self._wcenter)
        # name/filename label
        self.name = image.name
        self._wlabel = QLabel(self.name, self)
        self._number = 0
        self.setName(self.name)
        self._wlabel.setToolTip("%s %s" % (image.filename, "\u00D7".join(map(str, image.data().shape))))
        lo.addWidget(self._wlabel, 1)
        # if 'save' is specified, create a "save" button
        if save:
            self._wsave = QToolButton(self)
            lo.addWidget(self._wsave)
            self._wsave.setText("save")
            self._wsave.setAutoRaise(True)
            self._save_dir = save if isinstance(save, str) else "."
            QObject.connect(self._wsave, SIGNAL("clicked()"), self._saveImage)
            self._wsave.setToolTip("""<P>Click here to write this image to a FITS file.</P>""")
        # render control
        dprint(2, "creating RenderControl")
        self._rc = RenderControl(image, self)
        dprint(2, "done")
        # selectors for extra axes
        self._wslicers = []
        curslice = self._rc.currentSlice();  # this may be loaded from config, so not necessarily 0
        for iextra, axisname, labels in self._rc.slicedAxes():
            if axisname.upper() not in ["STOKES", "COMPLEX"]:
                lbl = QLabel("%s:" % axisname, self)
                lo.addWidget(lbl)
            else:
                lbl = None
            slicer = QComboBox(self)
            self._wslicers.append(slicer)
            lo.addWidget(slicer)
            slicer.addItems(labels)
            slicer.setToolTip("""<P>Selects current slice along the %s axis.</P>""" % axisname)
            slicer.setCurrentIndex(curslice[iextra])
            QObject.connect(slicer, SIGNAL("activated(int)"), self._currier.curry(self._rc.changeSlice, iextra))
        # min/max display ranges
        lo.addSpacing(5)
        self._wrangelbl = QLabel(self)
        lo.addWidget(self._wrangelbl)
        self._minmaxvalidator = FloatValidator(self)
        self._wmin = QLineEdit(self)
        self._wmax = QLineEdit(self)
        width = self._wmin.fontMetrics().width("1.234567e-05")
        for w in self._wmin, self._wmax:
            lo.addWidget(w, 0)
            w.setValidator(self._minmaxvalidator)
            w.setMaximumWidth(width)
            w.setMinimumWidth(width)
            QObject.connect(w, SIGNAL("editingFinished()"), self._changeDisplayRange)
        # full-range button
        self._wfullrange = QToolButton(self)
        lo.addWidget(self._wfullrange, 0)
        self._wfullrange.setIcon(pixmaps.zoom_range.icon())
        self._wfullrange.setAutoRaise(True)
        QObject.connect(self._wfullrange, SIGNAL("clicked()"), self.renderControl().resetSubsetDisplayRange)
        rangemenu = QMenu(self)
        rangemenu.addAction(pixmaps.full_range.icon(), "Full subset", self.renderControl().resetSubsetDisplayRange)
        for percent in (99.99, 99.9, 99.5, 99, 98, 95):
            rangemenu.addAction("%g%%" % percent, self._currier.curry(self._changeDisplayRangeToPercent, percent))
        self._wfullrange.setPopupMode(QToolButton.DelayedPopup)
        self._wfullrange.setMenu(rangemenu)
        # update widgets from current display range
        self._updateDisplayRange(*self._rc.displayRange())
        # lock button
        self._wlock = QToolButton(self)
        self._wlock.setIcon(pixmaps.unlocked.icon())
        self._wlock.setAutoRaise(True)
        self._wlock.setToolTip("""<P>Click to lock or unlock the intensity range. When the intensity range is locked across multiple images, any changes in the intensity
          range of one are propagated to the others. Hold the button down briefly for additional options.</P>""")
        lo.addWidget(self._wlock)
        QObject.connect(self._wlock, SIGNAL("clicked()"), self._toggleDisplayRangeLock)
        QObject.connect(self.renderControl(), SIGNAL("displayRangeLocked"), self._setDisplayRangeLock)
        QObject.connect(self.renderControl(), SIGNAL("dataSubsetChanged"), self._dataSubsetChanged)
        lockmenu = QMenu(self)
        lockmenu.addAction(pixmaps.locked.icon(), "Lock all to this",
                           self._currier.curry(imgman.lockAllDisplayRanges, self.renderControl()))
        lockmenu.addAction(pixmaps.unlocked.icon(), "Unlock all", imgman.unlockAllDisplayRanges)
        self._wlock.setPopupMode(QToolButton.DelayedPopup)
        self._wlock.setMenu(lockmenu)
        self._setDisplayRangeLock(self.renderControl().isDisplayRangeLocked())
        # dialog button
        self._wshowdialog = QToolButton(self)
        lo.addWidget(self._wshowdialog)
        self._wshowdialog.setIcon(pixmaps.colours.icon())
        self._wshowdialog.setAutoRaise(True)
        self._wshowdialog.setToolTip("""<P>Click for colourmap and intensity policy options.</P>""")
        QObject.connect(self._wshowdialog, SIGNAL("clicked()"), self.showRenderControls)
        tooltip = """<P>You can change the currently displayed intensity range by entering low and high limits here.</P>
    <TABLE>
      <TR><TD><NOBR>Image min:</NOBR></TD><TD>%g</TD><TD>max:</TD><TD>%g</TD></TR>
      </TABLE>""" % self.image.imageMinMax()
        for w in self._wmin, self._wmax, self._wrangelbl:
            w.setToolTip(tooltip)

        # create image operations menu
        self._menu = QMenu(self.name, self)
        self._qa_raise = self._menu.addAction(pixmaps.raise_up.icon(), "Raise image",
                                              self._currier.curry(self.image.emit, SIGNAL("raise")))
        self._qa_center = self._menu.addAction(pixmaps.center_image.icon(), "Center plot on image",
                                               self._currier.curry(self.image.emit, SIGNAL("center")))
        self._qa_show_rc = self._menu.addAction(pixmaps.colours.icon(), "Colours && Intensities...",
                                                self.showRenderControls)
        if save:
            self._qa_save = self._menu.addAction("Save image...", self._saveImage)
        self._menu.addAction("Export image to PNG file...", self._exportImageToPNG)
        self._export_png_dialog = None
        self._menu.addAction("Unload image", self._currier.curry(self.image.emit, SIGNAL("unload")))
        self._wraise.setMenu(self._menu)
        self._wraise.setPopupMode(QToolButton.DelayedPopup)

        # connect updates from renderControl and image
        self.image.connect(SIGNAL("slice"), self._updateImageSlice)
        QObject.connect(self._rc, SIGNAL("displayRangeChanged"), self._updateDisplayRange)

        # default plot depth of image markers
        self._z_markers = None
        # and the markers themselves
        self._image_border = QwtPlotCurve()
        self._image_label = QwtPlotMarker()

        # subset markers
        self._subset_pen = QPen(QColor("Light Blue"))
        self._subset_border = QwtPlotCurve()
        self._subset_border.setPen(self._subset_pen)
        self._subset_border.setVisible(False)
        self._subset_label = QwtPlotMarker()
        text = QwtText("subset")
        text.setColor(self._subset_pen.color())
        self._subset_label.setLabel(text)
        self._subset_label.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom)
        self._subset_label.setVisible(False)
        self._setting_lmrect = False

        self._all_markers = [self._image_border, self._image_label, self._subset_border, self._subset_label]
예제 #15
0
    def plotUpdate(self, data):
        ydata = data[0].tolist()
        xdata = data[1].tolist()

        if self.HOLD:
            if len(ydata) != self.slice_length * len(self.freqs):
                pass
            else:
                if len(self.max_hold) < len(data[0]):
                    self.max_hold = data[0]
                else:
                    dif = data[0] - self.max_hold
                    dif = dif.clip(0)
                    self.max_hold += dif
                self.ui.hold_curve.setData(xdata, self.max_hold.tolist())

        if self.AVERAGE:
            if len(ydata) != self.slice_length * len(self.freqs):
                pass
            else:
                if self.avg_counter == 0:
                    if len(self.avg) < self.num_avg:
                        self.avg.append(data[0])
                    else:
                        self.avg = self.avg[1:]
                        self.avg.append(data[0])
                    self.avg_counter = len(self.freqs)
                else:
                    self.avg_counter -= 1
                temp = np.sum(self.avg, 0)
                temp = temp / len(self.avg)
                ydata = temp

        if self.PEAK:
            index = np.argmax(data[0])
            self.peak_search = (xdata[index], ydata[index])
            self.ui.peak_marker.setValue(self.peak_search[0],
                                         self.peak_search[1])
            self.ui.peak_marker.setLabel(
                QwtText("Peak:\n%.2f MHz, %.2f dBm" % self.peak_search))

        for i in range(len(self.SAVE)):
            if self.SAVE[i]:
                if self.saved[i]:
                    self.ui.saved_curves[i].detach()
                    self.saved[i] = False
                    self.ui.traces[i].setDown(False)
                else:
                    self.ui.saved_curves[i].setData(xdata, ydata)
                    self.ui.saved_curves[i].attach(self.ui.plot)
                    self.saved[i] = True
                self.SAVE[i] = False

        for i in range(len(self.MARKERS)):
            if self.MARKERS[i]:
                if len(ydata) != self.slice_length * len(self.freqs):
                    pass
                else:
                    self.ui.markers[i].attach(self.ui.plot)
                    if self.marker_index[i] == None:
                        value = self.marker_value[i]
                        index = np.argmin(np.abs(data[1] - value))
                        self.marker_index[i] = index
                    self.ui.markers[i].setValue(xdata[self.marker_index[i]],
                                                ydata[self.marker_index[i]])
                    self.ui.markers[i].setLabel(
                        QwtText("Mk%i\n%.2fdBm" %
                                (i + 1, ydata[self.marker_index[i]])))

        if self.DELTA:
            if len(ydata) != self.slice_length * len(self.freqs):
                pass
            else:
                self.ui.delta_marker.attach(self.ui.plot)
                if self.delta_index == None:
                    value = self.delta_value
                    index = np.argmin(np.abs(data[1] - value))
                    self.delta_index = index
                self.ui.delta_marker.setValue(xdata[self.delta_index],
                                              ydata[self.delta_index])
                temp_x = xdata[self.delta_index] - xdata[self.marker_index[0]]
                temp_y = ydata[self.delta_index] - ydata[self.marker_index[0]]
                self.ui.delta_marker.setLabel(
                    QwtText("Delta\n%.2fMHz, %.2fdB" % (temp_x, temp_y)))

        while self.CORRECT > 0:

            correction = np.reshape(data[0], (-1, self.slice_length))
            correction = np.sum(correction, 0) / len(correction)
            self.correction += correction
            self.CORRECT -= 1
            if self.CORRECT == 0:
                self.correction = self.correction / 10000
                self.correction -= max(self.correction)
                print max(self.correction)
                #self.correction = self.correction[:100]+np.zeros(self.slice_length-200)+self.correction[-100:]
                self.correction -= np.mean(self.correction)
                for i in range(self.num_threads):
                    self.workers[i].correction = self.correction
                print "New correction vector applied"

        #print len(ydata)
        self.ui.curve.setData(xdata, ydata)
        self.ui.plot.replot()
예제 #16
0
 def setText(self, text):
     label = QwtText(text)
     label.setColor(self.color)
     self.marker.setLabel(label)
예제 #17
0
 def _setupHistogramPlot(self):
     self._histplot.setCanvasBackground(QColor("lightgray"))
     self._histplot.setAxisFont(QwtPlot.yLeft, QApplication.font())
     self._histplot.setAxisFont(QwtPlot.xBottom, QApplication.font())
     # add histogram curves
     self._histcurve1 = TiggerPlotCurve()
     self._histcurve2 = TiggerPlotCurve()
     self._histcurve1.setStyle(QwtPlotCurve.Steps)
     self._histcurve2.setStyle(QwtPlotCurve.Steps)
     self._histcurve1.setPen(QPen(Qt.NoPen))
     self._histcurve1.setBrush(QBrush(QColor("slategrey")))
     pen = QPen(QColor("red"))
     pen.setWidth(1)
     self._histcurve2.setPen(pen)
     self._histcurve1.setZ(0)
     self._histcurve2.setZ(100)
     #    self._histcurve1.attach(self._histplot)
     self._histcurve2.attach(self._histplot)
     # add maxbin and half-max curves
     self._line_0 = self.HistogramLineMarker(self._histplot, color="grey50", linestyle=Qt.SolidLine,
                                             align=Qt.AlignTop | Qt.AlignLeft, z=90)
     self._line_mean = self.HistogramLineMarker(self._histplot, color="black", linestyle=Qt.SolidLine,
                                                align=Qt.AlignBottom | Qt.AlignRight, z=91,
                                                label="mean", zlabel=151)
     self._line_std = self.HistogramLineMarker(self._histplot, color="black", linestyle=Qt.SolidLine,
                                               align=Qt.AlignTop | Qt.AlignRight, z=91,
                                               label="std", zlabel=151)
     sym = QwtSymbol()
     sym.setStyle(QwtSymbol.VLine)
     sym.setSize(8)
     self._line_std.line.setSymbol(sym)
     self._line_maxbin = self.HistogramLineMarker(self._histplot, color="green", linestyle=Qt.DotLine,
                                                  align=Qt.AlignTop | Qt.AlignRight, z=92,
                                                  label="max bin", zlabel=150)
     self._line_halfmax = self.HistogramLineMarker(self._histplot, color="green", linestyle=Qt.DotLine,
                                                   align=Qt.AlignBottom | Qt.AlignRight, z=90,
                                                   label="half-max", yaxis=QwtPlot.yLeft)
     # add current range
     self._rangebox = TiggerPlotCurve()
     self._rangebox.setStyle(QwtPlotCurve.Steps)
     self._rangebox.setYAxis(QwtPlot.yRight)
     self._rangebox.setPen(QPen(Qt.NoPen))
     self._rangebox.setBrush(QBrush(QColor("darkgray")))
     self._rangebox.setZ(50)
     self._rangebox.attach(self._histplot)
     self._rangebox2 = TiggerPlotCurve()
     self._rangebox2.setStyle(QwtPlotCurve.Sticks)
     self._rangebox2.setYAxis(QwtPlot.yRight)
     self._rangebox2.setZ(60)
     #  self._rangebox2.attach(self._histplot)
     # add intensity transfer function
     self._itfcurve = TiggerPlotCurve()
     self._itfcurve.setStyle(QwtPlotCurve.Lines)
     self._itfcurve.setPen(QPen(QColor("blue")))
     self._itfcurve.setYAxis(QwtPlot.yRight)
     self._itfcurve.setZ(120)
     self._itfcurve.attach(self._histplot)
     self._itfmarker = TiggerPlotMarker()
     label = QwtText("ITF")
     label.setColor(QColor("blue"))
     self._itfmarker.setLabel(label)
     try:
         self._itfmarker.setSpacing(0)
     except AttributeError:
         pass
     self._itfmarker.setLabelAlignment(Qt.AlignTop | Qt.AlignRight)
     self._itfmarker.setZ(120)
     self._itfmarker.attach(self._histplot)
     # add colorbar
     self._cb_item = self.ColorBarPlotItem(1, 1 + self.ColorBarHeight)
     self._cb_item.setYAxis(QwtPlot.yRight)
     self._cb_item.attach(self._histplot)
     # add pickers
     self._hist_minpicker = self.HistLimitPicker(self._histplot, "low: %(x).4g")
     self._hist_minpicker.setMousePattern(QwtEventPattern.MouseSelect1, Qt.LeftButton)
     QObject.connect(self._hist_minpicker, SIGNAL("selected(const QwtDoublePoint &)"), self._selectLowLimit)
     self._hist_maxpicker = self.HistLimitPicker(self._histplot, "high: %(x).4g")
     self._hist_maxpicker.setMousePattern(QwtEventPattern.MouseSelect1, Qt.RightButton)
     QObject.connect(self._hist_maxpicker, SIGNAL("selected(const QwtDoublePoint &)"), self._selectHighLimit)
     self._hist_maxpicker1 = self.HistLimitPicker(self._histplot, "high: %(x).4g")
     self._hist_maxpicker1.setMousePattern(QwtEventPattern.MouseSelect1, Qt.LeftButton, Qt.CTRL)
     QObject.connect(self._hist_maxpicker1, SIGNAL("selected(const QwtDoublePoint &)"), self._selectHighLimit)
     self._hist_zoompicker = self.HistLimitPicker(self._histplot, label="zoom",
                                                  tracker_mode=QwtPicker.AlwaysOn, track=self._trackHistCoordinates,
                                                  color="black",
                                                  mode=QwtPicker.RectSelection,
                                                  rubber_band=QwtPicker.RectRubberBand)
     self._hist_zoompicker.setMousePattern(QwtEventPattern.MouseSelect1, Qt.LeftButton, Qt.SHIFT)
     QObject.connect(self._hist_zoompicker, SIGNAL("selected(const QwtDoubleRect &)"), self._zoomHistogramIntoRect)
예제 #18
0
 def label(self, v):
     return QwtText(formatSeconds(v))
예제 #19
0
 def label(self, x):
     # label with full precision:
     return QwtText(str(x))
예제 #20
0
    def plot(self):
        numvalues = []
        wlvalues = []
        bandsUsed = []

        if (self.hasqwt or self.hasmpl):
            for row in self.values:
                layername, value = row
                bandsUsed.append(int(layername.split(' ')[-1]))
                try:
                    numvalues.append(float(value))
                except:
                    numvalues.append(0)
            if (len(self.wavelengths) != 0):
                for i in bandsUsed:
                    wlvalues.append(self.wavelengths[i])
            else:
                wlvalues = range(1, len(numvalues) + 1)

        ymin = self.ymin
        ymax = self.ymax
        xmin = float(min(wlvalues))
        xmax = float(max(wlvalues))
        if self.leYMin.text() != '' and self.leYMax.text() != '':
            ymin = float(self.leYMin.text())
            ymax = float(self.leYMax.text())

        if (self.hasqwt and (self.plotSelector.currentText() == 'Qwt')):

            self.qwtPlot.setAxisMaxMinor(QwtPlot.xBottom, 0)
            #self.qwtPlot.setAxisMaxMajor(QwtPlot.xBottom,0)
            self.qwtPlot.setAxisScale(QwtPlot.xBottom, xmin, xmax)
            #self.qwtPlot.setAxisScale(QwtPlot.yLeft,self.ymin,self.ymax)
            self.qwtPlot.setAxisScale(QwtPlot.yLeft, ymin, ymax)

            self.curve.setData(wlvalues, numvalues)
            if (self.wavelength_units.lower() == 'micrometers'
                    or self.wavelength_units.lower() == 'microns'):
                xlabel = QwtText('Wavelength (um)')
            elif (self.wavelength_units.lower() == 'nanometers'):
                xlabel = QwtText('Wavelength (nm)')
            else:
                xlabel = QwtText('Bands')
            self.qwtPlot.setAxisTitle(QwtPlot.xBottom, xlabel)
            self.qwtPlot.replot()
            self.qwtPlot.setVisible(len(numvalues) > 0)

        elif (self.hasmpl and (self.plotSelector.currentText() == 'mpl')):

            self.mplPlt.clear()
            self.mplPlt.plot(wlvalues,
                             numvalues,
                             marker='o',
                             color='k',
                             mfc='b',
                             mec='b')
            #self.mplPlt.xaxis.set_major_locator(ticker.MaxNLocator(integer=True))
            self.mplPlt.yaxis.set_minor_locator(ticker.AutoMinorLocator())
            self.mplPlt.set_xlim((xmin, xmax))
            self.mplPlt.set_ylim((ymin, ymax))

            if (self.wavelength_units.lower() == 'micrometers'
                    or self.wavelength_units.lower() == 'microns'):
                xlabel = 'Wavelength ($\mu$m)'
            elif (self.wavelength_units.lower() == 'nanometers'):
                xlabel = 'Wavelength (nm)'
            else:
                xlabel = 'Bands'
            self.mplPlt.set_xlabel(xlabel)
            self.mplFig.canvas.draw()