Storage
- class lys_instr.DataStorage.DataStorage(**kwargs)[source]
Bases:
QObjectThreaded, asynchronous storage and file management for multi-dimensional data.
This class reserves disk-backed arrays for incoming frames, buffers updates, and saves buffered data to disk using a background worker thread so the application remains responsive. It emits Qt signals to report saving state and to request metadata tags for saved files.
- property base
Base directory for saving data files.
- Returns:
Base directory.
- Return type:
str
- connect(detector)[source]
Connect this data storage instance to a detector.
- Parameters:
detector (
MultiDetectorInterface) – Detector that emitsdataAcquiredandbusyStateChangedsignals.
- property enabled
Whether the data storage instance is enabled.
- Returns:
True if enabled, False otherwise.
- Return type:
bool
- property folder
Data folder name under the base directory.
- Returns:
Data folder name.
- Return type:
str
- getNumber()[source]
Return the next available file number for saving.
If automatic numbering is enabled the returned number will be appended to the base file name (for example:
<name>_<number>.npz). If numbering is disabled this method returnsNone.- Returns:
Next available file number, or
Noneif numbering is disabled.- Return type:
int | None
- property name
Base file name used when saving data files.
- Returns:
File name.
- Return type:
str
- numberChanged
Signal emitted when the next available file number changes.
- property numbered
Whether automatic file numbering is enabled.
- Returns:
True if automatic file numbering is enabled, False otherwise.
- Return type:
bool
- reserve(shape, fillValue=None)[source]
Reserve storage for a new data array with the specified shape.
Allocate and initialize an internal NumPy array with the given shape, record a file path and tag for the upcoming save, emit
tagRequestto request metadata, and update saving state via thesavingStateChangedsignal.- Parameters:
shape (tuple, optional) – Shape of the data array to reserve.
fillValue (float | None, optional) – Value to initialize the array with. If
Nonethe array is initialized with NaNs. Defaults toNone.
- Returns:
None
- save(axes)[source]
Save the buffered data array asynchronously to disk.
This method constructs a
lys.Wavefrom the buffered array and provided coordinate arrays, attaches the queued metadata tag tolys.Wave.note, and enqueues the Wave for export on a background worker thread. Actual file write occurs in a_SaveThread.- Parameters:
axes (Sequence[np.ndarray]) – Coordinate arrays for each data axis used to construct the
Wave.
- property saving
Whether a save operation is in progress.
- Returns:
True if a save operation is in progress, False otherwise.
- Return type:
bool
- savingStateChanged
Signal (bool) emitted when saving state changes.
- tagRequest
Signal (dict) emitted to request metadata tags.