HDFMapDigiTemplate

class bapsflib._hdf.maps.digitizers.templates.HDFMapDigiTemplate(group: Group)

Bases: ABC

Template class for all digitizer mapping classes to inherit from.

Any inheriting class should define __init__ as:

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

    # define device adc's
    self._device_adcs = ()  # type: Tuple[str, ...]

    # populate self.configs
    self._build_configs()

Note

  • In the code sample above, self._device_adcs is digitizer specific and should be defined as a tuple of strings of analog-digital-converter (adc) names.

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

Parameters:

group – the digitizer HDF5 group

Attributes Summary

active_configs

List of active digitizer configurations

configs

Dictionary containing al the relevant mapping information to translate the HDF5 data into a numpy array by HDFReadData.

device_adcs

Tuple of the analog-digital-convert (adc) names integrated into the digitizer.

device_name

Name of digitizer

group

Instance of the HDF5 digitizer group

info

Digitizer dictionary of meta-info. For example, ::.

Methods Summary

construct_dataset_name(board, channel[, ...])

Constructs the name of the HDF5 dataset containing digitizer data.

construct_header_dataset_name(board, channel)

Construct the name of the HDF5 header dataset associated with the digitizer dataset.

deduce_config_active_status(config_name)

Determines if data was recorded using the configuration specified by config_name.

get_adc_info(board, channel[, adc, config_name])

Get adc setup info dictionary associated with board and channel.

Attributes Documentation

active_configs

List of active digitizer configurations

configs

Dictionary containing al the relevant mapping information to translate the HDF5 data into a numpy array by HDFReadData.

– Constructing configs

The configs dict is a nested dictionary where the first level of keys represents the digitizer configuration names. Each configuration dictionary then consists of a set of non-polymorphic and polymorphic keys. Any additional keys are currently ignored. The non-polymorphic keys are as follows:

Required Non-Polymorphic keys for config=configs['config name']

Key

Description

config['active']

True or False indicating if this configuration was used in recording the digitizer datasets

config['adc']

Tuple of strings naming the adc’s used for this configuration. For example,

('SIS 3301', )
config['config group path']

Internal HDF5 path to the digitizer configuration group. For example,

'/foo/bar/SIS 3301/Configuration: first_run'
config['shotnum']

Dictionary defining how the digitzier shot numbers are recorded. It is assumed, the shot numbers are recorded in the header dataset associated with the main dataset. The dictionary should look like,

config['shotnum'] = {
    'dset field': ('Shot number',),
    'shape': (),
    'dtype': numpy.uint32,
}

where 'dset field' is the field name of the header dataset containing shot numbers, 'shape' is the numpy shape of the shot number data, and 'dtype' is the numpy dtype of the data. This all defines the numpy dtype of the 'shotnum' field in the HDFReadData constructed numpy array.

The required polymorphic keys are the names of each adc listed in configs['config name']['adc']. These entries contain the adc board and channel hookup configuration, as well as, the adc setup configuration for each connected board. Continuing with the example above, this key would look something like

>>> type(config['SIS 3301'])
tuple
>>> type(config['SIS 3301'][0])
tuple
>>> len(config['SIS 3301'][0])
3

where each nested tuple represents one board connection to the adc and is 3 elements long. The breakdown of the nested tuple follows:

Breakdown of Polymorphic Key. (config=configs['config name'])

Key

Description

config['SIS 3301'][0][0]

int representing the connected board number

config['SIS 3301'][0][1]

Tuple[int, ...] representing the connected channel numbers associated with the board number

config['SIS 3301'][0][2]

Dict[str, Any] representing the setup configuration of the adc. The dictionary should look like:

config['SIS 3301'][0][2] = {
    'bit: 10,
    'clock rate':
        astropy.units.Quantity(100.0, unit='MHz'),
    'nshotnum': 10,
    'nt': 10000,
    'sample average (hardware)': None,
    'shot average (software)': None,
}

where 'bit' represents the bit resolution of the adc, 'clock rate' represents the base clock rate of the adc, 'nshotnum' is the number of shot numbers recorded, 'nt' is the number of time samples recorded, 'sample average (hardware)' is the number of time samples averaged together (this and the 'clock rate' make up the 'sample rate'), and 'shot average (software)' is the number of shots intended to be average together.

device_adcs

Tuple of the analog-digital-convert (adc) names integrated into the digitizer.

device_name

Name of digitizer

group

Instance of the HDF5 digitizer group

info

Digitizer dictionary of meta-info. For example,

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

Methods Documentation

abstract construct_dataset_name(board: int, channel: int, config_name=None, adc=None, return_info=False) str | Tuple[str, Dict[str, Any]]

Constructs the name of the HDF5 dataset containing digitizer data.

Parameters:
  • board – board number

  • channel – channel number

  • config_name (str) – digitizer configuration name

  • adc (str) – analog-digital-converter name

  • return_info (bool) – True will return a dictionary of meta-info associated with the digitizer data (DEFAULT False)

Returns:

digitizer dataset name. If return_info=True, then returns a tuple of (dataset name, dictionary of meta-info)

The returned adc information dictionary should look like:

adc_dict = {
    'adc': str,
    'bit': int,
    'clock rate': astropy.units.Quantity,
    'configuration name': str,
    'digitizer': str,
    'nshotnum': int,
    'nt': int,
    'sample average (hardware)': int,
    'shot average (software)': int,
}
Raise:

NotImplementedError

abstract construct_header_dataset_name(board: int, channel: int, config_name=None, adc='', **kwargs) str

Construct the name of the HDF5 header dataset associated with the digitizer dataset. The header dataset stores shot numbers and other shot number specific meta-data. It also has a one- to-one row correspondence with the digitizer dataset.

Parameters:
  • board – board number

  • channel – channel number

  • config_name (str) – digitizer configuration name

  • adc (str) – analog-digital-converter name

Returns:

header dataset name associated with the digitizer dataset

deduce_config_active_status(config_name: str) bool

Determines if data was recorded using the configuration specified by config_name. This is done by comparing the configuration name against the dataset names.

Parameters:

config_name – digitizer configuration name

Returns:

True if the configuration was used in recording the group datasets; otherwise, False

Note

If the digitizer does not use the configuration name in the name of the created datasets, then the subclassing digitzier mapping class should override this method with a rule that is appropriate for the digitizer the class is being designed for.

get_adc_info(board: int, channel: int, adc=None, config_name=None) Dict[str, Any]

Get adc setup info dictionary associated with board and channel.

Parameters:
  • board – board number

  • channel – channel number

  • adc (str) – analog-digital-converter name

  • config_name – digitizer configuration name

Returns:

dictionary of adc setup info (bit, clock rate, averaging, etc.) associated with board* and **channel