aboutsummaryrefslogtreecommitdiff
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
parent4a15541c3875cb4dca578fb2d7d253c34491be4e (diff)
Back out and abort refinement if things look bad
-rw-r--r--src/hrs-scaling.c4
-rw-r--r--src/image.h2
-rw-r--r--src/partialator.c1
-rw-r--r--src/post-refinement.c30
4 files changed, 37 insertions, 0 deletions
diff --git a/src/hrs-scaling.c b/src/hrs-scaling.c
index 5e7593f5..cbae682c 100644
--- a/src/hrs-scaling.c
+++ b/src/hrs-scaling.c
@@ -401,6 +401,10 @@ static RefList *lsq_intensities(struct image *images, int n,
double G;
Reflection *refl;
+ /* Don't scale intensities from this image if
+ * post refinement failed on the last step. */
+ if ( images[m].pr_dud ) continue;
+
G = images[m].osf;
for ( refl = find_refl(images[m].reflections,
diff --git a/src/image.h b/src/image.h
index d6e22aee..f60af673 100644
--- a/src/image.h
+++ b/src/image.h
@@ -82,6 +82,7 @@ typedef struct _imagefeaturelist ImageFeatureList;
* int i0_available;
* double osf;
* double profile_radius;
+ * int pr_dud;
*
* int width;
* int height;
@@ -143,6 +144,7 @@ struct image {
* from the input. */
double osf; /* Overall scaling factor */
double profile_radius; /* Radius of reflection */
+ int pr_dud; /* Post refinement failed */
int width;
int height;
diff --git a/src/partialator.c b/src/partialator.c
index 9418bbb1..aa55b81c 100644
--- a/src/partialator.c
+++ b/src/partialator.c
@@ -340,6 +340,7 @@ int main(int argc, char *argv[])
images[n_usable_patterns].height = det->max_ss;
images[n_usable_patterns].osf = 1.0;
images[n_usable_patterns].profile_radius = 0.005e9;
+ images[n_usable_patterns].pr_dud = 0;
/* Muppet proofing */
images[n_usable_patterns].data = NULL;
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) );