.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/loading_data/setting_scales_and_metadata.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_loading_data_setting_scales_and_metadata.py: Setting Scales and Metadata =========================== For the most part Rosettasciio will automatically get the scales and the metadata from the file. Sometimes, however, you may want to set the scales and metadata yourself. .. GENERATED FROM PYTHON SOURCE LINES 8-21 .. code-block:: Python from pyxem.data import simulated_strain strained_signal = simulated_strain( navigation_shape=(32, 32), signal_shape=(512, 512), disk_radius=20, num_electrons=1e5, strain_matrix=None, lazy=True, ) .. GENERATED FROM PYTHON SOURCE LINES 22-27 Setting the scales ------------------- The scales can be set using the ``set`` method. If you pass in a list it will automatically set the scales for each dimension. If you pass in a single value it will set that property for all dimensions. .. GENERATED FROM PYTHON SOURCE LINES 27-37 .. code-block:: Python strained_signal.axes_manager.navigation_axes.set( scale=0.1, units="nm", name=["x", "y"], offset=[2, 3] # offset in nm, ) strained_signal.axes_manager.signal_axes.set( scale=0.1, units="nm^-1", name=["kx", "ky"], offset=[2, 3] # offset in nm ) .. GENERATED FROM PYTHON SOURCE LINES 38-43 Setting the Detector Gain ------------------------- In most cases data is in units of detector counts or electrons. Setting the ``detector_gain`` property will set your plot to be in units of electrons. .. GENERATED FROM PYTHON SOURCE LINES 43-46 .. code-block:: Python strained_signal.calibration.detector_gain = 1 .. GENERATED FROM PYTHON SOURCE LINES 47-51 Setting Other Metadata ---------------------- Pyxem also has a number of other metadata properties that can be set using the calibration object for convenience. For example: .. GENERATED FROM PYTHON SOURCE LINES 51-64 .. code-block:: Python strained_signal.calibration.beam_energy = 200 # in keV strained_signal.calibration.physical_pixel_size = ( 15e-6 # in meters, this is the physical pixel size of the detector ) strained_signal.center = ( None # Set the center to be the center of the signal (changes offsets) ) strained_signal.center = ( 256, 256, ) # Set the center to be at (256, 256) in pixel coordinates strained_signal.calibration.convergence_angle = 1.5 # in mrad .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 9.107 seconds) .. _sphx_glr_download_examples_loading_data_setting_scales_and_metadata.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: setting_scales_and_metadata.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: setting_scales_and_metadata.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: setting_scales_and_metadata.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_