diff options
-rw-r--r-- | src/hrs-scaling.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/hrs-scaling.c b/src/hrs-scaling.c index fb0a813e..1c46effe 100644 --- a/src/hrs-scaling.c +++ b/src/hrs-scaling.c @@ -52,8 +52,7 @@ static double iterate_scale(struct image *images, int n, RefList *reference) RefListIterator *iter; double num = 0.0; double den = 0.0; - double new_sf; - double corr = 0.0; + double corr; if ( image->pr_dud ) continue; @@ -62,7 +61,7 @@ static double iterate_scale(struct image *images, int n, RefList *reference) refl = next_refl(refl, iter) ) { signed int h, k, l; - double Ih, Ihl; + double Ih, Ihl, esd; Reflection *r; if ( !get_scalable(refl) ) continue; @@ -81,18 +80,21 @@ static double iterate_scale(struct image *images, int n, RefList *reference) } Ihl = get_intensity(refl) / get_partiality(refl); + esd = get_esd_intensity(refl) / get_partiality(refl); - num += Ih * Ihl; - den += Ih * Ih; + num += Ih * (Ihl/image->osf) / pow(esd/image->osf, 2.0); + den += pow(Ih, 2.0)/pow(esd/image->osf, 2.0); } - new_sf = num / den; - if ( !isnan(new_sf) && !isinf(new_sf) ) { - corr = fabs(image->osf - new_sf); - image->osf = new_sf; + //num += image->osf / pow(SCALING_RESTRAINT, 2.0); + //den += pow(image->osf, 2.0)/pow(SCALING_RESTRAINT, 2.0); + + corr = num / den; + if ( !isnan(corr) && !isinf(corr) ) { + image->osf *= corr; } - if ( corr > max_shift ) max_shift = corr; + if ( fabs(corr-1.0) > max_shift ) max_shift = fabs(corr-1.0); } |