Example #1
0
    def test_slits(self):
        """
            Check slit data
        """
        filename = "cansas1d_slit.xml"
        data = CANSASReader().read(filename)
        self.data = data[0]
        self.assertEqual(self.data.filename, filename)
        self.assertEqual(self.data.run[0], "1234")

        # Data
        self.assertEqual(len(self.data.x), 2)
        self.assertEqual(self.data.x_unit, '1/A')
        self.assertEqual(self.data.y_unit, '1/cm')
        self.assertEqual(self.data.x[0], 0.02)
        self.assertEqual(self.data.y[0], 1000)
        self.assertEqual(self.data.dxl[0], 0.005)
        self.assertEqual(self.data.dxw[0], 0.001)
        self.assertEqual(self.data.dy[0], 3)
        self.assertEqual(self.data.x[1], 0.03)
        self.assertAlmostEquals(self.data.y[1], 1001.0)
        self.assertEqual(self.data.dx, None)
        self.assertEqual(self.data.dxl[1], 0.005)
        self.assertEqual(self.data.dxw[1], 0.001)
        self.assertEqual(self.data.dy[1], 4)
        self.assertEqual(self.data.run_name['1234'], 'run name')
        self.assertEqual(self.data.title, "Test title")
Example #2
0
 def test_units(self):
     """
         Check units.
         Note that not all units are available.
     """
     filename = "cansas1d_units.xml"
     data = CANSASReader().read(filename)
     self.data = data[0]
     self.assertEqual(self.data.filename, filename)
     self._checkdata()
Example #3
0
    def test_writer(self):
        r = CANSASReader()

        filename = "write_test.xml"
        r.write(filename, self.data)
        data = Loader().load(filename)
        self.data = data[0]
        self.assertEqual(self.data.filename, filename)
        self._checkdata()
        if os.path.isfile(filename):
            os.remove(filename)
Example #4
0
    def test_badunits(self):
        """
            Check units.
            Note that not all units are available.
        """
        filename = "cansas1d_badunits.xml"
        data = CANSASReader().read(filename)
        self.data = data[0]
        self.assertEqual(self.data.filename, filename)
        # The followed should not have been loaded
        self.assertAlmostEqual(self.data.sample.thickness, 0.00103)
        # This one should
        self.assertAlmostEqual(self.data.sample.transmission, 0.327)

        self.assertEqual(self.data.meta_data['loader'], "CanSAS XML 1D")
        print(self.data.errors)
        self.assertEqual(len(self.data.errors), 1)
Example #5
0
 def setUp(self):
     reader = CANSASReader()
     data = reader.read("cansas1d.xml")
     self.data = data[0]
Example #6
0
 def setUp(self):
     reader = CANSASReader()
     self.data_list = reader.read(find("cansas1d.xml"))
     self.data = self.data_list[0]