Example #1
0
def get_library(default_structure):
    diffraction_calculator = pxm.DiffractionGenerator(300., 0.02)
    dfl = pxm.DiffractionLibraryGenerator(diffraction_calculator)
    structure_library = StructureLibrary(['Phase'], [default_structure],
                                         [np.array([(0, 0, 0), (0, 0.2, 0)])])

    return dfl.get_diffraction_library(structure_library, 0.017, 2.4, (72, 72))
    def get_orientations_from_stereographic_triangle(self, inplane_rotations,
                                                     resolution):
        """
        Create a structure library from the stereographic triangles of the
        given crystal systems.

        Parameters
        ----------
        inplane_rotations : list
            List over identifiers of lists of inplane rotations of the
            diffraction patterns, in degrees.
        resolution : float
            Rotation list resolution in degrees.

        Returns
        -------
        structure_library : StructureLibrary
            Structure library for the given phase names, structures and crystal system.
        """
        rotation_lists = [
            rotation_list_stereographic(structure,
                                        *stereographic_corners[system],
                                        np.deg2rad(inplane_rotation),
                                        np.deg2rad(resolution))
            for phase_name, structure, system, inplane_rotation in zip(
                self.phase_names, self.structures, self.systems,
                inplane_rotations)
        ]
        return StructureLibrary(self.phase_names, self.structures,
                                rotation_lists)
Example #3
0
def get_template_library(structure, rot_list, edc):
    diff_gen = pxm.DiffractionLibraryGenerator(edc)
    struc_lib = StructureLibrary(['A'], [structure], [rot_list])
    library = diff_gen.get_diffraction_library(struc_lib,
                                               calibration=1 / half_side_length,
                                               reciprocal_radius=0.8,
                                               half_shape=(half_side_length,
                                                           half_side_length),
                                               with_direct_beam=False)
    return library
Example #4
0
def test_constructor():
    identifiers = ['a', 'b']
    # Arbitrary values for tracking
    structures = [1, 2]
    orientations = [3, 4]
    library = StructureLibrary(identifiers, structures, orientations)

    np.testing.assert_equal(library.identifiers, identifiers)
    np.testing.assert_equal(library.structures, structures)
    np.testing.assert_equal(library.orientations, orientations)
    np.testing.assert_equal(library.struct_lib['a'], (1, 3))
    np.testing.assert_equal(library.struct_lib['b'], (2, 4))
    def get_orientations_from_list(self, orientations):
        """Create a structure library from a list of rotations.

        Parameters
        ----------
        orientations : list
            A list over identifiers of lists of euler angles (as tuples) in the rzxz
            convention and in degrees.

        Returns
        -------
        structure_library : StructureLibrary
            Structure library for the given phase names, structures and orientations.
        """
        return StructureLibrary(self.phase_names, self.structures,
                                orientations)
Example #6
0
def get_vector_match_results(structure, rot_list, edc):
    diffraction_library = get_template_library(structure, rot_list, edc)
    peak_lists = []
    for simulation in diffraction_library['A'].values():
        peak_lists.append(simulation['pixel_coords'])
    peaks = DiffractionVectors((np.array([peak_lists, peak_lists]) - half_side_length) / half_side_length)
    peaks.axes_manager.set_signal_dimension(2)
    peaks.calculate_cartesian_coordinates(200, 0.2)
    peaks.cartesian.axes_manager.set_signal_dimension(2)
    structure_library = StructureLibrary(['A'], [structure], [[]])
    library_generator = VectorLibraryGenerator(structure_library)
    vector_library = library_generator.get_vector_library(1)
    indexation_generator = VectorIndexationGenerator(peaks, vector_library)
    return diffraction_library, indexation_generator.index_vectors(
        mag_tol=1.5 / half_side_length,
        angle_tol=1,
        index_error_tol=0.2,
        n_peaks_to_index=5,
        n_best=2,
        keys=['A'])
Example #7
0
def show_rotation_list(structure_info, reciprocal_angstrom_per_pixel,
                       simulated_gaussian_sigma, beam_energy,
                       specimen_thickness):
    phases = [structure_info['name']]

    # Ångström^{-1}, extent of relrods in reciprocal space. Inverse of specimen thickness is a starting points
    max_excitation_error = 1 / specimen_thickness
    reciprocal_radius = reciprocal_angstrom_per_pixel * (half_pattern_size - 1)

    structure = structure_info['structure']
    rotation_list = generate_complete_rotation_list(structure,
                                                    *structure_info['corners'],
                                                    [0],
                                                    resolution=np.deg2rad(1))
    # Only one inplane rotation angle, remove this extra dimension
    rotation_list = rotation_list.reshape(rotation_list.shape[0], -1, 3, 3)
    rotation_list_euler = rotation_matrices_to_euler(rotation_list)

    structure_library = StructureLibrary(phases, [structure],
                                         [rotation_list_euler])

    gen = pxm.DiffractionGenerator(beam_energy,
                                   max_excitation_error=max_excitation_error)
    library_generator = pxm.DiffractionLibraryGenerator(gen)

    diffraction_library = library_generator.get_diffraction_library(
        structure_library,
        calibration=reciprocal_angstrom_per_pixel,
        reciprocal_radius=reciprocal_radius,
        half_shape=(half_pattern_size, half_pattern_size),
        with_direct_beam=False)

    plot_lib_2d(diffraction_library,
                phase_name=structure_info['name'],
                rotation_list=rotation_list,
                size=target_pattern_dimension_pixels,
                scale=reciprocal_angstrom_per_pixel,
                sigma=simulated_gaussian_sigma,
                max_r=reciprocal_radius)

    plt.show()
Example #8
0
def get_library(default_structure):
    structure_library = StructureLibrary(['Phase'], [default_structure],
                                         [[(0, 0, 0), (0, 0.2, 0)]])
    vlg = pxm.VectorLibraryGenerator(structure_library)
    return vlg.get_vector_library(0.5)
Example #9
0
def test_constructor_parameter_validation_errors(identifiers, structures, orientations):
    StructureLibrary(identifiers, structures, orientations)
Example #10
0
def structure_library(default_structure):
    return StructureLibrary(['Si'], [default_structure], [[(0, 0, 0),
                                                           (0.1, 0.1, 0)]])