aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2017-03-14 14:14:06 +0100
committerThomas White <taw@physics.org>2017-05-02 12:03:12 +0200
commit8fbfaf71b1efef4bfdb40ce85200e772e82e9773 (patch)
treeb1b7fab1e2a5d55c8d43d645e4214633991120e7
parent4227f0b190b08ecc50a49875e86dbb9b14714bdd (diff)
Initial CBF stuff
-rw-r--r--libcrystfel/src/image.c4
-rw-r--r--libcrystfel/src/image.h17
-rw-r--r--libcrystfel/src/stream.c6
-rw-r--r--libcrystfel/src/stream.h9
-rw-r--r--src/process_image.c32
5 files changed, 46 insertions, 22 deletions
diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c
index 09f4958d..2cc0d792 100644
--- a/libcrystfel/src/image.c
+++ b/libcrystfel/src/image.c
@@ -3,12 +3,12 @@
*
* Handle images and image features
*
- * Copyright © 2012-2016 Deutsches Elektronen-Synchrotron DESY,
+ * Copyright © 2012-2017 Deutsches Elektronen-Synchrotron DESY,
* a research centre of the Helmholtz Association.
*
* Authors:
* 2014 Kenneth Beyerlein <kenneth.beyerlein@desy.de>
- * 2011-2016 Thomas White <taw@physics.org>
+ * 2011-2017 Thomas White <taw@physics.org>
*
* This file is part of CrystFEL.
*
diff --git a/libcrystfel/src/image.h b/libcrystfel/src/image.h
index 9fd9b495..2ed7140f 100644
--- a/libcrystfel/src/image.h
+++ b/libcrystfel/src/image.h
@@ -3,11 +3,11 @@
*
* Handle images and image features
*
- * Copyright © 2012-2016 Deutsches Elektronen-Synchrotron DESY,
+ * Copyright © 2012-2017 Deutsches Elektronen-Synchrotron DESY,
* a research centre of the Helmholtz Association.
*
* Authors:
- * 2009-2016 Thomas White <taw@physics.org>
+ * 2009-2017 Thomas White <taw@physics.org>
* 2014 Valerio Mariani
*
*
@@ -44,6 +44,8 @@ struct detector;
struct imagefeature;
struct sample;
struct image;
+struct imagefile;
+struct imagefile_field_list;
#include "utils.h"
#include "cell.h"
@@ -51,6 +53,7 @@ struct image;
#include "reflist.h"
#include "crystal.h"
#include "index.h"
+#include "events.h"
/**
* SpectrumType:
@@ -233,6 +236,16 @@ extern void image_add_crystal(struct image *image, Crystal *cryst);
extern void remove_flagged_crystals(struct image *image);
extern void free_all_crystals(struct image *image);
+/* Image files */
+extern struct imagefile *imagefile_open(const char *filename);
+extern int imagefile_read(struct imagefile *imfile, struct image *image,
+ struct event *event);
+extern struct hdfile *imagefile_get_hdfile(struct imagefile *imfile);
+extern void imagefile_copy_fields(struct imagefile *imfile,
+ struct copy_hdf5_file *copyme, FILE *fh,
+ struct event *ev);
+extern void imagefile_close(struct imagefile *imfile);
+
#ifdef __cplusplus
}
#endif
diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c
index 17da74b2..fb4b0c70 100644
--- a/libcrystfel/src/stream.c
+++ b/libcrystfel/src/stream.c
@@ -806,8 +806,8 @@ static int write_crystal(Stream *st, Crystal *cr, int include_reflections)
}
-int write_chunk(Stream *st, struct image *i, struct hdfile *hdfile,
- int include_peaks, int include_reflections, struct event* ev)
+int write_chunk(Stream *st, struct image *i, struct imagefile *imfile,
+ int include_peaks, int include_reflections, struct event *ev)
{
int j;
char *indexer;
@@ -832,7 +832,7 @@ int write_chunk(Stream *st, struct image *i, struct hdfile *hdfile,
fprintf(st->fh, "beam_divergence = %.2e rad\n", i->div);
fprintf(st->fh, "beam_bandwidth = %.2e (fraction)\n", i->bw);
- copy_hdf5_fields(hdfile, i->copyme, st->fh, ev);
+ imagefile_copy_fields(imfile, i->copyme, st->fh, ev);
if ( i->det != NULL ) {
diff --git a/libcrystfel/src/stream.h b/libcrystfel/src/stream.h
index ff8628c0..a95c7df0 100644
--- a/libcrystfel/src/stream.h
+++ b/libcrystfel/src/stream.h
@@ -3,11 +3,11 @@
*
* Stream tools
*
- * Copyright © 2013-2014 Deutsches Elektronen-Synchrotron DESY,
+ * Copyright © 2013-2017 Deutsches Elektronen-Synchrotron DESY,
* a research centre of the Helmholtz Association.
*
* Authors:
- * 2010-2014 Thomas White <taw@physics.org>
+ * 2010-2017 Thomas White <taw@physics.org>
* 2014 Valerio Mariani
* 2011 Andrew Aquila
*
@@ -110,6 +110,11 @@ extern int write_chunk(Stream *st, struct image *image, struct hdfile *hdfile,
int include_peaks, int include_reflections,
struct event *ev);
+extern int write_chunk_2(Stream *st, struct image *image,
+ struct imagefile *imfile,
+ int include_peaks, int include_reflections,
+ struct event *ev);
+
extern void write_command(Stream *st, int argc, char *argv[]);
extern void write_geometry_file(Stream *st, const char *geom_filename);
extern int rewind_stream(Stream *st);
diff --git a/src/process_image.c b/src/process_image.c
index cd5c0866..d3177d82 100644
--- a/src/process_image.c
+++ b/src/process_image.c
@@ -102,7 +102,7 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs,
int serial, struct sb_shm *sb_shared, TimeAccounts *taccs)
{
int check;
- struct hdfile *hdfile;
+ struct imagefile *imfile;
struct image image;
int i;
int r;
@@ -125,15 +125,15 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs,
time_accounts_set(taccs, TACC_HDF5OPEN);
sb_shared->pings[cookie]++;
- hdfile = hdfile_open(image.filename);
- if ( hdfile == NULL ) {
+ imfile = imagefile_open(image.filename);
+ if ( imfile == NULL ) {
ERROR("Couldn't open file: %s\n", image.filename);
return;
}
time_accounts_set(taccs, TACC_HDF5READ);
sb_shared->pings[cookie]++;
- check = hdf5_read2(hdfile, &image, image.event, 0);
+ check = imagefile_read(imfile, &image, image.event);
if ( check ) {
return;
}
@@ -159,9 +159,13 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs,
sb_shared->pings[cookie]++;
switch ( iargs->peaks ) {
+ struct hdfile *hdfile;
+
case PEAK_HDF5:
- if ( get_peaks_2(&image, hdfile, iargs->hdf5_peak_path,
- iargs->half_pixel_shift) )
+ hdfile = imagefile_get_hdfile(imfile);
+ if ( (hdfile == NULL)
+ || (get_peaks_2(&image, hdfile, iargs->hdf5_peak_path,
+ iargs->half_pixel_shift)) )
{
ERROR("Failed to get peaks from HDF5 file.\n");
}
@@ -174,9 +178,11 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs,
break;
case PEAK_CXI:
- if ( get_peaks_cxi_2(&image, hdfile, iargs->hdf5_peak_path,
- pargs->filename_p_e,
- iargs->half_pixel_shift) )
+ hdfile = imagefile_get_hdfile(imfile);
+ if ( (hdfile == NULL)
+ || (get_peaks_cxi_2(&image, hdfile, iargs->hdf5_peak_path,
+ pargs->filename_p_e,
+ iargs->half_pixel_shift)) )
{
ERROR("Failed to get peaks from CXI file.\n");
}
@@ -227,7 +233,7 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs,
if ( r ) {
ERROR("Failed to chdir to temporary folder: %s\n",
strerror(errno));
- hdfile_close(hdfile);
+ imagefile_close(imfile);
return;
}
@@ -250,7 +256,7 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs,
r = chdir(rn);
if ( r ) {
ERROR("Failed to chdir: %s\n", strerror(errno));
- hdfile_close(hdfile);
+ imagefile_close(imfile);
return;
}
free(rn);
@@ -288,7 +294,7 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs,
time_accounts_set(taccs, TACC_WRITESTREAM);
sb_shared->pings[cookie]++;
- ret = write_chunk(st, &image, hdfile,
+ ret = write_chunk(st, &image, imfile,
iargs->stream_peaks, iargs->stream_refls,
pargs->filename_p_e->ev);
if ( ret != 0 ) {
@@ -338,5 +344,5 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs,
image_feature_list_free(image.features);
free_detector_geometry(image.det);
- hdfile_close(hdfile);
+ imagefile_close(imfile);
}