read mdf4 in general
the most important “branch” in the tree is the list of data groups (DG block).
record used to store the plain measurement data, the records can either be contianed in one single “data” (DT) block, or distributed over several DT blocks using a “data list” block .
Each DG block has points to the data block, as well as necessary information to understand and decode the data.
the sub-tree of DG is channel group(CG) blocks and channel(CN) blocks.
record layout
each record contains all signal values which have the same time stamp, in the same channel. for different channel groups(CG), each record must start with a “record id”
the record layout of ID 1, will be described by one channel group, the record layout of ID 2 by another channel group. Both channel groups must be children of the DT block’s parent data group.
channels
Each channel describes a recorded signal and how its values are encoded in the records for the channel’s parent CG block.
vector APIs
which is licensed by vector
- GetFileManager()
- OpenFile()
- GetChannelByName()
- GetChannelGroup()
- CreaterDataPointer()
- GetRecordCount()
- SetReadMode()
- SeekPos()
- GetPos()
- GetTimeSec()
- ReadPhysValueDouble(pChannle, &value, &isvalid)
- ReadRawValueDouble(pChannel, &rawValue)
- ReadPhysValueDouble(pChannel, &phyValue)
- MultiReadPhysValueDouble(pChannel, valueBuffer, size, &read)
turbolab
ReadFileMF4 class:
- Open()
- Seek(pos)
- Read(Size, Buffer)
- Close()
CMdf4Calc class :
- Cmdf4Calc(pChan, pblock)
- Cmdf4Calc(pChan, mf4file)
cmf4DataGroup class:
- GetRecord()
- GetRawValueFromRecord()
- GetValueFromRecord()
mdf4FileImport class :
- ImportFile()
- ReleaseFile()
I am not reading this C++ code.
asammdf
MDF class
- init(name=None, ): name can be either
string
orBytesIO
- filter(channels, )
- get_group(index, channels=None, )
- iter_channels(,)
- iter_get(channel_name=None,group_id=None, group_index=None, )
- iter_groups()
- to_dataframe(), generate pandas DataFrame
- whereis(channel_name)
MDF4 class
includes data_group
, channel_group
, channels
, data_block
, data_location
, record_size
e.t.c
- get(channel_name=None, group=None, )
- get_can_signal()
- get_channel_name(group, index)
- get_channel_unit(channel_name=Nont, group=None, )
- get_master(index, data=None, ), return the master channel samples for given group
- info()
the following are sub data blocks of MDF4:
- Channel class
- ChannelGroup class
- DataGroup class
- DataList class
- DataBlock class
- HeaderBlock class
|
|
all group
, channel
data is packages as python dict
. the most exciting part, as asam-mdf can support BytesIO
, which gives the way to read mdf files stores in Amazon S3:
|
|
python necessary
buffered io
binary I/O, usually used in following:
|
|
open(file, mode=’r’, buffering=-1, encoding=…)
ifmode='b'
, the returned content is bytes object, can’t encoding. if buffereing
is not setted, for binary file with buffering with a fixed length. when with mode='w/r/t
, it returns io.TextIOwrapper
, if mode=rb
, it returns io.BufferedReader
, else if mode=wb
, it returns io.BufferedWriter
, else mode=wrb
, it returns io.BufferedRandom
. check here
dict built-in funs
|
|
a bit about readers
a few years ago I was in CAE field, dealing with different kind of CAE format, e.g .nas. during that time, there is a similar need to have a file transfer from vendor specified format to python format e.t.c.
so now it comes again, which is funny to know adapters in CAE and autonomous driving design.