.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/processing/azimuthal_integration.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_processing_azimuthal_integration.py: Azimuthal Integration (in Pyxem!) ================================= pyxem now includes built in azimuthal integration functionality. This is useful for extracting radial profiles from diffraction patterns in 1 or 2 dimensions. The new method will split the pixels into radial bins and then sum the intensity in each bin resulting in a `Diffraction1D` or `Polar2D` signal. In each case the total intensity of the diffraction pattern is preserved. .. GENERATED FROM PYTHON SOURCE LINES 11-26 .. code-block:: Python import pyxem as pxm import hyperspy.api as hs import numpy as np s = pxm.data.tilt_boundary_data() s.calibration( center=None ) # set the center to None to use center of the diffraction patterns s.calibration.units = "/AA^{-1}" s.calibration.scale = 0.03 # To angstroms s1d = s.get_azimuthal_integral1d(npt=100, inplace=False) s1d.sum().plot() .. image-sg:: /examples/processing/images/sphx_glr_azimuthal_integration_001.png :alt: Signal :srcset: /examples/processing/images/sphx_glr_azimuthal_integration_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none 0%| | 0/17 [00:00 .. GENERATED FROM PYTHON SOURCE LINES 90-95 At times you may want to use a mask to exclude certain pixels from the azimuthal integration or apply an affine transformation to the diffraction patterns before azimuthal integration. This can be done using the `mask` and `affine` parameters of the `Calibration` object. Here we just show a random affine transformation for illustration. .. GENERATED FROM PYTHON SOURCE LINES 95-104 .. code-block:: Python mask = s.get_direct_beam_mask(radius=20) # Mask the direct beam affine = np.array( [[0.9, 0.1, 0], [0.1, 0.9, 0], [0, 0, 1]] ) # Just a random affine transformation for illustration s.calibration(mask=mask, affine=affine) s.get_azimuthal_integral2d(npt=100, npt_azim=360, inplace=False).sum().plot() .. image-sg:: /examples/processing/images/sphx_glr_azimuthal_integration_006.png :alt: Signal :srcset: /examples/processing/images/sphx_glr_azimuthal_integration_006.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none 0%| | 0/17 [00:00, , , ] .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 53.335 seconds) .. _sphx_glr_download_examples_processing_azimuthal_integration.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: azimuthal_integration.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: azimuthal_integration.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: azimuthal_integration.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_