예제 #1
0
    def test_get_orientation_similarity_map(self):
        s = nickel_ebsd_small()

        s_dict1 = EBSD(s.data.reshape(-1, 60, 60))
        s_dict2 = EBSD(s.data.reshape(-1, 60, 60))
        n_patterns = s_dict1.axes_manager.navigation_size
        s_dict1._xmap = CrystalMap(Rotation(np.zeros((n_patterns, 4))))
        s_dict2._xmap = CrystalMap(Rotation(np.zeros((n_patterns, 4))))
        s_dict1.xmap.phases[0].name = "a"
        s_dict2.xmap.phases[0].name = "b"

        sd = StaticPatternMatching([s_dict1, s_dict2])
        res = sd(s, keep_n=1, get_orientation_similarity_map=True)
        xmap1, _ = res

        assert np.allclose(xmap1.scores, 1)
        assert np.all(["osm" in xmap.prop for xmap in res])
예제 #2
0
    def test_signal_varying_dimensions(self, dummy_signal, slices,
                                       desired_xmap_shape):
        s = dummy_signal.inav[slices]
        sig_shape = dummy_signal.axes_manager.signal_shape
        s_dict1 = EBSD(dummy_signal.data.reshape((-1, ) + sig_shape))
        n_sim = s_dict1.axes_manager.navigation_size
        s_dict1._xmap = CrystalMap(Rotation(np.zeros((n_sim, 4))))
        sd = StaticPatternMatching(s_dict1)
        res = sd(s)

        assert res.shape == desired_xmap_shape
예제 #3
0
    def test_keep_n(self, n_rot_in, n_rot_out, keep_n):
        s = nickel_ebsd_small()
        s_dict = EBSD(np.random.random((n_rot_in, 60, 60)).astype(np.float32))
        s_dict._xmap = CrystalMap(Rotation(np.zeros((n_rot_in, 4))))
        sd = StaticPatternMatching(s_dict)
        xmap = sd(s)

        assert xmap.rotations_per_point == n_rot_out

        xmap2 = sd(s, keep_n=keep_n)

        assert xmap2.rotations_per_point == keep_n
예제 #4
0
    def test_n_slices_input(self, dummy_signal):
        sig_shape = dummy_signal.axes_manager.signal_shape
        n_px = np.prod(sig_shape)
        n_sim = 13500 + 1
        rand_data = (np.random.randint(
            0, 255,
            n_sim * n_px).reshape((n_sim, ) + sig_shape).astype(np.uint8))
        s_dict1 = EBSD(rand_data)
        s_dict1._xmap = CrystalMap(Rotation(np.zeros((n_sim, 4))))
        sd = StaticPatternMatching(s_dict1)

        with replace_stdin(io.StringIO("y")):
            res = sd(dummy_signal, n_slices=1)
            assert isinstance(res, CrystalMap)

        with replace_stdin(io.StringIO("n")):
            res = sd(dummy_signal, n_slices=1)
            assert res is None
예제 #5
0
    def test_return_merged_crystal_map(self, return_merged_xmap,
                                       desired_n_xmaps_out):
        s = nickel_ebsd_small()
        s_dict1 = EBSD(s.data.reshape(-1, 60, 60))
        s_dict2 = s_dict1.deepcopy()
        n_patterns = s_dict1.axes_manager.navigation_size
        s_dict1._xmap = CrystalMap(Rotation(np.zeros((n_patterns, 4))))
        s_dict2._xmap = s_dict1.xmap.deepcopy()
        s_dict1.xmap.phases[0].name = "a"
        s_dict2.xmap.phases[0].name = "b"

        sd = StaticPatternMatching([s_dict1, s_dict2])
        res1 = sd(s, return_merged_crystal_map=return_merged_xmap)

        assert len(res1) == desired_n_xmaps_out

        sd.dictionaries.pop(-1)
        res2 = sd(s, return_merged_crystal_map=True)

        assert isinstance(res2, CrystalMap)

        res3 = sd(s)

        assert isinstance(res3, CrystalMap)