aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-07-10 13:43:30 +0200
committerThomas White <taw@physics.org>2020-07-29 18:53:45 +0200
commit865959d6b3adaae1f80fb50da4bebdd9b5d31830 (patch)
treed8da59cc4e0215d77935c88f2b3cc1dd96285435 /libcrystfel
parentf7ea70e422fafdc886d5829d1bb5f9f3e75d726f (diff)
Add --no-image-data and --no-mask-data
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/image.c64
-rw-r--r--libcrystfel/src/image.h7
2 files changed, 58 insertions, 13 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,