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:
objectIndex and refine EBSD patterns of several phases on the device.
- Parameters:
- masters
One
MasterPatternper phase, all at the samenpx. 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 tosearch_shapeandrefine_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.
Nonepicks 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 the simulations of fitted orientations g
(N, 3, 3)to the scan'sghost.One
(3, 3)map per pattern center; seecenter_maps().frames
(N, H, W)with the backgrounds removed asprepare()removes them, at their own resolution: what the indexer matches, to be looked at.directions_atframes
(N, H, W)on the device, indexed:(phase, g, score, entry).index(), then each orientation refined together with its pattern's strain (refine_deformation()):(phase, g, strain, score, entry).Add frames to the scan's static background.
frames on the device as float
(N, H, W)averaged to the refine shape.frames
(N, H, W)corrected and normalized, as(search, refine)rows(N, pixels)at the two shapes.The patterns
(M, pixels)of rotations(M, 3, 3), each from its own phase's master in texture, over directions(pixels, 3).Each orientation g
(N, 3, 3)refined against its pattern:(g, score), the score being the last level's at the seed.Each orientation refined together with its pattern's strain; see
refine_deformation().The pattern center that best fits the best-scored patterns of frames
(N, H, W), which the indexer then uses; seerefine_pattern_center().Forget the scan, for a new one: its static background and its ghost.
Scores
(N, K)of candidates(N, K, 3, 3)against their patterns' normalized rows(N, pixels), sampled at directions.The best dictionary entry for each pattern:
(phase, g, score, entry), entry indexingrotations(every phase's entries, in phase order).Index at pattern center pattern_center from now on: the dictionary is projected again, which takes milliseconds with the fused kernels.
The strain of frames relative to one real reference frame; see
strain_from_reference().Attributes
The scan's grains as the static background shows them, or
None; seeScanBackground.ghost.The scan's static background,
Noneuntil 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’sghost.
- corrected(frames)[source]#
frames
(N, H, W)with the backgrounds removed asprepare()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; seeScanBackground.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 (seesearch()): 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
ghostbefore its strains are fitted, as its frames joined the static background.
- 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; seerefine_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 indexingrotations(every phase’s entries, in phase order).The dictionary is scored
SEARCH_CHUNKentries 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,
Noneuntil enough frames have been seen.