示例#1
0
    def test_refresh(self):
        plot = os.path.join(self.tempdir, 'plot.svg')
        plot2 = os.path.join(self.tempdir, 'plot2.svg')

        sdf = specplot.openSpecFile(self.data_file.name)
        scan = sdf.getScan(3)
        plotter = specplot.LinePlotter()

        # plot the first data
        plotter.plot_scan(scan, plot)
        self.assertTrue(os.path.exists(plot))
        plotsize = os.path.getsize(plot)
        mtime = os.path.getmtime(plot)
        self.assertGreater(plotsize, 0)
        self.assertGreater(mtime, 0)

        for iter in range(2):
            scan_number = sdf.refresh()
            if scan_number is None:
                scan = sdf.getScan(3)
                self.assertTrue(scan.__interpreted__)
                # update the file with more data
                self.addMoreScans()
                time.sleep(0.1)
            else:
                scan = sdf.getScan(3)
                self.assertFalse(scan.__interpreted__)
                plotter.plot_scan(scan, plot2)
                self.assertTrue(os.path.exists(plot2))
                self.assertGreater(os.path.getmtime(plot2), mtime)
                self.assertNotEqual(os.path.getsize(plot2), plotsize)
示例#2
0
 def test_y_values_all_zero_lin_lin(self):
     specFile = os.path.join(os.path.dirname(__file__), 'data', 'issue64_data.txt')
     scan_number = 50
  
     sfile = specplot.openSpecFile(specFile)
     scan = sfile.getScan(scan_number)
     self.assertTrue(scan is not None)
     plotter = specplot.LinePlotter()
  
     if os.path.exists(self.plotFile):   # always re-create this plot for testing
         os.remove(self.plotFile)
     plotter.plot_scan(scan, self.plotFile)
     self.assertTrue(os.path.exists(self.plotFile))
示例#3
0
    def test_y_values_all_zero_lin_lin(self):
        specFile = os.path.join(os.path.dirname(__file__), 'data',
                                'issue64_data.txt')
        scan_number = 50

        sfile = specplot.openSpecFile(specFile)
        scan = sfile.getScan(scan_number)
        self.assertTrue(scan is not None)
        plotter = specplot.LinePlotter()

        if os.path.exists(
                self.plotFile):  # always re-create this plot for testing
            os.remove(self.plotFile)
        plotter.plot_scan(scan, self.plotFile)
        self.assertTrue(os.path.exists(self.plotFile))
示例#4
0
    def test_scan_aborted_after_0_points(self):
        specFile = self.abs_data_fname('33bm_spec.dat')
        scan_number = 15

        sfile = specplot.openSpecFile(specFile)
        scan = sfile.getScan(scan_number)
        self.assertTrue(scan is not None)
        plotter = specplot.LinePlotter()

        if os.path.exists(
                self.plotFile):  # always re-create this plot for testing
            os.remove(self.plotFile)

        self.assertRaises(specplot.NoDataToPlot, plotter.plot_scan, scan,
                          self.plotFile)

        self.assertFalse(os.path.exists(self.plotFile))
示例#5
0
    def test_40x35_grid_shown_properly_lmn40_spe(self):
        specFile = self.abs_data_fname('lmn40.spe')
        scan_number = 14

        sfile = specplot.openSpecFile(specFile)
        scan = sfile.getScan(scan_number)
        self.assertTrue(scan is not None)

        image_maker = specplot.Selector().auto(scan)
        self.assertTrue(issubclass(image_maker, specplot.ImageMaker))

        plotter = image_maker()
        self.assertTrue(isinstance(plotter, specplot.MeshPlotter))

        if os.path.exists(self.plotFile):   # always re-create this plot for testing
            os.remove(self.plotFile)
        plotter.plot_scan(scan, self.plotFile)
        self.assertTrue(os.path.exists(self.plotFile))
示例#6
0
    def test_one_line_mesh_scan_type_error_33id_29(self):
        specFile = self.abs_data_fname('33id_spec.dat')
        scan_number = 29
 
        sfile = specplot.openSpecFile(specFile)
        scan = sfile.getScan(scan_number)
        self.assertTrue(scan is not None)
 
        image_maker = specplot.Selector().auto(scan)
        self.assertTrue(issubclass(image_maker, specplot.ImageMaker))
 
        plotter = image_maker()
        self.assertTrue(isinstance(plotter, specplot.MeshPlotter))
 
        if os.path.exists(self.plotFile):   # always re-create this plot for testing
            os.remove(self.plotFile)
        plotter.plot_scan(scan, self.plotFile)
        self.assertTrue(os.path.exists(self.plotFile))
