The following classes implement different MDF version4 blocks.
AttachmentBlock Class¶
-
class
asammdf.v4_blocks.
AttachmentBlock
(**kwargs)[source]¶ ATBLOCK class
When adding new attachments only embedded attachments are allowed, with keyword argument data of type bytes
AttachmentBlock has the following key-value pairs
id
- bytes : block ID; always b’##AT’reserved0
- int : reserved bytesblock_len
- int : block bytes sizelinks_nr
- int : number of linksnext_at_addr
- int : next ATBLOCK addressfile_name_addr
- int : address of TXBLOCK that contains the attachment file namemime_addr
- int : address of TXBLOCK that contains the attachment mime type descriptioncomment_addr
- int : address of TXBLOCK/MDBLOCK that contains the attachment commentflags
- int : ATBLOCK flagscreator_index
- int : index of file history blockreserved1
- int : reserved bytesmd5_sum
- bytes : attachment file md5 sumoriginal_size
- int : original uncompress file size in bytesembedded_size
- int : embedded compressed file size in bytesembedded_data
- bytes : embedded atatchment bytes
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
- for dynamically created objects :
see the key-value pairs
Attributes: - address : int
attachment address
- file_name : str
attachment file name
- mime : str
mime type
- comment : str
attachment comment
Channel Class¶
-
class
asammdf.v4_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. Further more if the parse_xml_comment is not provided or is False, then the display name information from the channel comment is not processed (this is done to avoid expensive XML operations)
Channel has the following key-value pairs
id
- bytes : block ID; always b’##CN’reserved0
- int : reserved bytesblock_len
- int : block bytes sizelinks_nr
- int : number of linksnext_ch_addr
- int : next ATBLOCK addresscomponent_addr
- int : address of first channel in case of structure channel composition, or ChannelArrayBlock in case of arrays file namename_addr
- int : address of TXBLOCK that contains the channel namesource_addr
- int : address of channel source blockconversion_addr
- int : address of channel conversion blockdata_block_addr
- int : address of signal data block for VLSD channelsunit_addr
- int : address of TXBLOCK that contains the channel unitcomment_addr
- int : address of TXBLOCK/MDBLOCK that contains the channel commentattachment_<N>_addr
- int : address of N-th ATBLOCK referenced by the current channel; if no ATBLOCK is referenced there will be no such key-value pairdefault_X_dg_addr
- int : address of DGBLOCK where the default X axis channel for the current channel is found; this key-value pair will not exist for channels that don’t have a default X axisdefault_X_cg_addr
- int : address of CGBLOCK where the default X axis channel for the current channel is found; this key-value pair will not exist for channels that don’t have a default X axisdefault_X_ch_addr
- int : address of default X axis channel for the current channel; this key-value pair will not exist for channels that don’t have a default X axischannel_type
- int : integer code for the channel typesync_type
- int : integer code for the channel’s sync typedata_type
- int : integer code for the channel’s data typebit_offset
- int : bit offsetbyte_offset
- int : byte offset within the data recordbit_count
- int : channel bit countflags
- int : CNBLOCK flagspos_invalidation_bit
- int : invalidation bit position for the current channel if there are invalidation bytes in the data recordprecision
- int : integer code for teh precisionreserved1
- int : reserved bytesmin_raw_value
- int : min raw value of all samplesmax_raw_value
- int : max raw value of all sampleslower_limit
- int : min physical value of all samplesupper_limit
- int : max physical value of all sampleslower_ext_limit
- int : min physical value of all samplesupper_ext_limit
- int : max physical value of all samples
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
- parse_xml_comment : bool
option to parse XML channel comment to search for display name; default True
- for dynamically created objects :
see the key-value pairs
Attributes: - address : int
channel address
- attachments : list
list of referenced attachment blocks indexes; the index referece to the attachment block index
- comment : str
channel comment
- conversion : ChannelConversion
channel conversion; None if the channel has no conversion
- display_name : str
channel display name; this is extracted from the XML channel comment
- name : str
channel name
- source : SourceInformation
channel source information; None if the channel has no source information
- unit : str
channel unit
ChannelConversion Class¶
-
class
asammdf.v4_blocks.
ChannelConversion
(**kwargs)[source]¶ CCBLOCK class
ChannelConversion has the following common key-value pairs
id
- bytes : block ID; always b’##CG’reserved0
- int : reserved bytesblock_len
- int : block bytes sizelinks_nr
- int : number of linksname_addr
- int : address of TXBLOCK that contains the conversion nameunit_addr
- int : address of TXBLOCK that contains the conversion unitcomment_addr
- int : address of TXBLOCK/MDBLOCK that contains the conversion commentinv_conv_addr
int : address of invers conversionconversion_type
int : integer code for conversion typeprecision
- int : integer code for precisionflags
- int : conversion block flagsref_param_nr
- int : number fo referenced parameters (linked parameters)val_param_nr
- int : number of value parametersmin_phy_value
- float : minimum physical channel valuemax_phy_value
- float : maximum physical channel value
ChannelConversion has the following specific key-value pairs
linear conversion
a
- float : factorb
- float : offset
rational conversion
P1
toP6
- float : parameters
algebraic conversion
formula_add
- address of TXBLOCK that contains the the algebraic conversion formula
tabluar conversion with or without interpolation
raw_<N>
- float : N-th raw valuephys_<N>
- float : N-th physical value
tabular range conversion
lower_<N>
- float : N-th lower valueupper_<N>
- float : N-th upper valuephys_<N>
- float : N-th physical value
tabular value to text conversion
val_<N>
- float : N-th raw valuetext_<N>
- int : address of N-th TXBLOCK that contains the physical valuedefault
- int : address of TXBLOCK that contains the default physical value
tabular range to text conversion
lower_<N>
- float : N-th lower valueupper_<N>
- float : N-th upper valuetext_<N>
- int : address of N-th TXBLOCK that contains the physical valuedefault
- int : address of TXBLOCK that contains the default physical value
text to value conversion
val_<N>
- float : N-th physical valuetext_<N>
- int : address of N-th TXBLOCK that contains the raw valueval_default
- float : default physical value
text tranfosrmation (translation) conversion
input_<N>_addr
- int : address of N-th TXBLOCK that contains the raw valueoutput_<N>_addr
- int : address of N-th TXBLOCK that contains the physical valuedefault_addr
- int : address of TXBLOCK that contains the default physical value
Attributes: - address : int
channel conversion address
- comment : str
channel conversion comment
- formula : str
algebraic conversion formula; default ‘’
- referenced_blocks : list
list of refenced blocks; can be TextBlock objects for value to text, and text to text conversions; for partial conversions the referenced blocks can be ChannelConversion obejct as well
- name : str
channel conversion name
- unit : str
channel conversion unit
ChannelGroup Class¶
-
class
asammdf.v4_blocks.
ChannelGroup
(**kwargs)[source]¶ CGBLOCK class
ChannelGroup has the following key-value pairs
id
- bytes : block ID; always b’##CG’reserved0
- int : reserved bytesblock_len
- int : block bytes sizelinks_nr
- int : number of linksnext_cg_addr
- int : next channel group addressfirst_ch_addr
- int : address of first channel of this channel groupacq_name_addr
- int : address of TextBLock that contains the channel group acquisition nameacq_source_addr
- int : addres of SourceInformation that contains the channel group sourcefirst_sample_reduction_addr
- int : address of first SRBLOCK; this is considered 0 since sample reduction is not yet supportedcomment_addr
- int : address of TXBLOCK/MDBLOCK that contains the channel group commentrecord_id
- int : record ID for thei channel groupcycles_nr
- int : number of cycles for this channel groupflags
- int : channel group flagspath_separator
- int : ordinal for character used as path separatorreserved1
- int : reserved bytessamples_byte_nr
- int : number of bytes used for channels samples in the record for this channel group; this does not contain the invalidation bytesinvalidation_bytes_nr
- int : number of bytes used for invalidation bits by this channl group
Attributes: - acq_name : str
acquisition name
- acq_source : SourceInformation
acquisition source information
- address : int
channel group address
- comment : str
channel group comment
DataGroup Class¶
-
class
asammdf.v4_blocks.
DataGroup
(**kwargs)[source]¶ DGBLOCK class
DataGroup has the following key-value pairs
id
- bytes : block ID; always b’##DG’reserved0
- int : reserved bytesblock_len
- int : block bytes sizelinks_nr
- int : number of linksnext_dg_addr
- int : address of next data group blockfirst_cg_addr
- int : address of first channel group for this data groupdata_block_addr
- int : address of DTBLOCK, DZBLOCK, DLBLOCK or HLBLOCK that contains the raw samples for this data groupcomment_addr
- int : address of TXBLOCK/MDBLOCK tha contains the data group commentrecord_id_len
- int : size of record ID used in case of unsorted data groups; can be 1, 2, 4 or 8reserved1
- int : reserved bytes
Attributes: - address : int
dat group address
- comment : str
data group comment
DataList Class¶
-
class
asammdf.v4_blocks.
DataList
(**kwargs)[source]¶ DLBLOCK class
DataList has the following common key-value pairs
id
- bytes : block ID; always b’##DL’reserved0
- int : reserved bytesblock_len
- int : block bytes sizelinks_nr
- int : number of linksnext_dl_addr
- int : address of next DLBLOCKdata_block_addr<N>
- int : address of N-th data blockflags
- int : data list flagsreserved1
- int : reserved bytesdata_block_nr
- int : number of data blocks referenced by thsi listfor equall lenght blocks
data_block_len
- int : equall uncompressed size in bytes for all referenced data blocks; last block can be smaller
for variable lenght blocks
offset_<N>
- int : byte offset of N-th data block
Attributes: - address : int
data list address
DataBlock Class¶
-
class
asammdf.v4_blocks.
DataBlock
(**kwargs)[source]¶ DTBLOCK class
DataBlock has the following key-value pairs
id
- bytes : block ID; always b’##DT’reserved0
- int : reserved bytesblock_len
- int : block bytes sizelinks_nr
- int : number of linksdata
- bytes : raw samples
Parameters: - address : int
DTBLOCK address inside the file
- stream : int
file handle
Attributes: - address : int
data block address
FileIdentificationBlock Class¶
-
class
asammdf.v4_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 identifierreserved0
- bytes : reserved bytesmdf_version
- int : version number of MDF formatreserved1
- bytes : reserved bytesunfinalized_standard_flags
- int : standard flags for unfinalized MDFunfinalized_custom_flags
- int : custom flags for unfinalized MDF
Attributes: - address : int
should always be 0
HeaderBlock Class¶
-
class
asammdf.v4_blocks.
HeaderBlock
(**kwargs)[source]¶ HDBLOCK class
HeaderBlock has the following common key-value pairs
id
- bytes : block ID; always b’##HD’reserved0
- int : reserved bytesblock_len
- int : block bytes sizelinks_nr
- int : number of linksfirst_dg_addr
- int : address of first DGBLOCKfile_history_addr
- int : address of first FHBLOCKchannel_tree_addr
- int : address of first CHBLOCKfirst_attachment_addr
- int : address of first ATBLOCKfirst_event_addr
- int : address of first EVBLOCKcomment_addr
- int : address of TXBLOCK/MDBLOCK that contains the file commentabs_time
- int : time stamp at which recording was started in nanoseconds.tz_offset
- int : UTC time offset in hours (= GMT time zone)daylight_save_time
- int : daylight saving timetime_flags
- int : time flagstime_quality
- int : time quality flagsflags
- int : file flagsreserved1
- int : reserved bytesstart_angle
- int : angle value at measurement startstart_distance
- int : distance value at measurement start
Attributes: - address : int
header address
- comment : str
file comment
-
start_time
¶ getter and setter the measurement start timestamp
Returns: - timestamp : datetime.datetime
start timestamp
SourceInformation Class¶
-
class
asammdf.v4_blocks.
SourceInformation
(**kwargs)[source]¶ SIBLOCK class
SourceInformation has the following key-value pairs
id
- bytes : block ID; always b’##SI’reserved0
- int : reserved bytesblock_len
- int : block bytes sizelinks_nr
- int : number of linksname_addr
- int : address of TXBLOCK that contains the source namepath_addr
- int : address of TXBLOCK that contains the source pathcomment_addr
- int : address of TXBLOCK/MDBLOCK tha contains the source commentsource_type
- int : integer code for source typebus_type
- int : integer code for source bus typeflags
- int : source flagsreserved1
- bytes : reserved bytes
Attributes: - address : int
source information address
- comment : str
source comment
- name : str
source name
- path : str
source path
FileHistory Class¶
-
class
asammdf.v4_blocks.
FileHistory
(**kwargs)[source]¶ FHBLOCK class
FileHistory has the following common key-value pairs
id
- bytes : block ID; always b’##FH’reserved0
- int : reserved bytesblock_len
- int : block bytes sizelinks_nr
- int : number of linksnext_fh_addr
- int : address of next FHBLOCKcomment_addr
- int : address of TXBLOCK/MDBLOCK that contains the file history commentabs_time
- int : time stamp at which the file modification happenedtz_offset
- int : UTC time offset in hours (= GMT time zone)daylight_save_time
- int : daylight saving timetime_flags
- int : time flagsreserved1
- bytes : reserved bytes
Attributes: - address : int
file history address
- comment : str
history comment
TextBlock Class¶
-
class
asammdf.v4_blocks.
TextBlock
(**kwargs)[source]¶ common TXBLOCK and MDBLOCK class
TextBlock has the following key-value pairs
id
- bytes : block ID; b’##TX’ for TXBLOCK and b’##MD’ for MDBLOCKreserved0
- int : reserved bytesblock_len
- int : block bytes sizelinks_nr
- int : number of linkstext
- bytes : actual text content
Parameters: - address : int
block address
- stream : handle
file handle
- meta : bool
flag to set the block type to MDBLOCK for dynamically created objects; default False
- text : bytes/str
text content for dynamically created objects
Attributes: - address : int
text block address