aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-07-10 15:30:51 +0200
committerThomas White <taw@physics.org>2020-07-29 18:53:45 +0200
commit30973775e4bddba8ceebf4b93f58440cbb520617 (patch)
treebf11a7762e8d14e24d551e550243b8233147c005 /libcrystfel
parent47ecc15f4f32350bb29085459e23f208007e3d1c (diff)
stream_read_chunk: Add option to load image data
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/image.c36
-rw-r--r--libcrystfel/src/image.h5
-rw-r--r--libcrystfel/src/stream.c10
-rw-r--r--libcrystfel/src/stream.h3
4 files changed, 40 insertions, 14 deletions
diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c
index 2b6f5b16..52a7f5f5 100644
--- a/libcrystfel/src/image.c
+++ b/libcrystfel/src/image.c
@@ -538,6 +538,27 @@ int image_set_zero_mask(struct image *image,
}
+int image_read_image_data(struct image *image,
+ const DataTemplate *dtempl,
+ const char *filename,
+ const char *event)
+{
+ if ( is_hdf5_file(filename) ) {
+ return image_hdf5_read(image, dtempl, filename, event);
+
+ } else if ( is_cbf_file(filename) ) {
+ return image_cbf_read(image, dtempl, filename, event, 0);
+
+ } else if ( is_cbfgz_file(filename) ) {
+ return image_cbf_read(image, dtempl, filename, event, 1);
+
+ }
+
+ ERROR("Unrecognised file type: %s\n", filename);
+ return 1;
+}
+
+
struct image *image_read(DataTemplate *dtempl,
const char *filename,
const char *event,
@@ -561,19 +582,8 @@ struct image *image_read(DataTemplate *dtempl,
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_cbfgz_file(filename) ) {
- r = image_cbf_read(image, dtempl, filename, event, 1);
-
- } else {
- ERROR("Unrecognised file type: %s\n", filename);
- r = 1;
- }
+ r = image_read_image_data(image, dtempl,
+ filename, event);
} else {
diff --git a/libcrystfel/src/image.h b/libcrystfel/src/image.h
index 45a75f1e..9bb6f1bd 100644
--- a/libcrystfel/src/image.h
+++ b/libcrystfel/src/image.h
@@ -215,6 +215,11 @@ extern int image_set_zero_mask(struct image *image,
extern void create_detgeom(struct image *image,
const DataTemplate *dtempl);
+extern int image_read_image_data(struct image *image,
+ const DataTemplate *dtempl,
+ const char *filename,
+ const char *event);
+
#ifdef __cplusplus
}
#endif
diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c
index dbb213bf..02abd549 100644
--- a/libcrystfel/src/stream.c
+++ b/libcrystfel/src/stream.c
@@ -1013,7 +1013,15 @@ struct image *stream_read_chunk(Stream *st, const DataTemplate *dtempl,
if ( have_filename && have_ev ) {
/* Success */
create_detgeom(image, dtempl);
- image_set_zero_data(image, dtempl);
+ if ( srf & STREAM_IMAGE_DATA ) {
+ image_read_image_data(image,
+ dtempl,
+ image->filename,
+ image->ev);
+ } else {
+ image_set_zero_data(image, dtempl);
+ }
+ image_set_zero_mask(image, dtempl);
return image;
}
ERROR("Incomplete chunk found in input file.\n");
diff --git a/libcrystfel/src/stream.h b/libcrystfel/src/stream.h
index b086a1b6..a575cedb 100644
--- a/libcrystfel/src/stream.h
+++ b/libcrystfel/src/stream.h
@@ -85,6 +85,9 @@ typedef enum {
/** Read the general information about crystals */
STREAM_CRYSTALS = 8,
+ /** Read the image data */
+ STREAM_IMAGE_DATA = 16,
+
} StreamFlags;
#ifdef __cplusplus