Skip to content

Commit 0492494

Browse files
committed
Ensure areas are positive in auto powder picking
The areas can be negative if the beam vector is in the opposite direction from which HEXRD would normally expect it (HEXRD normally expects a negative Z beam vector). The powder picking code was assuming the areas are positive. Take the absolute value to ensure that is the case. This fixes automatic point picking for positive beam vectors. Signed-off-by: Patrick Avery <[email protected]>
1 parent 24211d1 commit 0492494

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

hexrd/gridutil.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ def cellCentroids(crd, con):
147147

148148
@numba.njit(nogil=True, cache=True)
149149
def compute_areas(xy_eval_vtx, conn):
150+
# NOTE: this function may return negative areas if the vertices
151+
# are passed in the opposite order to the function. This happens
152+
# if the beam vector is in the opposite direction (positive Z
153+
# instead of the usual negative Z)
150154
areas = np.empty(len(conn))
151155
for i in range(len(conn)):
152156
vtx0x, vtx0y = xy_eval_vtx[conn[i, 0]]

hexrd/instrument/hedm_instrument.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2686,6 +2686,12 @@ def _extract_ring_line_positions(iter_args, instr_cfg, panel, eta_tol, npdiv,
26862686
# strip relevant objects out of current patch
26872687
vtx_angs, vtx_xys, conn, areas, xys_eval, ijs = patch
26882688

2689+
# These areas can be negative if the beam vector is in
2690+
# the opposite direction than it normally is in (positive
2691+
# Z instead of the usual negative Z). Take the absolute
2692+
# value of the areas to ensure they are positive.
2693+
areas = np.abs(areas)
2694+
26892695
# need to reshape eval pts for interpolation
26902696
xy_eval = np.vstack([
26912697
xys_eval[0].flatten(),

0 commit comments

Comments
 (0)