From 9c31daa6d3b0ae0d666d92b53fc3b6aaee4b79e8 Mon Sep 17 00:00:00 2001 From: Carter Francis Date: Thu, 11 Apr 2024 10:36:10 -0500 Subject: [PATCH] Documentation: Add Example describing pixel coordinates. --- examples/standards/README.rst | 3 ++ examples/standards/pixel_coodinates.py | 65 ++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 examples/standards/README.rst create mode 100644 examples/standards/pixel_coodinates.py diff --git a/examples/standards/README.rst b/examples/standards/README.rst new file mode 100644 index 000000000..b90efb7d8 --- /dev/null +++ b/examples/standards/README.rst @@ -0,0 +1,3 @@ +Standards +========= +Below is a gallery of examples showing different standards in pyxem \ No newline at end of file diff --git a/examples/standards/pixel_coodinates.py b/examples/standards/pixel_coodinates.py new file mode 100644 index 000000000..0abdab543 --- /dev/null +++ b/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() + +# %%