HDFMapControlCLTemplateο
- class bapsflib._hdf.maps.controls.templates.HDFMapControlCLTemplate(group: Group)ο
Bases:
HDFMapControlTemplate,ABCA modified
HDFMapControlTemplatetemplate class for mapping control devices that record data around the concept of a command list.Note
If the control device is NOT structured around a command list, then its mapping class should subclass
HDFMapControlTemplateinstead.To fully define a subclass there are several abstract methods that need to be defined, which includes
-
- abstractmethod _build_configs()ο
Inspect the HDF5 group and build the configuration dictionary,
configs.Functionality should specifically populate
self._configsinstead ofself.configs. If a mapping fails, then aHDFMappingErrorshould be raised.
- abstractmethod _default_state_values_dict(config_name: str) dictο
Returns the default
'state values'dictionary for configuration config_name.- Parameters:
config_name (
str) β configuration name
Examples
# define default dict default_dict = { 'command': { 'dset paths': self._configs[config_name]['dese paths'], 'dset field': ('Command index', ), 're pattern': None, 'command list': self._configs[config_name]['command list'], 'cl str': self._configs[config_name]['command list'], 'shape': (), } } default_dict['command']['dtype'] = \ default_dict['command']['command list'].dtype # return return default_dict
If a subclass needs to initialize additional variables before
_build_configsis called in the__init__, then those routines can be defined in the_init_before_build_configsmethod.- _init_before_build_configs()
Any initialization that needs to be performed before executing
self._build_configsin__init__.By default we do nothing, but subclasses can override this for their specific purposes.
- Parameters:
group (
h5py.Group) β The HDF5 to apply the mapping to.
Attributes Summary
Dictionary containing all the relevant mapping information to translate the corresponding device data in the HDF5 file and provide a consistent user interface via
File.Control device type.
List of names of the HDF5 datasets within the mapped group, at the root level.
Name of Control device
Instance of the HDF5 group that was mapped.
Name of the mapped HDF5 group.
Path of the mapped HDF5 group in the HDF5 file.
Trueif the control device utilizes a command listMetadata information about the mapping type and the mapped group location in the HDF5 file.
Mapping class type (
MapTypes).Trueif each control configuration has its own datasetList of names of the HDF5 subgroups within the mapped group, at the root level.
Methods Summary
clparse(config_name)Return instance of
CLParseforconfig_name.construct_dataset_name(*args)Constructs the dataset name corresponding to the input arguments.
get_config_column_value(config_name)For the given configuration name
config_nameget the associated configuration value that would be in the configuration column of the associated HDF5 datasets.process_config_name(config_name)Process a given configuration name
config_nameand return the conditioned configuration name.reset_state_values_config(config_name[,Β ...])Reset the
configs[config_name]['state values']dictionary.set_state_values_config(config_name,Β patterns)Rebuild and set
configs[config_name]['state values']based on the supplied RE patterns.Attributes Documentation
- configsο
Dictionary containing all the relevant mapping information to translate the corresponding device data in the HDF5 file and provide a consistent user interface via
File.Notes
When a control device saves around the concept of a command list, then
configsshares the same structure as theHDFMapControlTemplateconfigsβ¦with a couple alterations. There is now a required'command list'key, and the'state values'needs additional information.The modified required keys look like:
Additional command list required keys for config = configs['config name']οKey
Description
config['command list']
A
tuplerepresenting the original command list. For example,config['command list'] = ( 'VOLT: 20.0', 'VOLT 25.0', 'VOLT 30.0', )
config['state values']
Has all the same keys as before, plus the addition of
'command list','cl str', andre pattern. For example,config['state values'] = { 'command': { 'dset paths': config['dset paths'], 'dset field': ('Command index',), 'shape': (), 'dtype': numpy.float32, 'command list': (20.0, 25.0, 30.0), 'cl str': ('VOLT: 20.0', 'VOLT 25.0', 'VOLT 30.0'), 're pattern': re.compile(r'some RE pattern'), }, }
where
're pattern'is the compiled RE pattern used to parse the original command list,'cl str'is the matched string segment of the command list, and'command list'is the set of values that will populate the constructed numpy array.
- contypeο
Control device type.
- dataset_namesο
List of names of the HDF5 datasets within the mapped group, at the root level.
- device_nameο
Name of Control device
- groupο
Instance of the HDF5 group that was mapped.
- group_nameο
Name of the mapped HDF5 group.
- group_pathο
Path of the mapped HDF5 group in the HDF5 file.
- has_command_listο
Trueif the control device utilizes a command list
- infoο
Metadata information about the mapping type and the mapped group location in the HDF5 file.
Extended Summaryο
The dictionary will contain the following elements:
info = { "group name": "Device", # name of the mapped HDF5 group "group path": "/foo/bar/Device", # internal HDF5 path to the group "maptype": self.maptype, # mapping class type "contype": self.contype, # control device type }
- maptypeο
Mapping class type (
MapTypes).
- subgroup_namesο
List of names of the HDF5 subgroups within the mapped group, at the root level.
Methods Documentation
- clparse(config_name: str) CLParseο
Return instance of
CLParseforconfig_name.- Parameters:
config_name (
str) β configuration name
- abstractmethod construct_dataset_name(*args) strο
Constructs the dataset name corresponding to the input arguments.
- Returns:
name of dataset
- Return type:
- get_config_column_value(config_name: str | int) str | Noneο
For the given configuration name
config_nameget the associated configuration value that would be in the configuration column of the associated HDF5 datasets.Typically, the column value is just
config_name, but subclasses may override this to provide more sophisticated behavior. For example, ifconfig_nameis a mash-up of the column value and some other specifier, then this method can be used to do the properregexto pull out the column value fromconfig_name.
- process_config_name(config_name: str | int) str | intο
Process a given configuration name
config_nameand return the conditioned configuration name.The conditioned configuration name is a key to the mapped
configsdictionary.Typically, the conditioned configuration name is just the given
config_name, but subclasses may override this method to allow desired βnicknamesβ to be conditioned into valid configuration names.Note
This method is integrated into
condition_controls, which is used byHDFReadDataandHDFReadControlsto condition the respective argumentsadd_controlsandcontrols. This integration is why the nickname mapping implemented here is available in theHDFReadDataandHDFReadControlsclasses, as well as the read data methods ofFile.