Skip to content

Commit

Permalink
Documentation: Add Example describing pixel coordinates.
Browse files Browse the repository at this point in the history
  • Loading branch information
CSSFrancis committed Apr 11, 2024
1 parent 517e32d commit 9c31daa
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/standards/README.rst
@@ -0,0 +1,3 @@
Standards
=========
Below is a gallery of examples showing different standards in pyxem
65 changes: 65 additions & 0 deletions examples/standards/pixel_coodinates.py
@@ -0,0 +1,65 @@
"""
====================
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)

# %%

s.plot(axes_ticks=True)
# %%

# 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)


# %%

# 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()

# %%

# 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()

# %%

0 comments on commit 9c31daa

Please sign in to comment.