LiveIndexer#

class de_ebsd.index.live.LiveIndexer(masters, point_groups, detector, *, resolution=3.0, search_shape=(32, 32), refine_shape=(128, 128), refine_steps_deg=(2.0, 1.0, 0.5, 0.25, 0.12), search_blur_deg=2.0, device=None, dtype=None)[source]#

Bases: object

Index and refine EBSD patterns of several phases on the device.

Parameters:
masters

One MasterPattern per phase, all at the same npx. Each is used at its highest energy bin.

point_groups

Each phase’s orix point group, whose fundamental zone its dictionary samples.

detector

The camera’s EBSDDetector (its pattern center and angles); frames may come at any resolution, since they are averaged to search_shape and refine_shape.

resolution

The dictionary’s sampling, in degrees.

search_shape, refine_shape

Detector shapes the search and the refine compare patterns at.

refine_steps_deg

The refine levels’ steps; empty for no refine.

search_blur_deg

How much the search’s copy of the masters is blurred, see SEARCH_BLUR_DEG.

device

Defaults to the first master’s.

dtype

The search dictionary’s. None picks float16 on GPUs with tensor cores (compute capability 7.0 and up) and float32 elsewhere: Pascal multiplies float16 at 1/64 of its float32 rate, and a CPU has no float16 product. Half precision halves the dictionary, which is what grows with low symmetry; the search only picks seeds, so the refine sets the accuracy either way.

Methods

add_fits

Add the simulations of fitted orientations g (N, 3, 3) to the scan's ghost.

center_maps

One (3, 3) map per pattern center; see center_maps().

corrected

frames (N, H, W) with the backgrounds removed as prepare() removes them, at their own resolution: what the indexer matches, to be looked at.

directions_at

index

frames (N, H, W) on the device, indexed: (phase, g, score, entry).

index_with_strain

index(), then each orientation refined together with its pattern's strain (refine_deformation()): (phase, g, strain, score, entry).

observe

Add frames to the scan's static background.

pooled

frames on the device as float (N, H, W) averaged to the refine shape.

prepare

frames (N, H, W) corrected and normalized, as (search, refine) rows (N, pixels) at the two shapes.

project

The patterns (M, pixels) of rotations (M, 3, 3), each from its own phase's master in texture, over directions (pixels, 3).

refine

Each orientation g (N, 3, 3) refined against its pattern: (g, score), the score being the last level's at the seed.

refine_deformation

Each orientation refined together with its pattern's strain; see refine_deformation().

refine_pattern_center

The pattern center that best fits the best-scored patterns of frames (N, H, W), which the indexer then uses; see refine_pattern_center().

restart_static

Forget the scan, for a new one: its static background and its ghost.

score_candidates

Scores (N, K) of candidates (N, K, 3, 3) against their patterns' normalized rows (N, pixels), sampled at directions.

search

The best dictionary entry for each pattern: (phase, g, score, entry), entry indexing rotations (every phase's entries, in phase order).

set_pattern_center

Index at pattern center pattern_center from now on: the dictionary is projected again, which takes milliseconds with the fused kernels.

strain_from_reference

The strain of frames relative to one real reference frame; see strain_from_reference().

Attributes

ghost

The scan's grains as the static background shows them, or None; see ScanBackground.ghost.

static

The scan's static background, None until enough frames have been seen.

add_fits(phase, g, center_maps=None)[source]#

Add the simulations of fitted orientations g (N, 3, 3) to the scan’s ghost.

center_maps(pattern_centers)[source]#

One (3, 3) map per pattern center; see center_maps().

corrected(frames)[source]#

frames (N, H, W) with the backgrounds removed as prepare() removes them, at their own resolution: what the indexer matches, to be looked at.

property ghost#

The scan’s grains as the static background shows them, or None; see ScanBackground.ghost.

index(frames)[source]#

frames (N, H, W) on the device, indexed: (phase, g, score, entry). entry is the dictionary entry the search seeded the refine from (see search()): anything worked out once per entry, such as a color, stands for the refined orientation to within the dictionary’s resolution.

index_with_strain(frames, pattern_centers=None)[source]#

index(), then each orientation refined together with its pattern’s strain (refine_deformation()): (phase, g, strain, score, entry). pattern_centers (N, 3), one per frame, default to the indexer’s.

Each buffer’s orientations join the scan’s ghost before its strains are fitted, as its frames joined the static background.

observe(frames)[source]#

Add frames to the scan’s static background.

pooled(frames)[source]#

frames on the device as float (N, H, W) averaged to the refine shape.

prepare(frames)[source]#

frames (N, H, W) corrected and normalized, as (search, refine) rows (N, pixels) at the two shapes.

project(texture, rotations, phases, directions)[source]#

The patterns (M, pixels) of rotations (M, 3, 3), each from its own phase’s master in texture, over directions (pixels, 3).

refine(refine_rows, phase, g, *, steps=None, directions=None)[source]#

Each orientation g (N, 3, 3) refined against its pattern: (g, score), the score being the last level’s at the seed. steps (radians) default to the indexer’s, directions to its pattern center’s.

refine_deformation(refine_rows, phase, g, **kwargs)[source]#

Each orientation refined together with its pattern’s strain; see refine_deformation().

refine_pattern_center(frames, **kwargs)[source]#

The pattern center that best fits the best-scored patterns of frames (N, H, W), which the indexer then uses; see refine_pattern_center().

restart_static(frames=None, *, blur=None)[source]#

Forget the scan, for a new one: its static background and its ghost.

frames from all over the same field, such as a search’s, start the new static background, so the scan’s first patterns are divided by one that holds no grain’s bands rather than by the mean of its first few frames.

With blur (a Gaussian sigma, as a share of the pattern’s width) the static background is the frames’ mean blurred, for a single crystal: its frames all carry its bands, so their mean would divide them out. It then has no ghost.

score_candidates(candidates, phases, rows, directions)[source]#

Scores (N, K) of candidates (N, K, 3, 3) against their patterns’ normalized rows (N, pixels), sampled at directions.

search(search_rows)[source]#

The best dictionary entry for each pattern: (phase, g, score, entry), entry indexing rotations (every phase’s entries, in phase order).

The dictionary is scored SEARCH_CHUNK entries at a time, keeping each pattern’s best so far, so the scores never outgrow one chunk.

set_pattern_center(pattern_center)[source]#

Index at pattern center pattern_center from now on: the dictionary is projected again, which takes milliseconds with the fused kernels.

Each chunk of entries is written straight into the dictionary, and a new center overwrites the old one’s in place: the dictionary is the largest thing on the device, and building it beside a copy of itself (or a list of its chunks) took two to three times its size.

property static#

The scan’s static background, None until enough frames have been seen.

strain_from_reference(frames, reference, **kwargs)[source]#

The strain of frames relative to one real reference frame; see strain_from_reference().