Skip to content
Snippets Groups Projects
Commit 2df41007 authored by David Hammer's avatar David Hammer
Browse files

Enable loading (some) h5 geometry files

parent a65e6c04
No related branches found
No related tags found
1 merge request!12Snapshot: field test deployed version as of end of run 202201
......@@ -160,6 +160,17 @@ class GeometryFileNode(Configurable):
assignment=Assignment.OPTIONAL,
accessMode=AccessMode.RECONFIGURABLE,
)
fileType = String(
displayedName="File type",
defaultValue="crystfel",
description="What kind of file will be loaded. Corresponds to options within "
"EXtra-geom. Note that the options listed here may not all apply to all "
"geometries. I think 'crystfel' (uses extra_geom.[geometry type]"
".from_crystfel_geom is the most 'universal', so I left that as default.",
options=["crystfel", "h5", "h5+quadrants"],
assignment=Assignment.OPTIONAL,
accessMode=AccessMode.RECONFIGURABLE,
)
offset = make_x_y_offset_node()
updateManualOnLoad = Bool(
defaultValue=True,
......@@ -246,9 +257,20 @@ class ManualGeometryBase(Device):
file_path = self.geometryFile.filePath.value
self._set_status(f"Loading geometry from {file_path}...")
file_type = self.geometryFile.fileType.value
try:
geometry = self.geometry_class.from_crystfel_geom(file_path)
if file_type == "crystfel":
geometry = self.geometry_class.from_crystfel_geom(file_path)
elif file_type == "h5":
geometry = self.geometry_class.from_h5_file(file_path)
elif file_type == "h5+quadrants":
geometry = self.geometry_class.from_h5_file_and_quad_positions(
file_path,
[(Q.x.value, Q.y.value) for Q in self._quadrant_corners],
)
else:
raise ValueError(f"Invalid file type {file_type}")
except FileNotFoundError:
self._set_status("Geometry file not found", level=logging.WARN)
except RuntimeError as e:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment