.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/reference_frames/crop_detector.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_reference_frames_crop_detector.py: Crop an EBSD detector ===================== This example shows how to crop an :class:`~kikuchipy.detectors.EBSDDetector`. .. GENERATED FROM PYTHON SOURCE LINES 28-29 Imports. .. GENERATED FROM PYTHON SOURCE LINES 29-33 .. code-block:: Python import matplotlib.pyplot as plt import kikuchipy as kp .. GENERATED FROM PYTHON SOURCE LINES 34-35 Create an EBSD detector. .. GENERATED FROM PYTHON SOURCE LINES 35-40 .. code-block:: Python det = kp.detectors.EBSDDetector((150, 200), pc=[0.6, 0.5, 0.5]) print(det) det.plot(coordinates="gnomonic", draw_gnomonic_circles=True) .. image-sg:: /examples/reference_frames/images/sphx_glr_crop_detector_001.png :alt: crop detector :srcset: /examples/reference_frames/images/sphx_glr_crop_detector_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none EBSDDetector shape (Ny, Nx): (150, 200) pc (PCx, PCy, PCz): (0.6, 0.5, 0.5) sample_tilt: 70.0° tilt: 0.0° azimuthal: 0.0° twist: 0.0° binning: 1 px_size: 1.0 um .. GENERATED FROM PYTHON SOURCE LINES 41-42 Crop away the upper 30 pixels and notice how the PC is adjusted accordingly. .. GENERATED FROM PYTHON SOURCE LINES 42-47 .. code-block:: Python det2 = det.crop(extent=(30, 150, 0, 200)) print(det2) det2.plot(coordinates="gnomonic", draw_gnomonic_circles=True) .. image-sg:: /examples/reference_frames/images/sphx_glr_crop_detector_002.png :alt: crop detector :srcset: /examples/reference_frames/images/sphx_glr_crop_detector_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none EBSDDetector shape (Ny, Nx): (120, 200) pc (PCx, PCy, PCz): (0.6, 0.375, 0.625) sample_tilt: 70.0° tilt: 0.0° azimuthal: 0.0° twist: 0.0° binning: 1 px_size: 1.0 um .. GENERATED FROM PYTHON SOURCE LINES 48-49 Plot a cropped detector with the PC on a cropped pattern. .. GENERATED FROM PYTHON SOURCE LINES 49-61 .. code-block:: Python s = kp.data.nickel_ebsd_small() print(s) s.remove_static_background(show_progressbar=False) det3 = s.detector det3.plot(pattern=s.inav[0, 0].data) det4 = det3.crop((0, 50, 0, 50)) det4.plot(pattern=s.inav[0, 0].data[:50, :50]) plt.show() .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/reference_frames/images/sphx_glr_crop_detector_003.png :alt: crop detector :srcset: /examples/reference_frames/images/sphx_glr_crop_detector_003.png :class: sphx-glr-multi-img * .. image-sg:: /examples/reference_frames/images/sphx_glr_crop_detector_004.png :alt: crop detector :srcset: /examples/reference_frames/images/sphx_glr_crop_detector_004.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.169 seconds) **Estimated memory usage:** 790 MB .. _sphx_glr_download_examples_reference_frames_crop_detector.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: crop_detector.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: crop_detector.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: crop_detector.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_