Skip to content

Commit

Permalink
Fix file extraction for HPLC data
Browse files Browse the repository at this point in the history
  • Loading branch information
kif committed Dec 5, 2024
1 parent b4e3024 commit a3eec1b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/freesas/app/extract_ascii.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

__author__ = "Jérôme Kieffer"
__license__ = "MIT"
__copyright__ = "2020, ESRF"
__copyright__ = "2020-2024, ESRF"
__date__ = "05/12/2024"

import io
Expand Down Expand Up @@ -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"][()]
Expand All @@ -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]
Expand Down

0 comments on commit a3eec1b

Please sign in to comment.