diff options
author | Thomas White <taw@physics.org> | 2011-04-26 12:07:10 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:27:24 +0100 |
commit | 136d9cc93b4012bdb1283f8cf283931786811948 (patch) | |
tree | 707cb1a5b477322b7a89573ff2821845e2f0d8be /src/geometry.c | |
parent | e0f621b0fa2094283f9a28155e5fbc75c74bd82c (diff) |
Work on post refinement
Diffstat (limited to 'src/geometry.c')
-rw-r--r-- | src/geometry.c | 73 |
1 files changed, 70 insertions, 3 deletions
diff --git a/src/geometry.c b/src/geometry.c index 749c194e..3ff39f31 100644 --- a/src/geometry.c +++ b/src/geometry.c @@ -23,9 +23,7 @@ #include "peaks.h" #include "beam-parameters.h" #include "reflist.h" - - -#define MAX_CPEAKS (256 * 256) +#include "reflist-utils.h" static signed int locate_peak(double x, double y, double z, double k, @@ -292,3 +290,72 @@ double integrate_all(struct image *image, RefList *reflections) return itot; } + + +/* Calculate partialities and apply them to the image's raw_reflections */ +void update_partialities(struct image *image, const char *sym, + int *n_expected, int *n_found, int *n_notfound) +{ + Reflection *refl; + RefListIterator *iter; + RefList *predicted; + + predicted = find_intersections(image, image->indexed_cell, 0); + + for ( refl = first_refl(predicted, &iter); + refl != NULL; + refl = next_refl(refl, iter) ) + { + + Reflection *peak_in_pattern; + double r1, r2, p, x, y; + signed int h, k, l; + int clamp1, clamp2, scalable; + + /* Get predicted indices and location */ + get_indices(refl, &h, &k, &l); + get_detector_pos(refl, &x, &y); + if ( n_expected != NULL ) (*n_expected)++; + + /* Look for this reflection in the pattern */ + peak_in_pattern = find_refl(image->raw_reflections, h, k, l); + if ( peak_in_pattern == NULL ) { + if ( n_notfound != NULL ) (*n_notfound)++; + continue; + } + if ( n_found != NULL ) (*n_found)++; + + /* Transfer partiality stuff */ + get_partial(refl, &r1, &r2, &p, &clamp1, &clamp2); + set_partial(peak_in_pattern, r1, r2, p, clamp1, clamp2); + + /* Transfer detector location */ + get_detector_pos(refl, &x, &y); + set_detector_pos(peak_in_pattern, 0.0, x, y); + + } + + reflist_free(predicted); +} + + +void update_partialities_and_asymm(struct image *image, const char *sym, + ReflItemList *obs, + int *n_expected, int *n_found, + int *n_notfound) +{ + /* Get rid of the old list, about to be replaced */ + reflist_free(image->reflections); + image->reflections = NULL; + + /* Fill in partialities */ + update_partialities(image, sym, n_expected, n_found, n_notfound); + + /* Rewrite the reflections with the asymmetric indices + * to get the list used for scaling and post refinement */ + image->reflections = asymmetric_indices(image->raw_reflections, + sym, obs); + + /* Need these lists to work fast */ + optimise_reflist(image->reflections); +} |