The C-API transforms version of gvec_to_xy does not return nans under the same conditions as the numpy version.
The numpy version uses two conditions to return an nan.
For diffraction to occur, the g-vector needs to make an acute angle with the negative beam direction. If that condition is not met, then nans are returned.
If the direction of the diffracted beam points away from the detector (dot product of diffracted beam direction and detector normal is nonnegative), then again the nans are returned.
Note that the diffracted beam direction in the C version (dvec_l) is the negative of the diffracted beam direction in numpy (also dvec_l), but the C version checks for denom > 0 while the numpy version checks for denom < -ztol, so they are the same except for the case that the diffracted beam is (very near) parallel to the detector plane.
So I don't understand how the C-version fails to return nans in so many cases.
The C-API transforms version of
gvec_to_xy
does not returnnan
s under the same conditions as the numpy version.The numpy version uses two conditions to return an
nan
.nan
s are returned.nan
s are returned.The relevant section of code is: https://github.com/HEXRD/hexrd/blob/32009f305d6e28905785e499e17d58eb38663333/hexrd/transforms/xf.py#L180-L207
The C-API version seems to check the same conditions (although in a slightly different way), but somehow they are ignored. The relevant code is: https://github.com/HEXRD/hexrd/blob/32009f305d6e28905785e499e17d58eb38663333/hexrd/transforms/transforms_CFUNC.c#L461-L493
Note that the diffracted beam direction in the C version (
dvec_l
) is the negative of the diffracted beam direction in numpy (alsodvec_l
), but the C version checks fordenom > 0
while the numpy version checks fordenom < -ztol
, so they are the same except for the case that the diffracted beam is (very near) parallel to the detector plane.So I don't understand how the C-version fails to return
nan
s in so many cases.