Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symmetrical HKLs included after new transforms #1412

Closed
psavery opened this issue Apr 19, 2023 · 3 comments · Fixed by HEXRD/hexrd#516
Closed

Symmetrical HKLs included after new transforms #1412

psavery opened this issue Apr 19, 2023 · 3 comments · Fixed by HEXRD/hexrd#516

Comments

@psavery
Copy link
Collaborator

psavery commented Apr 19, 2023

It appears that symmetrical HKLs are being included after HEXRD/hexrd#509 was merged.

Labeling HKLs for some Laue overlays used to appear like this (before that was merged):

correct

But now appear like this:

symmetrical_hkls

We should figure out why symmetric HKLs are not being identified correctly.

This issue is apparently not angles_to_gvec (I checked that one). Must be either gvec_to_xy or make_sample_rmat.

@psavery
Copy link
Collaborator Author

psavery commented Apr 20, 2023

Upon studying this further, we see that the issue lies in gvec_to_xy, and what it does with +g vs -g.

Taking a look at one of these spots, we saw two different g vectors being input: [-0.90453403, -0.30151134, 0.30151134] and [ 0.90453403, 0.30151134, -0.30151134]. We can think of one as +g and the other as -g. In the new xrd transforms, these both result in an xy output of [ -5.24220836, -17.28574434]. However, in the old xrd code, one of them would be set to nan.

We need to think about what to do about the +g versus -g case. Do we need the new transforms to match the old behavior, or do we need to filter out -g before passing it to gvec_to_xy?

Here's a test scrip that shows the difference (we are still able to call the old function in hexrd):

test_laue.zip

In this script, gvec = args[0], and gvec[314] is the first g vector mentioned above, while gvec[309] is the second vector. The old function would return nan for gvec[309] (where gvec[309] == [ 0.90453403, 0.30151134, -0.30151134])

@psavery
Copy link
Collaborator Author

psavery commented Apr 20, 2023

After even further testing, the following was observed:

  1. The old gvecToDetectorXY would return nan for some gvec values (one of +g or -g). But the old gvecToDetectorXYArray would not return nan for these values.
  2. In the HEDM workflow example we tested, gvecToDetectorXY was called in some places, but never with a g that would result in a nan as described in 1. Thus, we did not encounter this issue while testing the HEDM workflow.
  3. The places we need to watch out for are places where gvecToDetectorXY were previously called, because these sometimes resulted in nan values where the new gvec_to_xy does not. That is the cause of this Laue issue.

@psavery
Copy link
Collaborator Author

psavery commented Apr 20, 2023

It appears that I get the same results as we had before if I only keep the g-vectors whose z-component is opposite in sign compared to the beam vector's z-component. So I guess the old gvecToDetectorXY was doing this - maybe intentionally? I'm not sure.

psavery added a commit to HEXRD/hexrd that referenced this issue Apr 27, 2023
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]>
psavery added a commit to HEXRD/hexrd that referenced this issue Apr 27, 2023
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant