upxo.xtalphy.ipf module
ipf.py
Inverse-pole-figure colours for cubic (m-3m) crystals, reproducing the default key of mtex.
The key is white at the centre of the fundamental sector and carries the primary colours at its
vertices. A crystal direction is first brought into the sector z >= x >= y >= 0 (vertices
[001], [101], [111]) by the 24 proper cubic operators and the inversion. Its polar coordinates
about the sector centre then give the colour: the radius (1 at the centre, 0 on the boundary,
measured along the great circle through the centre) sets the lightness, and the azimuth, equalised
so that the three vertices sit at equal angles, sets the hue, with mtex’s hue correction. Two
crystallographically equivalent directions therefore have one colour.
The constants and the arithmetic follow mtex 1.0.0 (ipfHSVKey / HSVDirectionKey); the
tests in tests/xtalphy/test_ipf_vs_mtex.py carry colours computed by mtex.
Public API
reduce_to_cubic_sector(directions) -> directions in the fundamental sector cubic_ipf_rgb(crystal_directions) -> RGB in [0, 1] ipf_crystal_direction(R_or_quats, sample_direction, …) CUBIC_SECTOR_VERTICES, equal_area_xy(), sector_mask()
- upxo.xtalphy.ipf.CUBIC_SECTOR_VERTICES = array([[0. , 0. , 1. ], [0.70710678, 0. , 0.70710678], [0.57735027, 0.57735027, 0.57735027]])
Vertices of the fundamental sector, [001], [101], [111] (unit vectors).
- upxo.xtalphy.ipf.reduce_to_cubic_sector(directions)[source]
Bring crystal directions into the fundamental sector
z >= x >= y >= 0.
- upxo.xtalphy.ipf.sector_mask(directions, tol=1e-12)[source]
True where a direction lies inside the fundamental sector.
- upxo.xtalphy.ipf.equal_area_xy(directions)[source]
Equal-area projection of upper-hemisphere directions, radius 1 on the equator.
- upxo.xtalphy.ipf.cubic_ipf_rgb(crystal_directions)[source]
mtex-default IPF colour of crystal directions (cubic m-3m).
- Parameters:
crystal_directions (array-like, shape (..., 3)) – The direction of the chosen sample axis in crystal coordinates. Signs and the 24 cubic operators do not change the colour. Non-finite or zero vectors give the colour of the black centre.
- Return type:
ndarray, shape (…, 3), float64 in [0, 1]
- upxo.xtalphy.ipf.ipf_crystal_direction(orientation, sample_direction=(0.0, 0.0, 1.0), convention='defdap')[source]
Crystal coordinates of a sample direction for a stack of orientations.
- Parameters:
orientation (ndarray) – Quaternions (N, 4) as [w, x, y, z], or rotation matrices (N, 3, 3) with
convention='matrix'(the crystal -> sample matrix,euler_bunge_to_matrix).sample_direction (array-like, shape (3,))
convention ({'defdap', 'crystal_to_sample', 'matrix'}) –
'defdap': quaternions as DefDAP stores them (EBSDReader.quat_ebsd,grain_avg_quats), the quaternion of the Bunge g matrix, whose rotation matrix maps sample coordinates to crystal coordinates.'crystal_to_sample': the quaternion of the crystal -> sample rotation.'matrix': crystal -> sample matrices.
- Return type: