Skip to content

Commit

Permalink
Remove duplicate Laue spots from simulator
Browse files Browse the repository at this point in the history
This issue arose from #509, due to somewhat complex details.

In short, the old `gvecToDetectorXY()` would filter out g-vectors going
the wrong way (they would result in `nan`), but `gvecToDetectorXYArray()` would
not.

The new `gvec_to_xy()` has behavior matching `gvecToDetectorXYArray()`. But
that means that places where `gvecToDetectorXY()` used to be used, we need
to verify that the function does not receive g-vectors going the wrong way.

Looking through the code, however, I only found one place where
`gvecToDetectorXY()` used to receive g-vectors going the wrong way. It was
the Laue overlay simulator, which would compute g-vectors from symmetrical
HKLs (which is why it would have duplicate g-vectors going the wrong way).

All other cases where `gvecToDetectorXY()` was called would be after
the g-vectors were computed from `anglesToGvec()`, which I believe should
always produce g-vectors going in the correct direction.

As such, we only need to filter out wrong-direction g-vectors in the
Laue simulator.

Fixes: HEXRD/hexrdgui#1412

Signed-off-by: Patrick Avery <[email protected]>
  • Loading branch information
psavery committed Apr 27, 2023
1 parent 3056b7c commit 0c2117a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions hexrd/instrument/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,14 @@ def simulate_laue_pattern(self, crystal_data,

# and the unit plane normals (G-vectors) in CRYSTAL FRAME
gvec_c = np.dot(plane_data.latVecOps['B'], hkls)

# Filter out g-vectors going in the wrong direction. `gvec_to_xy()` used
# to do this, but not anymore.
bvec_z = self.bvec[2]
to_keep = gvec_c.T[:, 2] * bvec_z <= 0

hkls = hkls.T[to_keep].T
gvec_c = gvec_c.T[to_keep].T
elif len(crystal_data) == 2:
# !!! should clean this up
hkls = np.array(crystal_data[0])
Expand Down

0 comments on commit 0c2117a

Please sign in to comment.