Ejemplo n.º 1
0
    def test_not_offcentered(self):
        self.camera.rotation_radius = 0
        with self.assertRaises(ValueError) as ctx:
            align_rotation_axis(self.camera, self.y_motor,
                                x_motor=self.x_motor,
                                z_motor=self.z_motor).join()

        self.assertEqual("Sample off-centering too " +
                         "small, enlarge rotation radius.",
                         str(ctx.exception))
Ejemplo n.º 2
0
    def test_out_of_fov(self):
        def get_ones():
            return np.ones((self.camera.size,
                            self.camera.size))

        self.camera._grab_real = get_ones

        with self.assertRaises(ValueError) as ctx:
            align_rotation_axis(self.camera, self.y_motor,
                                x_motor=self.x_motor,
                                z_motor=self.z_motor).join()

        self.assertEqual("No sample tip points found.", str(ctx.exception))
Ejemplo n.º 3
0
    def align_check(self, x_angle, z_angle, has_x_motor=True,
                    has_z_motor=True, flat=None, dark=None):
        """"Align and check the results."""
        self.x_motor.position = z_angle
        self.z_motor.position = x_angle

        x_motor = self.x_motor if has_x_motor else None
        z_motor = self.z_motor if has_z_motor else None

        align_rotation_axis(self.camera, self.y_motor, x_motor=x_motor, z_motor=z_motor, flat=flat,
                            dark=dark).join()

        # In our case the best perfectly aligned position is when both
        # motors are in 0.
        if has_x_motor:
            assert np.abs(self.x_motor.position) < self.eps
        if has_z_motor:
            assert np.abs(self.z_motor.position) < self.eps
Ejemplo n.º 4
0
 def test_align_rotation_axis_func_type_error(self):
     with self.assertRaises(TypeError):
         align_rotation_axis(self.camera, self.linear_motor).result()
     with self.assertRaises(TypeError):
         align_rotation_axis(
             self.camera, self.rotation_motor, self.linear_motor).result()
     with self.assertRaises(TypeError):
         align_rotation_axis(
             self.camera,
             self.rotation_motor,
             self.rotation_motor,
             self.rotation_motor,
             measure=rotation_axis,
             num_frames=[
                 10,
                 20]).result()
     with self.assertRaises(TypeError):
         align_rotation_axis(
             self.camera,
             self.rotation_motor,
             self.rotation_motor,
             self.rotation_motor,
             measure=rotation_axis,
             num_frames=10 *
             q.mm).result()
     with self.assertRaises(TypeError):
         align_rotation_axis(
             self.camera,
             self.rotation_motor,
             self.rotation_motor,
             self.rotation_motor,
             measure=rotation_axis,
             num_frames=10,
             absolute_eps=[
                 1,
                 2] * q.deg).result()
Ejemplo n.º 5
0
 def test_align_rotation_axis_function(self):
     align_rotation_axis(
         self.camera, self.rotation_motor, x_motor=self.rotation_motor)
Ejemplo n.º 6
0
 def test_no_motor(self):
     with self.assertRaises(ValueError):
         align_rotation_axis(self.camera, self.y_motor, x_motor=None, z_motor=None).join()