.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/processing/centering_the_zero_beam.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_centering_the_zero_beam.py: Centering the Zero Beam ======================= .. GENERATED FROM PYTHON SOURCE LINES 7-8 Making a Dummy Dataset with a Zero Beam that systematically deviates from the center .. GENERATED FROM PYTHON SOURCE LINES 8-19 .. code-block:: Python import hyperspy.api as hs import pyxem as pxm s = pxm.data.tilt_boundary_data(correct_pivot_point=False) # Getting the Position of the Zero beam # ------------------------------------- # The zero beam position can be obtained using the :meth:`get_direct_beam_position` method. shifts = s.get_direct_beam_position(method="blur", sigma=5, half_square_width=20) hs.plot.plot_images(shifts.T) # Plotting the shifts .. image-sg:: /examples/processing/images/sphx_glr_centering_the_zero_beam_001.png :alt: (0,), (1,) :srcset: /examples/processing/images/sphx_glr_centering_the_zero_beam_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none [ ] | 0% Completed | 139.81 us [ ] | 0% Completed | 100.45 ms [########################################] | 100% Completed | 200.82 ms [ ] | 0% Completed | 131.71 us [########################################] | 100% Completed | 100.42 ms [, ] .. GENERATED FROM PYTHON SOURCE LINES 20-42 .. code-block:: Python # Making a Linear Plane # --------------------- # In many instances the zero beam position will vary systematically with the scan position. # This can be corrected by fitting a linear plane to the zero beam position using the # :meth:`make_linear_plane` method. shifts.make_linear_plane() # Making a linear plane to remove the systematic shift hs.plot.plot_images(shifts.T) # Plotting the shifts after making a linear plane # Centering the Zero Beam # ----------------------- # The zero beam can be centered using the :meth:`center_direct_beam` method. centered = s.center_direct_beam(shifts=shifts, inplace=False) pacbed_centered = ( centered.sum() ) # Plotting the sum of the dataset to check that the zero beam is centered pacbed = ( s.sum() ) # Plotting the sum of the dataset to check that the zero beam is centered hs.plot.plot_images([pacbed, pacbed_centered], label=["Original", "Centered"]) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/processing/images/sphx_glr_centering_the_zero_beam_002.png :alt: (0,), (1,) :srcset: /examples/processing/images/sphx_glr_centering_the_zero_beam_002.png :class: sphx-glr-multi-img * .. image-sg:: /examples/processing/images/sphx_glr_centering_the_zero_beam_003.png :alt: Original, Centered :srcset: /examples/processing/images/sphx_glr_centering_the_zero_beam_003.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none [ ] | 0% Completed | 163.25 us [ ] | 0% Completed | 100.46 ms [########################################] | 100% Completed | 200.80 ms [, ] .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.379 seconds) .. _sphx_glr_download_examples_processing_centering_the_zero_beam.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: centering_the_zero_beam.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: centering_the_zero_beam.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_