Skip to content

Commit

Permalink
added mask of ones, if no mask is given (#41)
Browse files Browse the repository at this point in the history
* added mask of ones, if no mask is given
  • Loading branch information
kremeyer authored Aug 16, 2022
1 parent b109adc commit 884d1ca
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
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)

0 comments on commit 884d1ca

Please sign in to comment.