aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2013-07-30 11:46:38 +0200
committerThomas White <taw@physics.org>2013-07-31 17:09:35 +0200
commit872fe94e12f7d8dca3abfa60559919fadbe60181 (patch)
treef2987544a20f0e8256ae934ef666127a80e1bbad /libcrystfel/src
parenta8b646119996c297fbdb7e044c776d7bf4fef21a (diff)
Revert refinement step if too many reflections are lost
Diffstat (limited to 'libcrystfel/src')
-rw-r--r--libcrystfel/src/geometry.c48
-rw-r--r--libcrystfel/src/geometry.h2
2 files changed, 36 insertions, 14 deletions
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;
diff --git a/libcrystfel/src/geometry.h b/libcrystfel/src/geometry.h
index a6708b2d..bceb97e0 100644
--- a/libcrystfel/src/geometry.h
+++ b/libcrystfel/src/geometry.h
@@ -63,6 +63,8 @@ extern RefList *find_intersections(struct image *image, Crystal *cryst);
extern RefList *select_intersections(struct image *image, Crystal *cryst);
extern void update_partialities(Crystal *cryst, PartialityModel pmodel);
+extern void update_partialities_2(Crystal *cryst, PartialityModel pmodel,
+ int *n_gained, int *n_lost);
extern void polarisation_correction(RefList *list, UnitCell *cell,
struct image *image);