aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorValerio Mariani <valerio.mariani@desy.de>2015-01-26 16:34:46 +0100
committervalerio.mariani@desy.de <vmariani@cfeld-valerio2.desy.de>2015-01-27 14:11:47 +0100
commit88cd2cfd80838dd57cf607ac0fa752665cae4c14 (patch)
tree041b82409216b639a90828f20c0f5a72b33a2270 /libcrystfel
parente406fe80b9c504de80308393fc09fa139dcc40a8 (diff)
Keep hold of HDF5 fields which came from the stream
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/image.h1
-rw-r--r--libcrystfel/src/stream.c57
-rw-r--r--libcrystfel/src/stream.h9
3 files changed, 67 insertions, 0 deletions
diff --git a/libcrystfel/src/image.h b/libcrystfel/src/image.h
index e196d052..10e83905 100644
--- a/libcrystfel/src/image.h
+++ b/libcrystfel/src/image.h
@@ -180,6 +180,7 @@ struct image {
char *filename;
struct event *event;
const struct copy_hdf5_field *copyme;
+ struct stuff_from_stream *stuff_from_stream;
int id; /* ID number of the thread
* handling this image */
diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c
index 2a352baf..3eb1d783 100644
--- a/libcrystfel/src/stream.c
+++ b/libcrystfel/src/stream.c
@@ -1066,6 +1066,7 @@ int read_chunk_2(Stream *st, struct image *image, StreamReadFlags srf)
image->crystals = NULL;
image->n_crystals = 0;
image->event = NULL;
+ image->stuff_from_stream = NULL;
if ( (srf & STREAM_READ_REFLECTIONS) || (srf & STREAM_READ_UNITCELL) ) {
srf |= STREAM_READ_CRYSTALS;
@@ -1147,6 +1148,37 @@ int read_chunk_2(Stream *st, struct image *image, StreamReadFlags srf)
}
}
+ if (strncmp(line, "hdf5", 3) == 0 ) {
+
+ char **new_fields;
+
+ if ( image->stuff_from_stream == NULL ) {
+ image->stuff_from_stream =
+ malloc(sizeof(struct stuff_from_stream));
+ if ( image->stuff_from_stream == NULL) {
+ ERROR("Failed reading hdf5 entries from "
+ "stream\n");
+ return 1;
+ }
+ image->stuff_from_stream->fields = NULL;
+ image->stuff_from_stream->n_fields = 0;
+ }
+
+ new_fields = realloc(image->stuff_from_stream->fields,
+ (1+image->stuff_from_stream->n_fields)*
+ sizeof(char *));
+ if ( new_fields == NULL ) {
+ ERROR("Failed reading hdf5 entries from stream\n");
+ return 1;
+ }
+ image->stuff_from_stream->fields = new_fields;
+ image->stuff_from_stream->fields[image->stuff_from_stream->n_fields]
+ = strdup(line);
+ image->stuff_from_stream->n_fields++;
+
+ }
+
+
if ( (srf & STREAM_READ_PEAKS)
&& strcmp(line, PEAK_LIST_START_MARKER) == 0 ) {
@@ -1480,3 +1512,28 @@ int rewind_stream(Stream *st)
{
return fseek(st->fh, 0, SEEK_SET);
}
+
+
+
+double extract_f_from_stuff(const char *field_name,
+ struct stuff_from_stream* stuff)
+{
+ int i;
+
+ char field_name_plus_equal[256];
+ sprintf(field_name_plus_equal, "hdf5%s = ", field_name);
+
+
+
+ for ( i=0; i<stuff->n_fields; i++ ) {
+
+ if ( strncmp(stuff->fields[i], field_name_plus_equal,
+ strlen(field_name_plus_equal)) == 0 ) {
+ return atoi(stuff->fields[i]+
+ strlen(field_name_plus_equal));
+ }
+ }
+
+ ERROR("Failed to recovery camera length from stream file\n");
+ return -1;
+}
diff --git a/libcrystfel/src/stream.h b/libcrystfel/src/stream.h
index 43e45923..afa9acda 100644
--- a/libcrystfel/src/stream.h
+++ b/libcrystfel/src/stream.h
@@ -77,6 +77,12 @@ typedef enum {
} StreamReadFlags;
+struct stuff_from_stream
+{
+ char **fields;
+ int n_fields;
+};
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -103,6 +109,9 @@ extern void write_geometry_file(Stream *st, const char *geom_filename);
extern int rewind_stream(Stream *st);
extern int is_stream(const char *filename);
+extern double extract_f_from_stuff(const char *field_name,
+ struct stuff_from_stream* stuff);
+
#ifdef __cplusplus
}
#endif