mdfinfo4 module documentation¶
Measured Data Format blocks paser for version 4.x
Platform and python version¶
With Unix and Windows for python 2.6+ and 3.2+
Created on Sun Dec 15 12:57:28 2013
Author: | Aymeric Rateau |
---|
Dependencies¶
- Python >2.6, >3.2 <http://www.python.org>
- Numpy >1.6 <http://numpy.scipy.org>
Attributes¶
- PythonVersion : float
- Python version currently running, needed for compatibility of both python 2.6+ and 3.2+
mdfinfo4 module¶
-
class
mdfinfo4.
ATBlock
(fid, pointer)¶ Bases:
mdfinfo4.MDFBlock
reads Attachment block and saves in class dict
Methods
-
class
mdfinfo4.
CABlock
(fid, pointer)¶ Bases:
mdfinfo4.MDFBlock
reads Channel Array block and saves in class dict
Methods
-
class
mdfinfo4.
CCBlock
(fid, pointer)¶ Bases:
mdfinfo4.MDFBlock
reads Channel Conversion block and saves in class dict
Methods
-
class
mdfinfo4.
CGBlock
(fid, pointer)¶ Bases:
mdfinfo4.MDFBlock
reads Channel Group block and saves in class dict
Methods
-
class
mdfinfo4.
CHBlock
(fid, pointer)¶ Bases:
mdfinfo4.MDFBlock
reads Channel Hierarchy block and saves in class dict
Methods
-
class
mdfinfo4.
CNBlock
(fid, pointer)¶ Bases:
mdfinfo4.MDFBlock
reads Channel block and saves in class dict
Methods
-
class
mdfinfo4.
CommentBlock
(fid, pointer, MDType=None)¶ Bases:
mdfinfo4.MDFBlock
reads Comment block and saves in class dict
Notes
Can read xml (MD metadata) or text (TX) comments from several kind of blocks
Methods
-
extractXmlField
(xml_tree, field)¶ Extract Xml field from a xml tree
Parameters: xml_tree : xml tree from xml.etree.ElementTree
field : str
Returns: field value in xml tree
-
-
class
mdfinfo4.
DGBlock
(fid, pointer)¶ Bases:
mdfinfo4.MDFBlock
reads Data Group block and saves in class dict
Methods
-
class
mdfinfo4.
EVBlock
(fid, pointer)¶ Bases:
mdfinfo4.MDFBlock
reads Event block and saves in class dict
Methods
-
class
mdfinfo4.
FHBlock
(fid, pointer)¶ Bases:
mdfinfo4.MDFBlock
reads File History block and save in class dict
Methods
-
class
mdfinfo4.
HDBlock
(fid, pointer=64)¶ Bases:
mdfinfo4.MDFBlock
reads Header block and save in class dict
Methods
-
class
mdfinfo4.
IDBlock
(fid)¶ Bases:
mdfinfo4.MDFBlock
reads ID Block and save in class dict
Methods
-
class
mdfinfo4.
MDFBlock
¶ Bases:
dict
MDFBlock base class for the MDF related block classes
Methods
loadHeader(fid, pointer) reads block’s header and put in class dict mdfblockread( fid, type, count ) converts a byte array of length count to a given data type mdfblockreadCHAR( fid, count ) reads a character chain of length count encoded in latin. mdfblockreadBYTE( fid, count ) reads an array of UTF-8 encoded bytes -
loadHeader
(fid, pointer)¶ reads block’s header and put in class dict
Parameters: fid : float
file identifier
pointer : int
position of block in file
-
static
mdfblockread
(fid, type, count)¶ converts a byte array of length count to a given data type
Parameters: type : str
C format data type
count : int
number of elements to sequentially read
Returns: array of values of ‘type’ parameter
-
static
mdfblockreadBYTE
(fid, count)¶ reads an array of UTF-8 encoded bytes. Removes trailing 0
Parameters: count : int
number of bytes to read
Returns: bytes array of length count
-
static
mdfblockreadCHAR
(fid, count)¶ reads a character chain of length count encoded in latin. Removes trailing 0
Parameters: count : int
number of characters to read
Returns: a string of length count
-
-
class
mdfinfo4.
SIBlock
(fid, pointer)¶ Bases:
mdfinfo4.MDFBlock
reads Source Information block and saves in class dict
Methods
-
class
mdfinfo4.
SRBlock
(fid, pointer)¶ Bases:
mdfinfo4.MDFBlock
reads Sample Reduction block and saves in class dict
Methods
-
mdfinfo4.
elementTreeToDict
(element)¶ converts xml tree into dictionnary
Parameters: element : xml tree from xml.etree.ElementTree Returns: dict of xml tree flattened
-
class
mdfinfo4.
info4
(fileName=None, fid=None)¶ Bases:
dict
information block parser fo MDF file version 4.x
Notes
mdfinfo(FILENAME) contains a dict of structures, for each data group, containing key information about all channels in each group. FILENAME is a string that specifies the name of the MDF file. Either file name or fid should be given. General dictionary structure is the following
- mdfinfo[‘HDBlock’] header block
- mdfinfo[‘DGBlock’][dataGroup] Data Group block
- mdfinfo[‘CGBlock’][dataGroup][channelGroup] Channel Group block
- mdfinfo[‘CNBlock’][dataGroup][channelGroup][channel] Channel block including text blocks for comment and identifier
- mdfinfo[‘CCBlock’][dataGroup][channelGroup][channel] Channel conversion information
Attributes
fileName (str) name of file Methods
-
listChannels4
(fileName=None)¶ Read MDF file and extract its complete structure
Parameters: fileName : str
file name
Returns: list of channel names contained in file
-
readATBlock
(selfself, fid, pointer)¶ reads Attachment blocks
Parameters: fid : float
file identifier
pointer : int
position of ATBlock in file
Returns: Attachments Blocks in a dict
-
readCGBlock
(fid, dg, channelNameList=False)¶ reads Channel Group blocks
Parameters: fid : float
file identifier
dg : int
data group number
channelNameList : bool
Flag to reads only channel blocks for listChannels4 method
-
readCNBlock
(fid, dg, cg, channelNameList=False)¶ reads Channel blocks
Parameters: fid : float
file identifier
dg : int
data group number
cg : int
channel group number in data group
channelNameList : bool
Flag to reads only channel blocks for listChannels4 method
-
readComposition
(fid, dg, cg, MLSDChannels, channelNameList=False)¶ check for composition of channels, arrays or structures
Parameters: fid : float
file identifier
dg : int
data group number
cg : int
channel group number in data group
MLSDChannels : list of int
channel numbers
channelNameList : bool
Flag to reads only channel blocks for listChannels4 method
Returns: MLSDChannels list of appended Maximum Length Sampling Data channels
-
readDGBlock
(fid, channelNameList=False)¶ reads Data Group Blocks
Parameters: fid : float
file identifier
channelNameList : bool
Flag to reads only channel blocks for listChannels4 method
-
readSRBlock
(fid, pointer)¶ reads Sample Reduction Blocks
Parameters: fid : float
file identifier
pointer : int
position of SRBlock in file
Returns: Sample Reduction Blocks in a dict
-
readinfo
(fid)¶ read all file blocks except data
Parameters: fid : float
file identifier