aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2011-10-07 16:31:42 +0200
committerThomas White <taw@physics.org>2012-02-22 15:27:39 +0100
commit055fc06b42b9917ddf466b90cfd61f1df3f337b1 (patch)
tree432399506a15e5f4752703adb7051d6e4a0213b8
parent3c21788dc0f08f42ab65c740f62b8cfc74ca7fe3 (diff)
Add weighting scheme
-rw-r--r--src/post-refinement.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/post-refinement.c b/src/post-refinement.c
index 5a6ba4dc..81ca8c61 100644
--- a/src/post-refinement.c
+++ b/src/post-refinement.c
@@ -351,6 +351,7 @@ static double pr_iterate(struct image *image, const RefList *full)
{
signed int ha, ka, la;
double I_full, delta_I;
+ double w;
double I_partial;
int k;
double p;
@@ -373,6 +374,11 @@ static double pr_iterate(struct image *image, const RefList *full)
I_partial = get_intensity(refl);
p = get_partiality(refl);
+ /* Calculate the weight for this reflection */
+ w = pow(get_esd_intensity(refl), 2.0);
+ w += p * I_full * pow(get_esd_intensity(match), 2.0);
+ w = pow(w, -1.0);
+
/* Calculate all gradients for this reflection */
for ( k=0; k<NUM_PARAMS; k++ ) {
double gr;
@@ -393,7 +399,7 @@ static double pr_iterate(struct image *image, const RefList *full)
if ( g > k ) continue;
M_c = gradients[g] * gradients[k];
- M_c *= pow(image->osf * I_full, 2.0);
+ M_c *= w * pow(image->osf * I_full, 2.0);
M_curr = gsl_matrix_get(M, k, g);
gsl_matrix_set(M, k, g, M_curr + M_c);
@@ -402,7 +408,7 @@ static double pr_iterate(struct image *image, const RefList *full)
}
delta_I = I_partial - (p * I_full);
- v_c = delta_I * I_full * gradients[k];
+ v_c = w * delta_I * I_full * gradients[k];
v_curr = gsl_vector_get(v, k);
gsl_vector_set(v, k, v_curr + v_c);