Beispiel #1
0
	def setdata(self, x, y):
		if self.canvas_width <> self.cached_canvas.width():
			self.logger.push("spectplot : changed canvas width")
			self.canvas_width = self.cached_canvas.width()
			self.update_xscale()
		
		if self.xmax <> x[-1]:
			self.logger.push("spectplot : changing x scale")
			self.xmax = x[-1]
			self.update_xscale()
			self.needfullreplot = True
		
		y_interp = interp(self.xscaled, x, y)
                
		#upsampling = 10.
		#upsampled_freq = linspace(x.min(), x.max(), len(x)*upsampling)
		#upsampled_xyzs = y.repeat(upsampling)
		#y_interp = histogram(upsampled_freq, bins=self.xscaled, normed=False, weights=upsampled_xyzs, new=None)[0]
		#y_interp /= upsampling
                
		ClassPlot.setdata(self, self.xscaled, y_interp)

		if self.peaks_enabled:
			self.compute_peaks(y_interp)
			self.curve_peak.setData(self.xscaled, self.peak)
		
		if self.needfullreplot:
			self.needfullreplot = False
			self.replot()
		else:
			# self.replot() would call updateAxes() which is dead slow (probably because it
			# computes label sizes); instead, let's just ask Qt to repaint the canvas next time
			# This works because we disable the cache
			self.cached_canvas.update()
Beispiel #2
0
	def setdataTwoChannels(self, x, y, y2):
		if self.canvas_width <> self.cached_canvas.width():
			self.logger.push("timeplot : changed canvas width")
			self.canvas_width = self.cached_canvas.width()
			self.update_xscale()

		if not self.dual_channel:
			self.dual_channel = True
			self.curve2.attach(self)
  			# enable the legend
  			# (to discrimate between the two channels)
			self.insertLegend(Qwt.QwtLegend(), Qwt.QwtPlot.RightLegend)
		
		x_ms =  1e3*x
		needfullreplot = False
		if self.xmax <> x_ms[-1]:
			self.logger.push("timeplot : changing x scale")
			self.xmax = x_ms[-1]
			self.setAxisScale(Qwt.QwtPlot.xBottom, 0., self.xmax)
			self.update_xscale()
			needfullreplot = True

		y_interp = interp(self.xscaled, x_ms, y)
  		y_interp2 = interp(self.xscaled, x_ms, y2)
		ClassPlot.setdata(self, self.xscaled, y_interp)
		self.curve2.setData(self.xscaled, y_interp2)

		if needfullreplot:
			self.replot()
		else:
			# self.replot() would call updateAxes() which is dead slow (probably because it
			# computes label sizes); instead, let's just ask Qt to repaint the canvas next time
			# This works because we disable the cache
			self.cached_canvas.update()
Beispiel #3
0
	def setdata(self, x, y):
		if self.canvas_width <> self.cached_canvas.width():
			self.logger.push("timeplot : changed canvas width")
			self.canvas_width = self.cached_canvas.width()
			self.update_xscale()

		if self.dual_channel:
			self.dual_channel = False
			self.curve2.detach()
  			# disable the legend
  			# (useless when one channel is active)
			self.insertLegend(None, Qwt.QwtPlot.RightLegend)

		x_ms =  1e3*x
		needfullreplot = False
		if self.xmax <> x_ms[-1]:
			self.logger.push("timeplot : changing x scale")
			self.xmax = x_ms[-1]
			self.setAxisScale(Qwt.QwtPlot.xBottom, 0., self.xmax)
			self.update_xscale()
			needfullreplot = True

		y_interp = interp(self.xscaled, x_ms, y)
		ClassPlot.setdata(self, self.xscaled, y_interp)

		if needfullreplot:
			self.replot()
		else:
			# self.replot() would call updateAxes() which is dead slow (probably because it
			# computes label sizes); instead, let's just ask Qt to repaint the canvas next time
			# This works because we disable the cache
			self.cached_canvas.update()
