.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/selecting_data/extract_patterns_from_grid.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_extract_patterns_from_grid.py: Extract patterns from a grid ============================ This example shows how to extract :class:`~kikuchipy.signals.EBSD` patterns from positions in a grid evenly spaced in navigation space. .. GENERATED FROM PYTHON SOURCE LINES 8-46 .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/selecting_data/images/sphx_glr_extract_patterns_from_grid_001.png :alt: extract patterns from grid :srcset: /examples/selecting_data/images/sphx_glr_extract_patterns_from_grid_001.png :class: sphx-glr-multi-img * .. image-sg:: /examples/selecting_data/images/sphx_glr_extract_patterns_from_grid_002.png :alt: extract patterns from grid :srcset: /examples/selecting_data/images/sphx_glr_extract_patterns_from_grid_002.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none | .. code-block:: default import hyperspy.api as hs import kikuchipy as kp import matplotlib.pyplot as plt plt.rcParams["font.size"] = 15 # Silence progressbars hs.preferences.General.show_progressbar = False # Import data (lazily) s = kp.data.nickel_ebsd_large(lazy=True) print(s) # Extract data, also getting the grid positions s2, idx = s.extract_grid((4, 3), return_indices=True) print(s2) # Get virtual backscatter electron (VBSE) image from the intensities from the # center of the detector, also slightly stretching the contrast roi = hs.roi.RectangularROI(left=20, top=20, right=40, bottom=40) vbse_img = s.get_virtual_bse_intensity(roi) vbse_img.compute() # Drop if data was not loaded lazily vbse_img.rescale_intensity(dtype_out="float32", percentiles=(0.5, 99.5)) # Plot grid of extracted patterns kp.draw.plot_pattern_positions_in_map( idx.reshape(2, -1).T, roi_shape=s.axes_manager.navigation_shape[::-1], roi_image=vbse_img.data, ) # Plot extracted patterns s2.remove_static_background() _ = hs.plot.plot_images( s2, per_row=4, axes_decor=None, label=None, colorbar=None, tight_layout=True ) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.370 seconds) **Estimated memory usage:** 9 MB .. _sphx_glr_download_examples_selecting_data_extract_patterns_from_grid.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: extract_patterns_from_grid.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: extract_patterns_from_grid.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_