From aab9901f18326214746402650179a13f22770118 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 11 Feb 2011 12:37:03 -0800 Subject: Make find_projected_peaks() behave like find_intersections() Also make sure output_intensities() deals only with integration --- src/calibrate_detector.c | 1 - src/cubeit.c | 1 - src/image.h | 5 ++++- src/indexamajig.c | 21 ++++++++++++++------- src/pattern_sim.c | 15 +++++++++++---- src/peaks.c | 21 +++++++-------------- src/peaks.h | 10 ++++++---- src/reintegrate.c | 16 ++++++++++++---- 8 files changed, 54 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/calibrate_detector.c b/src/calibrate_detector.c index 9aeae803..417ee36e 100644 --- a/src/calibrate_detector.c +++ b/src/calibrate_detector.c @@ -168,7 +168,6 @@ static void add_image(void *args, int cookie) image.flags = NULL; image.indexed_cell = NULL; image.filename = pargs->filename; - image.reflections = NULL; image.det = NULL; STATUS("%3i: Processing '%s'\n", cookie, pargs->filename); diff --git a/src/cubeit.c b/src/cubeit.c index 30deb724..d5a0a539 100644 --- a/src/cubeit.c +++ b/src/cubeit.c @@ -218,7 +218,6 @@ static void sum_image(void *pg, int cookie) image.flags = NULL; image.indexed_cell = NULL; image.filename = apargs->filename; - image.reflections = NULL; image.det = pargs->det; STATUS("Processing '%s'\n", apargs->filename); diff --git a/src/image.h b/src/image.h index ce0e7343..e0c190f2 100644 --- a/src/image.h +++ b/src/image.h @@ -65,7 +65,6 @@ struct image { struct detector *det; struct beam_params *beam; /* The nominal beam parameters */ char *filename; - RefList *reflections; int id; /* ID number of the thread * handling this image */ @@ -86,6 +85,10 @@ struct image { int width; int height; + /* Reflections (used for scaling ONLY) */ + RefList *reflections; + + /* Detected peaks */ ImageFeatureList *features; }; diff --git a/src/indexamajig.c b/src/indexamajig.c index 40d7cbd8..b3008232 100644 --- a/src/indexamajig.c +++ b/src/indexamajig.c @@ -38,6 +38,7 @@ #include "thread-pool.h" #include "beam-parameters.h" #include "symmetry.h" +#include "geometry.h" enum { @@ -262,9 +263,6 @@ static struct image *get_simage(struct image *template, int alternate) image->indexed_cell = template->indexed_cell; image->f0 = template->f0; - /* Prevent muppetry */ - image->reflections = NULL; - return image; } @@ -325,7 +323,6 @@ static void process_image(void *pp, int cookie) image.indexed_cell = NULL; image.id = cookie; image.filename = filename; - image.reflections = NULL; image.det = pargs->static_args.det; STATUS("Processing '%s'\n", image.filename); @@ -397,11 +394,22 @@ static void process_image(void *pp, int cookie) /* Measure intensities if requested */ if ( config_nearbragg ) { - output_intensities(&image, image.indexed_cell, + + RefList *reflections; + + //reflections = find_intersections(&image, image.indexed_cell, + // 0); + reflections = find_projected_peaks(&image, image.indexed_cell, + 0, 0.1); + + output_intensities(&image, image.indexed_cell, reflections, pargs->static_args.output_mutex, config_polar, pargs->static_args.config_closer, - pargs->static_args.ofh, 0, 0.1); + pargs->static_args.ofh); + + reflist_free(reflections); + } simage = get_simage(&image, config_alternate); @@ -432,7 +440,6 @@ done: free(image.data); free(image.flags); image_feature_list_free(image.features); - reflist_free(image.reflections); hdfile_close(hdfile); } diff --git a/src/pattern_sim.c b/src/pattern_sim.c index 90425328..326ce362 100644 --- a/src/pattern_sim.c +++ b/src/pattern_sim.c @@ -564,10 +564,17 @@ int main(int argc, char *argv[]) record_image(&image, !config_nonoise); if ( config_nearbragg ) { - find_projected_peaks(&image, cell, 0, 0.1); - output_intensities(&image, cell, NULL, 0, 0, stdout, - 0, 0.1); - reflist_free(image.reflections); + + RefList *reflections; + + reflections = find_projected_peaks(&image, cell, + 0, 0.1); + + output_intensities(&image, cell, reflections, NULL, + 0, 0, stdout); + + reflist_free(reflections); + } if ( powder_fn != NULL ) { diff --git a/src/peaks.c b/src/peaks.c index fa0d2843..c9dbe8e0 100644 --- a/src/peaks.c +++ b/src/peaks.c @@ -473,8 +473,8 @@ void dump_peaks(struct image *image, FILE *ofh, pthread_mutex_t *mutex) } -int find_projected_peaks(struct image *image, UnitCell *cell, - int circular_domain, double domain_r) +RefList *find_projected_peaks(struct image *image, UnitCell *cell, + int circular_domain, double domain_r) { int x, y; double ax, ay, az; @@ -550,9 +550,7 @@ int find_projected_peaks(struct image *image, UnitCell *cell, optimise_reflist(reflections); STATUS("Found %i reflections\n", n_reflections); - image->reflections = reflections; - - return n_reflections; + return reflections; } @@ -664,9 +662,8 @@ static void output_header(FILE *ofh, UnitCell *cell, struct image *image) void output_intensities(struct image *image, UnitCell *cell, - pthread_mutex_t *mutex, int polar, - int use_closer, FILE *ofh, - int circular_domain, double domain_r) + RefList *reflections, pthread_mutex_t *mutex, int polar, + int use_closer, FILE *ofh) { double asx, asy, asz; double bsx, bsy, bsz; @@ -674,10 +671,6 @@ void output_intensities(struct image *image, UnitCell *cell, Reflection *refl; RefListIterator *iter; - if ( image->reflections == NULL ) { - find_projected_peaks(image, cell, circular_domain, domain_r); - } - /* Get exclusive access to the output stream if necessary */ if ( mutex != NULL ) pthread_mutex_lock(mutex); @@ -687,7 +680,7 @@ void output_intensities(struct image *image, UnitCell *cell, &bsx, &bsy, &bsz, &csx, &csy, &csz); - for ( refl = first_refl(image->reflections, &iter); + for ( refl = first_refl(reflections, &iter); refl != NULL; refl = next_refl(refl, iter) ) { @@ -768,7 +761,7 @@ void output_intensities(struct image *image, UnitCell *cell, /* Write h,k,l, integrated intensity and centroid coordinates */ get_indices(refl, &h, &k, &l); fprintf(ofh, "%3i %3i %3i %6f (at %5.2f,%5.2f) max=%6f bg=%6f\n", - h, l, l, intensity, x, y, max, bg); + h, k, l, intensity, x, y, max, bg); } diff --git a/src/peaks.h b/src/peaks.h index 8b506e42..2801153d 100644 --- a/src/peaks.h +++ b/src/peaks.h @@ -19,14 +19,16 @@ #include +#include "reflist.h" + extern void search_peaks(struct image *image, float threshold, float min_gradient); extern void dump_peaks(struct image *image, FILE *ofh, pthread_mutex_t *mutex); extern void output_intensities(struct image *image, UnitCell *cell, + RefList *reflections, pthread_mutex_t *mutex, int polar, - int use_closer, FILE *ofh, int circular_domain, - double domain_r); + int use_closer, FILE *ofh); extern void output_pixels(struct image *image, UnitCell *cell, pthread_mutex_t *mutex, int do_polar, @@ -34,8 +36,8 @@ extern void output_pixels(struct image *image, UnitCell *cell, extern int peak_sanity_check(struct image *image, UnitCell *cell, int circular_domain, double domain_r); -extern int find_projected_peaks(struct image *image, UnitCell *cell, - int circular_domain, double domain_r); +extern RefList *find_projected_peaks(struct image *image, UnitCell *cell, + int circular_domain, double domain_r); extern int integrate_peak(struct image *image, int xp, int yp, float *xc, float *yc, float *intensity, double *pbg, double *pmax, diff --git a/src/reintegrate.c b/src/reintegrate.c index a3ee85c9..8450eaab 100644 --- a/src/reintegrate.c +++ b/src/reintegrate.c @@ -110,7 +110,6 @@ static void process_image(void *pg, int cookie) image.flags = NULL; image.indexed_cell = NULL; image.filename = apargs->filename; - image.reflections = NULL; image.det = pargs->det; STATUS("Processing '%s'\n", apargs->filename); @@ -137,9 +136,18 @@ static void process_image(void *pg, int cookie) } else { - output_intensities(&image, apargs->cell, - pargs->output_mutex, pargs->config_polar, - pargs->config_closer, pargs->ofh, 0, 0.1); + RefList *reflections; + + reflections = find_projected_peaks(&image, image.indexed_cell, + 0, 0.1); + + output_intensities(&image, image.indexed_cell, reflections, + pargs->output_mutex, + pargs->config_polar, + pargs->config_closer, + pargs->ofh); + + reflist_free(reflections); } free(image.data); -- cgit v1.2.3