.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/selecting_data/crop_signal_axes.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_selecting_data_crop_signal_axes.py: Crop signal axes ================ This example shows various ways to crop the signal axes of an :class:`~kikuchipy.signals.EBSD` signal using HyperSpy's ``isig`` slicer and the :meth:`~kikuchipy.signals.EBSD.crop` and :meth:`~hyperspy._signals.signal2d.Signal2D.crop_image` methods (see :ref:`hyperspy:signal.indexing` for details). .. GENERATED FROM PYTHON SOURCE LINES 11-27 .. code-block:: default import hyperspy.api as hs import kikuchipy as kp # Import data s = kp.data.nickel_ebsd_small() s.remove_static_background(show_progressbar=False) # Inspect data and attributes plot_kwds = dict(axes_decor=None, label=None, colorbar=None, tight_layout=True) _ = hs.plot.plot_images(s, **plot_kwds) print(s) print(s.static_background.shape) print(s.detector) .. image-sg:: /examples/selecting_data/images/sphx_glr_crop_signal_axes_001.png :alt: crop signal axes :srcset: /examples/selecting_data/images/sphx_glr_crop_signal_axes_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none (60, 60) EBSDDetector (60, 60), px_size 1 um, binning 8, tilt 0, azimuthal 0, pc (0.425, 0.213, 0.501) .. GENERATED FROM PYTHON SOURCE LINES 28-31 Get a new signal, removing the first and last ten rows of pixels and first and last five columns of pixels. Note how the :attr:`~kikuchipy.signals.EBSD.static_background` and :attr:`~kikuchipy.signals.EBSD.detector` attributes are updated. .. GENERATED FROM PYTHON SOURCE LINES 31-39 .. code-block:: default s2 = s.isig[5:55, 10:50] _ = hs.plot.plot_images(s2, **plot_kwds) print(s2) print(s2.static_background.shape) print(s2.detector) .. image-sg:: /examples/selecting_data/images/sphx_glr_crop_signal_axes_002.png :alt: crop signal axes :srcset: /examples/selecting_data/images/sphx_glr_crop_signal_axes_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none (40, 50) EBSDDetector (40, 50), px_size 1 um, binning 8, tilt 0, azimuthal 0, pc (0.41, 0.07, 0.751) .. GENERATED FROM PYTHON SOURCE LINES 40-41 Do the same inplace using :meth:`~kikuchipy.signals.EBSD.crop` .. GENERATED FROM PYTHON SOURCE LINES 41-51 .. code-block:: default s3 = s.deepcopy() s3.crop(2, start=5, end=55) s3.crop("dy", start=10, end=50) _ = hs.plot.plot_images(s3, **plot_kwds) print(s3) print(s3.static_background.shape) print(s3.detector) .. image-sg:: /examples/selecting_data/images/sphx_glr_crop_signal_axes_003.png :alt: crop signal axes :srcset: /examples/selecting_data/images/sphx_glr_crop_signal_axes_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none (40, 50) EBSDDetector (40, 50), px_size 1 um, binning 8, tilt 0, azimuthal 0, pc (0.41, 0.07, 0.751) .. GENERATED FROM PYTHON SOURCE LINES 52-53 Do the same inplace using ``crop_image()`` .. GENERATED FROM PYTHON SOURCE LINES 53-61 .. code-block:: default s4 = s.deepcopy() s4.crop_image(top=10, bottom=50, left=5, right=55) _ = hs.plot.plot_images(s4, **plot_kwds) print(s4) print(s4.static_background.shape) print(s4.detector) .. image-sg:: /examples/selecting_data/images/sphx_glr_crop_signal_axes_004.png :alt: crop signal axes :srcset: /examples/selecting_data/images/sphx_glr_crop_signal_axes_004.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none (40, 50) EBSDDetector (40, 50), px_size 1 um, binning 8, tilt 0, azimuthal 0, pc (0.41, 0.07, 0.751) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 3.002 seconds) **Estimated memory usage:** 13 MB .. _sphx_glr_download_examples_selecting_data_crop_signal_axes.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: crop_signal_axes.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: crop_signal_axes.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_