File¶
- class bapsflib._hdf.File(name: str, mode='r', control_path='/', digitizer_path='/', msi_path='/', silent=False, **kwargs)¶
Bases:
File
Open a HDF5 file created at the Basic Plasma Science Facility.
All functionality of
h5py.File
is preserved (for details see http://docs.h5py.org/en/latest/)- Parameters:
name – name (and path) of file on disk
mode – readonly
'r'
(DEFAULT) and read/write'r+'
control_path – internal HDF5 path to group containing control devices
digitizer_path – internal HDF5 path to group containing digitizer devices
msi_path – internal HDF5 path to group containing MSI devices
silent – set
True
to suppress warnings (False
DEFAULT)kwargs – additional keywords passed on to
h5py.File
- Example:
>>> # open HDF5 file >>> f = File('sample.hdf5', ... control_path='Raw data + config', ... digitizer_path='Raw data + config', ... msi_path='MSI') >>> type(f) bapsflib._hdf.utils.file.File
Attributes Summary
Dictionary of control device mappings.
Dictionary of digitizer device mappings
HDF5 file map (
HDFMap
)Dictionary of general info on the HDF5 file and the experimental run.
Dictionary of MSI device mappings.
HDF5 file overview.
Methods Summary
read_controls
(controls[, shotnum, ...])Reads data from control device datasets.
read_data
(board, channel[, index, shotnum, ...])Reads data from digitizer datasets and attaches control device data when requested.
read_msi
(msi_diag[, silent])Reads data from MSI Diagnostic datasets.
Attributes Documentation
- controls¶
Dictionary of control device mappings.
- digitizers¶
Dictionary of digitizer device mappings
- info¶
Dictionary of general info on the HDF5 file and the experimental run.
- msi¶
Dictionary of MSI device mappings.
- overview¶
HDF5 file overview. (
HDFOverview
)
Methods Documentation
- read_controls(controls: List[str | Tuple[str, Any]], shotnum=slice(None, None, None), intersection_set=True, silent=False, **kwargs)¶
Reads data from control device datasets. See
HDFReadControls
for more detail.- Parameters:
controls (List[Union[str, Tuple[str, Any]]]) – A list of strings and/or 2-element tuples indicating the control device(s). If a control device has only one configuration then only the device name
'control'
needs to be passed in the list. If a control device has multiple configurations, then the device name and its configuration “name” needs to be passed as a tuple element('control', 'config')
in the list. (seecondition_controls()
for details)shotnum (Union[int, list(int), slice(), numpy.array]) – HDF5 file shot number(s) indicating data entries to be extracted
intersection_set (bool) –
True
(DEFAULT) will force the returned shot numbers to be the intersection ofshotnum
and the shot numbers contained in each control device dataset.False
will return the union instead of the intersection, minus \(shotnum \le 0\). (seeHDFReadControls
for details)silent (bool) –
False
(DEFAULT). SetTrue
to ignore any UserWarnings (soft-warnings)
- Return type:
- Example:
>>> # open HDF5 file >>> f = File('sample.hdf5') >>> >>> # list control devices >>> list(f.controls) ['6K Compumotor', 'Waveform'] >>> >>> # list '6K Compumotor' configurations >>> list(f.controls['6K Compumotor'].configs) [2, 3] >>> >>> # extract all '6k Compumotor' data for configuration 3 >>> cdata = f.read_controls([('6K Compumotor', 3)]) >>> type(cdata) bapsflib._hdf.utils.hdfreadcontrols.HDFReadControls >>> >>> # list 'Waveform' configurations >>> list(f.file_map.controls['Waveform'].configs) ['config01'] >>> >>> # extract 'Waveform' data >>> cdata = f.read_controls(['Waveform']) >>> list(cdata.info['controls']) ['Waveform'] >>> >>> # extract both 'Waveform' and '6K Compumotor' >>> controls = ['Waveform', ('6K Compumotor', 2)] >>> cdata = f.read_controls(controls) >>> list(cdata.info['controls']) ['6K Compumotor', 'Waveform']
- read_data(board: int, channel: int, index=slice(None, None, None), shotnum=slice(None, None, None), digitizer=None, adc=None, config_name=None, keep_bits=False, add_controls=None, intersection_set=True, silent=False, **kwargs)¶
Reads data from digitizer datasets and attaches control device data when requested. (see
hdfreaddata.HDFReadData
for details)- Parameters:
board – digitizer board number
channel – digitizer channel number
index (Union[int, list(int), slice(), numpy.array]) – dataset row index
shotnum (Union[int, list(int), slice(), numpy.array]) – HDF5 global shot number
digitizer (str) – name of digitizer
adc (str) – name of the digitizer’s analog-digital converter
config_name (str) – name of digitizer configuration
keep_bits (bool) –
True
to keep digitizer signal in bits,False
(default) to convert digitizer signal to voltageadd_controls (List[Union[str, Tuple[str, Any]]]) – A list of strings and/or 2-element tuples indicating the control device(s). If a control device has only one configuration then only the device name
'control'
needs to be passed in the list. If a control device has multiple configurations, then the device name and its configuration “name” needs to be passed as a tuple element('control', 'config')
in the list. (seecondition_controls()
for details)intersection_set (bool) –
True
(DEFAULT) will force the returned shot numbers to be the intersection ofshotnum
, the digitizer dataset shot numbers, and, if requested, the shot numbers contained in each control device dataset.False
will return the union instead of the intersection, minus \(shotnum \le 0\). (seeHDFReadData
for details)silent (bool) –
False
(DEFAULT). SetTrue
to ignore any UserWarnings (soft-warnings)
- Return type:
- Example:
>>> # open HDF5 file >>> f = File('sample.hdf5') >>> >>> # list control devices >>> list(f.digitizers) ['SIS crate'] >>> >>> # get active configurations >>> f.digitizers['SIS crate'].configs ['config01', 'config02'] >>> >>> # get active adc's for config >>> f.digitizers['SIS crate'].configs['config01']['adc'] ('SIS 3302,) >>> >>> # get first connected brd and channels to adc >>> brd, chs = f.digitizers['SIS crate'].configs['config01'][ ... 'SIS 3302'][0][0:2] >>> brd 1 >>> chs (1, 2, 3) >>> >>> # get data for brd = 1, ch = 1 >>> data = f.read_data(brd, chs[0], ... digitizer='SIS crate', ... adc='SIS 3302', ... config_name='config01') >>> type(data) bapsflib._hdf.utils.hdfreaddata.HDFReadData >>> >>> # Note: a quicker way to see how the digitizers are >>> # configured is to use >>> # >>> # f.overview.report_digitizers() >>> # >>> # which prints to screen a report of the >>> # digitizer hookup
- read_msi(msi_diag: str, silent=False, **kwargs)¶
Reads data from MSI Diagnostic datasets. See
HDFReadMSI
for more detail.- Parameters:
msi_diag – name of MSI diagnostic
silent (bool) –
False
(DEFAULT). SetTrue
to ignore any UserWarnings (soft-warnings)
- Return type:
- Example:
>>> # open HDF5 file >>> f = File('sample.hdf5') >>> >>> # list msi diagnostics >>> list(f.msi) ['Interferometer array', 'Magnetic field'] >>> >>> # read 'Interferometer array' >>> mdata = f.read_msi('Interferometer array') >>> type(mdata) bapsflib._hdf.utils.hdfreadmsi.HDFReadMSI