morphogen.io.ebsd

Orientation maps of electron backscatter diffraction (EBSD): the text files of the acquisition systems, and the grains of a map.

Two formats are read and written: .ang (EDAX/TSL OIM: Euler angles in radians, a header of comments) and .ctf (Oxford Instruments/HKL Channel 5: Euler angles in degrees, a header of keys). A map (EBSDMap) holds, at each point of a rectangular grid of steps (dx, dy), the phase (0: a point that was not indexed) and the orientation of the crystal (Bunge Euler angles, degrees), with the measures of quality of the file; its rows are those of the file, from the top of the image. A hexagonal grid (.ang) is read row by row onto a rectangular one of the same steps: every other row is then half a step away from where it was measured.

Axes. The axes of a map are those of its image as the acquisition systems show it: the first to the right (along the columns), the second upwards (against the rows, which the files number from the top), the third towards the viewer, out of the sample. A .ctf file gives the orientations in these axes. An .ang file gives them in axes turned about the third one, by an angle that depends on a setting of the software (ANG_SETTINGS): with the usual one its first axis (the rolling direction) points down the image and its second one to the right. The maps are read with their orientations brought into the axes of the image (axes="map"), so that the grains of a polycrystal and their lattices are in the same axes; axes="file" keeps the angles of the file, and EBSDMap.turned() brings the orientations into any other axes.

The axes of the crystals are those of morphoGen (morphogen.texture): for the hexagonal and trigonal lattices the first axis along a = [2 -1 -1 0], as in an .ang file; a .ctf file has it along a* = [1 0 -1 0], and its crystals are turned by 30 degrees about c when they are read (and back when they are written).

Grains (EBSDMap.grains()). Two neighbouring points of the same phase belong to one grain when their disorientation (morphogen.texture.disorientation(), with the symmetries of the phase) is below a threshold; the grains are the connected sets of such points. Each has its mean orientation (morphogen.texture.mean_orientation()) and the spread of its points about it. The grains of fewer points than a minimum are dropped, and the points without a grain (those that were not indexed, the dropped ones) take the grain of the nearest point that has one. The result (Grains) gives a polycrystal (Grains.microstructure(): the map extruded through a thickness, with the labels and the orientations of its grains) for the solvers of the homogenization.

morphogen.io.ebsd.ANG_SYMMETRY = {1: 'triclinic', 2: 'monoclinic', 3: '-3', 4: '4/m', 6: '6/m', 22: 'orthorhombic', 23: 'm-3', 32: 'trigonal', 42: 'tetragonal', 43: 'cubic', 62: 'hexagonal'}

The symmetry of a phase in an .ang file (the point group of its proper rotations) as a Laue class of morphogen.texture.CLASSES

morphogen.io.ebsd.CTF_LAUE = {1: 'triclinic', 2: 'monoclinic', 3: 'orthorhombic', 4: '4/m', 5: 'tetragonal', 6: '-3', 7: 'trigonal', 8: '6/m', 9: 'hexagonal', 10: 'm-3', 11: 'cubic'}

The Laue group of a phase in a .ctf file

morphogen.io.ebsd.ANG_SETTINGS = {1: 90.0, 2: -90.0, 3: 0.0, 4: 180.0}

The settings of the axes of the orientations of an .ang file (numbered as by the reader of MTEX): the angle (degrees) about the third axis from them to the axes of the image of the map. The first axis of the orientations points down the image with the setting 1 (the usual one), up with the setting 2, to the right with the setting 3 and to the left with the setting 4

morphogen.io.ebsd.AXES = ('map', 'file')

The axes in which the orientations of a map are read and written

class morphogen.io.ebsd.Phase(name: str = '', lattice: str | None = 'cubic', cell: tuple[float, ...] = (1.0, 1.0, 1.0, 90.0, 90.0, 90.0))[source]

Bases: object

A phase of a map: its name, its Laue class (one of morphogen.texture.CLASSES; none when the file gives another one: its orientations are then compared without symmetry) and the constants of its cell (a, b, c and the three angles).

property c_over_a: float

The ratio of the third constant of the cell to the first.

