Skip to content

Commit 8115f87

Browse files
authored
Merge pull request #841 from HEXRD/positive-areas
Ensure areas are positive in auto powder picking
2 parents 24211d1 + 0492494 commit 8115f87

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)