Skip to content

Commit

Permalink
Testing: Test to_crystal_map function for multiple phases
Browse files Browse the repository at this point in the history
  • Loading branch information
CSSFrancis committed May 27, 2024
1 parent 8b0f762 commit 0657ba0
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pyxem/signals/polar_diffraction2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
41 changes: 40 additions & 1 deletion pyxem/tests/signals/test_indexation_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)

0 comments on commit 0657ba0

Please sign in to comment.