csaxs_bec.file_writer.csaxs_nexus.cSAXSNeXusFormat#

class cSAXSNeXusFormat(storage: HDF5Storage, data: dict, info_storage: dict, configuration: dict, file_references: dict[str, messages.FileMessage], beamline_states: dict[str, list[messages.BeamlineStateMessage]], device_manager: DeviceManagerBase)[source]#

Bases: DefaultFormat

NeXus file format for the cSAXS beamline (BEC era).

Mirrors the old SPEC layout.xml hierarchy and adds the flOMNI instrument group for the nano-positioning stage used in ptychography.

Device resilience#

Every device read (self.get_entry / device call) is wrapped in try/except. If a device is removed from the BEC config file between sessions it simply disappears from the device_manager — the corresponding dataset or link is silently omitted from the HDF5 file without raising an error. This means the file structure is additive: re-add the device to the config and the field reappears automatically on the next scan.

Top-level HDF5 structure ──────────────────────── /entry NXentry (definition = NXptycho)

/sample

NXsample ← primary sample group

/entry_ptycho

NXentry ← generic ptycho entry

/data_soft

NXentry ← convenience Eiger frame links

/control

NXmonitor

/instrument

NXinstrument /source /insertion_device /monochromator /XBPM3 /slit_3 … slit_5 /filter_set /beam_stop_1 … beam_stop_2 /eiger_1_5 NXdetector /mcs NXdetector /flOMNI NXpositioner

Device name mapping (old SPEC → current BEC) ──────────────────────────────────────────── samx / samy → samx / samy (generic; kept for non-flOMNI configs) sl3wh/wv/ch/cv → sl3trxi/o/b/t (individual blade motors; gap/centre TODO) sl4wh/wv/ch/cv → sl4trxi/o/b/t sl5wh/wv/ch/cv → sl5trxi/o/b/t bs1x / bs1y → bs1x / bs1y bs2x / bs2y → bs2x / bs2y dettrx → dettrx eiger_4 → eiger_1_5 mcs → mcs filter_array → filter_array_1_x … filter_array_4_x xbpm3 → xbpm3x / xbpm3y (stage positions; signal readouts TODO) energy → ccm_energy

TODO (devices not yet in BEC list) ─────────────────────────────────── curr, idgap ring current, undulator gap moth1, mobd monochromator crystal angles mith, mibd, mirror_coating mirror bpm3s/x/y/z XBPM3 signal readouts sl0 / sl1 / sl2 upstream optics-hutch slits slit gap / centre derived from blade pairs + calibration offset

Methods

format

Build the NeXus/HDF5 layout for a cSAXS scan.

get_entry

Get an entry from the scan data assuming a <device>.<device>.value structure.

get_storage_format

Internal method to extract the storage format after formatting the data.

write_bec_entries

Write the BEC entries to the NeXus file format.

format() None[source]#

Build the NeXus/HDF5 layout for a cSAXS scan.

get_entry(name: str, default=None) Any#

Get an entry from the scan data assuming a <device>.<device>.value structure.

This method is a helper to extract the device data from the scan data, irrespective of the data structure (list of entries or single entry).

Parameters:
  • name (str) – Entry name

  • default (Any, optional) – Default value. Defaults to None.

get_storage_format() dict#

Internal method to extract the storage format after formatting the data. This method should not be called directly.

Returns:

The storage format.

Return type:

dict

write_bec_entries() None#

Write the BEC entries to the NeXus file format.