Check out the Hyperspy Workshop May 13-17, 2024 Online

Coordinates in Pyxem#

Pyxem is flexible in how it handles coordinates for a diffraction pattern.

There are three main ways to handle coordinates in Pyxem:

  1. Pixel coordinates

  2. Calibrated Coordinates with evenly spaced axes

  3. Calibrated Coordinates with unevenly spaced axes (e.g. corrected for the Ewald sphere)

import pyxem as pxm
from skimage.morphology import disk


s = pxm.signals.Diffraction2D(disk((10)))
s.calibrate.center = None
print(s.calibrate.center)
[10.0, 10.0]
s.plot(axes_ticks=True)
Signal
# From the plot above you can see that hyperspy automatically sets the axes ticks to be centered
# on each pixel. This means that for a 21x21 pixel image, the center is at (-10, -10) in pixel coordinates.
# if we change the scale using the calibrate function it will automatically adjust the center.  Here it is
# now (-1, -1)

s.calibrate.scale = 0.1
s.calibrate.units = "nm$^{-1}$"
s.plot(axes_ticks=True)
print(s.calibrate.center)
Signal
[10.0, 10.0]
# Azimuthal Integration
# ---------------------
#
# Now if we do integrate this dataset it will choose the appropriate center based on the center pixel.

az = s.get_azimuthal_integral2d(npt=30)
az.plot()
Signal
[                                        ] | 0% Completed | 142.43 us
[########################################] | 100% Completed | 100.50 ms
# Non-Linear Axes
# ---------------
#
# Now consider the case where we have non-linear axes. In this case the center is still (10,10)
# but things are streatched based on the effects of the Ewald Sphere.

s.calibrate.beam_energy = 200
s.calibrate.detector(pixel_size=0.1, detector_distance=3)
print(s.calibrate.center)
s.plot()

az = s.get_azimuthal_integral2d(npt=30)
az.plot()
  • Signal
  • Signal
[10, 10]

[                                        ] | 0% Completed | 157.43 us
[########################################] | 100% Completed | 100.46 ms

Total running time of the script: (0 minutes 7.877 seconds)

Gallery generated by Sphinx-Gallery