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 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 #3
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 #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()