.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/orientation_mapping/single_phase_orientation.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_orientation_mapping_single_phase_orientation.py: Single Phase Orientation Mapping ================================ You can also calculate the orientation of the grains in a single phase sample using the :meth:`pyxem.signals.PolarSignal2D.get_orientation` method. This requires that you simulate the entire S2 space for the phase and then compare to the simulated diffraction. For more information on the orientation mapping process see :cite:`pyxemorientationmapping2022` .. GENERATED FROM PYTHON SOURCE LINES 10-17 .. code-block:: Python from pyxem.data import si_phase, si_grains from diffsims.generators.simulation_generator import SimulationGenerator from orix.sampling import get_sample_reduced_fundamental simulated_si = si_grains() .. GENERATED FROM PYTHON SOURCE LINES 18-25 Pre-Processing -------------- First we center the diffraction patterns and get a polar signal Increasing the number of npt_azim with give better polar sampling but will take longer to compute the orientation map The mean=True argument will return the mean pixel value in each bin rather than the sum this makes the high k values more visible .. GENERATED FROM PYTHON SOURCE LINES 25-32 .. code-block:: Python simulated_si.calibration.center = None polar_si = simulated_si.get_azimuthal_integral2d( npt=100, npt_azim=360, inplace=False, mean=True ) polar_si.plot() .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/orientation_mapping/images/sphx_glr_single_phase_orientation_001.png :alt: single phase orientation :srcset: /examples/orientation_mapping/images/sphx_glr_single_phase_orientation_001.png :class: sphx-glr-multi-img * .. image-sg:: /examples/orientation_mapping/images/sphx_glr_single_phase_orientation_002.png :alt: Signal :srcset: /examples/orientation_mapping/images/sphx_glr_single_phase_orientation_002.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none [ ] | 0% Completed | 182.31 us [ ] | 0% Completed | 101.38 ms [ ] | 0% Completed | 201.75 ms [ ] | 0% Completed | 302.10 ms [ ] | 0% Completed | 402.44 ms [ ] | 0% Completed | 502.75 ms [ ] | 0% Completed | 603.06 ms [ ] | 0% Completed | 703.35 ms [ ] | 0% Completed | 803.63 ms [ ] | 0% Completed | 903.91 ms [ ] | 0% Completed | 1.01 s [ ] | 0% Completed | 1.11 s [ ] | 0% Completed | 1.21 s [ ] | 0% Completed | 1.31 s [ ] | 0% Completed | 1.42 s [ ] | 0% Completed | 1.52 s [ ] | 0% Completed | 1.63 s [ ] | 0% Completed | 1.73 s [ ] | 0% Completed | 1.83 s [ ] | 0% Completed | 1.94 s [ ] | 0% Completed | 2.04 s [ ] | 0% Completed | 2.15 s [ ] | 0% Completed | 2.25 s [ ] | 0% Completed | 2.35 s [ ] | 0% Completed | 2.46 s [ ] | 0% Completed | 2.56 s [ ] | 0% Completed | 2.67 s [ ] | 0% Completed | 2.77 s [ ] | 0% Completed | 2.87 s [ ] | 0% Completed | 2.97 s [ ] | 0% Completed | 3.07 s [ ] | 0% Completed | 3.17 s [ ] | 0% Completed | 3.28 s [ ] | 0% Completed | 3.38 s [ ] | 0% Completed | 3.48 s [ ] | 0% Completed | 3.58 s [ ] | 0% Completed | 3.68 s [ ] | 0% Completed | 3.79 s [########################################] | 100% Completed | 3.89 s .. GENERATED FROM PYTHON SOURCE LINES 33-38 Building a Simulation --------------------- Now we can get make a simulation. In this case we want to set a minimum_intensity which removes the low intensity reflections. we also sample the S2 space using the :func`orix.sampling.get_sample_reduced_fundamental`. Make sure that you set ``with_direct_beam=False`` or the orientation mapping will be unduely affected by the center beam. .. GENERATED FROM PYTHON SOURCE LINES 38-49 .. code-block:: Python phase = si_phase() generator = SimulationGenerator(200, minimum_intensity=0.05) rotations = get_sample_reduced_fundamental(resolution=1, point_group=phase.point_group) sim = generator.calculate_diffraction2d( phase, rotation=rotations, max_excitation_error=0.1, reciprocal_radius=2, with_direct_beam=False, ) # Make sure that with_direct_beam ==False .. GENERATED FROM PYTHON SOURCE LINES 50-57 Getting the Orientation ----------------------- By default the `get_orientation` function uses a gamma correction equilivent to polar_si**0.5. For noisy datasets it might be a good idea to reduce the noise (Maybe by averaging neighboring patterns?) or simple background subtraction, otherwise the gamma correction will increase the effects of noise on the data. This tries to focus on "Is the Bragg vector there?" rather than "Is the Bragg vector the right intensity?" patially because the intensity of the Bragg vector might have many different effects. .. GENERATED FROM PYTHON SOURCE LINES 57-62 .. code-block:: Python orientation_map = polar_si.get_orientation(sim) orientation_map.plot_over_signal(simulated_si, vmax="96th") .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/orientation_mapping/images/sphx_glr_single_phase_orientation_003.png :alt: single phase orientation :srcset: /examples/orientation_mapping/images/sphx_glr_single_phase_orientation_003.png :class: sphx-glr-multi-img * .. image-sg:: /examples/orientation_mapping/images/sphx_glr_single_phase_orientation_004.png :alt: Signal :srcset: /examples/orientation_mapping/images/sphx_glr_single_phase_orientation_004.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none [ ] | 0% Completed | 185.14 us [ ] | 0% Completed | 107.82 ms [ ] | 0% Completed | 209.93 ms [ ] | 0% Completed | 315.57 ms [ ] | 0% Completed | 420.97 ms [ ] | 0% Completed | 524.82 ms [ ] | 0% Completed | 627.81 ms [ ] | 0% Completed | 733.18 ms [ ] | 0% Completed | 838.56 ms [ ] | 0% Completed | 943.94 ms [ ] | 0% Completed | 1.04 s [ ] | 0% Completed | 1.15 s [ ] | 0% Completed | 1.25 s [ ] | 0% Completed | 1.36 s [ ] | 0% Completed | 1.46 s [ ] | 0% Completed | 1.57 s [ ] | 0% Completed | 1.67 s [ ] | 0% Completed | 1.78 s [ ] | 0% Completed | 1.88 s [ ] | 0% Completed | 1.99 s [ ] | 0% Completed | 2.09 s [ ] | 0% Completed | 2.20 s [ ] | 0% Completed | 2.30 s [ ] | 0% Completed | 2.41 s [ ] | 0% Completed | 2.51 s [ ] | 0% Completed | 2.62 s [ ] | 0% Completed | 2.72 s [ ] | 0% Completed | 2.82 s [ ] | 0% Completed | 2.93 s [ ] | 0% Completed | 3.03 s [ ] | 0% Completed | 3.13 s [ ] | 0% Completed | 3.24 s [ ] | 0% Completed | 3.34 s [ ] | 0% Completed | 3.44 s [ ] | 0% Completed | 3.54 s [ ] | 0% Completed | 3.65 s [ ] | 0% Completed | 3.75 s [ ] | 0% Completed | 3.85 s [ ] | 0% Completed | 3.95 s [ ] | 0% Completed | 4.05 s [ ] | 0% Completed | 4.15 s [ ] | 0% Completed | 4.25 s [ ] | 0% Completed | 4.35 s [ ] | 0% Completed | 4.45 s [ ] | 0% Completed | 4.55 s [ ] | 0% Completed | 4.65 s [ ] | 0% Completed | 4.75 s [ ] | 0% Completed | 4.85 s [ ] | 0% Completed | 4.95 s [ ] | 0% Completed | 5.05 s [ ] | 0% Completed | 5.15 s [ ] | 0% Completed | 5.25 s [ ] | 0% Completed | 5.36 s [ ] | 0% Completed | 5.46 s [ ] | 0% Completed | 5.56 s [ ] | 0% Completed | 5.66 s [ ] | 0% Completed | 5.76 s [ ] | 0% Completed | 5.86 s [ ] | 0% Completed | 5.96 s [ ] | 0% Completed | 6.06 s [ ] | 0% Completed | 6.16 s [ ] | 0% Completed | 6.26 s [ ] | 0% Completed | 6.36 s [ ] | 0% Completed | 6.46 s [ ] | 0% Completed | 6.56 s [ ] | 0% Completed | 6.66 s [ ] | 0% Completed | 6.76 s [ ] | 0% Completed | 6.87 s [ ] | 0% Completed | 6.97 s [ ] | 0% Completed | 7.07 s [ ] | 0% Completed | 7.17 s [ ] | 0% Completed | 7.27 s [ ] | 0% Completed | 7.37 s [ ] | 0% Completed | 7.47 s [ ] | 0% Completed | 7.57 s [ ] | 0% Completed | 7.67 s [ ] | 0% Completed | 7.77 s [ ] | 0% Completed | 7.87 s [ ] | 0% Completed | 7.97 s [ ] | 0% Completed | 8.08 s [ ] | 0% Completed | 8.18 s [ ] | 0% Completed | 8.28 s [ ] | 0% Completed | 8.39 s [ ] | 0% Completed | 8.49 s [ ] | 0% Completed | 8.60 s [ ] | 0% Completed | 8.71 s [ ] | 0% Completed | 8.81 s [ ] | 0% Completed | 8.91 s [ ] | 0% Completed | 9.01 s [ ] | 0% Completed | 9.11 s [ ] | 0% Completed | 9.21 s [ ] | 0% Completed | 9.32 s [ ] | 0% Completed | 9.43 s [ ] | 0% Completed | 9.53 s [ ] | 0% Completed | 9.63 s [########################################] | 100% Completed | 9.73 s [ ] | 0% Completed | 153.13 us [########################################] | 100% Completed | 106.33 ms [ ] | 0% Completed | 118.21 us [ ] | 0% Completed | 107.12 ms [########################################] | 100% Completed | 207.48 ms [ ] | 0% Completed | 2.48 ms [ ] | 0% Completed | 106.98 ms [########################################] | 100% Completed | 207.36 ms .. GENERATED FROM PYTHON SOURCE LINES 63-64 sphinx_gallery_thumbnail_number = 4 .. rst-class:: sphx-glr-timing **Total running time of the script:** (1 minutes 7.914 seconds) .. _sphx_glr_download_examples_orientation_mapping_single_phase_orientation.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: single_phase_orientation.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: single_phase_orientation.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_