Beispiel #4
0
    def setdata(self, x, y):
        if self.canvas_width <> self.cached_canvas.width():
            self.logger.push("spectplot : changed canvas width")
            self.canvas_width = self.cached_canvas.width()
            self.update_xscale()

        if self.xmax <> x[-1]:
            self.logger.push("spectplot : changing x scale")
            self.xmax = x[-1]
            self.update_xscale()
            self.needfullreplot = True

        y_interp = interp(self.xscaled, x, y)

        #upsampling = 10.
        #upsampled_freq = linspace(x.min(), x.max(), len(x)*upsampling)
        #upsampled_xyzs = y.repeat(upsampling)
        #y_interp = histogram(upsampled_freq, bins=self.xscaled, normed=False, weights=upsampled_xyzs, new=None)[0]
        #y_interp /= upsampling

        ClassPlot.setdata(self, self.xscaled, y_interp)

        if self.peaks_enabled:
            self.compute_peaks(y_interp)
            self.curve_peak.setData(self.xscaled, self.peak)

        if self.needfullreplot:
            self.needfullreplot = False
            self.replot()
        else:
            # self.replot() would call updateAxes() which is dead slow (probably because it
            # computes label sizes); instead, let's just ask Qt to repaint the canvas next time
            # This works because we disable the cache
            self.cached_canvas.update()
Beispiel #5
0
	def __init__(self, parent, logger):
		ClassPlot.__init__(self)

		# store the logger instance
		self.logger = logger

		# we do not need caching
		self.canvas().setPaintAttribute(Qwt.QwtPlotCanvas.PaintCached, False)
		self.canvas().setPaintAttribute(Qwt.QwtPlotCanvas.PaintPacked, False)

		# attach a grid
		grid = Qwt.QwtPlotGrid()
		grid.setMajPen(Qt.QPen(Qt.Qt.lightGray))
		grid.attach(self)

		xtitle = Qwt.QwtText('Time (ms)')
		xtitle.setFont(QtGui.QFont(8))
		self.setAxisTitle(Qwt.QwtPlot.xBottom, xtitle)
		self.setAxisScale(Qwt.QwtPlot.yLeft, -1., 1.)
		# self.setAxisTitle(Qwt.QwtPlot.xBottom, 'Time (ms)')
		self.xmin = 0.
		self.xmax = 1.

		ytitle = Qwt.QwtText('Signal')
		ytitle.setFont(QtGui.QFont(8))
		self.setAxisTitle(Qwt.QwtPlot.yLeft, ytitle)
		# self.setAxisTitle(Qwt.QwtPlot.yLeft, 'Signal')
		self.setAxisScale(Qwt.QwtPlot.yLeft, -1., 1.)
		self.setAxisScaleEngine(Qwt.QwtPlot.xBottom, Qwt.QwtLinearScaleEngine())
		
		self.paint_time = 0.
		
		self.canvas_width = 0
  
		self.dual_channel = False
  
  		# insert an additional curve for the second channel
  		# (ClassPlot already has one by default)
		self.curve2 = Qwt.QwtPlotCurve("Ch2")
		self.curve2.setPen(QtGui.QPen(Qt.Qt.blue))
		#self.curve.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased)
		#self.curve2.attach(self)

  		# gives an appropriate title to the first curve
  		# (for the legend)
		self.curve.setTitle("Ch1")
		
		# picker used to display coordinates when clicking on the canvas
		self.picker = picker(Qwt.QwtPlot.xBottom,
                               Qwt.QwtPlot.yLeft,
                               Qwt.QwtPicker.PointSelection,
                               Qwt.QwtPlotPicker.CrossRubberBand,
                               Qwt.QwtPicker.ActiveOnly,
                               self.canvas())
		
		self.cached_canvas = self.canvas()
		
		#need to replot here for the size Hints to be computed correctly (depending on axis scales...)
		self.replot()
