class bapsflib._hdf.utils.hdfreadmsi.HDFReadMSI

Bases: numpy.ndarray

Reads MSI diagnostic data from the HDF5 file.

This class constructs and returns a structured numpy array. The data in the array is grouped in three categories:

  1. shot numbers which are contained in the 'shotnum' field

  2. metadata data that is both shot number and diagnostic specific which is stored in the sub-fields of the 'meta' field

  3. recorded data arrays which get unique fields based on their mapping configs attribute

Data that is not shot number specific is stored in the info attribute.

  • hdf_file (File) – HDF5 file object

  • dname (str) – name of desired MSI diagnostic


Here the 'Discharge' MSI diagnostic is used as an example:

>>> # open HDF5 file
>>> f = bapsflib.lapd.File('test.hdf5')
>>> # read MSI data
>>> # - this is equivalent to f.read_msi('Discharge')
>>> mdata = HDFReadMSI(f, 'Discharge')
>>> mdata.dtype
dtype([('shotnum', '<i4'),
       ('voltage', '<f4', (2048,)),
       ('current', '<f4', (2048,)),
       ('meta', [('timestamp', '<f8'),
                 ('data valid', 'i1'),
                 ('pulse length', '<f4'),
                 ('peak current', '<f4'),
                 ('bank voltage', '<f4')])])
>>> # display shot numbers
>>> mdata['shotnum']
array([    0, 19251], dtype=int32)
>>> # fields 'voltage' and 'current' belong to data arrays
>>> # - show first 3 elements of 'voltage' for shot number 0
>>> mdata['voltage'][0,0:3:]
array([-46.99707 , -46.844482, -46.99707], dtype=float32)
>>> # display peak current for shot number 0
>>> mdata['meta']['peak current'][0]
>>> # the `info` attribute has diagnostic specific data
>>> mdata.info
{'current conversion factor': [0.0],
 'device name': 'Discharge',
 'device group path': '/MSI/Discharge',
 'dt': [4.88e-05],
 'source file': '/foo/bar/test.hdf5',
 't0': [-0.0249856],
 'voltage conversion factor': [0.0]}
>>> # get time step for the data arrays
>>> mdata.info['dt'][0]

Attributes Summary


A dictionary of meta-info for the MSI diagnostic.

Attributes Documentation


A dictionary of meta-info for the MSI diagnostic.