Data Storage

class lys_instr.DataStorage.DataStorage(**kwargs)[source]

Bases: QObject

Threaded data storage and file management for multi-dimensional data.

This class reserves disk space for data arrays, buffers and updates them with new values, and saves the buffered data to disk. Saving is performed asynchronously in a background thread, keeping the main application responsive. Qt signals are emitted to notify when the save path or saving state changes.

Parameters:

**kwargs – Additional keyword arguments passed to QObject.

property base

Returns the base directory for saving data files.

Returns:

Base directory.

Return type:

str

connect(detector)[source]

Connects this DataStorage instance to a detector.

Parameters:

detector (object) – Detector instance emitting dataAcquired and busyStateChanged signals.

property enabled

Returns whether the DataStorage instance is enabled.

Returns:

True if the DataStorage instance is enabled, False otherwise.

Return type:

bool

property folder

Returns the data folder name under base directory.

Returns:

Data folder name.

Return type:

str

getNumber()[source]

Gets the next available file number for saving.

The number will be appended to the file name when saving if automatic numbering is enabled.

Returns:

Next available file number, or None if numbering is disabled.

Return type:

int or None

property name

Returns the base file name for saving data files.

Returns:

File name.

Return type:

str

property numbered

Returns whether automatic file numbering is enabled.

Returns:

True if automatic file numbering is enabled, False otherwise.

Return type:

bool

reserve(shape, fillValue=None)[source]

Reserves storage for a new data array with the specified shape.

Parameters:
  • shape (tuple, optional) – Shape of the data array to reserve.

  • fillValue (float, optional) – Value to initialize the array with (default: NaN).

save(axes)[source]

Saves the buffered data array asynchronously to disk.

This method starts a worker thread to write the buffered data array and emits signals for path and saving state updates.

property saving

Returns whether a save operation is currently 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.

update(data)[source]

Updates the buffered data array with new values.

Parameters:
  • indexShape (tuple) – Index shape for the data.

  • data (dict[str, np.ndarray]) – Dictionary mapping indices to data arrays for updating the buffer.

class lys_instr.gui.DataStorage.DataStorageGUI(obj)[source]

Bases: QWidget