Exemplo n.º 1
0
 def test_saturation_correction_shape_mismatch(self):
     det = Maxipix("Maxipix")
     det.saturation_threshold = 10
     data = np.ones((3, 3)) * 11
     mask = np.zeros((3, 4))
     with self.assertRaises(ValueError):
         det._saturation_correction(data, mask, nb_frames=1)
Exemplo n.º 2
0
 def test_saturation_correction_nbframes_wrong_value(self):
     det = Maxipix("Maxipix")
     det.saturation_threshold = 10
     data = np.ones((3, 3)) * 11
     mask = np.zeros((3, 3))
     with self.assertRaises(ValueError):
         det._saturation_correction(data, mask, nb_frames=0)
Exemplo n.º 3
0
 def test_saturation_correction_wrong_type(self):
     det = Maxipix("Maxipix")
     det.saturation_threshold = 10
     data = 11
     mask = np.zeros((3, 3))
     with self.assertRaises(TypeError):
         det._saturation_correction(data, mask, nb_frames=1)
Exemplo n.º 4
0
 def test_saturation_correction_nbframes_2(self):
     det = Maxipix("Maxipix")
     det.saturation_threshold = 10
     data = np.ones((3, 3)) * 11
     mask = np.zeros((3, 3))
     output = det._saturation_correction(data, mask, nb_frames=2)
     self.assertTrue(np.all(np.isclose(output[0], data)))
     self.assertTrue(np.all(np.isclose(output[1], mask)))
Exemplo n.º 5
0
class TestMaxipix(unittest.TestCase):
    """Tests related to the Maxipix detector."""
    def setUp(self) -> None:
        self.det = Maxipix("Maxipix")
        self.data = np.ones(self.det.unbinned_pixel_number)
        self.mask = np.zeros(self.det.unbinned_pixel_number)

    def test_unbinned_pixel_number_default(self):
        self.assertTupleEqual(self.det.unbinned_pixel_number, (516, 516))

    def test_unbinned_pixel_size_default(self):
        self.assertTupleEqual(self.det.unbinned_pixel_size, (55e-06, 55e-06))

    def test_mask_gaps(self):
        data, mask = self.det._mask_gaps(data=self.data, mask=self.mask)
        self.assertTrue(np.all(data[:, 255:261]) == 0)
        self.assertTrue(np.all(data[255:261, :]) == 0)
        self.assertTrue(np.all(mask[:, 255:261]) == 1)
        self.assertTrue(np.all(mask[255:261, :]) == 1)
Exemplo n.º 6
0
 def test_sum_roi_list_wrong_value_decreasing_x(self):
     with self.assertRaises(ValueError):
         Maxipix(name="Maxipix", sum_roi=[0, 256, 128, 35])
Exemplo n.º 7
0
 def test_sum_roi_none_default(self):
     det = Maxipix(name="Maxipix", sum_roi=None)
     self.assertEqual(det.sum_roi, [0, self.det.nb_pixel_y, 0, self.det.nb_pixel_x])
Exemplo n.º 8
0
 def test_rootdir_wrong_length(self):
     with self.assertRaises(ValueError):
         Maxipix(name="Maxipix", rootdir="")
Exemplo n.º 9
0
 def test_sum_roi_list_wrong_value_none(self):
     with self.assertRaises(ValueError):
         Maxipix(name="Maxipix", sum_roi=[None, 512, 12, 35])
Exemplo n.º 10
0
 def test_template_imagefile_correct(self):
     det = Maxipix(name="Maxipix", template_imagefile="S")
     self.assertEqual(det.template_imagefile, "S")
Exemplo n.º 11
0
 def test_roi_correct_tuple(self):
     det = Maxipix(name="Maxipix", roi=(2, 252, 1, 35))
     self.assertEqual(det.roi, (2, 252, 1, 35))
