aboutsummaryrefslogtreecommitdiff
path: root/src/detector.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2011-02-28 10:42:35 +0100
committerThomas White <taw@physics.org>2012-02-22 15:27:16 +0100
commite5ff1c404c096d97d665b7c6e897d4d8be5617f6 (patch)
treef50f96aad6eee1db51a11eee06153507d076665a /src/detector.c
parente5709dd5d7269730fca2776785675e2deea1045b (diff)
Get camera length from HDF5 if required
Diffstat (limited to 'src/detector.c')
-rw-r--r--src/detector.c35
1 files changed, 33 insertions, 2 deletions
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; i<det->n_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;