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 bytes
  • block_len - int : block bytes size
  • links_nr - int : number of links
  • next_at_addr - int : next ATBLOCK address
  • file_name_addr - int : address of TXBLOCK that contains the attachment file name
  • mime_addr - int : address of TXBLOCK that contains the attachment mime type description
  • comment_addr - int : address of TXBLOCK/MDBLOCK that contains the attachment comment
  • flags - int : ATBLOCK flags
  • creator_index - int : index of file history block
  • reserved1 - int : reserved bytes
  • md5_sum - bytes : attachment file md5 sum
  • original_size - int : original uncompress file size in bytes
  • embedded_size - int : embedded compressed file size in bytes
  • embedded_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 bytes
  • block_len - int : block bytes size
  • links_nr - int : number of links
  • next_ch_addr - int : next ATBLOCK address
  • component_addr - int : address of first channel in case of structure channel composition, or ChannelArrayBlock in case of arrays file name
  • name_addr - int : address of TXBLOCK that contains the channel name
  • source_addr - int : address of channel source block
  • conversion_addr - int : address of channel conversion block
  • data_block_addr - int : address of signal data block for VLSD channels
  • unit_addr - int : address of TXBLOCK that contains the channel unit
  • comment_addr - int : address of TXBLOCK/MDBLOCK that contains the channel comment
  • attachment_<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 pair
  • default_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 axis
  • default_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 axis
  • default_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 axis
  • channel_type - int : integer code for the channel type
  • sync_type - int : integer code for the channel’s sync type
  • data_type - int : integer code for the channel’s data type
  • bit_offset - int : bit offset
  • byte_offset - int : byte offset within the data record
  • bit_count - int : channel bit count
  • flags - int : CNBLOCK flags
  • pos_invalidation_bit - int : invalidation bit position for the current channel if there are invalidation bytes in the data record
  • precision - int : integer code for teh precision
  • reserved1 - int : reserved bytes
  • min_raw_value - int : min raw value of all samples
  • max_raw_value - int : max raw value of all samples
  • lower_limit - int : min physical value of all samples
  • upper_limit - int : max physical value of all samples
  • lower_ext_limit - int : min physical value of all samples
  • upper_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 bytes
  • block_len - int : block bytes size
  • links_nr - int : number of links
  • name_addr - int : address of TXBLOCK that contains the conversion name
  • unit_addr - int : address of TXBLOCK that contains the conversion unit
  • comment_addr - int : address of TXBLOCK/MDBLOCK that contains the conversion comment
  • inv_conv_addr int : address of invers conversion
  • conversion_type int : integer code for conversion type
  • precision - int : integer code for precision
  • flags - int : conversion block flags
  • ref_param_nr - int : number fo referenced parameters (linked parameters)
  • val_param_nr - int : number of value parameters
  • min_phy_value - float : minimum physical channel value
  • max_phy_value - float : maximum physical channel value