Beispiel #6
0
	def __init__(self, parent, logger):
		ClassPlot.__init__(self)

		# store the logger instance
		self.logger = logger

		# we do not need caching
		self.canvas().setPaintAttribute(Qwt.QwtPlotCanvas.PaintCached, False)
		self.canvas().setPaintAttribute(Qwt.QwtPlotCanvas.PaintPacked, False)

		# attach a grid
		grid = Qwt.QwtPlotGrid()
		grid.setMajPen(Qt.QPen(Qt.Qt.lightGray))
		grid.attach(self)

		xtitle = Qwt.QwtText('Time (ms)')
		xtitle.setFont(QtGui.QFont(8))
		self.setAxisTitle(Qwt.QwtPlot.xBottom, xtitle)
		# self.setAxisTitle(Qwt.QwtPlot.xBottom, 'Time (ms)')
		ytitle = Qwt.QwtText('Signal')
		ytitle.setFont(QtGui.QFont(8))
		self.setAxisTitle(Qwt.QwtPlot.yLeft, ytitle)
		# self.setAxisTitle(Qwt.QwtPlot.yLeft, 'Signal')
		self.setAxisScale(Qwt.QwtPlot.yLeft, -1., 1.)
		self.setAxisScaleEngine(Qwt.QwtPlot.xBottom, Qwt.QwtLinearScaleEngine())
		self.xmax = 0
		
		self.paint_time = 0.
		
		self.canvas_width = 0
  
		self.dual_channel = False
  
  		# insert an additional curve for the second channel
  		# (ClassPlot already has one by default)
		self.curve2 = Qwt.QwtPlotCurve("Ch2")
		self.curve2.setPen(QtGui.QPen(Qt.Qt.blue))
		#self.curve.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased)
		#self.curve2.attach(self)

  		# gives an appropriate title to the first curve
  		# (for the legend)
		self.curve.setTitle("Ch1")
		
		# picker used to display coordinates when clicking on the canvas
		self.picker = picker(Qwt.QwtPlot.xBottom,
                               Qwt.QwtPlot.yLeft,
                               Qwt.QwtPicker.PointSelection,
                               Qwt.QwtPlotPicker.CrossRubberBand,
                               Qwt.QwtPicker.ActiveOnly,
                               self.canvas())
		
		self.cached_canvas = self.canvas()
		
		#need to replot here for the size Hints to be computed correctly (depending on axis scales...)
		self.replot()
Beispiel #7
0
	def __init__(self, parent, logger):
		ClassPlot.__init__(self)

		# store the logger instance
		self.logger = logger

		# we do not need caching
		self.canvas().setPaintAttribute(Qwt.QwtPlotCanvas.PaintCached, False)
		self.canvas().setPaintAttribute(Qwt.QwtPlotCanvas.PaintPacked, False)

		self.ymin = -140.
		self.setAxisScale(Qwt.QwtPlot.yLeft, self.ymin, 0.)
		self.baseline_transformed = False
		self.baseline = 0.
		self.curve.setBaseline(self.ymin)
		xtitle = Qwt.QwtText('Frequency (Hz)')
		xtitle.setFont(QtGui.QFont(8))
		self.setAxisTitle(Qwt.QwtPlot.xBottom, xtitle)
		# self.setAxisTitle(Qwt.QwtPlot.xBottom, 'Frequency (Hz)')
		ytitle = Qwt.QwtText('PSD (dB A)')
		ytitle.setFont(QtGui.QFont(8))
		self.setAxisTitle(Qwt.QwtPlot.yLeft, ytitle)
		# self.setAxisTitle(Qwt.QwtPlot.yLeft, 'PSD (dB)')

		# attach a grid
		grid = Qwt.QwtPlotGrid()
		grid.enableXMin(True)
		grid.setMajPen(Qt.QPen(Qt.QPen(Qt.Qt.gray)))
		grid.setMinPen(Qt.QPen(Qt.QPen(Qt.Qt.lightGray)))
		grid.setZ(1000.)
		grid.attach(self)

		self.xmax = 0
		self.needfullreplot = False

		self.canvas_width = 0
		self.logfreqscale = False
		self.setfreqrange(20., 20000.)
		self.setlinfreqscale()
		
		self.setAxisScaleDraw(Qwt.QwtPlot.xBottom, FreqScaleDraw())
		
		self.paint_time = 0.

		# picker used to display coordinates when clicking on the canvas
		self.picker = picker(Qwt.QwtPlot.xBottom,
                               Qwt.QwtPlot.yLeft,
                               Qwt.QwtPicker.PointSelection,
                               Qwt.QwtPlotPicker.CrossRubberBand,
                               Qwt.QwtPicker.ActiveOnly,
                               self.canvas())
		
		# insert an additional curve for the peak
		self.curve_peak = Qwt.QwtPlotCurve()
		#self.curve_peak.setPen(QtGui.QPen(Qt.Qt.blue))
		self.curve_peak.setPen(Qt.QColor("#FF9000")) #dark orange
		#self.curve_peak.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased)
		#self.curve_peak.setPen(QtGui.QPen(Qt.Qt.NoPen))
		#self.curve_peak.setBrush(Qt.Qt.blue)
		self.curve_peak.attach(self)
		self.peak = zeros((1,))
		self.peakHold = 0
		self.peakDecay = PEAK_DECAY_RATE
		self.peaks_enabled = True
		
		# fill under the curve
		#self.curve.setBrush(Qt.QColor(255,0,190))
		#self.curve.setBrush(Qt.Qt.red)
		self.curve.setBrush(Qt.QColor("#057D9F")) #some sort of blue
		#self.curve.setPen(Qt.QColor(255,0,0,0))
		#self.curve.setPen(QtGui.QPen(Qt.Qt.red))
		self.curve.setPen(QtGui.QPen(Qt.Qt.NoPen))
		#self.curve.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased)
		
		self.cached_canvas = self.canvas()
		
		#need to replot here for the size Hints to be computed correctly (depending on axis scales...)
		self.replot()
