How to use the pyxem.signals.diffraction_simulation.DiffractionSimulation function in pyxem

To help you get started, we’ve selected a few pyxem examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyxem / pyxem / tests / test_library / test_diffraction_library.py View on Github external
def test_get_library_entry_assertionless(get_library):
    assert isinstance(get_library.get_library_entry()['Sim'],
                      DiffractionSimulation)
    assert isinstance(get_library.get_library_entry(phase='Phase')['Sim'],
                      DiffractionSimulation)
github pyxem / pyxem / tests / test_physical / test_marker_plotting.py View on Github external
def test_marker_placement_correct_beta():
    dps = []
    dp_cord_list = np.divide(generate_dp_cord_list(), 80)
    max_r = np.max(dp_cord_list) + 0.1
    for coords in dp_cord_list:
        dp_sim = DiffractionSimulation(coordinates=coords,
                                       intensities=np.ones_like(coords[:, 0]))
        dps.append(dp_sim.as_signal(144, 0.025, max_r).data)  # stores a numpy array of pattern
    dp = pxm.ElectronDiffraction(np.array([dps[0:2], dps[2:]]))  # now from a 2x2 array of patterns
    dp.set_diffraction_calibration(2 * max_r / (144))
    local_plotter(dp, dp_cord_list)

    # This is human assessed, if you see this comment, you should check it
    assert True
github pyxem / pyxem / tests / test_signals / test_diffraction_simulation.py View on Github external
def test_wrong_calibration_setting():
    DiffractionSimulation(coordinates=np.asarray([[0.3, 1.2, 0]]),
                          intensities=np.ones(1),
                          calibration=[1, 2, 5])
github pyxem / pyxem / tests / test_signals / test_diffraction_simulation.py View on Github external
def coords_intensity_simulation():
    return DiffractionSimulation(coordinates=np.asarray([[0.3, 1.2, 0]]),
                                 intensities=np.ones(1))
github pyxem / pyxem / tests / test_library / test_diffraction_library.py View on Github external
def test_angle_but_no_phase(get_library):
    # we have given an angle but no phase
    assert isinstance(get_library.get_library_entry(angle=(0, 0, 0))['Sim'],
                      DiffractionSimulation)
github pyxem / pyxem / tests / test_signals / test_diffraction_simulation.py View on Github external
def diffraction_simulation(self):
        return DiffractionSimulation()
github pyxem / pyxem / tests / test_components / test_diffraction_component.py View on Github external
def test_simulate(diffraction_calculator, default_structure):
    ref = ElectronDiffractionForwardModel(diffraction_calculator,
                                          default_structure,
                                          reciprocal_radius=1.,
                                          calibration=0.01)
    sim = ref.simulate()
    assert isinstance(sim, DiffractionSimulation)
github pyxem / pyxem / tests / test_physical / test_orientation_mapping_nonphys.py View on Github external
library["Phase"][rotation]['pattern_norm'] = np.sqrt(
        np.dot(pattern.intensities, pattern.intensities))
    return DiffractionLibrary(library)


dps, dp_sim_list = [], []
half_side_length = 72
library = dict()
half_shape = (half_side_length, half_side_length)
library["Phase"] = {}

# Creating the matchresults.

for alpha in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:
    coords = (np.random.rand(5, 2) - 0.5) * 2  # zero mean, range from -1 to +1
    dp_sim = DiffractionSimulation(coordinates=coords,
                                   intensities=np.ones_like(coords[:, 0]),
                                   calibration=1 / half_side_length)
    if alpha < 4:
        dps.append(
            dp_sim.as_signal(
                2 * half_side_length,
                0.075,
                1).data)  # stores a numpy array of pattern

    # add a new entry to the library
    library = create_library_entry(library, (alpha, alpha, alpha), dp_sim)

dp = pxm.ElectronDiffraction([dps[0:2], dps[2:]])  # now from a 2x2 array of patterns

indexer = IndexationGenerator(dp, library)
match_results = indexer.correlate()
github pyxem / pyxem / pyxem / generators / diffraction_generator.py View on Github external
# Calculate diffracted intensities based on a kinematical model.
        intensities = get_kinematical_intensities(structure,
                                                  intersection_indices,
                                                  g_hkls,
                                                  proximity,
                                                  max_excitation_error,
                                                  debye_waller_factors,
                                                  scattering_params)

        # Threshold peaks included in simulation based on minimum intensity.
        peak_mask = intensities > 1e-20
        intensities = intensities[peak_mask]
        intersection_coordinates = intersection_coordinates[peak_mask]
        intersection_indices = intersection_indices[peak_mask]

        return DiffractionSimulation(coordinates=intersection_coordinates,
                                     indices=intersection_indices,
                                     intensities=intensities,
                                     with_direct_beam=with_direct_beam)
github pyxem / pyxem / pyxem / generators / diffraction_generator.py View on Github external
# Calculate diffracted intensities based on a kinematical model.
        intensities = get_kinematical_intensities(structure,
                                                  intersection_indices,
                                                  g_hkls,
                                                  proximity,
                                                  max_excitation_error,
                                                  debye_waller_factors)

        # Threshold peaks included in simulation based on minimum intensity.
        peak_mask = intensities > 1e-20
        intensities = intensities[peak_mask]
        intersection_coordinates = intersection_coordinates[peak_mask]
        intersection_indices = intersection_indices[peak_mask]

        return DiffractionSimulation(coordinates=intersection_coordinates,
                                     indices=intersection_indices,
                                     intensities=intensities,
                                     with_direct_beam=with_direct_beam)