Imaging refactor part 2 - Atoms: add_atoms(), refine_atoms(), plot(kind='atoms') and tests#236
Open
darshan-mali wants to merge 3 commits into
Open
Imaging refactor part 2 - Atoms: add_atoms(), refine_atoms(), plot(kind='atoms') and tests#236darshan-mali wants to merge 3 commits into
darshan-mali wants to merge 3 commits into
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
Part 2 of Imaging refactor
Enables the Lattice class to store atoms and their data. This includes
add_atoms()function that checks if an atom is present at a given position and stores the atomic positions in both pixel and unit cell coordinatesrefine_atoms()function to refine the atomic positionsplot()now includeskind='atoms'Relevant references
Part 1 can be found at : #198
This PR involves the use of the
Vectordatastructure.A tutorial for the same can be found at: https://github.com/electronmicroscopy/quantem-tutorials/blob/main/tutorials/core/vector.ipynb
API and logic
After defining the lattice vectors, atoms can be added to$0 \leq u,v < 1$ .
Latticevia theadd_atoms()method.The
add_atoms()takes in the fractional/unit cell coordinates of all atoms in one unit cellThese are tiled across all unit cells and checked against the background to determine if an atom is present.
The
refine_atoms()functions optimizes for the position of the atom via 2D Gaussian fitting.The pixel and unit cell coordinates of the atoms are stored in
Lattice.atomswhich is aVectordatastructure, alongwith other fitting information.Both
add_atoms()andrefine_atoms()set thedefault_plot='atoms'inLattice.plot().Files changed
Updated files
src/quantem/imaging/lattice.py: Theadd_atoms()andrefine_atoms()functions were added.src/quantem/imaging/lattice_visualization.py: Functionality forplot(kind='atoms')was added along with necessary helperstests/imaging/test_lattice.py: Basic pytests foradd_atoms()andrefine_atoms()based on expected user behaviourExamples
A testing notebook with examples can be found here:
Lattice_refactor_2_atoms.ipynb
(Note: Some plotting calls have been commented out to reduce file size. Please uncomment them before running)
Example code block:
Example output:

PR Checklist
Reviewer checklist