From 45cbdb156b10f560d7d254348162e8dbd144be19 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 24 May 2013 15:26:15 +0200 Subject: Code organisation --- libcrystfel/src/integration.c | 117 +++++++++++++++++++++--------------------- 1 file changed, 58 insertions(+), 59 deletions(-) (limited to 'libcrystfel/src') diff --git a/libcrystfel/src/integration.c b/libcrystfel/src/integration.c index c7372bc7..bb7ec746 100644 --- a/libcrystfel/src/integration.c +++ b/libcrystfel/src/integration.c @@ -48,65 +48,6 @@ #include "integration.h" -struct integr_ind -{ - double res; - Reflection *refl; -}; - - -static int compare_resolution(const void *av, const void *bv) -{ - const struct integr_ind *a = av; - const struct integr_ind *b = bv; - - return a->res > b->res; -} - - -static struct integr_ind *sort_reflections(RefList *list, UnitCell *cell, - int *np) -{ - struct integr_ind *il; - Reflection *refl; - RefListIterator *iter; - int i, n; - - n = num_reflections(list); - *np = 0; /* For now */ - - if ( n == 0 ) return NULL; - - il = calloc(n, sizeof(struct integr_ind)); - if ( il == NULL ) return NULL; - - i = 0; - for ( refl = first_refl(list, &iter); - refl != NULL; - refl = next_refl(refl, iter) ) - { - signed int h, k, l; - double res; - - if ( get_redundancy(refl) == 0 ) continue; - - get_indices(refl, &h, &k, &l); - res = resolution(cell, h, k, l); - - il[i].res = res; - il[i].refl = refl; - - i++; - assert(i <= n); - } - - qsort(il, n, sizeof(struct integr_ind), compare_resolution); - - *np = n; - return il; -} - - static void check_eigen(gsl_vector *e_val) { int i; @@ -908,6 +849,64 @@ static void estimate_mosaicity(Crystal *cr, struct image *image) } +struct integr_ind +{ + double res; + Reflection *refl; +}; + + +static int compare_resolution(const void *av, const void *bv) +{ + const struct integr_ind *a = av; + const struct integr_ind *b = bv; + + return a->res > b->res; +} + + +static struct integr_ind *sort_reflections(RefList *list, UnitCell *cell, + int *np) +{ + struct integr_ind *il; + Reflection *refl; + RefListIterator *iter; + int i, n; + + *np = 0; /* For now */ + + n = num_reflections(list); + if ( n == 0 ) return NULL; + + il = calloc(n, sizeof(struct integr_ind)); + if ( il == NULL ) return NULL; + + i = 0; + for ( refl = first_refl(list, &iter); + refl != NULL; + refl = next_refl(refl, iter) ) + { + signed int h, k, l; + double res; + + if ( get_redundancy(refl) == 0 ) continue; + + get_indices(refl, &h, &k, &l); + res = resolution(cell, h, k, l); + + il[i].res = res; + il[i].refl = refl; + + i++; + } + + qsort(il, i, sizeof(struct integr_ind), compare_resolution); + + *np = i; + return il; +} + + static void estimate_resolution(RefList *reflections, Crystal *cr, struct image *image) { -- cgit v1.2.3