aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2017-05-05 16:33:38 +0200
committerThomas White <taw@physics.org>2017-05-05 16:41:57 +0200
commitbb552aba7ac926bfae331b5648abd8647ba1d9f5 (patch)
tree20e8d14349b018ec19c1ef168ec4240bd85a23b3 /libcrystfel
parent4c5ae5576d943350fd958db3674f4d30ae2d6eae (diff)
Allow location of photon energy (eg in HDF5 file) to start with any character
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/detector.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/libcrystfel/src/detector.c b/libcrystfel/src/detector.c
index e160d1e1..b2e3cc58 100644
--- a/libcrystfel/src/detector.c
+++ b/libcrystfel/src/detector.c
@@ -1076,12 +1076,17 @@ static void parse_toplevel(struct detector *det, struct beam_params *beam,
} else if ( strcmp(key, "photon_energy") == 0 ) {
if ( beam != NULL ) {
- if ( strncmp(val, "/", 1) == 0 ) {
+
+ double v;
+ char *end;
+
+ v = strtod(val, &end);
+ if ( (val[0] != '\0') && (end[0] == '\0') ) {
+ beam->photon_energy = v;
+ beam->photon_energy_from = NULL;
+ } else {
beam->photon_energy = 0.0;
beam->photon_energy_from = strdup(val);
- } else {
- beam->photon_energy = atof(val);
- beam->photon_energy_from = NULL;
}
}