8.6.1.6. pymodaq_data.h5modules.saving module
Created the 15/11/2022
@author: Sebastien Weber
- class pymodaq_data.h5modules.saving.DataType(*values)[source]
Bases:
BaseEnum- axis = 'Axis'
- bkg = 'Bkg'
- data = 'Data'
- data_enlargeable = 'EnlData'
- error = 'ErrorBar'
- external_h5 = 'ExtData'
- live_scan = 'Live'
- strings = 'Strings'
- class pymodaq_data.h5modules.saving.FileType(*values)[source]
Bases:
BaseEnum- actuator = 1
- axis = 2
- detector = 0
- scan = 3
- class pymodaq_data.h5modules.saving.H5SaverLowLevel(save_type: SaveType = 'scan', backend='tables')[source]
Bases:
H5BackendObject containing basic methods in order to structure and interact with a h5file compatible with the h5browser
See also
H5Browser- h5_file
object used to save all datas and metadas
- Type:
pytables hdf5 file
- Attributes:
- h5_file
- raw_group
Methods
add_act_group(where[, title, ...])Add a new group of type detector .
add_array(where, name, data_type[, ...])save data arrays on the hdf5 file together with metadata :param where: node where to save the array :type where: GROUP :param name: name of the array in the hdf5 file :type name: str :param data_type: mandatory so that the h5Browser can interpret correctly the array :type data_type: DataType :param data_shape: the shape of the array to save, mandatory if array_to_save is None :type data_shape: Iterable :param data_dimension: The data's dimension :type data_dimension: DataDim :param scan_shape: the shape of the scan dimensions :type scan_shape: Iterable :param title: the title attribute of the array node :type title: str :param array_to_save: data to be saved in the array. If None, array_type and data_shape should be specified in order to init correctly the memory :type array_to_save: ndarray or None :param array_type: eg np.float, np.int32 ... :type array_type: np.dtype or numpy types :param enlargeable: if False, data are saved as a CARRAY, otherwise as a EARRAY (for ragged data, see add_string_array) :type enlargeable: bool :param metadata: dictionnary whose keys will be saved as the array attributes :type metadata: dict :param add_scan_dim: In that case, the array is usually initialized as zero and further populated :type add_scan_dim: if True, the scan axes dimension (scan_shape iterable) is prepended to the array shape on the hdf5.
add_ch_group(where[, title, ...])Add a new group of type channel .
add_data_group(where, data_dim[, title, ...])Creates a group node at given location in the tree
add_det_group(where[, title, ...])Add a new group of type detector .
add_generic_group([where, title, ...])Add a new group of type given by the input argument group_type
add_incremental_group(group_type, where[, ...])Add a node in the h5 file tree of the group type with an increment in the given name :param group_type: one of the possible values of group_types :type group_type: str or GroupType enum :param where: parent node where to create the new group :type where: str or node :param title: node title :type title: str :param settings_as_xml: XML string containing Parameter representation :type settings_as_xml: str :param metadata: extra metadata to be saved with this new group node :type metadata: dict
add_move_group(where[, title, ...])Add a new group of type actuator .
add_scan_group([where, title, ...])Add a new group of type scan
get_groups(where, group_type)Get all groups hanging from a Group and of a certain type
get_node_from_attribute_match(where, ...)Get a Node starting from a given node (Group) matching a pair of node attribute name and value
get_node_from_title(where, title)Get a Node starting from a given node (Group) matching the given title
get_set_group(where, name[, title])Get the group located at where if it exists otherwise creates it
get_set_logger([where])Retrieve or create (if absent) a logger enlargeable array to store logs Get attributed to the class attribute
logger_array:param where: location within the tree where to save or retrieve the array :type where: nodeinit_file(file_name[, raw_group_name, ...])Initializes a new h5 file.
add_log
add_string_array
get_last_group
save_file
- add_act_group(where, title='', settings_as_xml='', metadata=None)[source]
Add a new group of type detector .. seealso::
add_incremental_group
- add_array(where: GROUP | str, name: str, data_type: DataType, array_to_save: ndarray = None, data_shape: tuple = None, array_type: dtype = None, data_dimension: DataDim = None, scan_shape: tuple = (), add_scan_dim=False, enlargeable: bool = False, title: str = '', metadata={})[source]
save data arrays on the hdf5 file together with metadata :param where: node where to save the array :type where: GROUP :param name: name of the array in the hdf5 file :type name: str :param data_type: mandatory so that the h5Browser can interpret correctly the array :type data_type: DataType :param data_shape: the shape of the array to save, mandatory if array_to_save is None :type data_shape: Iterable :param data_dimension: The data’s dimension :type data_dimension: DataDim :param scan_shape: the shape of the scan dimensions :type scan_shape: Iterable :param title: the title attribute of the array node :type title: str :param array_to_save: data to be saved in the array. If None, array_type and data_shape should be specified in order to init
correctly the memory
- Parameters:
array_type (np.dtype or numpy types) – eg np.float, np.int32 …
enlargeable (bool) – if False, data are saved as a CARRAY, otherwise as a EARRAY (for ragged data, see add_string_array)
metadata (dict) – dictionnary whose keys will be saved as the array attributes
add_scan_dim (if True, the scan axes dimension (scan_shape iterable) is prepended to the array shape on the hdf5) – In that case, the array is usually initialized as zero and further populated
- Return type:
See also
add_data,add_string_array
- add_ch_group(where, title='', settings_as_xml='', metadata=None)[source]
Add a new group of type channel .. seealso::
add_incremental_group
- add_data_group(where, data_dim: DataDim, title='', settings_as_xml='', metadata=None)[source]
Creates a group node at given location in the tree
- Parameters:
where (group node) – where to create data group
group_data_type (DataDim)
title (str, optional) – a title for this node, will be saved as metadata
settings_as_xml (str, optional) – XML string created from a Parameter object to be saved as metadata
metadata (dict, optional) – will be saved as a new metadata attribute with name: key and value: dict value
- Returns:
group
- Return type:
group node
See also
add_group()
- add_det_group(where, title='', settings_as_xml='', metadata=None)[source]
Add a new group of type detector .. seealso::
add_incremental_group
- add_generic_group(where='/RawData', title='', settings_as_xml='', metadata=None, group_type=GroupType.scan)[source]
Add a new group of type given by the input argument group_type
At creation adds the attributes description and scan_done to be used elsewhere
See also
- add_incremental_group(group_type: str | GroupType | Enum, where, title='', settings_as_xml='', metadata=None)[source]
Add a node in the h5 file tree of the group type with an increment in the given name :param group_type: one of the possible values of group_types :type group_type: str or GroupType enum :param where: parent node where to create the new group :type where: str or node :param title: node title :type title: str :param settings_as_xml: XML string containing Parameter representation :type settings_as_xml: str :param metadata: extra metadata to be saved with this new group node :type metadata: dict
- Returns:
node
- Return type:
newly created group node
- add_move_group(where, title='', settings_as_xml='', metadata=None)[source]
Add a new group of type actuator .. seealso::
add_incremental_group
- add_scan_group(where='/RawData', title='', settings_as_xml='', metadata=None)[source]
Add a new group of type scan
deprecated, use add_generic_group with a group type as GroupType.scan
- get_groups(where: str | GROUP, group_type: str | GroupType | BaseEnum)[source]
Get all groups hanging from a Group and of a certain type
- get_node_from_attribute_match(where, attr_name, attr_value)[source]
Get a Node starting from a given node (Group) matching a pair of node attribute name and value
- get_node_from_title(where, title: str)[source]
Get a Node starting from a given node (Group) matching the given title
- get_set_group(where, name, title='', **kwargs)[source]
Get the group located at where if it exists otherwise creates it
This also set the _current_group property
- get_set_logger(where: Node = None) VLARRAY[source]
Retrieve or create (if absent) a logger enlargeable array to store logs Get attributed to the class attribute
logger_array:param where: location within the tree where to save or retrieve the array :type where: node- Returns:
enlargeable array accepting strings as elements
- Return type:
vlarray
- init_file(file_name: Path, raw_group_name='RawData', new_file=False, metadata: dict = None)[source]
Initializes a new h5 file.
- Parameters:
- Returns:
True if new file has been created, False otherwise
- Return type:
- property h5_file
- property raw_group