aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2015-03-12 13:20:17 +0100
committerThomas White <taw@physics.org>2015-03-12 16:37:25 +0100
commitd17da445040ac23aec7770c214ab0bdbf315f959 (patch)
tree135d2193f56c93d83910da891219b07464efedb2
parent5777736c952477d2bf912739862a66d1c0089cbc (diff)
Show more information about rejected crystals
-rw-r--r--src/hrs-scaling.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/src/hrs-scaling.c b/src/hrs-scaling.c
index e21c9066..141139d5 100644
--- a/src/hrs-scaling.c
+++ b/src/hrs-scaling.c
@@ -425,31 +425,45 @@ static void reset_scaling_flag(Crystal *crystal)
}
-static int test_convergence(double *old_osfs, double *old_Bs, int n,
- Crystal **crystals)
+static int test_convergence(double *old_osfs, double *old_Bs, int *old_flags,
+ int n, Crystal **crystals)
{
int i;
double total_osf_change = 0.0;
double total_B_change = 0.0;
int n_change = 0;
+ int n_newreject = 0;
int n_reject = 0;
for ( i=0; i<n; i++ ) {
- if ( crystal_get_user_flag(crystals[i]) == 0 ) {
+
+ int oldf = old_flags[i];
+ int newf = crystal_get_user_flag(crystals[i]);
+
+ if ( (oldf==0) && (newf==0) ) {
+ /* Crystal OK before and now */
double new_osf = crystal_get_osf(crystals[i]);
double new_B = crystal_get_Bfac(crystals[i]);
total_osf_change += fabs(new_osf - old_osfs[i]);
total_B_change += fabs(new_B - old_Bs[i]);
n_change++;
- } else {
+
+ } else if ( (oldf==0) && (newf!=0) ) {
+ /* Crystal bad now, but OK before */
+ n_newreject++;
+
+ }
+
+ if ( newf != 0 ) {
+ /* Crystal is bad now, don't care about before */
n_reject++;
}
}
STATUS("Mean OSF change: %10.3f Mean B change: %10.3f A^2 "
- "Rejected: %i\n",
+ "Newly rejected: %4i Total rejected : %4i\n",
total_osf_change/n_change, 1e20*total_B_change/n_change,
- n_reject);
+ n_newreject, n_reject);
return (total_osf_change/n_change) < 0.01;
}
@@ -463,6 +477,7 @@ RefList *scale_intensities(Crystal **crystals, int n, int n_threads,
RefList *full = NULL;
double *old_osfs;
double *old_Bs;
+ int *old_flags;
int done;
for ( i=0; i<n; i++ ) {
@@ -476,7 +491,10 @@ RefList *scale_intensities(Crystal **crystals, int n, int n_threads,
old_osfs = malloc(n*sizeof(double));
old_Bs = malloc(n*sizeof(double));
- if ( (old_osfs == NULL) || (old_Bs == NULL) ) return NULL;
+ old_flags = malloc(n*sizeof(int));
+ if ( (old_osfs == NULL) || (old_Bs == NULL) || (old_flags == NULL) ) {
+ return NULL;
+ }
/* Iterate */
i = 0;
@@ -490,6 +508,7 @@ RefList *scale_intensities(Crystal **crystals, int n, int n_threads,
for ( j=0; j<n; j++ ) {
old_osfs[j] = crystal_get_osf(crystals[j]);
old_Bs[j] = crystal_get_Bfac(crystals[j]);
+ old_flags[j] = crystal_get_user_flag(crystals[j]);
reset_scaling_flag(crystals[j]);
}
@@ -510,7 +529,8 @@ RefList *scale_intensities(Crystal **crystals, int n, int n_threads,
crystal_get_osf(crystals[j])/norm_sf);
}
- done = test_convergence(old_osfs, old_Bs, n, crystals);
+ done = test_convergence(old_osfs, old_Bs, old_flags,
+ n, crystals);
/* Generate list for next iteration */
reflist_free(full);
@@ -526,5 +546,6 @@ RefList *scale_intensities(Crystal **crystals, int n, int n_threads,
free(old_osfs);
free(old_Bs);
+ free(old_flags);
return full;
}