# refine_orientation#

EBSD.refine_orientation(xmap: CrystalMap, detector: EBSDDetector, master_pattern: EBSDMasterPattern, energy: Union[int, float], mask: Optional[np.ndarray] = None, signal_mask: Optional[np.ndarray] = None, method: Optional[str] = 'minimize', method_kwargs: Optional[dict] = None, trust_region: Optional[list] = None, compute: bool = True, rechunk: bool = True, chunk_kwargs: Optional[dict] = None) Union[CrystalMap, da.Array][source]#

Refine orientations by searching orientation space around the best indexed solution using fixed projection centers.

Refinement attempts to maximize the similarity between patterns in this signal and simulated patterns projected from a master pattern. The similarity metric used is the normalized cross-correlation (NCC). The orientation, represented by a Rodrigues-Frank vector ($$R_x$$, $$R_y$$, $$R_z$$), is optimized during refinement, while the sample-detector geometry, represented by the three projection center (PC) parameters (PCx, PCy, PCz), is fixed.

A subset of the optimization methods in SciPy are available:
Parameters:
xmap

Single phase crystal map with at least one orientation per point. The orientations are assumed to be relative to the EDAX TSL sample reference frame RD-TD-ND.

detector

Detector describing the detector-sample geometry with either one PC to be used for all map points or one for each point.

master_pattern

Master pattern in the square Lambert projection of the same phase as the one in the crystal map.

energy

Accelerating voltage of the electron beam in kV specifying which master pattern energy to use during projection of simulated patterns.

A boolean mask equal to the experimental patterns’ detector shape (n rows, n columns), where only pixels equal to False are matched. If not given, all pixels are used.

Deprecated since version 0.7.0: Use signal_mask instead.

A boolean mask equal to the experimental patterns’ detector shape (n rows, n columns), where only pixels equal to False are matched. If not given, all pixels are used.

method

Name of the scipy.optimize optimization method, among "minimize", "differential_evolution", "dual_annealing", "basinhopping", and "shgo". Default is "minimize", which by default performs local optimization with the Nelder-Mead method unless another "minimize" method is passed to method_kwargs.

method_kwargs

Keyword arguments passed to the scipy.optimize method. For example, to perform refinement with the modified Powell algorithm, pass method="minimize" and method_kwargs=dict(method="Powell").

trust_region

List of +/- angular deviation in degrees as bound constraints on the three Rodrigues-Frank vector components. If not given and method requires bounds, they are set to [1, 1, 1]. If given, method is assumed to support bounds and they are passed to method.

compute

Whether to refine now (True) or later (False). Default is True. See compute() for more details.

rechunk

If True (default), rechunk the dask array with patterns used in refinement (not the signal data inplace) if it is returned from get_dask_array() in a single chunk. This ensures small data sets are rechunked so as to utilize multiple CPUs.

chunk_kwargs

Keyword arguments passed to get_chunking() if rechunk=True and the dask array with patterns used in refinement is returned from get_dask_array() in a single chunk.

Returns:
out

Crystal map with refined orientations and similarity metrics in a "scores" property if compute=True. If compute=False, a dask array of navigation shape + (4,) is returned, to be computed later. See compute_refine_orientation_results(). Each navigation point has the optimized score and the three Euler angles in radians in element 0, 1, 2, and 3, respectively.