Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated documentation for rotations.misorientation #644

Merged
merged 2 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions hexrd/rotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,23 @@ def invertQuat(q):

def misorientation(q1, q2, *args):
"""
sym is a tuple (crystal_symmetry, *sample_symmetry)
generally coded.

!!! may split up special cases for no symmetry or crystal/sample only...
PARAMETERS
----------
q1: array(4, 1)
a single quaternion
q2: array(4, n)
array of quaternions
*args: tuple
there can be only one extra argument, which is 1- or 2-tuple with
symmetries (quaternion arrays); for crystal symmetry only,
use a 1-tuple; with both crystal and sample symmetry use a 2-tuyple

RETURNS
-------
angle: array(n)
the misorientation angle between `q1` and each quaternion in `q2`
mis: array(4, n)
the quaternion of the smallest misorientation angle
"""
if not isinstance(q1, ndarray) or not isinstance(q2, ndarray):
raise RuntimeError("quaternion args are not of type `numpy ndarray'")
Expand Down
26 changes: 26 additions & 0 deletions tests/test_rotations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Test rotations module"""
import numpy as np
import pytest

from hexrd.material import symmetry
from hexrd import rotations


def test_misorientations():
"""Use Laue groups to test for zero misorientation"""
#
# This tests that all the 11 Laue groups have zero misorientation with
# their own members.
#
laue_groups = [
"ci", "c2h", "d2h", "c4h", "d4h", "c3i",
"d3d", "c6h", "d6h", "th", "oh"
]
for lg in laue_groups:
print("group: ", lg)
qsym = symmetry.quatOfLaueGroup(lg)
q1 = qsym[:, -1:]
ang, mis = rotations.misorientation(q1, qsym, (qsym,))
assert np.allclose(ang, 0.0)
assert np.allclose(mis[0, :], 1.)
assert np.allclose(mis[1:, :], 0.)
Loading