aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-07-03 16:06:13 +0200
committerThomas White <taw@physics.org>2020-07-29 18:53:45 +0200
commit6a809813b520d8c882daf569cd86a241b538788c (patch)
treebda370830fd6bbf72927270cfc27865582d45c42 /libcrystfel
parent0e8a06927065c275e5e235c9f6ebcb0a397efc81 (diff)
Create detgeom and data arrays when reading from stream
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/image.c42
-rw-r--r--libcrystfel/src/image.h7
-rw-r--r--libcrystfel/src/stream.c2
3 files changed, 50 insertions, 1 deletions
diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c
index 20e91e6d..cce29f73 100644
--- a/libcrystfel/src/image.c
+++ b/libcrystfel/src/image.c
@@ -388,7 +388,7 @@ static double get_wavelength(struct image *image, const char *from)
}
-static void create_detgeom(struct image *image, DataTemplate *dtempl)
+void create_detgeom(struct image *image, const DataTemplate *dtempl)
{
struct detgeom *detgeom;
int i;
@@ -640,6 +640,46 @@ struct image *image_new()
}
+int create_blank_arrays(struct image *image)
+{
+ int pn;
+ int num_panels = image->detgeom->n_panels;
+
+ image->dp = malloc(num_panels*sizeof(float *));
+ image->bad = malloc(num_panels*sizeof(int *));
+ image->sat = malloc(num_panels*sizeof(float *));
+
+ if ( (image->dp == NULL) || (image->bad == NULL)
+ || (image->sat == NULL) ) return 1;
+
+ for ( pn=0; pn<num_panels; pn++ ) {
+
+ long int i;
+ struct detgeom_panel *p = &image->detgeom->panels[pn];
+
+ image->dp[pn] = malloc(p->w*p->h*sizeof(float));
+ image->bad[pn] = malloc(p->w*p->h*sizeof(int));
+ image->sat[pn] = malloc(p->w*p->h*sizeof(float));
+
+ if ( (image->dp[pn] == NULL)
+ || (image->bad[pn] == NULL)
+ || (image->sat[pn] == NULL) )
+ {
+ return 1;
+ }
+
+ for ( i=0; i<p->w*p->h; i++ ) {
+ image->dp[pn][i] = 0.0;
+ image->bad[pn][i] = 0;
+ image->sat[pn][i] = INFINITY;
+ }
+
+ }
+
+ return 0;
+}
+
+
ImageFeatureList *image_read_peaks(const DataTemplate *dtempl,
const char *filename,
const char *event,
diff --git a/libcrystfel/src/image.h b/libcrystfel/src/image.h
index 93b41c34..8721a2bf 100644
--- a/libcrystfel/src/image.h
+++ b/libcrystfel/src/image.h
@@ -202,6 +202,13 @@ extern ImageFeatureList *image_read_peaks(const DataTemplate *dtempl,
extern char **image_expand_frames(const DataTemplate *dtempl,
const char *filename, int *nframes);
+/* The following functions are not part of the public API -
+ * use within libcrystfel only */
+extern void create_detgeom(struct image *image,
+ const DataTemplate *dtempl);
+
+extern int create_blank_arrays(struct image *image);
+
#ifdef __cplusplus
}
#endif
diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c
index 150bf0af..36eedb2d 100644
--- a/libcrystfel/src/stream.c
+++ b/libcrystfel/src/stream.c
@@ -1012,6 +1012,8 @@ struct image *stream_read_chunk(Stream *st, const DataTemplate *dtempl,
if ( strcmp(line, STREAM_CHUNK_END_MARKER) == 0 ) {
if ( have_filename && have_ev ) {
/* Success */
+ create_detgeom(image, dtempl);
+ create_blank_arrays(image);
return image;
}
ERROR("Incomplete chunk found in input file.\n");