aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2022-07-12 12:39:51 +0200
committerThomas White <taw@physics.org>2022-07-12 14:10:20 +0200
commite8847558c3831e309d0325382589f34b273e96c8 (patch)
treecdd7a00c554f24023355fb1a869cafd3b4a79e89 /libcrystfel
parentb4e22ead6ce9ed53660666a3ab715682872e319d (diff)
Zero-weight negative intensity peaks in prediction refinement
Strongly negative peaks can occur if there are unmasked bad pixels. These cause the refinement to diverge badly. This change stabilises the refinement such that it works even in these cases. But of course, the real solution is to mask out those pixels. Negative intensity peaks are unlikely to show up "for real" in the peak search results (because we look for strong peaks!). However, if the intensity is negative, we aren't even sure that the peak exists at all and have no reason to assume it should be close to the Bragg condition.
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/predict-refine.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libcrystfel/src/predict-refine.c b/libcrystfel/src/predict-refine.c
index fbadcc67..19c689cd 100644
--- a/libcrystfel/src/predict-refine.c
+++ b/libcrystfel/src/predict-refine.c
@@ -612,7 +612,11 @@ int refine_prediction(struct image *image, Crystal *cr)
return 1;
}
for ( i=0; i<n; i++ ) {
- rps[i].Ih = rps[i].peak->intensity / max_I;
+ if ( rps[i].peak->intensity > 0.0 ) {
+ rps[i].Ih = rps[i].peak->intensity / max_I;
+ } else {
+ rps[i].Ih = 0.0;
+ }
}
//STATUS("Initial residual = %e\n",