pyxem / kikuchipy

Toolbox for analysis of electron backscatter diffraction (EBSD) patterns
https://kikuchipy.org
GNU General Public License v3.0
79 stars 30 forks source link

Allow projection of patterns with a varying PC from a master pattern #567

Closed hakonanes closed 1 year ago

hakonanes commented 1 year ago

Description of the change

This PR adds the ability to project patterns with a varying projection center (PC) from a master pattern with EBSDMasterPattern.get_patterns() by passing an EBSDDetector with multiple PCs, one per rotation. An example is added to the methods' docstring. Solves #503.

The ability to not pass the energy parameter to EBSDMasterPattern.get_patterns() is also added, upon which the highest energy in the master pattern is used. Solves #554.

Finally, by restricting ipywidgets<=7.7 in the docs build, the PyVista plots of master patterns in the docs are displayed. Solves #566.

Fix #565 and #519.

Progress of the PR

Minimal example of the bug fix or new feature

The example from EBSDMasterPattern.get_patterns():

import numpy as np
from orix.quaternion import Rotation
import hyperspy.api as hs
import kikuchipy as kp

mp = kp.data.nickel_ebsd_master_pattern_small(projection="lambert")
det = kp.detectors.EBSDDetector(
    shape=(60, 60),
    pc=np.array([
        [[0.4, 0.5, 0.4], [0.6, 0.5, 0.4]],
        [[0.4, 0.5, 0.6], [0.6, 0.5, 0.6]],
    ])
)
rot = Rotation.identity(det.navigation_shape)
s = mp.get_patterns(rot, det, compute=True, show_progressbar=False)
_ = hs.plot.plot_images(
    s,
    per_row=2,
    cmap="inferno",
    label=np.array_str(det.pc.reshape((-1, 3)))[1:-1].split("\n "),
    axes_decor=None,
)

bilde

For reviewers