aboutsummaryrefslogtreecommitdiff
path: root/src/post-refinement.c
diff options
context:
space:
mode:
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) );