diff options
author | Thomas White <taw@physics.org> | 2011-07-01 12:14:43 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:27:31 +0100 |
commit | 07ce52b6bf630a915b81cf9b801550c4872cd4b3 (patch) | |
tree | 71e2cf7537e614b7cab687a934ba46d14a09a15f | |
parent | 0c8dcb1afd7a88ecfa0da40375ec345e12c92646 (diff) |
Add "-e" options to power_plot and sum_stack
-rw-r--r-- | src/powder_plot.c | 63 | ||||
-rw-r--r-- | src/sum_stack.c | 37 |
2 files changed, 86 insertions, 14 deletions
diff --git a/src/powder_plot.c b/src/powder_plot.c index b75115b2..7d12f31b 100644 --- a/src/powder_plot.c +++ b/src/powder_plot.c @@ -597,7 +597,8 @@ static unsigned int process_stream_h5(FILE *fh, struct image *image, struct histogram_info *info, struct bin_stats *histdata, int config_satcorr, int only_indexed, - unsigned int *n_patterns) + unsigned int *n_patterns, + const char *element) { int fs, ss, rval; double intensity; @@ -614,11 +615,29 @@ static unsigned int process_stream_h5(FILE *fh, struct image *image, /* Get data from next chunk */ rval = read_chunk(fh, image); if ( rval ) continue; - if ((only_indexed == 0) || - ((only_indexed == 1) && - ((*image).reflections != NULL))) { - hdfile = hdfile_open((*image).filename); - hdfile_set_image(hdfile, "/data/data"); + if ( !only_indexed || + ( only_indexed && (image->reflections != NULL) ) ) + { + hdfile = hdfile_open(image->filename); + if ( element != NULL ) { + int r; + r = hdfile_set_image(hdfile, element); + if ( r ) { + ERROR("Couldn't select path '%s'\n", + element); + hdfile_close(hdfile); + return 0; + } + } else { + int r; + r = hdfile_set_first_image(hdfile, "/"); + if ( r ) { + ERROR("Couldn't select first path\n"); + hdfile_close(hdfile); + return 0; + } + + } hdf5_read(hdfile, image, config_satcorr); hdfile_close(hdfile); n_patterns++; @@ -699,6 +718,10 @@ static void show_help(const char *s) " of measurements and not the number of symetrical\n" " equivelent reflections as the number of time a\n" " reflection occurs in the powder\n" +" -e, --image=<element> Use this image when reading an HDF5 file.\n" +" Example: /data/data0.\n" +" Default: The first one found.\n" + "\n"); } @@ -720,6 +743,7 @@ int main(int argc, char *argv[]) image.lambda = -1.0; image.beam = NULL; image.det = NULL; + char *element = NULL; unsigned int n_patterns = 0; unsigned int n_peaks = 0; @@ -763,6 +787,7 @@ int main(int argc, char *argv[]) {"ring-corr", 0, &ring_corr, 1 }, {"use-redundancy", 0, &use_redundancy, 1 }, {"data", 1, NULL, 'd'}, + {"image", 1, NULL, 'e'}, {0, 0, NULL, 0} }; @@ -805,6 +830,10 @@ int main(int argc, char *argv[]) hist_info.histsize = atoi(optarg); break; + case 'e' : + element = strdup(optarg); + break; + case 1 : hist_info.q_max = atof(optarg); break; @@ -864,7 +893,25 @@ int main(int argc, char *argv[]) file_type = FILE_H5; need_geometry = 1; hdfile = hdfile_open(filename); - hdfile_set_image(hdfile, "/data/data"); + if ( element != NULL ) { + int r; + r = hdfile_set_image(hdfile, element); + if ( r ) { + ERROR("Couldn't select path '%s'\n", + element); + hdfile_close(hdfile); + return 0; + } + } else { + int r; + r = hdfile_set_first_image(hdfile, "/"); + if ( r ) { + ERROR("Couldn't select first path\n"); + hdfile_close(hdfile); + return 0; + } + + } hdf5_read(hdfile, &image, config_satcorr); hdfile_close(hdfile); @@ -1066,7 +1113,7 @@ int main(int argc, char *argv[]) case PLOT_H5 : n_peaks = process_stream_h5(fh, &image, &hist_info, histdata, config_satcorr, only_indexed, - &n_patterns); + &n_patterns, element); break; default : break; diff --git a/src/sum_stack.c b/src/sum_stack.c index 8d00a87f..2e5b138e 100644 --- a/src/sum_stack.c +++ b/src/sum_stack.c @@ -49,6 +49,7 @@ struct sum_args SumMethod sum_method; double threshold; double min_gradient; + char *element; }; @@ -63,6 +64,7 @@ struct queue_args SumMethod sum_method; double threshold; double min_gradient; + char *element; char *use_this_one_instead; char *prefix; @@ -98,6 +100,9 @@ static void show_help(const char *s) " method. Default: 400 adu\n" " --min-gradient=<n> Minimum gradient for Zaefferer peak search.\n" " Default: 100,000.\n" +" -e, --image=<element> Use this image from the HDF5 file.\n" +" Example: /data/data0.\n" +" Default: The first one found.\n" "\n" " --filter-cm Perform common-mode noise subtraction on images\n" " before proceeding.\n" @@ -182,12 +187,25 @@ static void add_image(void *args, int cookie) STATUS("%3i: Processing '%s'\n", cookie, pargs->filename); hdfile = hdfile_open(pargs->filename); - if ( hdfile == NULL ) { - return; - } else if ( hdfile_set_first_image(hdfile, "/") ) { - ERROR("Couldn't select path\n"); - hdfile_close(hdfile); - return; + if ( hdfile == NULL ) return; + + if ( pargs->element != NULL ) { + int r; + r = hdfile_set_image(hdfile, pargs->element); + if ( r ) { + ERROR("Couldn't select path '%s'\n", pargs->element); + hdfile_close(hdfile); + return; + } + } else { + int r; + r = hdfile_set_first_image(hdfile, "/"); + if ( r ) { + ERROR("Couldn't select first path\n"); + hdfile_close(hdfile); + return; + } + } hdf5_read(hdfile, &image, 1); @@ -305,6 +323,7 @@ int main(int argc, char *argv[]) char prepare_filename[1024]; char *rval; int config_basename = 0; + char *element = NULL; /* Long options */ const struct option longopts[] = { @@ -319,6 +338,7 @@ int main(int argc, char *argv[]) {"threshold", 1, NULL, 't'}, {"min-gradient", 1, NULL, 4}, {"basename", 0, &config_basename, 1}, + {"image", 1, NULL, 'e'}, {0, 0, NULL, 0} }; @@ -359,6 +379,10 @@ int main(int argc, char *argv[]) threshold = atof(optarg); break; + case 'e' : + element = strdup(optarg); + break; + case 4 : min_gradient = strtof(optarg, NULL); break; @@ -453,6 +477,7 @@ int main(int argc, char *argv[]) qargs.sum = calloc(qargs.w*qargs.h, sizeof(double)); qargs.prefix = prefix; qargs.fh = fh; + qargs.element = element; do { |