From 2e101d99268b467c1ab900121c4fba3bbab6f4b1 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 5 Jun 2019 11:15:18 +0200 Subject: Allow correct_reflection() to correct anything, not just intensities --- src/merge.c | 25 +++++++++++++------------ src/merge.h | 8 ++++---- src/partialator.c | 2 +- src/post-refinement.c | 2 +- src/rejection.c | 4 ++-- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/merge.c b/src/merge.c index 1ca3ccda..a2a49ccf 100644 --- a/src/merge.c +++ b/src/merge.c @@ -223,9 +223,9 @@ static void run_merge_job(void *vwargs, int cookie) /* Running mean and variance calculation */ temp = w + sumweight; if ( ln_merge ) { - delta = log(correct_reflection(refl, G, B, res)) - mean; + delta = log(correct_reflection(get_intensity(refl), refl, G, B, res)) - mean; } else { - delta = correct_reflection(refl, G, B, res) - mean; + delta = correct_reflection(get_intensity(refl), refl, G, B, res) - mean; } R = delta * w / temp; set_intensity(f, mean + R); @@ -343,21 +343,22 @@ RefList *merge_intensities(Crystal **crystals, int n, int n_threads, } -/* Correct intensity in pattern for scaling and Lorentz factors, - * but not partiality nor polarisation */ -double correct_reflection_nopart(Reflection *refl, double osf, double Bfac, - double res) +/* Correct 'val' (probably an intensity from one pattern, maybe an e.s.d.) + * for scaling and Lorentz factors but not partiality nor polarisation */ +double correct_reflection_nopart(double val, Reflection *refl, double osf, + double Bfac, double res) { double corr = osf * exp(-Bfac*res*res); - return (get_intensity(refl) / corr) / get_lorentz(refl); + return (val / corr) / get_lorentz(refl); } -/* Correct intensity in pattern for scaling, partiality and Lorentz factors, - * but not polarisation */ -double correct_reflection(Reflection *refl, double osf, double Bfac, double res) +/* Correct 'val' (probably an intensity from one pattern, maybe an e.s.d.) + * for scaling, partiality and Lorentz factors but not polarisation */ +double correct_reflection(double val, Reflection *refl, double osf, double Bfac, + double res) { - double Ipart = correct_reflection_nopart(refl, osf, Bfac, res); + double Ipart = correct_reflection_nopart(val, refl, osf, Bfac, res); return Ipart / get_partiality(refl); } @@ -394,7 +395,7 @@ double residual(Crystal *cr, const RefList *full, int free, if ( get_redundancy(match) < 2 ) continue; - int1 = correct_reflection_nopart(refl, G, B, res); + int1 = correct_reflection_nopart(get_intensity(refl), refl, G, B, res); int2 = get_partiality(refl)*I_full; w = 1.0; diff --git a/src/merge.h b/src/merge.h index 2c2cfeda..4edef109 100644 --- a/src/merge.h +++ b/src/merge.h @@ -47,11 +47,11 @@ extern RefList *merge_intensities(Crystal **crystals, int n, int n_threads, int min_meas, double push_res, int use_weak, int ln_merge); -extern double correct_reflection_nopart(Reflection *refl, double osf, - double Bfac, double res); +extern double correct_reflection_nopart(double val, Reflection *refl, + double osf, double Bfac, double res); -extern double correct_reflection(Reflection *refl, double osf, double Bfac, - double res); +extern double correct_reflection(double val, Reflection *refl, double osf, + double Bfac, double res); extern double residual(Crystal *cr, const RefList *full, int free, int *pn_used, const char *filename); diff --git a/src/partialator.c b/src/partialator.c index 82580e4c..082b9fec 100644 --- a/src/partialator.c +++ b/src/partialator.c @@ -661,7 +661,7 @@ static void write_to_pgraph(FILE *fh, RefList *list, RefList *full, Crystal *cr, pcalc = get_partiality(refl); /* Observed partiality */ - Ipart = correct_reflection_nopart(refl, G, B, res); + Ipart = correct_reflection_nopart(get_intensity(refl), refl, G, B, res); pobs = Ipart / get_intensity(match); fprintf(fh, "%5i %4i %4i %4i %e %e %8.3f %8.3f %s\n", diff --git a/src/post-refinement.c b/src/post-refinement.c index 27c73570..bcef016c 100644 --- a/src/post-refinement.c +++ b/src/post-refinement.c @@ -570,7 +570,7 @@ void write_specgraph(Crystal *crystal, const RefList *full, /* Don't calculate pobs if reference reflection is weak */ if ( fabs(get_intensity(match)) / get_esd_intensity(match) < 3.0 ) continue; - Ipart = correct_reflection_nopart(refl, G, B, res); + Ipart = correct_reflection_nopart(get_intensity(refl), refl, G, B, res); Ifull = get_intensity(match); pobs = Ipart / Ifull; pcalc = get_partiality(refl); diff --git a/src/rejection.c b/src/rejection.c index 99ed767e..8d6c30bb 100644 --- a/src/rejection.c +++ b/src/rejection.c @@ -143,7 +143,7 @@ static int calculate_refl_mean_var(RefList *full) G = crystal_get_osf(c->contrib_crystals[j]); B = crystal_get_Bfac(c->contrib_crystals[j]); - Ii = correct_reflection(c->contribs[j], G, B, res); + Ii = correct_reflection(get_intensity(c->contribs[j]), c->contribs[j], G, B, res); Ex += Ii - K; Ex2 += (Ii - K) * (Ii - K); @@ -234,7 +234,7 @@ static double calculate_cchalf(RefList *template, RefList *full, if ( get_partiality(exrefl) > MIN_PART_MERGE ) { - double Ii = correct_reflection(exrefl, G, B, res); + double Ii = correct_reflection(get_intensity(exrefl), exrefl, G, B, res); /* Remove contribution of this reflection */ Ex -= Ii - K; -- cgit v1.2.3