From a3eec1b371d661c69ccae1171064202f43fdea25 Mon Sep 17 00:00:00 2001 From: Jerome Kieffer Date: Thu, 5 Dec 2024 15:19:08 +0100 Subject: [PATCH] Fix file extraction for HPLC data --- src/freesas/app/extract_ascii.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/freesas/app/extract_ascii.py b/src/freesas/app/extract_ascii.py index 9ae68cf..ef03d06 100644 --- a/src/freesas/app/extract_ascii.py +++ b/src/freesas/app/extract_ascii.py @@ -26,7 +26,7 @@ __author__ = "Jérôme Kieffer" __license__ = "MIT" -__copyright__ = "2020, ESRF" +__copyright__ = "2020-2024, ESRF" __date__ = "05/12/2024" import io @@ -91,10 +91,14 @@ def extract_averaged(filename): results["h5path"] = entry_grp.name default = entry_grp.attrs["default"] if posixpath.split(default)[-1] == "hplc": - default = posixpath.join(posixpath.split(default)[0],"result") + default = posixpath.join(posixpath.split(default)[0],"results") + print(default) nxdata_grp = nxsr.h5[default] signal = nxdata_grp.attrs["signal"] axis = nxdata_grp.attrs["axes"] + if not isinstance(axis, (str,bytes)): + logger.error(f"There are several curves if the dataset {default} from file {filename}, please use the option --all to extract them all") + sys.exit(1) results["I"] = nxdata_grp[signal][()] results["q"] = nxdata_grp[axis][()] results["std"] = nxdata_grp["errors"][()] @@ -105,15 +109,12 @@ def extract_averaged(filename): results["geometry"] = json.loads( integration_grp["configuration/data"][()] ) - results["polarization"] = integration_grp[ - "configuration/polarization_factor" - ][()] + results["polarization"] = integration_grp["configuration/polarization_factor"][()] instrument_grps = nxsr.get_class(entry_grp, class_type="NXinstrument") if instrument_grps: - detector_grp = nxsr.get_class( - instrument_grps[0], class_type="NXdetector" - )[0] + detector_grp = nxsr.get_class(instrument_grps[0], + class_type="NXdetector")[0] results["mask"] = detector_grp["pixel_mask"].attrs["filename"] sample_grp = nxsr.get_class(entry_grp, class_type="NXsample")[0] results["sample"] = posixpath.split(sample_grp.name)[-1]