HDFMapMSITemplate

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

Bases: ABC

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

Any inheriting class should define __init__ as:

def __init__(self, group: h5py.Group):
    """
    :param group: HDF5 group object
    """
    # initialize
    HDFMapMSITemplate.__init__(self, group)

    # populate self.configs
    self._build_configs()

Note

Any method that raises a NotImplementedError is intended to be overwritten by the inheriting class.

Parameters:

group – the MSI diagnostic HDF5 group

Attributes Summary

configs

Dictionary containing all the relevant mapping information to translate the HDF5 data into a numpy array.

device_name

Name of MSI diagnostic (device)

group

Instance of MSI diagnostic group

info

MSI diagnostic dictionary of meta-info. For example, ::.

Attributes Documentation

configs

Dictionary containing all the relevant mapping information to translate the HDF5 data into a numpy array. The actually numpy array construction is done by HDFReadMSI.

– Constructing configs

The configs dict is broken into a set of required keys ('shape', 'shotnum', 'signals', and 'meta') and optional keys. Any option key is considered as meta-info for the device and is added to the info dictionary when the numpy array is constructed. The required keys constitute the mapping for constructing the 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 diagnostic’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']

This is another dictionary where each key will map to a field in the HDFReadMSI numpy array. For example,

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

would created 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.

device_name

Name of MSI diagnostic (device)

group

Instance of MSI diagnostic group

info

MSI diagnostic dictionary of meta-info. For example,

info = {
    'group name': 'Diagnostic',
    'group path': '/foo/bar/Diagnostic',
}