From a8b646119996c297fbdb7e044c776d7bf4fef21a Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 29 Jul 2013 14:10:52 +0200 Subject: partialator: New convergence criterion for scaling Instead of stopping iteration when the absolute value of any scaling factor changes by more than a certain (small) amount, calculate the ratios of the scaling factors to their previous values, and stop when no scaling factor changes by more than 1% compared to the mean ratio. This method is robust against "drifting" of the scale factors when the partiality estimates are poor. --- src/hrs-scaling.c | 52 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/hrs-scaling.c b/src/hrs-scaling.c index 47c4301e..8f0cd8f5 100644 --- a/src/hrs-scaling.c +++ b/src/hrs-scaling.c @@ -486,6 +486,32 @@ static void calculate_esds(Crystal **crystals, int n, RefList *full, } +static double max_outlier_change(Crystal **crystals, int n, double *old_osfs) +{ + double rdtot = 0.0; + double rdmax = 0.0; + double rdmean; + int j; + + for ( j=0; j rdmax ) { + rdmax = fabs(r-rdmean); + } + } + + return rdmax; +} + + /* Scale the stack of images */ RefList *scale_intensities(Crystal **crystals, int n, RefList *gref, int n_threads, int noscale, PartialityModel pmodel, @@ -494,6 +520,11 @@ RefList *scale_intensities(Crystal **crystals, int n, RefList *gref, int i; double max_corr; RefList *full = NULL; + double *old_osfs; + double rdval; + + old_osfs = malloc(n*sizeof(double)); + if ( old_osfs == NULL ) return NULL; for ( i=0; i generate list for next iteration */ if ( gref == NULL ) { @@ -540,7 +575,7 @@ RefList *scale_intensities(Crystal **crystals, int n, RefList *gref, i++; - } while ( (max_corr > 0.01) && (i < MAX_CYCLES) ); + } while ( (rdval > 0.01) && (i < MAX_CYCLES) ); if ( i == MAX_CYCLES ) { ERROR("Warning: Scaling did not converge.\n"); @@ -552,5 +587,6 @@ RefList *scale_intensities(Crystal **crystals, int n, RefList *gref, calculate_esds(crystals, n, full, n_threads, min_redundancy, pmodel); + free(old_osfs); return full; } -- cgit v1.2.3