From bb552aba7ac926bfae331b5648abd8647ba1d9f5 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 5 May 2017 16:33:38 +0200 Subject: Allow location of photon energy (eg in HDF5 file) to start with any character --- libcrystfel/src/detector.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'libcrystfel/src') 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; } } -- cgit v1.2.3