From 872fe94e12f7d8dca3abfa60559919fadbe60181 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 30 Jul 2013 11:46:38 +0200 Subject: Revert refinement step if too many reflections are lost --- libcrystfel/src/geometry.c | 48 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 14 deletions(-) (limited to 'libcrystfel/src/geometry.c') diff --git a/libcrystfel/src/geometry.c b/libcrystfel/src/geometry.c index 744c13ea..c6ae1f63 100644 --- a/libcrystfel/src/geometry.c +++ b/libcrystfel/src/geometry.c @@ -380,7 +380,8 @@ static void set_unity_partialities(Crystal *cryst) /* Calculate partialities and apply them to the image's reflections */ -void update_partialities(Crystal *cryst, PartialityModel pmodel) +void update_partialities_2(Crystal *cryst, PartialityModel pmodel, + int *n_gained, int *n_lost) { Reflection *refl; RefListIterator *iter; @@ -420,26 +421,45 @@ void update_partialities(Crystal *cryst, PartialityModel pmodel) vals = check_reflection(image, cryst, h, k, l, xl, yl, zl); if ( vals == NULL ) { - set_redundancy(refl, 0); - continue; - } - set_redundancy(refl, 1); - /* Transfer partiality stuff */ - get_partial(vals, &r1, &r2, &p, &clamp1, &clamp2); - set_partial(refl, r1, r2, p, clamp1, clamp2); - L = get_lorentz(vals); - set_lorentz(refl, L); + if ( get_redundancy(refl) != 0 ) { + (*n_lost)++; + set_redundancy(refl, 0); + } + + } else { + + if ( get_redundancy(refl) == 0 ) { + (*n_gained)++; + set_redundancy(refl, 1); + } - /* Transfer detector location */ - get_detector_pos(vals, &x, &y); - set_detector_pos(refl, 0.0, x, y); + /* Transfer partiality stuff */ + get_partial(vals, &r1, &r2, &p, &clamp1, &clamp2); + set_partial(refl, r1, r2, p, clamp1, clamp2); + L = get_lorentz(vals); + set_lorentz(refl, L); + + /* Transfer detector location */ + get_detector_pos(vals, &x, &y); + set_detector_pos(refl, 0.0, x, y); + + reflection_free(vals); + + } - reflection_free(vals); } } +void update_partialities(Crystal *cryst, PartialityModel pmodel) +{ + int n_gained = 0; + int n_lost = 0; + update_partialities_2(cryst, pmodel, &n_gained, &n_lost); +} + + void polarisation_correction(RefList *list, UnitCell *cell, struct image *image) { Reflection *refl; -- cgit v1.2.3