.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/standards/pixel_coodinates.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_standards_pixel_coodinates.py: ==================== Coordinates in Pyxem ==================== Pyxem is flexible in how it handles coordinates for a diffraction pattern. There are three main ways to handle coordinates in Pyxem: 1. Pixel coordinates 2. Calibrated Coordinates with evenly spaced axes 3. Calibrated Coordinates with unevenly spaced axes (e.g. corrected for the Ewald sphere) .. GENERATED FROM PYTHON SOURCE LINES 14-23 .. code-block:: Python import pyxem as pxm from skimage.morphology import disk s = pxm.signals.Diffraction2D(disk((10))) s.calibration.center = None print(s.calibration.center) .. rst-class:: sphx-glr-script-out .. code-block:: none [10.0, 10.0] .. GENERATED FROM PYTHON SOURCE LINES 24-26 .. code-block:: Python s.plot(axes_ticks=True) .. image-sg:: /examples/standards/images/sphx_glr_pixel_coodinates_001.png :alt: Signal :srcset: /examples/standards/images/sphx_glr_pixel_coodinates_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 27-39 .. code-block:: Python # From the plot above you can see that hyperspy automatically sets the axes ticks to be centered # on each pixel. This means that for a 21x21 pixel image, the center is at (-10, -10) in pixel coordinates. # if we change the scale using the calibration function it will automatically adjust the center. Here it is # now (-1, -1) s.calibration.scale = 0.1 s.calibration.units = "nm$^{-1}$" s.plot(axes_ticks=True) print(s.calibration.center) .. image-sg:: /examples/standards/images/sphx_glr_pixel_coodinates_002.png :alt: Signal :srcset: /examples/standards/images/sphx_glr_pixel_coodinates_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none [10.0, 10.0] .. GENERATED FROM PYTHON SOURCE LINES 40-49 .. code-block:: Python # Azimuthal Integration # --------------------- # # Now if we do integrate this dataset it will choose the appropriate center based on the center pixel. az = s.get_azimuthal_integral2d(npt=30) az.plot() .. image-sg:: /examples/standards/images/sphx_glr_pixel_coodinates_003.png :alt: Signal :srcset: /examples/standards/images/sphx_glr_pixel_coodinates_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none [ ] | 0% Completed | 140.67 us [########################################] | 100% Completed | 100.48 ms .. GENERATED FROM PYTHON SOURCE LINES 50-65 .. code-block:: Python # Non-Linear Axes # --------------- # # Now consider the case where we have non-linear axes. In this case the center is still (10,10) # but things are streatched based on the effects of the Ewald Sphere. s.calibration.beam_energy = 200 s.calibration.detector(pixel_size=0.1, detector_distance=3) print(s.calibration.center) s.plot() az = s.get_azimuthal_integral2d(npt=30) az.plot() .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/standards/images/sphx_glr_pixel_coodinates_004.png :alt: Signal :srcset: /examples/standards/images/sphx_glr_pixel_coodinates_004.png :class: sphx-glr-multi-img * .. image-sg:: /examples/standards/images/sphx_glr_pixel_coodinates_005.png :alt: Signal :srcset: /examples/standards/images/sphx_glr_pixel_coodinates_005.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none [10, 10] [ ] | 0% Completed | 138.72 us [########################################] | 100% Completed | 100.44 ms .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 7.780 seconds) .. _sphx_glr_download_examples_standards_pixel_coodinates.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: pixel_coodinates.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: pixel_coodinates.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_