class morphogen.io.ebsd.Grains(labels: ndarray, orientations: ndarray, phase: ndarray, size: ndarray, spread: ndarray, step: tuple[float, float], phases: tuple[Phase, ...] = (), unit: str = 'um')[source]

Bases: object

The grains of an orientation map (EBSDMap.grains()).

labels: ndarray

none

Type:

The grain of each point, (ny, nx); -1

orientations: ndarray

The mean orientation of each grain (Bunge Euler angles, degrees), (n, 3)

phase: ndarray

phases[phase - 1])

Type:

The phase of each grain (from 1

size: ndarray

The number of points of each grain

spread: ndarray

The mean disorientation (degrees) of the indexed points of each grain from its mean orientation

step: tuple[float, float]

The steps of the grid along x and y, and its unit of length

phases: tuple[Phase, ...] = ()

The phases of the map

property count: int
property areas: ndarray

The area of each grain.

property diameters: ndarray

The diameter of the disc of the area of each grain.

lattice(phase: int = 1) → str[source]

The Laue class of a phase ("triclinic" when the file does not give it).

table() → dict[source]

The grains as the columns of a table (morphogen.io.write_table()): the number of each grain, its phase, its Bunge angles (degrees), its number of points, its area, its diameter and the spread of its orientations (degrees).

boundaries()[source]

The boundaries between the grains of one phase: the pairs of neighbouring grains (b, 2), the length of the boundary of each pair (the sides of the points that they share, in the unit of the map) and its disorientation (degrees, with the symmetries of the phase).

summary(*, poles=None, halfwidth: float = 10.0) → dict[source]

The numbers of the grains of a map, phase by phase: the grains, their share of the area, their mean diameter (by number and by area), the mean spread inside them, the number of their boundaries with the mean of their disorientations by length (40.74 degrees for cubic crystals at random) and, for the cubic and hexagonal phases, the largest density of the pole figures of the families poles (lists of indices; {100}, {110}, {111} or (0001), {10-10}, {10-11} by default), the grains weighted by their areas, in multiples of a random texture.

microstructure(thickness: float | None = None, *, periodic: bool = False)[source]

The polycrystal of the map: a lattice of one cell through a thickness (the smaller step by default), each cell with the phase, the label and the orientation of its grain (LatticeField; the points without a grain are of phase 0), in the axes of the image of the map: the last row of the map along the first axis, at the origin.

class morphogen.io.ebsd.EBSDMap(euler, phase, step=(1.0, 1.0), phases=None, quality=None, unit: str = 'um')[source]

Bases: object

An orientation map on a rectangular grid.

Parameters:
  • euler – Bunge Euler angles (degrees) of the crystal of each point, (ny, nx, 3): the rows of the file, from the top of the image (the second axis points against them), and the columns along the first axis.

  • phase – The phase of each point, (ny, nx): 0 for a point that was not indexed, k for the phase phases[k - 1].

  • step – The steps of the grid along x and y.

  • phases – The phases of the map (one cubic phase by default).

  • quality – Other arrays (ny, nx) of the file by name ("iq" and "ci" of an .ang file; "bands", "error", "mad", "bc" and "bs" of a .ctf file).

property shape: tuple[int, int]

The numbers of rows and of columns.

property size: tuple[float, float]

The lengths of the map along x and y.

property indexed: ndarray

The points that were indexed.

lattice(phase: int = 1) → str[source]

The Laue class of a phase ("triclinic" when the file does not give it).

orientations(phase: int | None = None) → ndarray[source]

The Euler angles (n, 3) of the indexed points (of one phase).

colours(direction=(0.0, 0.0, 1.0)) → ndarray[source]

The map as an image (ny, nx, 3) of colours (from 0 to 1): each point by the direction of its crystal along a direction of the sample (morphogen.texture.ipf_colours()); black where it was not indexed, grey for a phase whose lattice has no colour key.

turned(rotation) → EBSDMap[source]

The map with its orientations in other axes of the sample: rotation (3 x 3) gives the new axes in the old ones (its rows), so that g becomes g rotation^T. The positions of the points are not changed.

cropped(columns: slice, rows: slice) → EBSDMap[source]

The part of the map of some columns and rows.

classmethod from_grains(labels, orientations, step=(1.0, 1.0), *, phase=None, phases=None, unit: str = 'um') → EBSDMap[source]

The map of an image of labels (ny, nx), its rows from the top, whose grains have the given orientations (and phases, 1 by default); negative labels are points that were not indexed. The section of a computed polycrystal (synthetic_map()), to be written for the tools that read the maps.

grains(threshold: float = 5.0, *, min_size: int = 1, fill: bool = True) → Grains[source]

The grains of the map: connected sets of neighbouring points of one phase whose disorientation is below threshold degrees, those of fewer than min_size points dropped; with fill the points without a grain take that of the nearest point that has one.

morphogen.io.ebsd.read_ang(path, *, axes: str = 'map', setting: int = 1) → EBSDMap[source]

The map of an .ang file (EDAX/TSL OIM): the columns phi1, PHI, phi2 (radians), x, y, image quality, confidence index and phase of its rows, on the square or hexagonal grid of its header. A point is not indexed where its confidence index is negative or its angles are out of range. The orientations are brought into the axes of the map (axes="map"; setting: that of the system, one of ANG_SETTINGS) or left in those of the file (axes="file").

morphogen.io.ebsd.write_ang(path, ebsd: EBSDMap, *, axes: str = 'map', setting: int = 1) → Path[source]

Writes a map as an .ang file on a square grid (angles in radians; a point that was not indexed has a confidence index of -1). axes="map": the orientations of the map are in the axes of its image, and are written in those of the system (setting); axes="file": they are written as they are.

morphogen.io.ebsd.read_ctf(path, *, axes: str = 'map') → EBSDMap[source]

The map of a .ctf file (Channel Text File): the phases of its header, and the columns Phase, X, Y, Euler1, Euler2, Euler3 (degrees) of its rows, with the bands, the error, the mean angular deviation and the contrasts; the phase 0 is a point that was not indexed. Decimal commas are read. The orientations of the file are in the axes of the image of the map (axes: both values give them as they are); the hexagonal and trigonal crystals are turned to the axes of morphoGen (the first along a).

morphogen.io.ebsd.write_ctf(path, ebsd: EBSDMap, *, axes: str = 'map') → Path[source]

Writes a map as a .ctf file (angles in degrees; the phase 0 for a point that was not indexed). The orientations are written as they are: the axes of the image of the map are those of the file (axes: both values). The hexagonal and trigonal crystals are written with their first axis along a*.

morphogen.io.ebsd.synthetic_map(micro, shape, *, layer: int = 0, orientations=None, phase=None, phases=None, scatter: float = 0.0, missing: float = 0.0, boundaries: float = 0.0, seed=None) → EBSDMap[source]

The map that an acquisition would give of a layer of a polycrystal: the cells of micro (a microstructure with labels and orientations: a tessellation, grains grown or measured) on the grid shape (nx, ny, nz) of its domain, the layer layer along its third axis, seen from the end of that axis (the axes of the map are those of the domain). Each point has the orientation of its cell (orientations: other ones, per cell; phase: the phase of each cell, 1 by default, among phases), turned about a random axis by an angle of the half-normal law of standard deviation scatter degrees; a share missing of the points, and a share boundaries of those next to another cell, are not indexed.

morphogen.io.ebsd.example_map(name: str = 'ebsd_map.ctf') → Path[source]

The path of a map that comes with morphoGen (ebsd_map.ctf: the map of the template ebsd, a section of a polycrystal of nickel as an acquisition would give it, written by examples/ebsd_map.py).

morphogen.io.ebsd.read_ebsd(path, *, axes: str = 'map', setting: int = 1) → EBSDMap[source]

The map of an .ang or a .ctf file (by its extension), its orientations in the axes of the map (axes="map"; setting: that of the system of an .ang file) or in those of the file (axes="file").

morphogen.io.ebsd.write_ebsd(path, ebsd: EBSDMap, *, axes: str = 'map', setting: int = 1) → Path[source]

Writes a map as an .ang or a .ctf file (by its extension); axes and setting as in read_ebsd().