The following classes implement different MDF version4 blocks.

AttachmentBlock Class

class asammdf.blocks.v4_blocks.AttachmentBlock(**kwargs)[source]

When adding new attachments only embedded attachments are allowed, with keyword argument data of type bytes

AttachmentBlock has the following attributes, that are also available as dict like key-value pairs

ATBLOCK fields

  • 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

Other attributes

  • address - int : attachment address
  • file_name - str : attachment file name
  • mime - str : mime type
  • comment - str : attachment comment
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

extract()[source]

extract attachment data

Returns:
data : bytes

Channel Class

class asammdf.blocks.v4_blocks.Channel(**kwargs)[source]

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 attributes, that are also available as dict like key-value pairs

CNBLOCK fields

  • 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

Other 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
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

ChannelConversion Class

class asammdf.blocks.v4_blocks.ChannelConversion(**kwargs)[source]

ChannelConversion has the following attributes, that are also available as dict like key-value pairs

CCBLOCK common fields

  • 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

CCBLOCK specific fields

  • linear conversion

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

    • P1 to P6 - float : parameters
  • algebraic conversion

    • formula_addr - 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

Other 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.blocks.v4_blocks.ChannelGroup(**kwargs)[source]

ChannelGroup has the following attributes, that are also available as dict like key-value pairs

CGBLOCK fields

  • 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

Other 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.blocks.v4_blocks.DataGroup(**kwargs)[source]

DataGroup has the following attributes, that are also available as dict like key-value pairs

DGBLOCK fields

  • 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

Other attributes

  • address - int : dat group address
  • comment - str : data group comment

DataList Class

class asammdf.blocks.v4_blocks.DataList(**kwargs)[source]

DataList has the following attributes, that are also available as dict like key-value pairs

DLBLOCK common fields

  • 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

DLBLOCK specific fields

  • 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

Other attributes

  • address - int : data list address

DataBlock Class

class asammdf.blocks.v4_blocks.DataBlock(**kwargs)[source]

Common implementation for DTBLOCK/RDBLOCK/SDBLOCK

DataBlock has the following attributes, that are also available as dict like key-value pairs

DTBLOCK fields

  • id - bytes : block ID; b’##DT’ for DTBLOCK, b’##RD’ for RDBLOCK or b’##SD’ for SDBLOCK
  • reserved0 - int : reserved bytes
  • block_len - int : block bytes size
  • links_nr - int : number of links
  • data - bytes : raw samples

Other attributes

  • address - int : data block address
Parameters:
address : int

DTBLOCK/RDBLOCK/SDBLOCK address inside the file

stream : int

file handle

reduction : bool

sample reduction data block

FileIdentificationBlock Class

class asammdf.blocks.v4_blocks.FileIdentificationBlock(**kwargs)[source]

FileIdentificationBlock has the following attributes, that are also available as dict like key-value pairs

IDBLOCK fields

  • 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

Other attributes

  • address - int : should always be 0

HeaderBlock Class

class asammdf.blocks.v4_blocks.HeaderBlock(**kwargs)[source]

HeaderBlock has the following attributes, that are also available as dict like key-value pairs

HDBLOCK fields

  • 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

Other attributes

  • address - int : header address
  • comment - str : file comment
  • author - str : measurement author
  • department - str : author’s department
  • project - str : working project
  • subject - str : measurement subject
start_time

getter and setter the measurement start timestamp

Returns:
timestamp : datetime.datetime

start timestamp

SourceInformation Class

class asammdf.blocks.v4_blocks.SourceInformation(**kwargs)[source]

SourceInformation has the following attributes, that are also available as dict like key-value pairs

SIBLOCK fields

  • 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

Other attributes

  • address - int : source information address
  • comment - str : source comment
  • name - str : source name
  • path - str : source path

FileHistory Class

class asammdf.blocks.v4_blocks.FileHistory(**kwargs)[source]

FileHistory has the following attributes, that are also available as dict like key-value pairs

FHBLOCK fields

  • 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

Other attributes

  • address - int : file history address
  • comment - str : history comment

TextBlock Class

class asammdf.blocks.v4_blocks.TextBlock(**kwargs)[source]

common TXBLOCK and MDBLOCK class

TextBlock has the following attributes, that are also available as dict like key-value pairs

TXBLOCK fields

  • 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

Other attributes

  • address - int : text block address
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

EventBlock Class

class asammdf.blocks.v4_blocks.EventBlock(**kwargs)[source]

EventBlock has the following attributes, that are also available as dict like key-value pairs

EVBLOCK fields

  • id - bytes : block ID; always b’##EV’
  • reserved0 - int : reserved bytes
  • block_len - int : block bytes size
  • links_nr - int : number of links
  • next_ev_addr - int : address of next EVBLOCK
  • parent_ev_addr - int : address of parent EVLBOCK
  • range_start_ev_addr - int : address of EVBLOCK that is the start of the range for which this event is the end
  • name_addr - int : address of TXBLOCK that contains the event name
  • comment_addr - int : address of TXBLOCK/MDBLOCK that contains the event comment
  • scope_<N>_addr - int : address of N-th block that represents a scope for this event (can be CGBLOCK, CHBLOCK, DGBLOCK)
  • attachemnt_<N>_addr - int : address of N-th attachment referenced by this event
  • event_type - int : integer code for event type
  • sync_type - int : integer code for event sync type
  • range_type - int : integer code for event range type
  • cause - int : integer code for event cause
  • flags - int : event flags
  • reserved1 - int : reserved bytes
  • scope_nr - int : number of scopes referenced by this event
  • attachment_nr - int : number of attachments referenced by this event
  • creator_index - int : index of FHBLOCK
  • sync_base - int : timestamp base value
  • sync_factor - float : timestamp factor

Other attributes

  • address - int : event block address
  • comment - str : event comment
  • name - str : event name
  • parent - int : index of event block that is the parent for the current event
  • range_start - int : index of event block that is the start of the range for which the current event is the end
  • scopes - list : list of (group index, channel index) or channel group index that define the scope of the current event