From e5ff1c404c096d97d665b7c6e897d4d8be5617f6 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 28 Feb 2011 10:42:35 +0100 Subject: Get camera length from HDF5 if required --- src/detector.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'src/detector.c') diff --git a/src/detector.c b/src/detector.c index e4f15aff..7d2cb513 100644 --- a/src/detector.c +++ b/src/detector.c @@ -21,6 +21,7 @@ #include "diffraction.h" #include "detector.h" #include "beam-parameters.h" +#include "hdf5-file.h" static int atob(const char *a) @@ -240,6 +241,24 @@ struct panel *find_panel(struct detector *det, int x, int y) } +void fill_in_values(struct detector *det, struct hdfile *f) +{ + int i; + + for ( i=0; in_panels; i++ ) { + + struct panel *p = &det->panels[i]; + + if ( p->clen_from != NULL ) { + p->clen = get_value(f, p->clen_from) * 1.0e-3; + free(p->clen_from); + p->clen_from = NULL; + } + + } +} + + struct detector *get_detector_geometry(const char *filename) { FILE *fh; @@ -359,7 +378,18 @@ struct detector *get_detector_geometry(const char *filename) } else if ( strcmp(path[1], "corner_y") == 0 ) { det->panels[np].cy = atof(bits[2]); } else if ( strcmp(path[1], "clen") == 0 ) { - det->panels[np].clen = atof(bits[2]); + + char *end; + double v = strtod(bits[2], &end); + if ( end == bits[2] ) { + /* This means "fill in later" */ + det->panels[np].clen = -1.0; + det->panels[np].clen_from = strdup(bits[2]); + } else { + det->panels[np].clen = v; + det->panels[np].clen_from = NULL; + } + } else if ( strcmp(path[1], "res") == 0 ) { det->panels[np].res = atof(bits[2]); } else if ( strcmp(path[1], "peak_sep") == 0 ) { @@ -442,7 +472,8 @@ struct detector *get_detector_geometry(const char *filename) " panel %i\n", i); reject = 1; } - if ( det->panels[i].clen == -1 ) { + if ( (det->panels[i].clen < 0.0) + && (det->panels[i].clen_from == NULL) ) { ERROR("Please specify the camera length for" " panel %i\n", i); reject = 1; -- cgit v1.2.3