Skip to content

Commit

Permalink
rotation option
Browse files Browse the repository at this point in the history
  • Loading branch information
smribet committed Dec 1, 2023
1 parent 09a1d28 commit d669df3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions py4DSTEM/datacube/virtualimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ def make_bragg_mask(
max_q,
return_sum=True,
include_origin=True,
rotation_deg=0,
**kwargs,
):
"""
Expand All @@ -698,13 +699,22 @@ def make_bragg_mask(
slice contains a single disk; if False, return a single
2D masks of all disks
include_origin (bool) : if False, removes origin disk
rotation_deg (float) : rotate g1 and g2 vectors
Returns:
(2 or 3D array) the mask
"""
nas = np.asarray
g1, g2, origin = nas(g1), nas(g2), nas(origin)

rotation_rad = np.deg2rad(rotation_deg)
cost = np.cos(rotation_rad)
sint = np.sin(rotation_rad)
rotation_matrix = np.array(((cost, sint), (-sint, cost)))

g1 = np.dot(g1, rotation_matrix)
g2 = np.dot(g2, rotation_matrix)

# Get N,M, the maximum indices to tile out to
L1 = np.sqrt(np.sum(g1**2))
H = int(max_q / L1) + 1
Expand Down

0 comments on commit d669df3

Please sign in to comment.