HEXRD / hexrd

A cross-platform, open-source library for the analysis of X-ray diffraction data.
Other
56 stars 25 forks source link

Remove duplicate Laue spots from simulator #516

Closed psavery closed 1 year ago

psavery commented 1 year ago

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

psavery commented 1 year ago

For my example, this produces nearly the same results with a few differences. One of which is that (2, -4, 0) near the bottom becomes (-2, 4, 0). It looks like that is what it actually was previously (before the transforms were merged), so that also matches better.

Previous: current

Using np.dot(): new

psavery commented 1 year ago

And actually, this now matches exactly what we had before migrating to the new transforms. Here is what we used to have in the old transforms:

oscar

It appears the dot product version is an exact match for this example.