示例#1
0
 def test_z_rotation_90(self):
     # +90 degree z-rotation
     self.rotmat = euler(np.radians(90), 'z')
     _powerfit.rotate_image3d(self.image, self.rotmat, self.center,
                              self.radius, self.out)
     self.answer[0, :self.radius, 0] = 1
     self.assertTrue(np.allclose(self.answer, self.out))
示例#2
0
 def test_z_rotation_m90(self):
     # -90 degree z-rotation
     self.rotmat = euler(np.radians(-90), "z")
     _powerfit.rotate_image3d(self.image, self.rotmat, self.center, self.radius, self.out)
     self.answer[0, -self.radius + 1 :, 0] = 1
     self.answer[0, 0, 0] = 1
     self.assertTrue(np.allclose(self.answer, self.out))
示例#3
0
    def test_euler(self):
        # 90 z-rotation
        angle = np.radians(90)
        out = euler(angle, 'z')
        answer = [[0, -1, 0], [1, 0, 0], [0, 0, 1]]
        self.assertTrue(np.allclose(answer, out))

        # 90 y-rotation
        out = euler(angle, 'y')
        answer = [[0, 0, 1], [0, 1, 0], [-1, 0, 0]]
        self.assertTrue(np.allclose(answer, out))

        # 90 x-rotation
        out = euler(angle, 'x')
        answer = [[1, 0, 0], [0, 0, -1], [0, 1, 0]]
        self.assertTrue(np.allclose(answer, out))
示例#4
0
    def test_euler(self):
        # 90 z-rotation
        angle = np.radians(90)
        out = euler(angle, 'z')
        answer = [[0, -1, 0], [1, 0, 0], [0, 0, 1]]
        self.assertTrue(np.allclose(answer, out))

        # 90 y-rotation
        out = euler(angle, 'y')
        answer = [[0, 0, 1], [0, 1, 0], [-1, 0, 0]]
        self.assertTrue(np.allclose(answer, out))

        # 90 x-rotation
        out = euler(angle, 'x')
        answer = [[1, 0, 0], [0, 0, -1], [0, 1, 0]]
        self.assertTrue(np.allclose(answer, out))
示例#5
0
 def test_near(self):
     self.rotmat = euler(np.radians(85), 'z')
     _powerfit.rotate_image3d(self.image,
                              self.rotmat,
                              self.center,
                              self.radius,
                              self.out,
                              nearest=True)
     self.answer[0, :self.radius, 0] = 1
     self.assertTrue(np.allclose(self.answer, self.out))
示例#6
0
    def test_rotate_grids(self):
        # identity matrix
        rotmat = np.identity(3, dtype=np.float64)
        mask = np.ones(self.shape, dtype=np.float64)
        template = np.zeros(self.shape, dtype=np.float64)
        radius = 3
        template[0, 0, 0:radius] = 1
        self.corr._template = template
        self.corr._mask = mask
        self.corr._center = np.asarray([0, 0, 0], dtype=np.float64)
        self.corr._rmax = radius
        # get clean arrays
        self.corr._allocate_arrays(self.shape)
        self.corr._rotate_grids(rotmat)
        self.assertTrue(np.allclose(self.corr._rot_template, template))

        # 90 degree Z-rotation.
        rotmat = euler(np.radians(90), 'z')
        self.corr._allocate_arrays(self.shape)
        self.corr._rotate_grids(rotmat)
        answer = np.zeros(self.shape, dtype=np.float64)
        answer[0, :radius, 0] = 1
        self.assertTrue(np.allclose(self.corr._rot_template, answer))
示例#7
0
    def test_rotate_grids(self):
        # identity matrix
        rotmat = np.identity(3, dtype=np.float64)
        mask = np.ones(self.shape, dtype=np.float64)
        template = np.zeros(self.shape, dtype=np.float64)
        radius = 3
        template[0, 0, 0: radius] = 1
        self.corr._template = template
        self.corr._mask = mask
        self.corr._center = np.asarray([0, 0, 0], dtype=np.float64)
        self.corr._rmax = radius
        # get clean arrays
        self.corr._allocate_arrays(self.shape)
        self.corr._rotate_grids(rotmat)
        self.assertTrue(np.allclose(self.corr._rot_template, template))

        # 90 degree Z-rotation.
        rotmat = euler(np.radians(90), 'z')
        self.corr._allocate_arrays(self.shape)
        self.corr._rotate_grids(rotmat)
        answer = np.zeros(self.shape, dtype=np.float64)
        answer[0, :radius, 0] = 1
        self.assertTrue(np.allclose(self.corr._rot_template, answer))
示例#8
0
 def test_near(self):
     self.rotmat = euler(np.radians(85), "z")
     _powerfit.rotate_image3d(self.image, self.rotmat, self.center, self.radius, self.out, nearest=True)
     self.answer[0, : self.radius, 0] = 1
     self.assertTrue(np.allclose(self.answer, self.out))