From 0657ba07f46e9c71fc1e6205c7fb85e9432cde80 Mon Sep 17 00:00:00 2001 From: Carter Francis Date: Mon, 27 May 2024 16:46:32 -0500 Subject: [PATCH] Testing: Test `to_crystal_map` function for multiple phases --- pyxem/signals/polar_diffraction2d.py | 3 ++ .../tests/signals/test_indexation_results.py | 41 ++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/pyxem/signals/polar_diffraction2d.py b/pyxem/signals/polar_diffraction2d.py index cb19f1c96..476cd7f4e 100644 --- a/pyxem/signals/polar_diffraction2d.py +++ b/pyxem/signals/polar_diffraction2d.py @@ -381,6 +381,9 @@ def rotation_index_to_degrees(data, axis): data[:, 2] = rad2deg(axis[ind]) return data + orientation.axes_manager.signal_axes[0].name = "n-best" + orientation.axes_manager.signal_axes[1].name = "columns" + orientation.map( rotation_index_to_degrees, axis=self.axes_manager.signal_axes[0].axis ) diff --git a/pyxem/tests/signals/test_indexation_results.py b/pyxem/tests/signals/test_indexation_results.py index 2c5014ab9..6688ea2db 100644 --- a/pyxem/tests/signals/test_indexation_results.py +++ b/pyxem/tests/signals/test_indexation_results.py @@ -33,7 +33,15 @@ from pyxem.generators import TemplateIndexationGenerator from pyxem.signals import VectorMatchingResults, DiffractionVectors, OrientationMap from pyxem.utils.indexation_utils import OrientationResult -from pyxem.data import si_grains, si_phase, si_tilt, si_grains_simple +from pyxem.data import ( + si_grains, + si_phase, + si_tilt, + si_grains_simple, + fe_multi_phase_grains, + fe_bcc_phase, + fe_fcc_phase, +) import hyperspy.api as hs @@ -211,6 +219,32 @@ def simple_multi_rot_orientation_result(self): orientations = polar.get_orientation(sims) return orientations, r + @pytest.fixture + def multi_phase_orientation_result(self): + s = fe_multi_phase_grains() + s.calibration.center = None + polar = s.get_azimuthal_integral2d( + npt=100, npt_azim=180, inplace=False, mean=True + ) + phase = fe_fcc_phase() + phase2 = fe_bcc_phase() + + generator = SimulationGenerator(200, minimum_intensity=0.05) + rotations = get_sample_reduced_fundamental( + resolution=1, point_group=phase.point_group + ) + rotations2 = get_sample_reduced_fundamental( + resolution=1, point_group=phase2.point_group + ) + sims = generator.calculate_diffraction2d( + [phase, phase2], + rotation=[rotations, rotations2], + max_excitation_error=0.1, + reciprocal_radius=2, + ) + orientations = polar.get_orientation(sims) + return orientations + def test_tilt_orientation_result(self, single_rot_orientation_result): assert isinstance(single_rot_orientation_result, OrientationMap) orients = single_rot_orientation_result.to_single_phase_orientations() @@ -242,3 +276,8 @@ def test_to_crystal_map(self, simple_multi_rot_orientation_result): crystal_map = orientations.to_crystal_map() assert isinstance(crystal_map, CrystalMap) assert np.all(crystal_map.phase_id == 0) + + def test_to_crystal_map_multi_phase(self, multi_phase_orientation_result): + crystal_map = multi_phase_orientation_result.to_crystal_map() + assert isinstance(crystal_map, CrystalMap) + assert np.all(crystal_map.phase_id < 2)