MODULE REFERENCE

daq

anomx.data.sources.daq

Optional, isolated readers for scalar fields in native FLASH/XFEL DAQ files.

DaqReadError

DaqReadError

Bases: RuntimeError

The optional native reader failed, timed out or returned an unsupported record.

DaqRecord

DaqRecord(timestamp: float, event_id: int, channel: str, values: Mapping[str, float | None], invalid_fields: Mapping[str, str], field_metadata: Mapping[str, Mapping[str, Any]], source_path: str, dataset_version: str, record_index: int)

One native event, without inferred time units, calibration or physical labels.

Signature parameters
ParameterTypeDefault
timestampfloatrequired
event_idintrequired
channelstrrequired
valuesMapping[str, float | None]required
invalid_fieldsMapping[str, str]required
field_metadataMapping[str, Mapping[str, Any]]required
source_pathstrrequired
dataset_versionstrrequired
record_indexintrequired

Members

timestampattribute
event_idattribute
channelattribute
valuesattribute
values: Mapping[str, float | None]
invalid_fieldsattribute
invalid_fields: Mapping[str, str]
field_metadataattribute
field_metadata: Mapping[str, Mapping[str, Any]]
source_pathattribute
dataset_versionattribute
record_indexattribute

iter_daq_records

iter_daq_records(source: MountedSource, *, channel: str, fields: Mapping[str, int], experiment: str, linac: str, python_executable: str | None = None, environment: Mapping[str, str] | None = None, batch_size: int = 128, timeout_seconds: float = 60.0, limit: int | None = None) -> Iterator[DaqRecord]

Read explicit scalar subchannels using one isolated native process per source.

fields maps output aliases to native subchannel indices. Actual native names/types are retained, never guessed. Nonfinite values become None with an explicit invalid_fields reason. Timestamps and macropulse IDs are preserved numerically; their scientific interpretation belongs to the caller. Missing requested fields or unsupported shapes fail closed.

python_executable can select a separate Python with a compatible pydaq ABI. environment extends its environment (for example library paths). No pydaq dependency is imported in the parent. Data is transferred in batches through a bounded pipe/queue, not a new process per record. timeout_seconds bounds waiting for startup, each batch or completion. Source size/time/identity are checked by MountedSource.open around the read. Close the iterator explicitly when stopping early, e.g. with contextlib.closing. No content hash is implied by metadata validation.

Signature parameters
ParameterTypeDefault
sourceMountedSourcerequired
channelkeyword onlystrrequired
fieldskeyword onlyMapping[str, int]required
experimentkeyword onlystrrequired
linackeyword onlystrrequired
python_executablekeyword onlystr | NoneNone
environmentkeyword onlyMapping[str, str] | NoneNone
batch_sizekeyword onlyint128
timeout_secondskeyword onlyfloat60.0
limitkeyword onlyint | NoneNone

Returns Iterator[DaqRecord]