Exemplo n.º 12
0
 def test_scandir_datadir_defined(self):
     dir_path = os.path.abspath(os.path.join(self.valid_path, os.pardir)) + "/"
     det = Maxipix(name="Maxipix", datadir=self.valid_path)
     self.assertEqual(det.scandir, dir_path.replace("\\", "/"))
Exemplo n.º 13
0
 def test_template_imagefile_wrong_type(self):
     with self.assertRaises(TypeError):
         Maxipix(name="Maxipix", template_imagefile=777)
Exemplo n.º 14
0
 def test_sample_name_None(self):
     det = Maxipix(name="Maxipix", sample_name=None)
     self.assertEqual(det.sample_name, None)
Exemplo n.º 15
0
 def test_sample_name_correct(self):
     det = Maxipix(name="Maxipix", sample_name="S")
     self.assertEqual(det.sample_name, "S")
Exemplo n.º 16
0
 def test_sample_name_wrong_length(self):
     with self.assertRaises(ValueError):
         Maxipix(name="Maxipix", sample_name="")
Exemplo n.º 17
0
 def test_sample_name_wrong_type(self):
     with self.assertRaises(TypeError):
         Maxipix(name="Maxipix", sample_name=777)
Exemplo n.º 18
0
 def test_rootdir_None(self):
     det = Maxipix(name="Maxipix", rootdir=None)
     self.assertEqual(det.rootdir, None)
Exemplo n.º 19
0
 def test_sum_roi_none_default_roi_defined(self):
     det = Maxipix(name="Maxipix", sum_roi=None, roi=(2, 252, 1, 35))
     self.assertEqual(det.sum_roi, det.roi)
     self.assertEqual(det.sum_roi, (2, 252, 1, 35))
Exemplo n.º 20
0
 def test_scandir_datadir_none(self):
     det = Maxipix(name="Maxipix", datadir=None)
     self.assertEqual(det.scandir, None)
Exemplo n.º 21
0
 def test_sum_roi_empty_list(self):
     det = Maxipix(name="Maxipix", sum_roi=(), roi=(2, 252, 1, 35))
     self.assertEqual(det.sum_roi, det.roi)
     self.assertEqual(det.sum_roi, (2, 252, 1, 35))
Exemplo n.º 22
0
 def test_rootdir_not_exist(self):
     with self.assertRaises(ValueError):
         Maxipix(name="Maxipix", rootdir="this directory does not exist")
Exemplo n.º 23
0
 def test_template_imagefile_None(self):
     det = Maxipix(name="Maxipix", template_imagefile=None)
     self.assertEqual(det.template_imagefile, None)
Exemplo n.º 24
0
 def test_roi_list_wrong_value_decreasing_y(self):
     with self.assertRaises(ValueError):
         Maxipix(name="Maxipix", roi=[128, 0, 12, 35])
Exemplo n.º 25
0
 def test_rootdir_exists(self):
     det = Maxipix(name="Maxipix", rootdir=self.valid_path)
     self.assertEqual(det.rootdir, self.valid_path)
Exemplo n.º 26
0
 def test_sum_roi_list_wrong_length(self):
     with self.assertRaises(ValueError):
         Maxipix(name="Maxipix", sum_roi=[2, 2])
Exemplo n.º 27
0
 def test_sum_roi_number(self):
     with self.assertRaises(TypeError):
         Maxipix(name="Maxipix", sum_roi=2)
Exemplo n.º 28
0
 def test_rootdir_wrong_type(self):
     with self.assertRaises(TypeError):
         Maxipix(name="Maxipix", rootdir=777)
Exemplo n.º 29
0
 def setUp(self) -> None:
     self.det = Maxipix("Maxipix")
     self.data = np.ones(self.det.unbinned_pixel_number)
     self.mask = np.zeros(self.det.unbinned_pixel_number)
Exemplo n.º 30
0
 def test_sum_roi_list_wrong_type(self):
     with self.assertRaises(TypeError):
         Maxipix(name="Maxipix", sum_roi=[2.0, 512, 12, 35])