The following classes implement different MDF version3 blocks.
Channel Class¶
-
class
asammdf.v2_v3_blocks.
Channel
(**kwargs)[source]¶ CNBLOCK class
If the load_metadata keyword argument is not provided or is False, then the conversion, source and display name information is not processed.
Channel has the following key-value pairs
id
- bytes : block ID; always b’CN’block_len
- int : block bytes sizenext_ch_addr
- int : next CNBLOCK addressconversion_addr
- int : address of channel conversion blocksource_addr
- int : address of channel source blockch_depend_addr
- int : address of dependency block (CDBLOCK) of this channelcomment_addr
- int : address of TXBLOCK that contains the channel commentchannel_type
- int : integer code for channel typeshort_name
- bytes : short signal namedescription
- bytes : signal descriptionstart_offset
- int : start offset in bits to determine the first bit of the signal in the data recordbit_count
- int : channel bit countdata_type
- int : integer code for channel data typerange_flag
- int : value range valid flagmin_raw_value
- float : min raw value of all samplesmax_raw_value
- float : max raw value of all samplessampling_rate
- float : sampling rate in ‘s’ for a virtual time channellong_name_addr
- int : address of TXBLOCK that contains the channel’s namedisplay_name_addr
- int : address of TXBLOCK that contains the channel’s display nameaditional_byte_offset
- int : additional Byte offset of the channel in the data recor
Parameters: - address : int
block address; to be used for objects created from file
- stream : handle
file handle; to be used for objects created from file
- load_metadata : bool
option to load conversion, source and display_name; default True
- for dynamically created objects :
see the key-value pairs
Examples
>>> with open('test.mdf', 'rb') as mdf: ... ch1 = Channel(stream=mdf, address=0xBA52) >>> ch2 = Channel() >>> ch1.name 'VehicleSpeed' >>> ch1['id'] b'CN'
Attributes: - address : int
block address inside mdf file
- comment : str
channel comment
- conversion : ChannelConversion
channel conversion; None if the channel has no conversion
- display_name : str
channel display name
- name : str
full channel name
- source : SourceInformation
channel source information; None if the channel has no source information
ChannelConversion Class¶
-
class
asammdf.v2_v3_blocks.
ChannelConversion
(**kwargs)[source]¶ CCBLOCK class
The ChannelConversion object can be created in two modes:
ChannelConversion has the following common key-value pairs
id
- bytes : block ID; always b’CC’block_len
- int : block bytes sizerange_flag
- int : value range valid flagmin_phy_value
- float : min raw value of all samplesmax_phy_value
- float : max raw value of all samplesunit
- bytes : physical unitconversion_type
- int : integer code for conversion typeref_param_nr
- int : number of referenced parameters
ChannelConversion has the following specific key-value pairs
linear conversion
a
- float : factorb
- float : offsetCANapeHiddenExtra
- bytes : sometimes CANape appends extra information; not compliant with MDF specs
algebraic conversion
formula
- bytes : ecuation as string
polynomial or rational conversion
P1
toP6
- float : parameters
exponential or logarithmic conversion
P1
toP7
- float : parameters
tabular with or without interpolation (grouped by index)
raw_<N>
- int : N-th raw value (X axis)phys_<N>
- float : N-th physical value (Y axis)
text table conversion
param_val_<N>
- int : N-th raw value (X axis)text_<N>
- N-th text physical value (Y axis)
text range table conversion
default_lower
- float : default lower raw valuedefault_upper
- float : default upper raw valuedefault_addr
- int : address of default text physical valuelower_<N>
- float : N-th lower raw valueupper_<N>
- float : N-th upper raw valuetext_<N>
- int : address of N-th text physical value
Parameters: - address : int
block address inside mdf file
- raw_bytes : bytes
complete block read from disk
- stream : file handle
mdf file handle
- for dynamically created objects :
see the key-value pairs
Examples
>>> with open('test.mdf', 'rb') as mdf: ... cc1 = ChannelConversion(stream=mdf, address=0xBA52) >>> cc2 = ChannelConversion(conversion_type=0) >>> cc1['b'], cc1['a'] 0, 100.0
Attributes: - address : int
block address inside mdf file
- formula : str
formula string in case of algebraic conversion
- referenced_blocks : list
list of CCBLOCK/TXBLOCK referenced by the conversion
- unit : str
physical unit
ChannelDependency Class¶
-
class
asammdf.v2_v3_blocks.
ChannelDependency
(**kwargs)[source]¶ CDBLOCK class
ChannelDependency has the following key-value pairs
id
- bytes : block ID; always b’CD’block_len
- int : block bytes sizedependency_type
- int : integer code for dependency typesd_nr
- int : total number of signals dependenciesdg_<N>
- address of data group block (DGBLOCK) of N-th signal dependencydg_<N>
- address of channel group block (CGBLOCK) of N-th signal dependencydg_<N>
- address of channel block (CNBLOCK) of N-th signal dependencydim_<K>
- int : Optional size of dimension K for N-dimensional dependency
Parameters: - stream : file handle
mdf file handle
- address : int
block address inside mdf file
- for dynamically created objects :
see the key-value pairs
Attributes: - address : int
block address inside mdf file
- referenced_channels : list
list of (group index, channel index) pairs
ChannelExtension Class¶
-
class
asammdf.v2_v3_blocks.
ChannelExtension
(**kwargs)[source]¶ CEBLOCK class
Channel has the following common key-value pairs
id
- bytes : block ID; always b’CE’block_len
- int : block bytes sizetype
- int : extension type identifier
Channel has the following specific key-value pairs
for DIM block
module_nr
- int: module numbermodule_address
- int : module addressdescription
- bytes : module descriptionECU_identification
- bytes : identification of ECUreserved0
- bytes : reserved bytes
for Vector CAN block
CAN_id
- int : CAN message IDCAN_ch_index
- int : index of CAN channelmessage_name
- bytes : message namesender_name
- btyes : sender namereserved0
- bytes : reserved bytes
Parameters: - stream : file handle
mdf file handle
- address : int
block address inside mdf file
- for dynamically created objects :
see the key-value pairs
Attributes: - address : int
block address inside mdf file
- comment : str
extension comment
- name : str
extension name
- path : str
extension path
ChannelGroup Class¶
-
class
asammdf.v2_v3_blocks.
ChannelGroup
(**kwargs)[source]¶ CGBLOCK class
ChannelGroup has the following key-value pairs
id
- bytes : block ID; always b’CG’block_len
- int : block bytes sizenext_cg_addr
- int : next CGBLOCK addressfirst_ch_addr
- int : address of first channel block (CNBLOCK)comment_addr
- int : address of TXBLOCK that contains the channel group commentrecord_id
- int : record ID used as identifier for a record if the DGBLOCK defines a number of record IDs > 0 (unsorted group)ch_nr
- int : number of channelssamples_byte_nr
- int : size of data record in bytes without record IDcycles_nr
- int : number of cycles (records) of this type in the data blocksample_reduction_addr
- int : addresss to first sample reduction block
Parameters: - stream : file handle
mdf file handle
- address : int
block address inside mdf file
- for dynamically created objects :
see the key-value pairs
Examples
>>> with open('test.mdf', 'rb') as mdf: ... cg1 = ChannelGroup(stream=mdf, address=0xBA52) >>> cg2 = ChannelGroup(sample_bytes_nr=32) >>> hex(cg1.address) 0xBA52 >>> cg1['id'] b'CG'
Attributes: - address : int
block address inside mdf file
- comment : str
channel group comment
DataGroup Class¶
-
class
asammdf.v2_v3_blocks.
DataGroup
(**kwargs)[source]¶ DGBLOCK class
Channel has the following key-value pairs
id
- bytes : block ID; always b’DG’block_len
- int : block bytes sizenext_dg_addr
- int : next DGBLOCK addressfirst_cg_addr
- int : address of first channel group block (CGBLOCK)trigger_addr
- int : address of trigger block (TRBLOCK)data_block_addr
- addrfss of data blockcg_nr
- int : number of channel groupsrecord_id_len
- int : number of record IDs in the data blockreserved0
- bytes : reserved bytes
Parameters: - stream : file handle
mdf file handle
- address : int
block address inside mdf file
- for dynamically created objects :
see the key-value pairs
Attributes: - address : int
block address inside mdf file
FileIdentificationBlock Class¶
-
class
asammdf.v2_v3_blocks.
FileIdentificationBlock
(**kwargs)[source]¶ IDBLOCK class
FileIdentificationBlock has the following key-value pairs
file_identification
- bytes : file identifierversion_str
- bytes : format identifierprogram_identification
- bytes : creator program identifierbyte_order
- int : integer code for byte order (endiannes)float_format
- int : integer code for floating-point formatmdf_version
- int : version number of MDF formatcode_page
- int : unicode code page numberreserved0
- bytes : reserved bytesreserved1
- bytes : reserved bytesunfinalized_standard_flags
- int : standard flags for unfinalized MDFunfinalized_custom_flags
- int : custom flags for unfinalized MDF
Parameters: - stream : file handle
mdf file handle
- version : int
mdf version in case of new file (dynamically created)
Attributes: - address : int
block address inside mdf file; should be 0 always
HeaderBlock Class¶
-
class
asammdf.v2_v3_blocks.
HeaderBlock
(**kwargs)[source]¶ HDBLOCK class
HeaderBlock has the following key-value pairs
id
- bytes : block ID; always b’HD’block_len
- int : block bytes sizefirst_dg_addr
- int : address of first data group block (DGBLOCK)comment_addr
- int : address of TXBLOCK taht contains the measurement file commentprogram_addr
- int : address of program block (PRBLOCK)dg_nr
- int : number of data groupsdate
- bytes : date at which the recording was started in “DD:MM:YYYY” formattime
- btyes : time at which the recording was started in “HH:MM:SS” formatauthor
- btyes : author nameorganization
- bytes : organization nameproject
- bytes : project namesubject
- bytes : subject
Since version 3.2 the following extra keys were added:
abs_time
- int : time stamp at which recording was started in nanoseconds.tz_offset
- int : UTC time offset in hours (= GMT time zone)time_quality
- int : time quality classtimer_identification
- bytes : timer identification (time source)
Parameters: - stream : file handle
mdf file handle
- version : int
mdf version in case of new file (dynamically created)
Attributes: - address : int
block address inside mdf file; should be 64 always
- comment : int
file comment
- program : ProgramBlock
program block
- author : str
measurement author
- department : str
author’s department
- project : str
working project
- subject : str
measurement subject
ProgramBlock Class¶
-
class
asammdf.v2_v3_blocks.
ProgramBlock
(**kwargs)[source]¶ PRBLOCK class
ProgramBlock has the following key-value pairs
id
- bytes : block ID; always b’PR’block_len
- int : block bytes sizedata
- btyes : creator program free format data
Parameters: - stream : file handle
mdf file handle
- address : int
block address inside mdf file
Attributes: - address : int
block address inside mdf file
SampleReduction Class¶
-
class
asammdf.v2_v3_blocks.
SampleReduction
(**kwargs)[source]¶ SRBLOCK class
SampleReduction has the following key-value pairs
id
- bytes : block ID; always b’SR’block_len
- int : block bytes sizenext_sr_addr
- int : next SRBLOCK addressdata_block_addr
- int : address of data block for this sample reductioncycles_nr
- int : number of reduced samples in the data blocktime_interval
- float : length of time interval [s] used to calculate- the reduced samples
Parameters: - stream : file handle
mdf file handle
- address : int
block address inside mdf file
Attributes: - address : int
block address inside mdf file
TextBlock Class¶
-
class
asammdf.v2_v3_blocks.
TextBlock
(**kwargs)[source]¶ TXBLOCK class
TextBlock has the following key-value pairs
id
- bytes : block ID; always b’TX’block_len
- int : block bytes sizetext
- bytes : text content
Parameters: - stream : file handle
mdf file handle
- address : int
block address inside mdf file
- text : bytes | str
bytes or str for creating a new TextBlock
Examples
>>> tx1 = TextBlock(text='VehicleSpeed') >>> tx1.text_str 'VehicleSpeed' >>> tx1['text'] b'VehicleSpeed'
Attributes: - address : int
block address inside mdf file
TriggerBlock Class¶
-
class
asammdf.v2_v3_blocks.
TriggerBlock
(**kwargs)[source]¶ TRBLOCK class
Channel has the following key-value pairs
id
- bytes : block ID; always b’TR’block_len
- int : block bytes sizetext_addr
- int : address of TXBLOCK that contains the trigger comment texttrigger_events_nr
- int : number of trigger eventstrigger_<N>_time
- float : trigger time [s] of trigger’s N-th eventtrigger_<N>_pretime
- float : pre trigger time [s] of trigger’s N-th eventtrigger_<N>_posttime
- float : post trigger time [s] of trigger’s N-th event
Parameters: - stream : file handle
mdf file handle
- address : int
block address inside mdf file
Attributes: - address : int
block address inside mdf file
- comment : str
trigger comment