How to use the orix.quaternion.orientation.Orientation function in orix

To help you get started, we’ve selected a few orix examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyxem / orix / tests / test_orientation.py View on Github external
def orientation(request):
    return Orientation(request.param)
github pyxem / orix / tests / test_orientation.py View on Github external
def test_orientation_persistence(symmetry, vector):
    v = symmetry.outer(vector).flatten()
    o = Orientation.random()
    oc = o.set_symmetry(symmetry)
    v1 = o * v
    v1 = Vector3d(v1.data.round(4))
    v2 = oc * v
    v2 = Vector3d(v2.data.round(4))
    assert v1._tuples == v2._tuples
github pyxem / orix / orix / quaternion / orientation.py View on Github external
def __sub__(self, other):
        if isinstance(other, Orientation):
            misorientation = Misorientation(self * ~other)
            m_inside = misorientation.set_symmetry(
                self.symmetry, other.symmetry
            ).squeeze()
            return m_inside
        return NotImplemented
github pyxem / orix / orix / crystal_map / crystal_map.py View on Github external
def orientations(self):
        """Rotations, respecting symmetry, in data."""
        # TODO: Consider whether orientations should be calculated upon
        #  loading since computing orientations are slow (should benefit
        #  from dask!)
        phases = self.phases_in_data
        if phases.size == 1:
            # Extract top matching rotations per point, if more than one
            if self.rotations_per_point > 1:
                rotations = self.rotations[:, 0]
            else:
                rotations = self.rotations
            return Orientation(rotations).set_symmetry(phases[:].symmetry)
        else:
            raise ValueError(
                f"Data has the phases {phases.names}, however, you are executing a "
                "command that only permits one phase."
github pyxem / orix / orix / quaternion / orientation.py View on Github external
-------
        Orientation
            The instance itself, with equivalent values.

        Examples
        --------
        >>> from orix.quaternion.symmetry import C4
        >>> data = np.array([[0.5, 0.5, 0.5, 0.5], [0, 1, 0, 0]])
        >>> o = Orientation(data).set_symmetry((C4))
        >>> o
        Orientation (2,) 4
        [[-0.7071  0.     -0.7071  0.    ]
        [ 0.      1.      0.      0.    ]]

        """
        return super(Orientation, self).set_symmetry(C1, symmetry)
github pyxem / orix / orix / quaternion / orientation.py View on Github external
def equivalent(self, grain_exchange=False):
        """Equivalent misorientations

        grain_exchange : bool
            If true the rotation g and g^{-1} are considered to be identical

        Returns
        -------
        Misorientation

        """
        Gl, Gr = self._symmetry

        if grain_exchange and (Gl._tuples == Gr._tuples):
            orientations = Orientation.stack([self, ~self]).flatten()
        else:
            orientations = Orientation(self)

        equivalent = Gr.outer(orientations.outer(Gl))
        return self.__class__(equivalent).flatten()
github pyxem / orix / orix / quaternion / orientation.py View on Github external
"""Equivalent misorientations

        grain_exchange : bool
            If true the rotation g and g^{-1} are considered to be identical

        Returns
        -------
        Misorientation

        """
        Gl, Gr = self._symmetry

        if grain_exchange and (Gl._tuples == Gr._tuples):
            orientations = Orientation.stack([self, ~self]).flatten()
        else:
            orientations = Orientation(self)

        equivalent = Gr.outer(orientations.outer(Gl))
        return self.__class__(equivalent).flatten()