def set_data(self, evt): dB = evt.data num_curves = evt.ninputs L = len(dB) / num_curves self._points = [] for i in range(0, num_curves): self._points.append(numpy.zeros((L, 2), numpy.float64)) for i in range(0, num_curves): self._points[i][:, 0] = self.curvesink.x_vals self._points[i][:, 1] = dB[i * L:(i * L) + L] lines = [] for i in range(0, num_curves): lines.append( plot.PolyLine(self._points[i], colour=COLOR_LIST[i % num_curves], legend=self.curvesink.legends[i])) graphics = plot.PlotGraphics(lines, title=self.curvesink.title, xLabel=self.x_units, yLabel=self.y_units) x_range = self.curvesink.x_vals[0], self.curvesink.x_vals[-1] ymax = self.curvesink.ref_level ymin = self.curvesink.ref_level - self.curvesink.y_per_div * self.curvesink.y_divs y_range = ymin, ymax self.plot.Draw(graphics, xAxis=x_range, yAxis=y_range, step=self.curvesink.y_per_div)
def format_xy_data(self, evt): info = self.info records = evt.data nchannels = len(records) npoints = len(records[0]) if nchannels < 2: return objects = [] # points = zip(records[0], records[1]) points = numpy.zeros((len(records[0]), 2), numpy.float32) points[:, 0] = records[0] points[:, 1] = records[1] self.SetXUseScopeTicks(False) m = info.get_marker() if m == 'line': objects.append(plot.PolyLine(points, colour=self.channel_color(0))) else: objects.append( plot.PolyMarker(points, marker=m, colour=self.channel_color(0))) graphics = plot.PlotGraphics(objects, title=self.info.title, xLabel='I', yLabel='Q') self.Draw(graphics, xAxis=self.x_range, yAxis=self.y_range) self.update_y_range() self.update_x_range()
def set_data(self, evt): dB = evt.data L = len(dB) if self.peak_hold: if self.peak_vals is None: self.peak_vals = dB else: self.peak_vals = numpy.maximum(dB, self.peak_vals) dB = self.peak_vals x = max(abs(self.facsink.sample_rate), abs(self.facsink.baseband_freq)) sf = 1000.0 units = "ms" x_vals = ((numpy.arange(L / 2) * ((sf / self.facsink.sample_rate)))) points = numpy.zeros((len(x_vals), 2), numpy.float64) points[:, 0] = x_vals points[:, 1] = dB[0:L / 2] lines = plot.PolyLine(points, colour='green') # DARKRED graphics = plot.PlotGraphics([lines], title=self.facsink.title, xLabel=units, yLabel="dB") self.Draw(graphics, xAxis=None, yAxis=self.y_range) self.update_y_range()
def format_data (self, evt): if not self.info.running: return if self.info.xy: self.format_xy_data (evt) return info = self.info records = evt.data nchannels = len (records) npoints = len (records[0]) objects = [] Ts = 1.0 / (info.get_sample_rate () / info.get_decimation_rate ()) x_vals = Ts * numpy.arange (-npoints/2, npoints/2) # preliminary clipping based on time axis here, instead of in graphics code time_per_window = self.info.get_time_per_div () * 10 n = int (time_per_window / Ts + 0.5) n = n & ~0x1 # make even n = max (2, min (n, npoints)) self.SetXUseScopeTicks (True) # use 10 divisions, no labels for ch in range(nchannels): r = records[ch] # plot middle n points of record lb = npoints/2 - n/2 ub = npoints/2 + n/2 # points = zip (x_vals[lb:ub], r[lb:ub]) points = numpy.zeros ((ub-lb, 2), numpy.float64) points[:,0] = x_vals[lb:ub] points[:,1] = r[lb:ub] m = info.get_marker () if m == 'line': objects.append (plot.PolyLine (points, colour=self.channel_color (ch), legend=('Ch%d' % (ch+1,)))) else: objects.append (plot.PolyMarker (points, marker=m, colour=self.channel_color (ch), legend=('Ch%d' % (ch+1,)))) graphics = plot.PlotGraphics (objects, title=self.info.title, xLabel = '', yLabel = '') time_per_div = info.get_time_per_div () x_range = (-5.0 * time_per_div, 5.0 * time_per_div) # ranges are tuples! volts_per_div = info.get_volts_per_div () if not self.info.autorange: self.y_range = (-4.0 * volts_per_div, 4.0 * volts_per_div) self.Draw (graphics, xAxis=x_range, yAxis=self.y_range) self.update_y_range () # autorange to self.y_range
def format_data(self, evt): if not self.info.running: return info = self.info records = evt.data nchannels = len(records) npoints = len(records[0]) self.total_points += npoints x_vals = numpy.arange(0, evt.samples_per_symbol) self.SetXUseScopeTicks(True) # use 10 divisions, no labels objects = [] colors = [ 'red', 'orange', 'yellow', 'green', 'blue', 'violet', 'cyan', 'magenta', 'brown', 'black' ] r = records[0] # input data v_min = None v_max = None for i in range(evt.num_plots): points = [] for j in range(evt.samples_per_symbol): v = r[i * evt.samples_per_symbol + j] if (v_min is None) or (v < v_min): v_min = v if (v_max is None) or (v > v_max): v_max = v p = [j, v] points.append(p) objects.append( plot.PolyLine(points, colour=colors[i % len(colors)], legend=(''))) graphics = plot.PlotGraphics(objects, title=self.info.title, xLabel='Time', yLabel='Amplitude') x_range = (0., 0. + (evt.samples_per_symbol - 1)) # ranges are tuples! if self.y_range is None: v_scale = max(abs(v_min), abs(v_max)) y_range = (-v_scale, v_scale) #y_range = (min, max) else: y_range = self.y_range self.Draw(graphics, xAxis=x_range, yAxis=y_range)
def format_data(self, evt): if not self.info.running: return info = self.info records = evt.data nchannels = len(records) npoints = len(records[0]) self.total_points += npoints x_vals = numpy.arange(0, self.samples_per_symbol) self.SetXUseScopeTicks(True) # use 10 divisions, no labels objects = [] colors = [ 'red', 'orange', 'yellow', 'green', 'blue', 'violet', 'cyan', 'magenta', 'brown', 'black' ] r = records[0] # input data for i in range(self.num_plots): points = [] for j in range(self.samples_per_symbol): p = [j, r[i * self.samples_per_symbol + j]] points.append(p) objects.append( plot.PolyLine(points, colour=colors[i % len(colors)], legend=(''))) graphics = plot.PlotGraphics(objects, title='Data Scope', xLabel='Time', yLabel='Amplitude') x_range = (0., 0. + (self.samples_per_symbol - 1) ) # ranges are tuples! self.y_range = (-4., 4.) # for standard -3/-1/+1/+3 self.Draw(graphics, xAxis=x_range, yAxis=self.y_range)
def set_data (self, evt): calc_min = 99e10 calc_max = -99e10 dB = evt.data L = len (dB) calc_min = min(dB) calc_max = max(dB) if (self.ra_fftsink.ofunc != None): self.ra_fftsink.ofunc(evt.data,L) if self.peak_hold: if self.peak_vals is None: self.peak_vals = dB else: self.peak_vals = numpy.maximum(dB, self.peak_vals) dB = self.peak_vals x = max(abs(self.ra_fftsink.sample_rate), abs(self.ra_fftsink.baseband_freq)) if x >= 1e9: sf = 1e-9 units = "GHz" elif x >= 1e6: sf = 1e-6 units = "MHz" elif x >= 1e3: sf = 1e-3 units = "kHz" else: sf = 1.0 units = "Hz" if self.ra_fftsink.input_is_real: # only plot 1/2 the points x_vals = ((numpy.arange (L/2) * (self.ra_fftsink.sample_rate * sf / L)) + self.ra_fftsink.baseband_freq * sf) points = numpy.zeros((len(x_vals), 2), numpy.float64) points[:,0] = x_vals points[:,1] = dB[0:L/2] else: # the "negative freqs" are in the second half of the array x_vals = ((numpy.arange(-L/2, L/2) * (self.ra_fftsink.sample_rate * sf / L)) + self.ra_fftsink.baseband_freq * sf) points = numpy.zeros((len(x_vals), 2), numpy.float64) points[:,0] = x_vals points[:,1] = numpy.concatenate ((dB[L/2:], dB[0:L/2])) lines = plot.PolyLine (points, colour='BLUE') graphics = plot.PlotGraphics ([lines], title=self.ra_fftsink.title, xLabel = units, yLabel = "dB") self.Draw (graphics, xAxis=None, yAxis=self.y_range) d = calc_max - calc_min d = d * 0.1 if self.ra_fftsink.autoscale == True: self.y_range = self._axisInterval ('min', calc_min-d, calc_max+d) else: self.update_y_range ()