Ejemplo n.º 1
0
    def test_plot_clear(self):
        # tests to make sure that when the clear flag is passed
        # to plots, that clear works as expected
        plot_item = MyPlotItem()
        x = [1]
        y = [1]
        plot = PlotCurveItem(x, y)
        plot_item.addItem(plot)

        plot2 = PlotCurveItem(y, x)
        plot_item.add_event_item(plot2)

        plot5 = PlotCurveItem(y, x)
        plot_item.addItem(plot5)

        x = y = np.zeros(2)
        plot3 = PathItem(x, y)
        plot_item.add_event_item(plot3)

        plot4 = plot_item.plot(clear=True)

        # Test that all of the plots have been cleared,
        # and that plot4 was added successfully
        self.assertEqual(len(plot_item.listDataItems()), 1)
        self.assertEqual(len(plot_item._myEventItemList), 0)
        self.assertEqual(len(plot_item._myItemList), 1)
        self.assertEqual(plot_item.listDataItems()[0], plot4)
        self.assertEqual(plot_item._myItemList[0], plot4)
Ejemplo n.º 2
0
    def test_bounding_rect_small_values(self):
        x = np.random.uniform(-1.e-9, 1.e-9, size=10)
        y = np.random.uniform(-1.e-9, 1.e-9, size=10)

        x_max = x.max()
        x_min = x.min()
        y_max = y.max()
        y_min = y.min()

        item = PathItem(x, y)
        rect = item.boundingRect()
        rect_left = rect.left()
        self.assertAlmostEqual(rect_left, x_min, 12)
        rect_top = rect.top()
        self.assertAlmostEqual(rect_top, y_min, 12)
        wid = rect.width()
        hei = rect.height()
        self.assertAlmostEqual(wid, x_max - x_min, 12)
        self.assertAlmostEqual(hei, y_max - y_min)
Ejemplo n.º 3
0
    def testBoundingRectSmallVales(self):
        x = np.random.uniform(-1.e-9, 1.e-9, size=10)
        y = np.random.uniform(-1.e-9, 1.e-9, size=10)

        xmax = x.max()
        xmin = x.min()
        ymax = y.max()
        ymin = y.min()

        item = PathItem(x, y)
        rect = item.boundingRect()
        rectleft = rect.left()
        self.assertAlmostEqual(rectleft, xmin, 12)
        recttop = rect.top()
        self.assertAlmostEqual(recttop, ymin, 12)
        wid = rect.width()
        hei = rect.height()
        self.assertAlmostEqual(wid, xmax - xmin, 12)
        self.assertAlmostEqual(hei, ymax - ymin)
Ejemplo n.º 4
0
 def testBoundingRectSmallVales(self):
     x = np.random.uniform(-1.e-9,1.e-9,size=10)
     y = np.random.uniform(-1.e-9,1.e-9,size=10)
     
     xmax = x.max()
     xmin = x.min()
     ymax = y.max()
     ymin = y.min()
     
     item = PathItem(x,y)
     rect = item.boundingRect()
     rectleft = rect.left()
     self.assertAlmostEqual(rectleft, xmin, 12)
     recttop = rect.top()
     self.assertAlmostEqual(recttop, ymin, 12)
     wid = rect.width()
     hei = rect.height()
     self.assertAlmostEqual(wid, xmax-xmin, 12)
     self.assertAlmostEqual(hei, ymax-ymin)
Ejemplo n.º 5
0
    def test_my_plot_item_add_item(self):
        plot_item = MyPlotItem()
        x = [1]
        y = [1]
        plot = PlotCurveItem(x, y)
        plot_item.addItem(plot)

        self.assertEqual(len(plot_item._myItemList), 1)

        x = y = np.zeros(2)
        plot2 = PathItem(x, y)
        plot_item.addItem(plot2)
        self.assertEqual(len(plot_item._myItemList), 2)
Ejemplo n.º 6
0
    def test_clear(self):
        plot_item = MyPlotItem()
        x = [1]
        y = [1]
        plot = PlotCurveItem(x, y)
        plot_item.addItem(plot)

        plot2 = PlotCurveItem(y, x)
        plot_item.add_event_item(plot2)

        x = y = np.zeros(2)
        plot3 = PathItem(x, y)
        plot_item.add_event_item(plot3)

        plot_item.clear()
        self.assertEqual(len(plot_item.listDataItems()), 0)
        self.assertEqual(len(plot_item._myEventItemList), 0)
        self.assertEqual(len(plot_item._myItemList), 0)
Ejemplo n.º 7
0
    def plot_debug(self, event_database):
        """
        Plots the data, baseline, and thresholds of the debug group in the event_database, if they exist,
        in the main plot.

        :param event_database: An already open\
                :class:`EventDatabase <pypore.filetypes.event_database.EventDatabase>`.
        """
        if not event_database.is_debug():
            return

        self.eventview_plotwid.clear()

        sample_rate = event_database.get_sample_rate()

        # TODO remove the step_size.
        step_size = 1000

        data = event_database.root.debug.data[0][::step_size]

        data_size = data.size
        times = np.linspace(0, data_size *1.0/sample_rate, data_size)
        item = PathItem(times, data)
        item.setPen(pg.mkPen('w'))
        self.eventview_plotwid.addItem(item)

        baseline = event_database.root.debug.baseline[0][::step_size]
        item = PathItem(times, baseline)
        item.setPen(pg.mkPen('y'))
        self.eventview_plotwid.addItem(item)

        threshold_p = event_database.root.debug.threshold_positive[0][::step_size]
        item = PathItem(times, threshold_p)
        item.setPen(pg.mkPen('g'))
        self.eventview_plotwid.addItem(item)

        threshold_n = event_database.root.debug.threshold_negative[0][::step_size]
        item = PathItem(times, threshold_n)
        item.setPen(pg.mkPen('g'))
        self.eventview_plotwid.addItem(item)
Ejemplo n.º 8
0
    def plot_debug(self, event_database):
        """
        Plots the data, baseline, and thresholds of the debug group in the event_database, if they exist,
        in the main plot.

        :param event_database: An already open\
                :class:`EventDatabase <pypore.filetypes.event_database.EventDatabase>`.
        """
        if not event_database.is_debug():
            return

        self.eventview_plotwid.clear()

        sample_rate = event_database.get_sample_rate()

        # TODO remove the step_size.
        step_size = 1000

        data = event_database.root.debug.data[0][::step_size]

        data_size = data.size
        times = np.linspace(0, data_size * 1.0 / sample_rate, data_size)
        item = PathItem(times, data)
        item.setPen(pg.mkPen('w'))
        self.eventview_plotwid.addItem(item)

        baseline = event_database.root.debug.baseline[0][::step_size]
        item = PathItem(times, baseline)
        item.setPen(pg.mkPen('y'))
        self.eventview_plotwid.addItem(item)

        threshold_p = event_database.root.debug.threshold_positive[
            0][::step_size]
        item = PathItem(times, threshold_p)
        item.setPen(pg.mkPen('g'))
        self.eventview_plotwid.addItem(item)

        threshold_n = event_database.root.debug.threshold_negative[
            0][::step_size]
        item = PathItem(times, threshold_n)
        item.setPen(pg.mkPen('g'))
        self.eventview_plotwid.addItem(item)