merge_crystal_maps#

kikuchipy.indexing.merge_crystal_maps(crystal_maps: List[CrystalMap], mean_n_best: int = 1, greater_is_better: int | None = None, scores_prop: str = 'scores', simulation_indices_prop: str | None = None, navigation_masks: List[None | ndarray] | None = None) CrystalMap[source]#

Return a multi phase CrystalMap by merging maps of 1D or 2D navigation shape based on scores.

It is required that all maps have the same number of rotations and scores (and simulation indices if applicable) per point.

Parameters:
crystal_maps

A list of at least two crystal maps with simulated indices and scores among their properties. The maps must have the same shape, unless navigation masks are passed (see navigation_masks). Identical phases are considered as one phase in the returned map.

mean_n_best

Number of best metric results to take the mean of before comparing. Default is 1. If given with a negative sign and greater_is_better is not given, the n lowest valued metric results are chosen.

greater_is_better

True if a higher score means a better match. If not given, the sign of mean_n_best is used, with a positive sign meaning True.

scores_prop

Name of scores array in the crystal maps’ properties. Default is "scores".

simulation_indices_prop

Name of simulated indices array in the crystal maps’ properties. If not given (default), the merged crystal map will not contain an array of merged simulation indices from the input crystal maps’ properties. If a string, there must be as many simulation indices per point as there are scores.

navigation_masks

A list of boolean masks of shapes equal to the full 1D or 2D navigation (map) shape, where only points equal to False are considered when comparing scores. The number of False entries in a mask must be equal to the number of points in a crystal map (size). The order corresponds to the order in crystal_maps. If not given, all points are used. If all points in one or more of the maps should be used, this map’s entry can be None.

Returns:
merged_xmap

A crystal map where the rotation of the phase with the best matching score(s) is assigned to each point. The best matching scores, merge sorted, are added to its properties with a name equal to whatever passed to scores_prop with “merged” as a suffix. If simulation_indices_prop is passed, the best matching simulation indices are added in the same way as the scores.

Notes

The initial motivation behind this function was to merge single phase maps produced by dictionary indexing.