aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/detector.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2014-09-22 18:06:07 +0200
committerThomas White <taw@physics.org>2014-09-22 18:06:07 +0200
commit0a5a04cc90619a1973c91489c71585ce127df045 (patch)
treec1903fc77534cd97840330b914b98b7b1187bce0 /libcrystfel/src/detector.c
parent142e1ad4e0fad73d223c67a842dfb9728a3bf34c (diff)
Beam file removal, part I
Diffstat (limited to 'libcrystfel/src/detector.c')
-rw-r--r--libcrystfel/src/detector.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/libcrystfel/src/detector.c b/libcrystfel/src/detector.c
index 4cf6dac9..3cf59786 100644
--- a/libcrystfel/src/detector.c
+++ b/libcrystfel/src/detector.c
@@ -43,7 +43,6 @@
#include "image.h"
#include "utils.h"
#include "detector.h"
-#include "beam-parameters.h"
#include "hdf5-file.h"
@@ -784,8 +783,8 @@ static int parse_field_bad(struct badregion *panel, const char *key,
}
-static void parse_toplevel(struct detector *det, const char *key,
- const char *val)
+static void parse_toplevel(struct detector *det, struct beam_params *beam,
+ const char *key, const char *val)
{
if ( strcmp(key, "mask_bad") == 0 ) {
@@ -807,6 +806,20 @@ static void parse_toplevel(struct detector *det, const char *key,
} else if ( strcmp(key, "coffset") == 0 ) {
det->defaults.coffset = atof(val);
+
+ } else if ( strcmp(key, "photon_energy") == 0 ) {
+ if ( beam == NULL ) {
+ ERROR("Geometry file contains a reference to "
+ "photon_energy, which is inappropriate in this "
+ "situation.\n");
+ } else if ( strncmp(val, "/", 1) == 0 ) {
+ beam->photon_energy = 0.0;
+ beam->photon_energy_from = strdup(val);
+ } else {
+ beam->photon_energy = atof(val);
+ beam->photon_energy_from = NULL;
+ }
+
} else if ( parse_field_for_panel(&det->defaults, key, val, det) ) {
ERROR("Unrecognised top level field '%s'\n", key);
}
@@ -871,7 +884,8 @@ static void find_min_max_d(struct detector *det)
}
-struct detector *get_detector_geometry(const char *filename)
+struct detector *get_detector_geometry(const char *filename,
+ struct beam_params *beam)
{
FILE *fh;
struct detector *det;
@@ -971,7 +985,7 @@ struct detector *get_detector_geometry(const char *filename)
n2 = assplode(bits[0], "/\\.", &path, ASSPLODE_NONE);
if ( n2 < 2 ) {
/* This was a top-level option, not handled above. */
- parse_toplevel(det, bits[0], bits[2]);
+ parse_toplevel(det, beam, bits[0], bits[2]);
for ( i=0; i<n1; i++ ) free(bits[i]);
free(bits);
for ( i=0; i<n2; i++ ) free(path[i]);