Exemplo n.º 1
0
    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()
Exemplo n.º 2
0
    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