Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions rsciio/empad/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

Expand Down
1 change: 1 addition & 0 deletions upcoming_changes/513.bugfix.rst
Original file line number Diff line number Diff line change
@@ -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.
Loading