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
- 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 metadash5_file_path (
strorPath) – 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:
ParameterTree
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)get_params_for_save_type
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 grouporNone
- 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 itcustom_naming (
bool) – if True, a selection file dialog opens to set a new file nameaddhoc_file_path (
Pathorstr) – supplied name by the user for the new filemetadata (
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
- 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', 'h5py'], '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'}, {'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'