aboutsummaryrefslogtreecommitdiff
path: root/src/post-refinement.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2011-06-24 11:41:30 +0200
committerThomas White <taw@physics.org>2012-02-22 15:27:30 +0100
commit45c407fe626f98eb8d44209f8e2b7e553ae77fb0 (patch)
tree3addb31678f54b5ebc0093860264e719df66367f /src/post-refinement.c
parent4a15541c3875cb4dca578fb2d7d253c34491be4e (diff)
Back out and abort refinement if things look bad
Diffstat (limited to 'src/post-refinement.c')
-rw-r--r--src/post-refinement.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/post-refinement.c b/src/post-refinement.c
index 138e4cc9..d66458b6 100644
--- a/src/post-refinement.c
+++ b/src/post-refinement.c
@@ -486,7 +486,16 @@ void pr_refine(struct image *image, const RefList *full, const char *sym)
i = 0;
do {
+ double asx, asy, asz;
+ double bsx, bsy, bsz;
+ double csx, csy, csz;
double dev;
+ int old_nexp, old_nfound;
+
+ cell_get_reciprocal(image->indexed_cell, &asx, &asy, &asz,
+ &bsx, &bsy, &bsz, &csx, &csy, &csz);
+ old_nexp = nexp;
+ old_nfound = nfound;
max_shift = pr_iterate(image, full, sym);
@@ -500,6 +509,27 @@ void pr_refine(struct image *image, const RefList *full, const char *sym)
i+1, max_shift, dev, nfound, nexp);
}
+ if ( (double)nfound / (double)nexp < 0.5 ) {
+
+ if ( verbose ) {
+ ERROR("Bad refinement step - backtracking.\n");
+ ERROR("I'll come back to this image later.\n");
+ }
+
+ cell_set_reciprocal(image->indexed_cell, asx, asy, asz,
+ bsx, bsy, bsz, csx, csy, csz);
+
+ update_partialities(image, sym, NULL,
+ &nexp, &nfound, &nnotfound);
+
+ image->pr_dud = 1;
+
+ return;
+
+ } else {
+ image->pr_dud = 0;
+ }
+
i++;
} while ( (max_shift > 0.01) && (i < MAX_CYCLES) );