HDFReadData¶
- class bapsflib._hdf.utils.hdfreaddata.HDFReadData(hdf_file: File, board: int, channel: int, index=slice(None, None, None), shotnum=slice(None, None, None), digitizer=None, config_name=None, adc=None, keep_bits=False, add_controls=None, intersection_set=True, **kwargs)¶
Bases:
ndarrayReads digitizer and control device data from the HDF5 file. Control device data is extracted using
HDFReadControlsand combined with the digitizer data.This class constructs and returns a structured numpy array. The data in the array is grouped into three categories:
shot numbers which are contained in the
'shotnum'fielddigitizer data which is contained in the
'signal'fieldcontrol device data which is represented by the remaining fields in the numpy array. These field names are polymorphic and are defined by the control device mapping class. (see
HDFReadControlsfor more detail)
Data that is not shot number specific is stored in the
infoattribute.Note
Evey returned numpy array will have the
'xyz'field, which is reserved for probe position data. If a control device specifies this field, then field will be filled with the control device data;otherwise, the field will be filled withnumpy.nanvalues.
- Parameters
hdf_file – HDF5 file object
board – analog-digital-converter board number
channel – analog-digital-converter channel number
index (Union[int, List[int], slice, numpy.ndarray]) – dataset row indices to be sliced (overridden by
shotnum)shotnum (Union[int, List[int], slice, numpy.ndarray]) – HDF5 file shot number(s) indicating data entries to be extracted (overrides
index)digitizer (str) – digitizer name
adc (str) – name of analog-digital-converter
config_name (str) – name of the digitizer configuration
keep_bits (bool) – set
Trueto keep data in bits,False(DEFAULT) to convert data to voltageadd_controls – a list indicating the desired control device names and their configuration name (if more than one configuration exists)
intersection_set (bool) –
True(DEFAULT) will force the returned shot numbers to be the intersection ofshotnumand the shot numbers contained in each control device and digitizer dataset.Falsewill return the union of shot numbers.
Behavior of
index,shotnumandintersection_set:Note
The
shotnumkeyword will always override theindexkeyword, but, due to extra overhead required for identifying shot number locations in the digitizer dataset, theindexkeyword will always execute quicker than theshotnumkeyword.
- Example
Here data is extracted from the digitizer
'SIS crate'and position data is mated from the control device'6K Compumotor'.>>> # open HDF5 file >>> f = bapsflib.lapd.File('test.hdf5') >>> >>> # read digitizer data from board 1, channel 1, >>> # - this is equivalent to >>> # f.read_data(1, 1) >>> data = HDFReadData(f, 1, 1) >>> data.dtype dtype([('shotnum', '<u4'), ('signal', '<f4', (100,)), ('xyz', '<f4', (3,))]) >>> >>> # display shot numbers >>> data['shotnum'] array([ 1, 2, ..., 98, 99], dtype=uint32) >>> >>> # show 'signal' values for shot number 1 >>> data['signal'][0] array([-0.41381955, -0.4134333 , -0.4118886 , ..., -0.41127062, -0.4105754 , -0.41119337], dtype=float32) >>> >>> # show 'xyz' values for shot number 1 >>> data['xyz'][0] array([nan, nan, nan], dtype=float32) >>> >>> # read digitizer data while adding '6K Compumotor' data >>> # from receptacle (configuration) 3 >>> data = HDFReadData(f, 1, 1, add_controls=[('6K Compumotor', 3)]) >>> data.dtype dtype([('shotnum', '<u4'), ('signal', '<f4', (100,)), ('xyz', '<f4', (3,)), ('ptip_rot_theta', '<f8'), ('ptip_rot_phi', '<f8')]) >>> >>> # show 'xyz' values for shot number 1 >>> data['xyz'][0] array([ -32. , 15. , 1022.4], dtype=float32)
Attributes Summary
Temporal step size (in sec) calculated from the
'clock rate'and'sample average'items ininfo.Voltage step size (in volts) calculated from the
'bit'and'voltage offset'items ininfo.A dictionary of metadata for the extracted data.
Dictionary of plasma parameters.
Methods Summary
convert_signal([to_volt, to_bits, force])converts signal from volts (bits) to bits (volts)
set_plasma(Bo, kTe, kTi, m_i, n_e, Z[, gamma])Set
plasmaand add key frequency, length, and velocity parameters.set_plasma_value(key, value)Re-define one of the base plasma values (Bo, gamma, kT, kTe, kTi, m_i, n, n_e, or Z) in the
plasmadictionary.Attributes Documentation
- dt¶
Temporal step size (in sec) calculated from the
'clock rate'and'sample average'items ininfo. ReturnsNoneif step size can not be calculated.
- dv¶
Voltage step size (in volts) calculated from the
'bit'and'voltage offset'items ininfo. ReturnsNoneif step size can not be calculated.
- info¶
A dictionary of metadata for the extracted data. The dict() keys are:
hdf fileHDF5 file name the data was retrieved from
dataset namename of the dataset
dataset pathpath to said dataset in the HDF5 file
digitizerdigitizer group name
configuration namename of data configuration
adcanalog-digital converter in which the data was recorded on
bitbit resolution for the adc
clock ratetuple containing clock rate, e.g. (100.0, ‘MHz’)
clock rate(hardware sampling) number of data sample average together
shot average(software averaging) number of shot sequences averaged together
boardboard that the probe was connected to
channelchannel of the board that the probe was connected to
voltage offsetvoltage offset of the digitized signal
probe namename of deployed probe…empty for user to use at his/her discretion
port2-element tuple indicating which port the probe was deployed on, eg. (19, ‘W’)
- plasma¶
Dictionary of plasma parameters. (All quantities are in cgs units except temperature is in eV)
Base Values
Bomagnetic field
kTtemperature (generic)
kTeelectron temperature
kTiion temperature
gammaadiabatic index
m_eelectron mass
m_iion mass
nplasma number density
n_eelectron number density
n_iion number density
Zion charge number
Calculated Values
fceelectron cyclotron frequency
fciion cyclotron frequency
fpeelectron plasma frequency
fpiion plasma frequency
fUHUpper-Hybrid Resonance frequency
lDDebye Length
lpeelectron-inertial length
lpiion-inertial length
rceelectron gyroradius
rciion gyroradius
csion sound speed
VAAlfven speed
vTeelectron thermal velocity
vTiion thermal velocity
Methods Documentation
- convert_signal(to_volt=False, to_bits=False, force=False)¶
converts signal from volts (bits) to bits (volts)