From 45c407fe626f98eb8d44209f8e2b7e553ae77fb0 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 24 Jun 2011 11:41:30 +0200 Subject: Back out and abort refinement if things look bad --- src/post-refinement.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/post-refinement.c') 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) ); -- cgit v1.2.3