.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/virtual_imaging/creating_a_segmented_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_virtual_imaging_creating_a_segmented_detector.py: ============================= Creating a Segmented Detector ============================= In this example we will show how to create virtual images for a segmented-like detector. This is helpful for basic mapping of orientation etc. in a diffraction pattern and can be useful for a first look at the data. .. GENERATED FROM PYTHON SOURCE LINES 11-39 .. code-block:: Python import pyxem as pxm from pyxem.utils._azimuthal_integrations import _get_control_points import numpy as np import hyperspy.api as hs dp = pxm.data.tilt_boundary_data() dp.calibration.center = None # Center the diffraction patterns dp.calibration.scale = 0.1 # Scale the diffraction patterns in reciprocal space # Visualizing the virtual detector cp = _get_control_points( 1, npt_azim=8, radial_range=(1, 5), azimuthal_range=(-np.pi, np.pi), affine=dp.calibration.affine, )[:, :, ::-1] poly = hs.plot.markers.Polygons(verts=cp, edgecolor="w", facecolor="none") dp.plot() dp.add_marker(poly) pos = np.mean(cp, axis=1) texts = np.arange(len(pos)).astype(str) texts = hs.plot.markers.Texts(offsets=pos, texts=texts, color="w") dp.add_marker(texts) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/virtual_imaging/images/sphx_glr_creating_a_segmented_detector_001.png :alt: creating a segmented detector :srcset: /examples/virtual_imaging/images/sphx_glr_creating_a_segmented_detector_001.png :class: sphx-glr-multi-img * .. image-sg:: /examples/virtual_imaging/images/sphx_glr_creating_a_segmented_detector_002.png :alt: Signal :srcset: /examples/virtual_imaging/images/sphx_glr_creating_a_segmented_detector_002.png :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 40-45 .. code-block:: Python az = dp.get_azimuthal_integral2d(npt=1, npt_azim=8, radial_range=(2, 5)) az.T.plot() .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/virtual_imaging/images/sphx_glr_creating_a_segmented_detector_003.png :alt: creating a segmented detector :srcset: /examples/virtual_imaging/images/sphx_glr_creating_a_segmented_detector_003.png :class: sphx-glr-multi-img * .. image-sg:: /examples/virtual_imaging/images/sphx_glr_creating_a_segmented_detector_004.png :alt: Signal :srcset: /examples/virtual_imaging/images/sphx_glr_creating_a_segmented_detector_004.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none [ ] | 0% Completed | 139.80 us [########################################] | 100% Completed | 100.47 ms .. GENERATED FROM PYTHON SOURCE LINES 46-48 sphinx_gallery_thumbnail_number = 2 %% .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.858 seconds) .. _sphx_glr_download_examples_virtual_imaging_creating_a_segmented_detector.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: creating_a_segmented_detector.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: creating_a_segmented_detector.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_