mesoOSU / Mart2Aust_Hackathon

Fork of Orix for developing tools necessary to make the AusRecon package in python
https://orix.readthedocs.io
GNU General Public License v3.0
2 stars 13 forks source link

orix-equivilant of MTEX ori.symmeterise #44

Open argerlt opened 2 years ago

argerlt commented 2 years ago

NOTE: this may already exist under another name in orix already, if so, write it on the white board.

In MTEX, you can "symmeterise" a list of orientations as follows:

filename = "AF96_001.ang" ebsd = EBSD.load(filename,'convertEuler2SpatialReferenceFrame'); rots = ebsd.rotations CS = ebsd.CSList{1} ori = orientation(rots,CS) symm_oris = ori.symmetrise

Here, "ori" is a length n vector of orientations with crystal symmetry "CS", where "CS" has m crystallographically equivalent orientations. the result is "symm_oris", an m-by-n array of the m crystallographically equivalent orientations for each of the n orientations.

This should be a function of the "orientation" Class inside the quaternion folder.

Link to the function: https://mtex-toolbox.github.io/orientation.symmetrise.html

argerlt commented 2 years ago

the equivalent function is orientation.equivalent. We should include this in a Jupyter notebook example at some point.

jcappola commented 2 years ago

Since we need this quite a lot later, the equivalent function of MTEX's symmetrise() is a right and left multiply of the CS and the SS on the orix quaternion, respectively. This matches MATLAB in value, but a few of the quaternions are signed (shouldn't be an issue).

Here is MATLAB test code:

% Prepare the testbed
CS = crystalSymmetry('432'); % Returns proper set
SS = specimenSymmetry('1');
ori = orientation.byEuler(107.028*degree, 43.8449*degree, 260.18*degree, CS, SS);
%
% Perform the symmetrise function and extract quat. components
ori_sym = ori.symmetrise;
ori_sym_quat = [ori_sym.a, ori_sym.b, ori_sym.c, ori_sym.d];

Here is the equivalent Python test code:

import numpy as np
import orix.quaternion as q
from orix.quaternion import Rotation as r

# Assemble the test orientation and symmetries
euler_triplets = np.radians(np.array([107.0280, 43.8449, 260.18]))
CS = q.symmetry.O  # 432 Symmetry
SS = q.symmetry.C1 # Triclinic Symmetry

# Construct the respective quats as you usually would
ori_quat  = r.from_euler(euler_triplets, direction='MTEX')

# Symmetrise directly
ori_sym_quat = SS * ori_quat * CS

I will push into a function later. The function should take in:

  1. Orientation
  2. Crystal Symmetry
  3. Specimen Symmetry
  4. Direction (as this affects the multiplication order)
  5. Antipodal (return flag; only for completeness)

Some helpful links: https://github.com/pyxem/orix/blob/v0.9.0.post0/orix/quaternion/symmetry.py#L356-L399 https://mtex-toolbox.github.io/OrientationSymmetry.html