Beispiel #8
0
    def __init__(self, parent, logger):
        ClassPlot.__init__(self)

        # store the logger instance
        self.logger = logger

        # we do not need caching
        self.canvas().setPaintAttribute(Qwt.QwtPlotCanvas.PaintCached, False)
        self.canvas().setPaintAttribute(Qwt.QwtPlotCanvas.PaintPacked, False)

        self.ymin = -140.
        self.setAxisScale(Qwt.QwtPlot.yLeft, self.ymin, 0.)
        self.baseline_transformed = False
        self.baseline = 0.
        self.curve.setBaseline(self.ymin)
        xtitle = Qwt.QwtText('Frequency (Hz)')
        xtitle.setFont(QtGui.QFont(8))
        self.setAxisTitle(Qwt.QwtPlot.xBottom, xtitle)
        # self.setAxisTitle(Qwt.QwtPlot.xBottom, 'Frequency (Hz)')
        ytitle = Qwt.QwtText('PSD (dB A)')
        ytitle.setFont(QtGui.QFont(8))
        self.setAxisTitle(Qwt.QwtPlot.yLeft, ytitle)
        # self.setAxisTitle(Qwt.QwtPlot.yLeft, 'PSD (dB)')

        # attach a grid
        grid = Qwt.QwtPlotGrid()
        grid.enableXMin(True)
        grid.setMajPen(Qt.QPen(Qt.QPen(Qt.Qt.gray)))
        grid.setMinPen(Qt.QPen(Qt.QPen(Qt.Qt.lightGray)))
        grid.setZ(1000.)
        grid.attach(self)

        self.xmax = 0
        self.needfullreplot = False

        self.canvas_width = 0
        self.logfreqscale = False
        self.setfreqrange(20., 20000.)
        self.setlinfreqscale()

        self.setAxisScaleDraw(Qwt.QwtPlot.xBottom, FreqScaleDraw())

        self.paint_time = 0.

        # picker used to display coordinates when clicking on the canvas
        self.picker = picker(Qwt.QwtPlot.xBottom, Qwt.QwtPlot.yLeft,
                             Qwt.QwtPicker.PointSelection,
                             Qwt.QwtPlotPicker.CrossRubberBand,
                             Qwt.QwtPicker.ActiveOnly, self.canvas())

        # insert an additional curve for the peak
        self.curve_peak = Qwt.QwtPlotCurve()
        #self.curve_peak.setPen(QtGui.QPen(Qt.Qt.blue))
        self.curve_peak.setPen(Qt.QColor("#FF9000"))  #dark orange
        #self.curve_peak.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased)
        #self.curve_peak.setPen(QtGui.QPen(Qt.Qt.NoPen))
        #self.curve_peak.setBrush(Qt.Qt.blue)
        self.curve_peak.attach(self)
        self.peak = zeros((1, ))
        self.peakHold = 0
        self.peakDecay = PEAK_DECAY_RATE
        self.peaks_enabled = True

        # fill under the curve
        #self.curve.setBrush(Qt.QColor(255,0,190))
        #self.curve.setBrush(Qt.Qt.red)
        self.curve.setBrush(Qt.QColor("#057D9F"))  #some sort of blue
        #self.curve.setPen(Qt.QColor(255,0,0,0))
        #self.curve.setPen(QtGui.QPen(Qt.Qt.red))
        self.curve.setPen(QtGui.QPen(Qt.Qt.NoPen))
        #self.curve.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased)

        self.cached_canvas = self.canvas()

        #need to replot here for the size Hints to be computed correctly (depending on axis scales...)
        self.replot()