HDFMapMSITemplate

class bapsflib._hdf.maps.msi.templates.HDFMapMSITemplate(group: Group)

Bases: HDFMapTemplate, ABC

Template class for all MSI diagnostic mapping classes to inherit from.

Note

  • To fully define a subclass the _build_configs abstract method needs to be defined.

    abstractmethod _build_configs()

    Inspect the HDF5 group and build the configuration dictionary, configs.

    Functionality should specifically populate self._configs instead of self.configs. If a mapping fails, then a HDFMappingError should be raised.

  • If a subclass needs to initialize additional variables before _build_configs is called in the __init__, then those routines can be defined in the _init_before_build_configs method.

    _init_before_build_configs()

    Any initialization that needs to be performed before executing self._build_configs in __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

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.

dataset_names

List of names of the HDF5 datasets within the mapped group, at the root level.

device_name

Name of MSI diagnostic (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.

info

Metadata information about the mapping type and the mapped group location in the HDF5 file.

maptype

Mapping class type (MapTypes).

subgroup_names

List of names of the HDF5 subgroups within the mapped group, at the root level.

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

The information stored in this configs dictionary is used by HDFReadMSI to build the MSI numpy array from the associated HDF5 dataset(s).

The configs dict is broken into a set of required keys ('shape', 'shotnum', 'signals', and 'meta') and optional keys. The required keys are used by HDFReadMSI to extract the MSI data and build the numpy arrays. Any optional key is considered as meta-data and is included in the info attribute of the constructed MSI numpy array.

Key

Description

configs['shape']

This is used as the shape for the HDFReadMSI constructed numpy array and typically looks like:

configs['shape'] = (nsn, )

where nsn is the number of shot numbers saved to the diagnostics’s datasets.

configs['shotnum']

Specifies the dataset(s) containing the recorded HDF5 shot numbers. This maps to the 'shotnum' field of the numpy array constructed by HDFReadMSI. Should look like:

configs['shotnum'] = {
    'dset paths': ('/foo/bar/d1',),
    'dset field': ('Shot number',),
    'shape': (),
    'dtype': numpy.int32,
}

where 'dset paths' is the internal HDF5 path to the dataset(s), 'dset field' is the field name of the dataset containing shot numbers, 'shape' of the shot number data, and 'dtype' is the numpy dtype that the 'shotnum' field of the constructed numpy array will be.

configs['signals']

A dictionary that maps MSI data signals to the numpy array constructed by HDFReadMSI. Each key in this dictionary corresponds to a field name in HDFReadMSI array and the value defines the data location in the HDF5 file. For example,

configs['signals'] = {
    'current': {
        'dset paths': ('/foo/bar/dset',),
        'dset field': (),
        'shape': (100,),
        'dtype': numpy.float32,
    },
}

would create a 'current' field in the constructed numpy array. Any field specified in this key is considered to be your plot-able, or “primary”, diagnostic data.

configs['meta']

This is another dictionary specifying meta-data that is both diagnostic and shot number specific. For example,

configs['meta'] = {
    'shape': (),
    'max current': {
        'dset paths': ('/foo/bar/dset',),
        'dset field': ('Max current',),
        'shape': (),
        'dtype': numpy.float32},
}

would create a 'max current' field in the 'meta' field of the constructed numpy array.

Note

For further details, look to Adding a MSI Diagnostic Mapping Module.

dataset_names

List of names of the HDF5 datasets within the mapped group, at the root level.

device_name

Name of MSI diagnostic (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.

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
}
maptype

Mapping class type (MapTypes).

subgroup_names

List of names of the HDF5 subgroups within the mapped group, at the root level.