Example #1
0
    def get_eulers(self, ref='TSL'):
        """
        DESCRIPTION
        -----------
        phi1, PhH, phi2 = self.get_eulers(ref='TSL')
        PARAMETERS
        ----------
        ref: string
            The configuration in which the Euler Angles is computed.
            The default output (a*,b*,c*) in the xml file is in the
            APS coordinate system according to
            http://www.aps.anl.gov/Sectors/33_34/microdiff/Instrument/coordinates-PE-system.pdf
        RETURNS
        -------
        phi1,PHI,phi2: tuple
            Computed Euler angles in degrees
        NOTE
        ----
        The change of reference configuration will affect the output
        of the Euler angle calculation, as a result, it is necessary
        define what configuration/reference the calculation is in and
        make sure all calculation is done under the same reference
        configuration.
        """
        if not(self._validonly):
            raise ValueError("Invalid data, ABORT!")
        # get the rotation matrix first
        ref = ref.upper()
        if ref == 'TSL':
            r = R_APS2TSL
        elif ref == 'APS':
            r = R_APS2APS
        elif ref == 'XHF':
            r = R_APS2XHF
        else:
            raise ValueError("unknown configuration")
        # calculate the real lattice first
        c = np.cross(self.astar, self.bstar)
        c = c/np.linalg.norm(c)
        a = np.cross(self.bstar, self.cstar)
        a = a/np.linalg.norm(a)
        # equivalent to b*,
        # b*/b go through atoms
        # a go through faces
        b = np.cross(c, a)
        b = b/np.linalg.norm(b)
        # rotate real lattice into given configuration
        a = np.dot(r.T, a)
        b = np.dot(r.T, b)
        c = np.dot(r.T, c)
        # use the three basis vectors to form a base,
        # its column stack will be the rotation matrix, which
        # is used to perform reference transformation
        g = np.column_stack((a, b, c)).T

        return OrientationMatrix(g).toEulers()  
Example #2
0
class testOrienationMatrix(unittest.TestCase):
    def setUp(self):
        tmp = np.array([0.2623303, 0.8853649, 0.1311652, -0.3607042])
        self.q = Quaternion(tmp)
        self.g = OrientationMatrix(self.q.toOrientationMatrix())

    def test_toQuaternion(self):
        q = self.q.toOrientationMatrix()
        g = self.g.tondarray()
        np.testing.assert_almost_equal(q, g)
Example #3
0
class testOrienationMatrix(unittest.TestCase):

    def setUp(self):
        tmp    = np.array([0.2623303, 0.8853649, 0.1311652, -0.3607042])
        self.q = Quaternion(tmp)
        self.g = OrientationMatrix(self.q.toOrientationMatrix())

    def test_toQuaternion(self):
        q = self.q.toOrientationMatrix()
        g = self.g.tondarray()
        np.testing.assert_almost_equal(q,g)
Example #4
0
 def setUp(self):
     tmp = np.array([0.2623303, 0.8853649, 0.1311652, -0.3607042])
     self.q = Quaternion(tmp)
     self.g = OrientationMatrix(self.q.toOrientationMatrix())
Example #5
0
 def setUp(self):
     tmp    = np.array([0.2623303, 0.8853649, 0.1311652, -0.3607042])
     self.q = Quaternion(tmp)
     self.g = OrientationMatrix(self.q.toOrientationMatrix())