pyxem / kikuchipy

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

Fix merging of maps with non-indexed points and release v0.8.5 #639

Closed hakonanes closed 1 year ago

hakonanes commented 1 year ago

Description of the change

Fixes #637.

@Erlendos12, can you test this branch in EBSP Indexer against your problem reported in #637 for me?

Progress of the PR

Minimal example of the bug fix or new feature

Create two crystal maps with some points considered not-indexed, only some of them not-indexed in both maps

import kikuchipy as kp
import numpy as np
from orix.crystal_map import CrystalMap
from orix.quaternion import Rotation

xmap_a = CrystalMap.empty((4, 3))
xmap_a.phases[0].name = "a"
is_indexed_a = np.array([[1, 1, 0], [1, 0, 1], [0, 1, 1], [0, 1, 1]], dtype=bool).ravel()
xmap_a.phases.add_not_indexed()
xmap_a[~is_indexed_a].phase_id = -1
xmap_a.prop["scores"] = np.array([[2, 2, 0], [3, 0, 4], [0, 4, 3], [0, 2, 1]], dtype=float).ravel()

xmap_b = CrystalMap.empty((4, 3))
xmap_b.phases[0].name = "b"
is_indexed_b = np.array([[1, 1, 0], [1, 1, 1], [0, 1, 1], [0, 1, 0]], dtype=bool).ravel()
xmap_b.phases.add_not_indexed()
xmap_b[~is_indexed_b].phase_id = -1
xmap_b.prop["scores"] = np.array([[3, 1, 0], [2, 1, 5], [0, 2, 4], [0, 1, 0]], dtype=float).ravel()

xmap_ab = kp.indexing.merge_crystal_maps([xmap_a, xmap_b])

print(xmap_ab)
# Before:
# Phase  Orientations         Name  Space group  Point group  Proper point group       Color
#     0   12 (100.0%)  not_indexed         None         None                None      w
# Properties: scores, merged_scores
# Scan unit: px

# Now:
# Phase  Orientations         Name  Space group  Point group  Proper point group       Color
#    -1     3 (25.0%)  not_indexed         None         None                None           w
#     0     5 (41.7%)            a         None         None                None    tab:blue
#     1     4 (33.3%)            b         None         None                None  tab:orange
# Properties: scores, merged_scores
# Scan unit: px

For reviewers

Erlendos12 commented 1 year ago

@Erlendos12, can you test this branch in EBSP Indexer against your problem reported in #637 for me?

Thanks! Checking it out now, will let you know by the end of the day.

Erlendos12 commented 1 year ago

@Erlendos12, can you test this branch in EBSP Indexer against your problem reported in #637 for me?

Thanks! Checking it out now, will let you know by the end of the day.

I can confirm that the branch fixes our problem in #637, @hakonanes 👍

hakonanes commented 1 year ago

Fantastic, thank you for checking. I'll release v0.8.5 later today.