aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-07-09 11:44:49 +0200
committerThomas White <taw@physics.org>2020-07-29 18:53:45 +0200
commit3ee67722fa62588f3c347dddf296fe1dd57f5a84 (patch)
tree9cc2f13e74f872ee6e23eff9bf566b96488dd5b8
parent91308a018a7a791459c0ee918d9cb2fa6aed768f (diff)
Handle scalar values for HDF5 headers
-rw-r--r--libcrystfel/src/image-hdf5.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/libcrystfel/src/image-hdf5.c b/libcrystfel/src/image-hdf5.c
index 5c41ad90..0a222046 100644
--- a/libcrystfel/src/image-hdf5.c
+++ b/libcrystfel/src/image-hdf5.c
@@ -676,12 +676,25 @@ double image_hdf5_get_value(const char *name, const char *filename,
}
H5Sget_simple_extent_dims(sh, size, NULL);
- /* We expect a scalar value */
+ /* We want to read the value as a scalar */
m_offset[0] = 0;
m_count[0] = 1;
msdims[0] = 1;
ms = H5Screate_simple(1, msdims, NULL);
+ if ( ndims == 0 ) {
+ /* Easy case, because value is a scalar */
+ r = H5Dread(dh, H5T_NATIVE_DOUBLE, ms, sh, H5P_DEFAULT, &val);
+ if ( r < 0 ) {
+ ERROR("Couldn't read scalar value from %s.\n",
+ subst_name);
+ free(subst_name);
+ close_hdf5(fh);
+ return NAN;
+ }
+ return val;
+ }
+
dim_vals = read_dim_parts(event, &n_dim_vals);
if ( dim_vals == NULL ) {
ERROR("Couldn't parse event '%s'\n");