ImageD11.rgb_colors.ipf module#
Inverse pole figure (IPF) colours of orientation matrices.
The colour of a grain is the colour of the crystal direction along a sample axis, uvw = inv(ubi).T . axis (ubi rows are a, b, c), in an MTEX 7.2 colour key (TSL or HSV) of the crystal’s point group. The keys are tabulated as integer plane normals (hkl) and directions (uvw) in ipf_keys.py, so nothing depends on a B matrix convention or on an origin of orientation space:
the direction is folded into the sector h.uvw >= 0 with the integer symmetry operations (TSL: the Laue group, HSV: the point group), so all equivalent ubi give one colour. h is the hkl of a boundary plane, or g_s.uvw for a plane normal to a direction (monoclinic HSV split planes);
angles use the symmetrised metric g_s = <M^T g M> over the group (g = ubi.ubi^T), which every equivalent ubi shares. The strain that g_s removes is reported by symmetric_metric; colours are warned about when it exceeds maxstrain.
For the arithmetic the metric is factored once per grain, g_s = L.L^T, so a direction is L^T.uvw and a plane normal inv(L).hkl. Only dot and cross products enter, so any right handed factor gives the same colour.
MTEX 7.2.0 TSLDirectionKey and HSVDirectionKey (default options), with two of MTEX’s approximations done exactly: the hue integral (MTEX sums 1000 steps, up to 6e-5 in rgb) and the centre of a sector with 4 corners (TSL m-3 and 23; MTEX averages a 1 deg grid, up to 6e-3). The HSV hue correction starts at 0, where MTEX’s starts at 1.7e-3 and jumps (up to 1e-2 in rgb). See ipf_colour_math.md.
- ImageD11.rgb_colors.ipf.group_name(grp)#
The ipf_keys.GROUPS name of a sym_u group, found from its operations
- ImageD11.rgb_colors.ipf.ipf_points(ubis, group, view='default', key='tsl', axis=(0.0, 0.0, 1.0), projection='stereographic', chunk=4096)#
Where each ubi goes in the drawing of key_image: the crystal direction along axis, folded into the sector as for ubi_to_rgb, projected about the out-of-screen axis of the view with its east axis to the right. Returns x, y (n,) and panel (n,): 1 for the lower hemisphere (seen from above).
- ImageD11.rgb_colors.ipf.key_image(ubi, group, view='default', key='tsl', projection='stereographic', n=301)#
The colour key of ubi_to_rgb as images of the sector, looking down the out-of-screen axis of the view with its east axis to the right.
ubi gives the lattice (only its symmetrised metric is used). projection : “stereographic” (equal angle) or “equal area” Returns a list of (n,n,4) RGBA images, alpha 0 outside the sector: the upper hemisphere, and the lower one (seen from above) when the sector reaches it; and a list of (panel, x, y, label) for the corners.
- ImageD11.rgb_colors.ipf.plot_ipf(ubis, group, view='default', key='tsl', axis=(0.0, 0.0, 1.0), projection='stereographic', axes=None, n=301, alpha=0.3, **scatter_kwargs)#
Inverse pole figure: each ubi as a point in its colour (ubi_to_rgb) on the key (plot_key, faded by alpha, drawn in the metric of the first ubi). Returns the axes.
- ImageD11.rgb_colors.ipf.plot_key(ubi, group, view='default', key='tsl', projection='stereographic', n=301, axes=None, alpha=1.0, zoom=True)#
Draw the IPF colour key with matplotlib (alpha fades it, zoom shows the sector rather than the whole projection), on axes with one per panel. Returns the axes used.
- ImageD11.rgb_colors.ipf.point_group(name)#
The sym_u group of a point group name in ipf_keys.GROUPS (e.g. “6mm”, “121”, “-3mR”)
- ImageD11.rgb_colors.ipf.spacegroup_group(spacegroup, cell_choice='standard')#
The ipf_keys.GROUPS name of the point group of a space group (1-230). cell_choice “rhombohedral” puts R groups on rhombohedral axes (as unitcell)
- ImageD11.rgb_colors.ipf.symmetric_metric(ubis, grp)#
g_s = <M^T g M> over the group, g = ubi.ubi^T, for ubis (n,3,3). Returns g_s (n,3,3) and the strain that g_s removes, e = (eigenvalues(inv(g_s).g) - 1)/2, (n,3). sum(e) = 0.
- ImageD11.rgb_colors.ipf.ubi_to_rgb(ubis, group, view='default', key='tsl', axis=(0.0, 0.0, 1.0), maxstrain=0.005, chunk=4096)#
IPF colours (n,3) of orientation matrices ubis (n,3,3), rows a, b, c.
- groupa sym_u group, or a name in ipf_keys.GROUPS. Its operations
choose the key, so give the point group: the TSL key folds with its Laue group, the HSV key with the point group itself.
view : MTEX how2plot, “default” or “out-of-screen|east” such as “+c*|+a” key : “tsl” or “hsv” axis : the sample direction, colours show the crystal direction along it maxstrain : a warning is logged when a ubi departs from the symmetry of the
group by more than this strain (see symmetric_metric)