From b7620b55472dd5646547cb221cbd80d5e2349351 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 26 Aug 2010 18:25:44 +0200 Subject: process_hkl: Generate intensity histograms --- src/process_hkl.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 97 insertions(+), 7 deletions(-) (limited to 'src/process_hkl.c') diff --git a/src/process_hkl.c b/src/process_hkl.c index ec23e1cd..05c71985 100644 --- a/src/process_hkl.c +++ b/src/process_hkl.c @@ -29,8 +29,8 @@ #include "symmetry.h" -/* Number of divisions for R vs |q| graphs */ -#define RVQDV (20) +/* Number of divisions for intensity histograms */ +#define NBINS (200) static void show_help(const char *s) @@ -56,6 +56,8 @@ static void show_help(const char *s) " --stop-after= Stop after processing n patterns. Zero means\n" " keep going until the end of the input, and is\n" " the default.\n" +" -g, --histogram= Calculate the histogram of measurements for this\n" +" reflection.\n" "\n" " --scale Scale each pattern for best fit with the current\n" " model.\n" @@ -64,6 +66,47 @@ static void show_help(const char *s) } +static void plot_histogram(double *vals, int n) +{ + int i; + double max = -INFINITY; + double min = +INFINITY; + double step; + int histo[NBINS]; + FILE *fh; + + fh = fopen("histogram.dat", "w"); + if ( fh == NULL ) { + ERROR("Couldn't open 'histogram.dat'\n"); + return; + } + + for ( i=0; i max ) max = vals[i]; + if ( vals[i] < min ) min = vals[i]; + } + STATUS("%f %f\n", min, max); + + for ( i=0; i ", hist_h, hist_k, hist_l); + /* Put into the asymmetric cell for the target group */ + get_asymm(hist_h, hist_k, hist_l, + &hist_h, &hist_k, &hist_l, sym); + STATUS("%i %i %i\n", hist_h, hist_k, hist_l); + } + /* Open the data stream */ if ( strcmp(filename, "-") == 0 ) { fh = stdin; @@ -492,13 +574,21 @@ int main(int argc, char *argv[]) STATUS("There are %i patterns to process\n", n_total_patterns); rewind(fh); + hist_i = 0; merge_all(fh, &model, &observed, &counts, config_maxonly, config_scale, config_sum, config_stopafter, - twins, holo, sym, n_total_patterns); + twins, holo, sym, n_total_patterns, + hist_vals, hist_h, hist_k, hist_l, &hist_i); rewind(fh); fclose(fh); + if ( hist_vals != NULL ) { + STATUS("%i %i %i was seen %i times.\n", hist_h, hist_k, hist_l, + hist_i); + plot_histogram(hist_vals, hist_i); + } + if ( output != NULL ) { write_reflections(output, observed, model, NULL, counts, cell); } -- cgit v1.2.3