forked from pyxem/pyxem
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Documentation: Add Example describing pixel coordinates.
- Loading branch information
1 parent
517e32d
commit 9c31daa
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Standards | ||
========= | ||
Below is a gallery of examples showing different standards in pyxem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
|
||
# %% |