MasterPattern#

class de_ebsd.sim.MasterPattern(data, energies_kev, metadata=<factory>)[source]#

Bases: object

Backscatter intensity on the sphere in square-Lambert storage.

Attributes:
data

Intensities, shape (n_energies, 2, n, n); hemisphere 0 is north.

energies_kev

Energy bin centers in keV, shape (n_energies,).

metadata

Free-form provenance (crystal, dmin, backend name, …).

Methods

energy_index

load

Load a master pattern saved with save().

project

Project onto a detector for one or more crystal orientations.

sample

Interpolate the master pattern at unit vectors (..., 3).

save

Save to HDF5 (data, energies, and string metadata).

show

Display the master pattern.

to

Copy to another device.

to_equirectangular

Resample the full sphere into an equirectangular (lat-long) image.

to_stereographic

Resample one hemisphere into a stereographic (equal-angle) image.

Attributes

device

npx

Half-width of the Lambert grid (n = 2 npx + 1).

data

energies_kev

metadata

classmethod load(path, device=None)[source]#

Load a master pattern saved with save().

property npx#

Half-width of the Lambert grid (n = 2 npx + 1).

project(detector, orientation, energy_kev=None, rescale=True)[source]#

Project onto a detector for one or more crystal orientations.

Parameters:
detector

The detector geometry (fixed pattern center).

orientation

Crystal orientation(s): an orix.quaternion.Rotation or a tensor/array of unit quaternions (N, 4) in (a, b, c, d) order.

energy_kev

Energy bin to project (default: highest).

rescale

Linearly rescale each pattern to [-1, 1].

Returns:
torch.Tensor

Patterns of shape (N, n_rows, n_cols).

sample(directions, energy_kev=None)[source]#

Interpolate the master pattern at unit vectors (…, 3).

Bilinear interpolation on the square-Lambert grid via grid_sample(align_corners=True), identical to kikuchipy’s interpolation. The hemisphere is selected by sign(z).

save(path)[source]#

Save to HDF5 (data, energies, and string metadata).

show(projection='lambert', energy_kev=None, texture_height=256, **kwargs)[source]#

Display the master pattern.

Parameters:
projection

"lambert" (both hemispheres side by side), "stereographic" (both hemispheres, equal-angle), or "sphere" (interactive 3D sphere with the pattern as texture).

energy_kev

Energy bin to display (default: highest).

texture_height

Height of the equirectangular texture used by the interactive sphere. Lower values reduce notebook/SpyDE payload size while leaving the master-pattern data unchanged.

to(device)[source]#

Copy to another device.

to_equirectangular(height=256, energy_kev=None)[source]#

Resample the full sphere into an equirectangular (lat-long) image.

Row 0 is the north pole; used as the texture for the sphere view.

to_stereographic(n=501, hemisphere='north', energy_kev=None)[source]#

Resample one hemisphere into a stereographic (equal-angle) image.