diff options
author | Thomas White <taw@physics.org> | 2020-07-10 13:43:30 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2020-07-29 18:53:45 +0200 |
commit | 865959d6b3adaae1f80fb50da4bebdd9b5d31830 (patch) | |
tree | d8da59cc4e0215d77935c88f2b3cc1dd96285435 | |
parent | f7ea70e422fafdc886d5829d1bb5f9f3e75d726f (diff) |
Add --no-image-data and --no-mask-data
-rw-r--r-- | libcrystfel/src/image.c | 64 | ||||
-rw-r--r-- | libcrystfel/src/image.h | 7 | ||||
-rw-r--r-- | src/crystfel_gui.c | 3 | ||||
-rw-r--r-- | src/indexamajig.c | 11 | ||||
-rw-r--r-- | src/process_image.c | 11 | ||||
-rw-r--r-- | src/process_image.h | 1 | ||||
-rw-r--r-- | tests/wavelength_geom.c | 2 |
7 files changed, 79 insertions, 20 deletions
diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c index b9450fc0..b41364d4 100644 --- a/libcrystfel/src/image.c +++ b/libcrystfel/src/image.c @@ -474,8 +474,41 @@ void create_detgeom(struct image *image, const DataTemplate *dtempl) } -struct image *image_read(DataTemplate *dtempl, const char *filename, - const char *event) +static int zero_data_arrays(struct image *image, + const DataTemplate *dtempl) +{ + int pi; + + image->dp = malloc(dtempl->n_panels*sizeof(float *)); + if ( image->dp == NULL ) return 1; + + for ( pi=0; pi<dtempl->n_panels; pi++ ) { + + struct panel_template *p; + int p_w, p_h; + long int i; + + p = &dtempl->panels[pi]; + p_w = p->orig_max_fs - p->orig_min_fs + 1; + p_h = p->orig_max_ss - p->orig_min_ss + 1; + + image->dp[pi] = malloc(p_w*p_h*sizeof(float)); + if ( image->dp[pi] == NULL ) return 1; + + for ( i=0; i<p_w*p_h; i++ ) { + image->dp[pi][i] = 0.0; + } + } + + return 0; +} + + +struct image *image_read(DataTemplate *dtempl, + const char *filename, + const char *event, + int no_image_data, + int no_mask_data) { struct image *image; int i; @@ -492,18 +525,26 @@ struct image *image_read(DataTemplate *dtempl, const char *filename, return NULL; } - if ( is_hdf5_file(filename) ) { - r = image_hdf5_read(image, dtempl, filename, event); + if ( !no_image_data ) { + + if ( is_hdf5_file(filename) ) { + r = image_hdf5_read(image, dtempl, filename, event); - } else if ( is_cbf_file(filename) ) { - r = image_cbf_read(image, dtempl, filename, event, 0); + } else if ( is_cbf_file(filename) ) { + r = image_cbf_read(image, dtempl, filename, event, 0); - } else if ( is_cbfgz_file(filename) ) { - r = image_cbf_read(image, dtempl, filename, event, 1); + } else if ( is_cbfgz_file(filename) ) { + r = image_cbf_read(image, dtempl, filename, event, 1); + + } else { + ERROR("Unrecognised file type: %s\n", filename); + r = 1; + } } else { - ERROR("Unrecognised file type: %s\n", filename); - r = 1; + + r = zero_data_arrays(image, dtempl); + } if ( r ) { @@ -562,7 +603,8 @@ struct image *image_read(DataTemplate *dtempl, const char *filename, } /* Load mask (skip if panel is bad anyway) */ - if ( (!p->bad) && (p->mask != NULL) ) { + if ( (!no_mask_data) && (!p->bad) && (p->mask != NULL) ) + { if ( p->mask_file == NULL ) { mask_fn = filename; } else { diff --git a/libcrystfel/src/image.h b/libcrystfel/src/image.h index 8721a2bf..bbddadb3 100644 --- a/libcrystfel/src/image.h +++ b/libcrystfel/src/image.h @@ -190,8 +190,11 @@ extern void mark_resolution_range_as_bad(struct image *image, double min, double max); extern struct image *image_new(void); -extern struct image *image_read(DataTemplate *dtempl, const char *filename, - const char *event); +extern struct image *image_read(DataTemplate *dtempl, + const char *filename, + const char *event, + int no_image_data, + int no_mask_data); extern void image_free(struct image *image); extern ImageFeatureList *image_read_peaks(const DataTemplate *dtempl, diff --git a/src/crystfel_gui.c b/src/crystfel_gui.c index 54e2b72d..fc7e265f 100644 --- a/src/crystfel_gui.c +++ b/src/crystfel_gui.c @@ -159,7 +159,8 @@ static void update_imageview(struct crystfelproject *proj) image = image_read(proj->dtempl, proj->filenames[proj->cur_frame], - proj->events[proj->cur_frame]); + proj->events[proj->cur_frame], + 0, 0); if ( image == NULL ) { ERROR("Failed to load image\n"); diff --git a/src/indexamajig.c b/src/indexamajig.c index f9c938a3..68b293f6 100644 --- a/src/indexamajig.c +++ b/src/indexamajig.c @@ -9,7 +9,7 @@ * Copyright © 2012 Lorenzo Galli * * Authors: - * 2010-2019 Thomas White <taw@physics.org> + * 2010-2020 Thomas White <taw@physics.org> * 2011 Richard Kirian * 2012 Lorenzo Galli * 2012 Chunhong Yoon @@ -81,6 +81,7 @@ struct indexamajig_arguments int basename; int zmq; int no_image_data; + int no_mask_data; int serial_start; char *temp_location; int if_refine; @@ -210,6 +211,10 @@ static error_t parse_arg(int key, char *arg, struct argp_state *state) "yet work in a useful way.\n"); break; + case 210 : + args->no_mask_data = 1; + break; + /* ---------- Peak search ---------- */ case 't' : @@ -658,6 +663,7 @@ int main(int argc, char *argv[]) args.iargs.fix_profile_r = -1.0; args.iargs.fix_divergence = -1.0; args.iargs.no_image_data = 0; + args.iargs.no_mask_data = 0; argp_program_version_hook = show_version; @@ -690,9 +696,10 @@ int main(int argc, char *argv[]) "processing"}, {"zmq-msgpack", 207, NULL, OPTION_NO_USAGE, "Receive data in MessagePack format " "over ZMQ"}, - {"no-image-data", 208, NULL, OPTION_NO_USAGE, "Do not load image data (from ZMQ)"}, + {"no-image-data", 208, NULL, OPTION_NO_USAGE, "Do not load image data"}, {"spectrum-file", 209, "fn", OPTION_NO_USAGE | OPTION_HIDDEN, "File containing radiation spectrum"}, + {"no-mask-data", 210, NULL, OPTION_NO_USAGE, "Do not load mask data"}, {NULL, 0, 0, OPTION_DOC, "Peak search options:", 3}, {"peaks", 301, "method", 0, "Peak search method. Default: zaef"}, diff --git a/src/process_image.c b/src/process_image.c index bec73a08..179997e2 100644 --- a/src/process_image.c +++ b/src/process_image.c @@ -106,7 +106,9 @@ static struct image *file_wait_open_read(const char *filename, TimeAccounts *taccs, char *last_task, signed int wait_for_file, - int cookie) + int cookie, + int no_image_data, + int no_mask_data) { signed int file_wait_time = wait_for_file; int wait_message_done = 0; @@ -157,7 +159,8 @@ static struct image *file_wait_open_read(const char *filename, set_last_task(last_task, "read file"); sb_shared->pings[cookie]++; - image = image_read(dtempl, filename, event); + image = image_read(dtempl, filename, event, + no_image_data, no_mask_data); if ( image == NULL ) { if ( wait_for_file && !read_retry_done ) { read_retry_done = 1; @@ -201,7 +204,9 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, iargs->dtempl, sb_shared, taccs, last_task, iargs->wait_for_file, - cookie); + cookie, + iargs->no_image_data, + iargs->no_mask_data); if ( image == NULL ) { if ( iargs->wait_for_file != 0 ) { pthread_mutex_lock(&sb_shared->totals_lock); diff --git a/src/process_image.h b/src/process_image.h index 6e86f923..50f69918 100644 --- a/src/process_image.h +++ b/src/process_image.h @@ -98,6 +98,7 @@ struct index_args Spectrum *spectrum; signed int wait_for_file; /* -1 means wait forever */ int no_image_data; + int no_mask_data; }; diff --git a/tests/wavelength_geom.c b/tests/wavelength_geom.c index 814e2eb3..3a371ad1 100644 --- a/tests/wavelength_geom.c +++ b/tests/wavelength_geom.c @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) return 1; } - image = image_read(dtempl, image_filename, NULL); + image = image_read(dtempl, image_filename, NULL, 0, 0); if ( image == NULL ) return 1; printf("wavelength = %e\n", image->lambda); |