示例#7
0
 def test_one_line_mesh_scan_as_1D_plot_issue82(self):
     specFile = os.path.join(os.path.dirname(__file__), 'data', 'issue82_data.txt')
     scan_number = 17
 
     sfile = specplot.openSpecFile(specFile)
     scan = sfile.getScan(scan_number)
     self.assertTrue(scan is not None)
 
     image_maker = specplot.Selector().auto(scan)
     self.assertTrue(issubclass(image_maker, specplot.ImageMaker))
 
     plotter = image_maker()
     self.assertTrue(isinstance(plotter, specplot.MeshPlotter))
 
     if os.path.exists(self.plotFile):   # always re-create this plot for testing
         os.remove(self.plotFile)
     plotter.plot_scan(scan, self.plotFile)
     self.assertTrue(os.path.exists(self.plotFile))
示例#8
0
    def test_40x35_grid_shown_properly_lmn40_spe(self):
        specFile = self.abs_data_fname('lmn40.spe')
        scan_number = 14

        sfile = specplot.openSpecFile(specFile)
        scan = sfile.getScan(scan_number)
        self.assertTrue(scan is not None)

        image_maker = specplot.Selector().auto(scan)
        self.assertTrue(issubclass(image_maker, specplot.ImageMaker))

        plotter = image_maker()
        self.assertTrue(isinstance(plotter, specplot.MeshPlotter))

        if os.path.exists(
                self.plotFile):  # always re-create this plot for testing
            os.remove(self.plotFile)
        plotter.plot_scan(scan, self.plotFile)
        self.assertTrue(os.path.exists(self.plotFile))
示例#9
0
    def test_one_line_mesh_scan_type_error_33id_29(self):
        specFile = self.abs_data_fname('33id_spec.dat')
        scan_number = 29

        sfile = specplot.openSpecFile(specFile)
        scan = sfile.getScan(scan_number)
        self.assertTrue(scan is not None)

        image_maker = specplot.Selector().auto(scan)
        self.assertTrue(issubclass(image_maker, specplot.ImageMaker))

        plotter = image_maker()
        self.assertTrue(isinstance(plotter, specplot.MeshPlotter))

        if os.path.exists(
                self.plotFile):  # always re-create this plot for testing
            os.remove(self.plotFile)
        plotter.plot_scan(scan, self.plotFile)
        self.assertTrue(os.path.exists(self.plotFile))
示例#10
0
    def test_one_line_mesh_scan_as_1D_plot_issue82(self):
        specFile = os.path.join(os.path.dirname(__file__), 'data',
                                'issue82_data.txt')
        scan_number = 17

        sfile = specplot.openSpecFile(specFile)
        scan = sfile.getScan(scan_number)
        self.assertTrue(scan is not None)

        image_maker = specplot.Selector().auto(scan)
        self.assertTrue(issubclass(image_maker, specplot.ImageMaker))

        plotter = image_maker()
        self.assertTrue(isinstance(plotter, specplot.MeshPlotter))

        if os.path.exists(
                self.plotFile):  # always re-create this plot for testing
            os.remove(self.plotFile)
        plotter.plot_scan(scan, self.plotFile)
        self.assertTrue(os.path.exists(self.plotFile))
示例#11
0
 def test_scan_aborted_after_0_points(self):
     specFile = self.abs_data_fname('33bm_spec.dat')
     scan_number = 15
  
     sfile = specplot.openSpecFile(specFile)
     scan = sfile.getScan(scan_number)
     self.assertTrue(scan is not None)
     plotter = specplot.LinePlotter()
  
     if os.path.exists(self.plotFile):   # always re-create this plot for testing
         os.remove(self.plotFile)
          
     self.assertRaises(
         specplot.NoDataToPlot, 
         plotter.plot_scan, 
         scan, 
         self.plotFile
         )
          
     self.assertFalse(os.path.exists(self.plotFile))