qudi.util.datastorage.NpyDataStorage
- class qudi.util.datastorage.NpyDataStorage(*, root_dir, **kwargs)[source]
Bases:
qudi.util.datastorage.DataStorageBaseHelper class to store (measurement)data on disk as binary .npy file.
- __init__(*, root_dir, **kwargs)[source]
- Parameters:
- root_dirstr, optional
Root directory for this storage instance to work in.
- include_global_metadatabool, optional
Flag indicating whether to save global metadata.
- image_formatImageFormat, optional
Image file format Enum for saving thumbnails.
Methods
__init__(*, root_dir, **kwargs)- Parameters:
add_global_metadata(name[, value, overwrite])Set a single global metadata key-value pair or alternatively multiple ones as dict.
create_header(timestamp, dtype[, metadata, ...])Return a copy of the global metadata dict.
get_unified_metadata([local_metadata])Helper method to return a dictionary containing provided local metadata as well as global metadata depending on the include_global_metadata flag.
load_data(file_path)See
load_data()for more information.remove_global_metadata(names)Remove a global metadata key-value pair by key.
save_data(data, *[, metadata, notes, ...])Saves a binary file containing the data array.
save_thumbnail(mpl_figure, file_path)Save a matplotlib figure visualizing the saved data in the configured image format.
Attributes
- classmethod add_global_metadata(name, value=None, *, overwrite=False)
Set a single global metadata key-value pair or alternatively multiple ones as dict. Metadata added this way will persist for all data storage instances in this process until being selectively removed by calls to “remove_global_metadata”.
- property file_extension
!! processed by numpydoc !!
- classmethod get_global_metadata()
Return a copy of the global metadata dict.
- get_unified_metadata(local_metadata=None)
Helper method to return a dictionary containing provided local metadata as well as global metadata depending on the include_global_metadata flag.
- Parameters:
- local_metadatadict
Metadata to include in addition to global metadata.
- include_global_metadatabool, optional
Flag indicating whether to include global metadata.
- Returns:
- dict
New dictionary containing local metadata and global metadata.
- static load_data(file_path)[source]
See
load_data()for more information.- Parameters:
- file_pathstr
Path to the file to load data from.
- classmethod remove_global_metadata(names)
Remove a global metadata key-value pair by key. Does not raise an error if the key is not found.
- save_data(data, *, metadata=None, notes=None, nametag=None, timestamp=None, column_headers=None, filename=None)[source]
Saves a binary file containing the data array. Also saves alongside a text file containing the notes, (global) metadata, and column headers for this data set. The filename of the text file will be the same as for the binary file appended by “_metadata”.
For more information, see
save_data().- Parameters:
- column_headersstr or list, optional
Data column header strings or a single string.
- save_thumbnail(mpl_figure, file_path)
Save a matplotlib figure visualizing the saved data in the configured image format. It is recommended to use the same file path as the corresponding data file (if applicable) and exclude the file extension (which will be added according to the image format).
- Parameters:
- mpl_figurematplotlib.figure.Figure
The matplotlib figure object to save as an image.
- file_pathstr
Full file path to use without the file extension.
- Returns:
- str
Full absolute path of the saved image.