Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

added mask of ones, if no mask is given #41

Merged
merged 3 commits into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions skued/image/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def bragg_peaks(im, mask=None, center=None, min_dist=None):
Liu, Lai Chung. Chemistry in Action: Making Molecular Movies with Ultrafast
Electron Diffraction and Data Science, Chapter 2. Springer Nature, 2020.
"""
if mask is None:
mask = np.ones(im.shape)
if center is None:
center = autocenter(im=im, mask=mask)

Expand Down
18 changes: 18 additions & 0 deletions skued/image/tests/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,21 @@ def test_bragg_peaks():
peaks = bragg_peaks(I, mask=np.ones_like(I, dtype=bool))

assert len(peaks) == len(in_plane_refls)


def test_bragg_peaks_no_mask():
"""Test that the `bragg_peaks` function finds all Bragg peaks, without supplying a mask file."""
kx, ky, I, cryst = diff_pattern_sc()
kk = np.sqrt(kx**2 + ky**2)

# only in-plane refls (hk0) and not (000)
# Also, some reflections will appear at the edge of the frame
in_plane_refls = [
refl
for refl in cryst.bounded_reflections(kk.max())
if (refl[2] == 0 and np.abs(cryst.scattering_vector(refl)[0]) < kx.max())
]

peaks = bragg_peaks(I)

assert len(peaks) == len(in_plane_refls)