From 51557aff7122b2561037b31e84376764ada0e46b Mon Sep 17 00:00:00 2001 From: matao1984 Date: Wed, 27 May 2026 10:46:53 -0400 Subject: [PATCH 1/2] Modified parsing logic for empad data to be from the raw file name. --- rsciio/empad/_api.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/rsciio/empad/_api.py b/rsciio/empad/_api.py index 88a6c1fe7..592e7fc48 100644 --- a/rsciio/empad/_api.py +++ b/rsciio/empad/_api.py @@ -80,16 +80,20 @@ def _parse_xml(filename): elif om.has_item("root.pix_x") and om.has_item("root.pix_y"): # 2D x 2D info.update({"scan_x": int(om.root.pix_x), "scan_y": int(om.root.pix_y)}) - # in case root.pix_x and root.pix_y are not available - elif om.has_item("root.scan_parameters.scan_resolution_x") and om.has_item( - "root.scan_parameters.scan_resolution_y" - ): - info.update( - { - "scan_x": int(om.root.scan_parameters.scan_resolution_x), - "scan_y": int(om.root.scan_parameters.scan_resolution_y), - } - ) + # in case root.pix_x and root.pix_y are not available, parse from the raw_file name + elif om.has_item("root.raw_file.filename"): + raw_filename = om.root.raw_file.filename + # The raw filename is in the format of "scan_xxx_yxx.raw", where xx is the scan size in x and y direction. + if raw_filename.startswith("scan_"): + try: + basename = raw_filename.split(".")[0] + scan_x = int(basename.split("_")[-2][1:]) + scan_y = int(basename.split("_")[-1][1:]) + info.update({"scan_x": scan_x, "scan_y": scan_y}) + except Exception: + raise IOError( + "Unsupported Empad file: the scan parameters cannot be imported." + ) else: raise IOError("Unsupported Empad file: the scan parameters cannot be imported.") From 1ec3a9b739b5c82812f9b449948359e3773d3e73 Mon Sep 17 00:00:00 2001 From: matao1984 Date: Wed, 27 May 2026 15:19:10 -0400 Subject: [PATCH 2/2] Modified parsing logic for empad data to be from the raw file name. --- upcoming_changes/513.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 upcoming_changes/513.bugfix.rst diff --git a/upcoming_changes/513.bugfix.rst b/upcoming_changes/513.bugfix.rst new file mode 100644 index 000000000..fcdf55de5 --- /dev/null +++ b/upcoming_changes/513.bugfix.rst @@ -0,0 +1 @@ +Modified empad reader to parse scan sizes from the raw file name following the pattern "scan_xaaa_ybbb.raw", where "aaa" and "bbb" represent the scan sizes in the x and y dimensions, respectively. \ No newline at end of file