-
Notifications
You must be signed in to change notification settings - Fork 28
Add Documentation Examples #209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c34e4b6
Examples: Add examples for simulating diffraction libraries.
CSSFrancis 1fab94b
Examples: Clean up example scripts for building documentation
CSSFrancis cf66851
Refactor: calculate_ed_data--> calculate_diffraction2d in examples
CSSFrancis fec7955
Add sphinx gallery to doc requirements
CSSFrancis 4117bb5
Refactor: Add examples to MANIFEST.in
CSSFrancis 357bdaf
Refactor: Fix formatting
CSSFrancis 777ab63
Refactor: Refactor simulation examples
CSSFrancis 3e301b4
Use numpydoc for docs formatting, enable doc nav with arrow keys
hakonanes 04de779
Minor fixes to docstring formatting to allow doc build with numpydoc
hakonanes 5936535
Modify "make clean" to remove dirs for build, examples, generated API
hakonanes 8e26b42
Fix header level for Examples README.rst, remove "Gallery of" in title
hakonanes 5f7ac67
Fix doc/index examples link and formatting, restructure slightly
hakonanes c6cf175
Add numpydoc config (welcome, build warnings!), fix API minigallery
hakonanes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,7 @@ | ||
.. _examples-index: | ||
|
||
======== | ||
Examples | ||
======== | ||
|
||
Below is a gallery of examples for different operations in diffsims. |
This file contains hidden or 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,4 @@ | ||
Creating a Simulation Library | ||
============================= | ||
|
||
These examples show specific workflows for creating a library of simulations. |
This file contains hidden or 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,84 @@ | ||
""" | ||
0.5.x --> 0.6.x Migration Guide | ||
=============================== | ||
This is a migration guide for version 0.5.x to 0.6.x. This guide helps to show the changes | ||
that were made to the API and how to update your code to use the new API. | ||
|
||
Here you can see how to make an equivalent to a diffraction library | ||
|
||
Old | ||
--- | ||
""" | ||
|
||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
from diffpy.structure import Atom, Lattice, Structure | ||
|
||
from diffsims.libraries.structure_library import StructureLibrary | ||
hakonanes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
from diffsims.generators.diffraction_generator import DiffractionGenerator | ||
from diffsims.generators.library_generator import DiffractionLibraryGenerator | ||
|
||
|
||
latt = Lattice(4, 4, 4, 90, 90, 90) | ||
atoms = [ | ||
Atom(atype="Al", xyz=[0.0, 0.0, 0.0], lattice=latt), | ||
Atom(atype="Al", xyz=[0.5, 0.5, 0.0], lattice=latt), | ||
Atom(atype="Al", xyz=[0.5, 0.0, 0.5], lattice=latt), | ||
Atom(atype="Al", xyz=[0.0, 0.5, 0.5], lattice=latt), | ||
] | ||
structure_matrix = Structure(atoms=atoms, lattice=latt) | ||
euler_angles = np.array([[0, 0, 0], [10.0, 0.0, 0.0]]) | ||
struct_library = StructureLibrary(["Al"], [structure_matrix], [euler_angles]) | ||
diff_gen = DiffractionGenerator(accelerating_voltage=200) | ||
lib_gen = DiffractionLibraryGenerator(diff_gen) | ||
diff_lib = lib_gen.get_diffraction_library( | ||
struct_library, | ||
calibration=0.0262, | ||
reciprocal_radius=1.6768, | ||
half_shape=64, | ||
with_direct_beam=True, | ||
max_excitation_error=0.02, | ||
) | ||
|
||
# %% | ||
# New | ||
# --- | ||
|
||
from orix.crystal_map import Phase | ||
from orix.quaternion import Rotation | ||
from diffsims.generators.simulation_generator import SimulationGenerator | ||
|
||
latt = Lattice(4, 4, 4, 90, 90, 90) | ||
atoms = [ | ||
Atom(atype="Al", xyz=[0.0, 0.0, 0.0], lattice=latt), | ||
Atom(atype="Al", xyz=[0.5, 0.5, 0.0], lattice=latt), | ||
Atom(atype="Al", xyz=[0.5, 0.0, 0.5], lattice=latt), | ||
Atom(atype="Al", xyz=[0.0, 0.5, 0.5], lattice=latt), | ||
] | ||
structure_matrix = Structure(atoms=atoms, lattice=latt) | ||
p = Phase("Al", point_group="m-3m", structure=structure_matrix) | ||
gen = SimulationGenerator(accelerating_voltage=200) | ||
rot = Rotation.from_euler([[0, 0, 0], [10.0, 0.0, 0.0]], degrees=True) | ||
sim = gen.calculate_diffraction2d( | ||
phase=p, | ||
rotation=rot, | ||
reciprocal_radius=1.6768, | ||
max_excitation_error=0.02, | ||
with_direct_beam=True, | ||
) | ||
|
||
fig, axs = plt.subplots(2, 2, figsize=(10, 10)) | ||
for i in range(2): | ||
diff_lib["Al"]["simulations"][i].plot( | ||
size_factor=15, show_labels=True, ax=axs[i, 0] | ||
) | ||
sim.irot[i].plot(ax=axs[i, 1], size_factor=15, show_labels=True) | ||
axs[i, 0].set_xlim(-1.5, 1.5) | ||
axs[i, 0].set_ylim(-1.5, 1.5) | ||
axs[i, 1].set_xlim(-1.5, 1.5) | ||
axs[i, 1].set_ylim(-1.5, 1.5) | ||
|
||
_ = axs[0, 0].set_title("Old") | ||
_ = axs[0, 1].set_title("New") | ||
|
||
# %% |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.