diff options
author | Thomas White <taw@physics.org> | 2024-07-29 15:00:32 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2024-07-29 15:00:32 +0200 |
commit | 66a5efece6c2c219af873f1522dd4a82003bf6b9 (patch) | |
tree | 4d3f12aa07504103d68521bd3f21850b8e053a72 | |
parent | 274b61d5b8489fc9348aa4cf9f773a3473e24dee (diff) |
Catch NaNs in ggpm model
Previously, these NaNs would result in very many reflections being
predicted with meaningless partiality when the profile radius was zero.
This would take a long time (~30 seconds) and hold up the processing of
other patterns. A zero radius is sometimes returned by the auto profile
radius calculation, which is a separate problem.
Now, the model simply doesn't predict any reflections and returns very
quickly.
It feels strange to not have any predictions in this case, but the model
is actually giving the expected answer, because the overlap integral is
always zero when the profile radius is zero. Therefore there can be no
intensity in the peak and hence no prediction.
Fixes: https://gitlab.desy.de/thomas.white/crystfel/-/issues/109
-rw-r--r-- | libcrystfel/src/geometry.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libcrystfel/src/geometry.c b/libcrystfel/src/geometry.c index 10a7fa19..7bcb8d8f 100644 --- a/libcrystfel/src/geometry.c +++ b/libcrystfel/src/geometry.c @@ -306,7 +306,7 @@ static Reflection *check_reflection(struct image *image, Crystal *cryst, z -= g.kcen; /* Three because the general case fails in extreme cases */ - if ( w0 / w1 <= DBL_MIN ) { + if ( isinf(w0) || (w0 / w1 <= DBL_MIN) ) { /* 'Laue' corner case */ kpred = g.kcen; @@ -352,6 +352,7 @@ static Reflection *check_reflection(struct image *image, Crystal *cryst, /* Revert the 'Lorentz' factor */ partiality *= sqrt( ( R*R + M2_k/sumw_k) / ( R*R ) ); + if ( isnan(partiality) ) partiality = 0.0; if ( (updateme == NULL) && ( partiality < min_partiality ) ) return NULL; |