8.5.2.3. pymodaq_gui.h5modules.saving module
Created the 15/11/2022
@author: Sebastien Weber
- class pymodaq_gui.h5modules.saving.H5Saver(*args, **kwargs)[source]
Bases:
H5SaverBase,QObject- status_sig: Signal
emits a signal of type Threadcommand in order to senf log information to a main UI
- new_file_sig: Signal
emits a boolean signal to let the program know when the user pressed the new file button on the UI
Methods
emit_new_file(status)Emits the new_file_sig
close
new_file_sig
show_file_content
status_sig
- emit_new_file(status)[source]
Emits the new_file_sig
- Parameters:
status (bool) – emits True if a new file has been asked by the user pressing the new file button on the UI
- new_file_sig
int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Type:
pyqtSignal(*types, name
- Type:
str = …, revision
- status_sig
int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Type:
pyqtSignal(*types, name
- Type:
str = …, revision
- class pymodaq_gui.h5modules.saving.H5SaverBase(save_type='scan', backend='tables')[source]
Bases:
H5SaverLowLevel,ParameterManagerObject containing all methods in order to save datas in a hdf5 file with a hierarchy compatible with the H5Browser. The saving parameters are contained within a Parameter object: self.settings that can be displayed on a UI using the widget self.settings_tree. At the creation of a new file, a node group named Raw_data and represented by the attribute
raw_groupis created and set with a metadata attribute:‘type’ given by the save_type class parameter
The root group of the file is then set with a few metadata:
‘pymodaq_version’ the current pymodaq version, e.g. 1.6.2
‘pymodaq_data_version’ the current pymodaq_data version, e.g. 0.0.1
‘file’ the file name
‘date’ the current date
‘time’ the current time
All data will then be saved under this node in various groups
See also
H5Browser- Parameters:
h5_file (pytables hdf5 file) – object used to save all datas and metadas
h5_file_path (str or Path) – Signal signal represented by a float. Is emitted each time the hardware reached the target position within the epsilon precision (see comon_parameters variable)
save_type (str) – an element of the enum module attribute SaveType * ‘scan’ is used for DAQScan module and should be used for similar application * ‘detector’ is used for DAQ_Viewer module and should be used for similar application * ‘custom’ should be used for customized applications
- settings
Parameter instance (pyqtgraph) containing all settings (could be represented using the settings_tree widget)
- Type:
Parameter
- settings_tree
Widget representing as a Tree structure, all the settings defined in the class preamble variable
params- Type:
Methods
find_part_in_path_and_subpath(base_dir[, ...])Find path from part time.
Gets the last scan node within the h5_file and under the raw_group
return the scan group index in the "scan templating": Scan000, Scan001 as an integer
init_file([update_h5, custom_naming, ...])Initializes a new h5 file.
load_file([base_path, file_path])Opens a file dialog to select a h5file saved on disk to be used
set_current_scan_path(base_dir[, base_name, ...])update_file_paths([update_h5])value_changed(param)Non-mandatory method to be subclassed for actions to perform (methods to call) when one of the param's value in self._settings is changed
get_scan_groups
save_file
show_settings
update_status
- classmethod find_part_in_path_and_subpath(base_dir, part='', create=False, increment=True)[source]
Find path from part time.
Parameters
Type
Description
base_dir
Path object
The directory to browse
part
string
The date of the directory to find/create
create
boolean
Indicate the creation flag of the directory
- Returns:
found path from part
- Return type:
Path object
- classmethod set_current_scan_path(base_dir, base_name='Scan', update_h5=False, next_scan_index=0, create_scan_folder=False, create_dataset_folder=True, curr_date=None, ind_dataset=None)[source]
- Parameters:
base_dir
base_name
update_h5
next_scan_index
create_scan_folder
create_dataset_folder
- get_last_scan()[source]
Gets the last scan node within the h5_file and under the raw_group
- Returns:
scan_group
- Return type:
pytables group or None
- get_scan_index()[source]
return the scan group index in the “scan templating”: Scan000, Scan001 as an integer
- init_file(update_h5=False, custom_naming=False, addhoc_file_path=None, metadata={})[source]
Initializes a new h5 file. Could set the h5_file attributes as:
a file with a name following a template if
custom_namingisFalseandaddhoc_file_pathisNonea file within a name set using a file dialog popup if
custom_namingisTruea file with a custom name if
addhoc_file_pathis aPathobject or a path string
- Parameters:
update_h5 (bool) – create a new h5 file with name specified by other parameters if false try to open an existing file and will append new data to it
custom_naming (bool) – if True, a selection file dialog opens to set a new file name
addhoc_file_path (Path or str) – supplied name by the user for the new file
metadata (dict) – dictionnary with pair of key, value that should be saved as attributes of the root group
- Returns:
update_h5 – True if new file has been created, False otherwise
- Return type:
- load_file(base_path=None, file_path=None)[source]
Opens a file dialog to select a h5file saved on disk to be used
- Parameters:
base_path
file_path
See also
- update_file_paths(update_h5=False)[source]
- Parameters:
update_h5 (bool) – if True, will increment the file name and eventually the current scan index if False, get the current scan index in the h5 file
- Returns:
scan_path (Path)
current_filename (str)
dataset_path (Path)
- value_changed(param)[source]
Non-mandatory method to be subclassed for actions to perform (methods to call) when one of the param’s value in self._settings is changed
For this to be triggered, the Parameter method: setValue should be used
- Parameters:
param (Parameter) – the parameter whose value just changed
Examples
>>> if param.name() == 'do_something': >>> if param.value(): >>> print('Do something') >>> self.settings.child('main_settings', 'something_done').setValue(False)
- params = [{'limits': ['scan', 'detector', 'logger', 'custom', 'actuator', 'optimizer'], 'name': 'save_type', 'readonly': True, 'title': 'Save type:', 'type': 'list'}, {'name': 'save_2D', 'title': 'Save 2D datas and above:', 'type': 'bool', 'value': True}, {'name': 'save_raw_only', 'title': 'Save raw datas only:', 'tooltip': 'if True, will not save extracted ROIs used to do live plotting, only raw datas will be saved', 'type': 'bool', 'value': True}, {'default': False, 'name': 'do_save', 'title': 'Do Save:', 'type': 'bool', 'value': False}, {'default': 0, 'name': 'N_saved', 'title': 'N saved:', 'type': 'int', 'value': 0, 'visible': False}, {'children': [{'limits': ['tables'], 'name': 'backend_type', 'readonly': True, 'title': 'Backend type:', 'type': 'list'}, {'children': [{'name': 'endpoint', 'readonly': False, 'title': 'Endpoint:', 'type': 'str', 'value': 'http://hsds.sebastienweber.fr'}, {'name': 'user', 'readonly': False, 'title': 'User:', 'type': 'str', 'value': 'pymodaq_user'}, {'name': 'password', 'readonly': False, 'title': 'password:', 'type': 'str', 'value': 'pymodaq'}], 'name': 'hsds_options', 'title': 'HSDS Server:', 'type': 'group', 'visible': False}], 'name': 'backend', 'title': 'Backend:', 'type': 'group'}, {'default': False, 'name': 'custom_name', 'title': 'custom_name?:', 'type': 'bool', 'value': False}, {'default': False, 'name': 'show_file', 'title': 'show file content?', 'type': 'bool_push', 'value': False}, {'filetype': False, 'name': 'base_path', 'readonly': True, 'title': 'Base path:', 'type': 'browsepath', 'value': 'C:\\Data'}, {'name': 'base_name', 'readonly': True, 'title': 'Base name:', 'type': 'str', 'value': 'Scan'}, {'name': 'current_scan_name', 'readonly': True, 'title': 'Current scan:', 'type': 'str', 'value': ''}, {'name': 'current_scan_path', 'readonly': True, 'title': 'Current path:', 'type': 'text', 'value': 'C:\\Data', 'visible': False}, {'name': 'current_h5_file', 'readonly': True, 'title': 'h5file:', 'type': 'text', 'value': ''}, {'name': 'new_file', 'title': 'New file', 'type': 'action'}, {'limits': ['uint8', 'int8', 'uint16', 'int16', 'uint32', 'int32', 'uint64', 'int64', 'float64'], 'name': 'dynamic', 'title': 'Saving dynamic', 'type': 'list', 'value': 'float64'}, {'children': [{'limits': ['zlib', 'gzip'], 'name': 'h5comp_library', 'title': 'Compression library:', 'type': 'list', 'value': 'zlib'}, {'max': 9, 'min': 0, 'name': 'h5comp_level', 'title': 'Compression level:', 'type': 'int', 'value': 5}], 'name': 'compression_options', 'title': 'Compression options:', 'type': 'group'}]
- settings_name = 'h5saver_settings'