upxo.pxtal.fm_steel_3d.orientation_mean_3d module

orientation_mean_3d.py

Crystallographically-correct averaging of several Bunge ZXZ Euler-angle orientations (degrees), and the specific “packet mean orientation” derived quantity for this pipeline’s hierarchy.

Why not just average the Euler angles directly

Euler angles are cyclic/non-linear coordinates on SO(3) – arithmetic mean of e.g. two phi1 values either side of the 0/360 wrap, or of two orientations related by the quaternion double-cover (q and -q represent the same rotation), gives a physically meaningless result. The standard fix is to average in quaternion space instead: convert each orientation to a unit quaternion, put every quaternion on the same hemisphere (w >= 0 – this resolves the q/-q sign ambiguity, which is unrelated to crystal symmetry), average the quaternion components, and renormalise. This mirrors xtalphy.crystal_orientation.grain_avg_quats’ own three-step approach (hemisphere-fix, mean, renormalise), reused here for consistency.

Deliberately NOT performed: crystal-symmetry-equivalence search (picking whichever of e.g. 24 cubic-symmetry-equivalent representations of each input orientation is closest to a reference before averaging). That search is the right move when averaging several noisy measurements of one true orientation (e.g. EBSD pixels within a grain). It is the WRONG move here: a packet’s up to 6 constituent block orientations are 6 deliberately distinct KS (Kurdjumov-Sachs) variants assigned to that packet – forcing them into one symmetry-equivalence bucket before averaging would silently erase the very variant diversity being summarised.

upxo.pxtal.fm_steel_3d.orientation_mean_3d.mean_orientation_euler_deg(eulers_deg: Sequence[Sequence[float]]) → Tuple[float, float, float][source]

Mean of several Bunge ZXZ Euler-angle orientations (degrees), computed correctly in quaternion space (see module docstring). Returns a single (phi1, Phi, phi2) tuple in degrees.

Raises ValueError if eulers_deg is empty.

upxo.pxtal.fm_steel_3d.orientation_mean_3d.compute_packet_mean_orientations(grain_to_blocks_map: Dict[int, List[str]], block_orientations: Dict[str, Tuple[float, float, float]]) → Dict[int, Tuple[float, float, float]][source]

{packet_id: mean orientation (phi1, Phi, phi2) in degrees}, for every packet (packet_id == grain_id in this pipeline) that has at least one block with an assigned orientation. A packet’s own KS-variant-group identity isn’t tracked as a single orientation anywhere else in the model – this is the representative summary orientation used for plotting/overlaying “packet orientation” on a pole figure (per the up-to-6-block-orientations-per-packet model).