ChannelConversion has the following specific key-value pairs

  • linear conversion

    • a - float : factor
    • b - float : offset
  • rational conversion

    • P1 to P6 - 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 value
    • phys_<N> - float : N-th physical value
  • tabular range conversion

    • lower_<N> - float : N-th lower value
    • upper_<N> - float : N-th upper value
    • phys_<N> - float : N-th physical value
  • tabular value to text conversion

    • val_<N> - float : N-th raw value
    • text_<N> - int : address of N-th TXBLOCK that contains the physical value
    • default - int : address of TXBLOCK that contains the default physical value
  • tabular range to text conversion

    • lower_<N> - float : N-th lower value
    • upper_<N> - float : N-th upper value
    • text_<N> - int : address of N-th TXBLOCK that contains the physical value
    • default - int : address of TXBLOCK that contains the default physical value
  • text to value conversion

    • val_<N> - float : N-th physical value
    • text_<N> - int : address of N-th TXBLOCK that contains the raw value
    • val_default - float : default physical value
  • text tranfosrmation (translation) conversion

    • input_<N>_addr - int : address of N-th TXBLOCK that contains the raw value
    • output_<N>_addr - int : address of N-th TXBLOCK that contains the physical value
    • default_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 bytes
  • block_len - int : block bytes size
  • links_nr - int : number of links
  • next_cg_addr - int : next channel group address
  • first_ch_addr - int : address of first channel of this channel group
  • acq_name_addr - int : address of TextBLock that contains the channel group acquisition name
  • acq_source_addr - int : addres of SourceInformation that contains the channel group source
  • first_sample_reduction_addr - int : address of first SRBLOCK; this is considered 0 since sample reduction is not yet supported
  • comment_addr - int : address of TXBLOCK/MDBLOCK that contains the channel group comment
  • record_id - int : record ID for thei channel group
  • cycles_nr - int : number of cycles for this channel group
  • flags - int : channel group flags
  • path_separator - int : ordinal for character used as path separator
  • reserved1 - int : reserved bytes
  • samples_byte_nr - int : number of bytes used for channels samples in the record for this channel group; this does not contain the invalidation bytes
  • invalidation_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 bytes
  • block_len - int : block bytes size
  • links_nr - int : number of links
  • next_dg_addr - int : address of next data group block
  • first_cg_addr - int : address of first channel group for this data group
  • data_block_addr - int : address of DTBLOCK, DZBLOCK, DLBLOCK or HLBLOCK that contains the raw samples for this data group
  • comment_addr - int : address of TXBLOCK/MDBLOCK tha contains the data group comment
  • record_id_len - int : size of record ID used in case of unsorted data groups; can be 1, 2, 4 or 8
  • reserved1 - 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 bytes

  • block_len - int : block bytes size

  • links_nr - int : number of links

  • next_dl_addr - int : address of next DLBLOCK

  • data_block_addr<N> - int : address of N-th data block

  • flags - int : data list flags

  • reserved1 - int : reserved bytes

  • data_block_nr - int : number of data blocks referenced by thsi list

  • for 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 bytes
  • block_len - int : block bytes size
  • links_nr - int : number of links
  • data - 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 identifier
  • version_str - bytes : format identifier
  • program_identification - bytes : creator program identifier
  • reserved0 - bytes : reserved bytes
  • mdf_version - int : version number of MDF format
  • reserved1 - bytes : reserved bytes
  • unfinalized_standard_flags - int : standard flags for unfinalized MDF
  • unfinalized_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 bytes
  • block_len - int : block bytes size
  • links_nr - int : number of links
  • first_dg_addr - int : address of first DGBLOCK
  • file_history_addr - int : address of first FHBLOCK
  • channel_tree_addr - int : address of first CHBLOCK
  • first_attachment_addr - int : address of first ATBLOCK
  • first_event_addr - int : address of first EVBLOCK
  • comment_addr - int : address of TXBLOCK/MDBLOCK that contains the file comment
  • abs_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 time
  • time_flags - int : time flags
  • time_quality - int : time quality flags
  • flags - int : file flags
  • reserved1 - int : reserved bytes
  • start_angle - int : angle value at measurement start
  • start_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 bytes
  • block_len - int : block bytes size
  • links_nr - int : number of links
  • name_addr - int : address of TXBLOCK that contains the source name
  • path_addr - int : address of TXBLOCK that contains the source path
  • comment_addr - int : address of TXBLOCK/MDBLOCK tha contains the source comment
  • source_type - int : integer code for source type
  • bus_type - int : integer code for source bus type
  • flags - int : source flags
  • reserved1 - 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 bytes
  • block_len - int : block bytes size
  • links_nr - int : number of links
  • next_fh_addr - int : address of next FHBLOCK
  • comment_addr - int : address of TXBLOCK/MDBLOCK that contains the file history comment
  • abs_time - int : time stamp at which the file modification happened
  • tz_offset - int : UTC time offset in hours (= GMT time zone)
  • daylight_save_time - int : daylight saving time
  • time_flags - int : time flags
  • reserved1 - 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 MDBLOCK
  • reserved0 - int : reserved bytes
  • block_len - int : block bytes size
  • links_nr - int : number of links
  • text - 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