The following classes implement different MDF version 4 blocks.
AttachmentBlock Class¶
- class asammdf.blocks.v4_blocks.AttachmentBlock(**kwargs: Unpack[AttachmentBlockKwargs])[source]¶
When adding new attachments only embedded attachments are allowed, with keyword argument
dataof type bytes.AttachmentBlockhas the following attributes, which are also available as dict-like key-value pairs.ATBLOCK fields:
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 uncompressed file size in bytesembedded_size- int : embedded compressed file size in bytesembedded_data- bytes : embedded attachment bytes
Other attributes:
address- int : attachment addressfile_name- str : attachment file namemime- str : mime typecomment- str : attachment comment
- Parameters:
- addressint
Block address; to be used for objects created from file.
- streamhandle
File handle; to be used for objects created from file.
- for dynamically created objects
See the key-value pairs.
Channel Class¶
- class asammdf.blocks.v4_blocks.Channel(**kwargs: Unpack[ChannelKwargs])[source]¶
If the
load_metadatakeyword argument is not provided or is False, then the conversion, source and display name information is not processed. Furthermore if theparse_xml_commentis 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).Channelhas the following attributes, which are also available as dict-like key-value pairs.CNBLOCK fields:
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 the 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
Other attributes:
address- int : channel addressattachments- list : list of referenced attachment blocks indexes; the index reference to the attachment block indexcomment- str : channel commentconversion- ChannelConversion : channel conversion; None if the channel has no conversiondisplay_name- str : channel display name; this is extracted from the XML channel commentname- str : channel namesource- SourceInformation : channel source information; None if the channel has no source informationunit- str : channel unit
- Parameters:
- addressint
Block address; to be used for objects created from file.
- streamhandle
File handle; to be used for objects created from file.
- load_metadatabool
Option to load conversion, source and display_name; default is True.
- parse_xml_commentbool
Option to parse XML channel comment to search for display name; default is True.
- for dynamically created objects
See the key-value pairs.
ChannelConversion Class¶
- class asammdf.blocks.v4_blocks.ChannelConversion(**kwargs: Unpack[ChannelConversionKwargs])[source]¶
ChannelConversionhas the following attributes, which are also available as dict-like key-value pairs.CCBLOCK common fields:
id- bytes : block ID; always b’##CC’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 inverse 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
CCBLOCK specific fields:
linear conversion
a- float : factorb- float : offset
rational conversion
P1toP6- float : parameters
algebraic conversion
formula_addr- address of TXBLOCK that contains the algebraic conversion formula
tabular 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 transformation (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
Other attributes:
address- int : channel conversion addresscomment- str : channel conversion commentformula- str : algebraic conversion formula; default ‘’referenced_blocks- dict : dict of referenced blocks; can be TextBlock objects for value to text, and text to text conversions; for partial conversions the referenced blocks can be ChannelConversion object as wellname- str : channel conversion nameunit- str : channel conversion unit
ChannelGroup Class¶
- class asammdf.blocks.v4_blocks.ChannelGroup(**kwargs: Unpack[ChannelGroupKwargs])[source]¶
ChannelGrouphas the following attributes, which are also available as dict-like key-value pairs.CGBLOCK fields:
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 : address 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 the 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 channel group
Other attributes:
acq_name- str : acquisition nameacq_source- SourceInformation : acquisition source informationaddress- int : channel group addresscomment- str : channel group comment
DataGroup Class¶
- class asammdf.blocks.v4_blocks.DataGroup(**kwargs: Unpack[DataGroupKwargs])[source]¶
DataGrouphas the following attributes, which are also available as dict-like key-value pairs.DGBLOCK fields:
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 that 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
Other attributes:
address- int : data group addresscomment- str : data group comment
DataList Class¶
- class asammdf.blocks.v4_blocks.DataList(**kwargs: Unpack[DataListKwargs])[source]¶
DataListhas the following attributes, which are also available as dict-like key-value pairs.DLBLOCK common fields:
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 this list
DLBLOCK specific fields:
for equal-length blocks
data_block_len- int : equal uncompressed size in bytes for all referenced data blocks; last block can be smaller
for variable-length 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: Unpack[DataBlockKwargs])[source]¶
Common implementation for DTBLOCK/RDBLOCK/SDBLOCK/DVBLOCK/DIBLOCK.
DataBlockhas the following attributes, which are also available as dict-like key-value pairs.DTBLOCK fields:
id- bytes : block ID; b’##DT’ for DTBLOCK, b’##RD’ for RDBLOCK, b’##SD’ for SDBLOCK, b’##DV’ for DVBLOCK or b’##DI’ for DIBLOCKreserved0- int : reserved bytesblock_len- int : block bytes sizelinks_nr- int : number of linksdata- bytes : raw samples
Other attributes:
address- int : data block address
- Parameters:
- addressint
DTBLOCK/RDBLOCK/SDBLOCK/DVBLOCK/DIBLOCK address inside the file.
- streamint
File handle.
- reductionbool
Sample reduction data block.
FileIdentificationBlock Class¶
- class asammdf.blocks.v4_blocks.FileIdentificationBlock(**kwargs: Unpack[FileIdentificationBlockKwargs])[source]¶
FileIdentificationBlockhas the following attributes, which are also available as dict-like key-value pairs.IDBLOCK fields:
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
Other attributes:
address- int : should always be 0
HeaderBlock Class¶
- class asammdf.blocks.v4_blocks.HeaderBlock(**kwargs: Unpack[HeaderBlockKwargs])[source]¶
HeaderBlockhas the following attributes, which are also available as dict-like key-value pairs.HDBLOCK fields:
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 : timestamp 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
Other attributes:
address- int : header addresscomment- str : file commentauthor- str : measurement authordepartment- str : author’s departmentproject- str : working projectsubject- str : measurement subject
- property start_time: datetime¶
Getter and setter of the measurement start timestamp.
- Returns:
- timestampdatetime.datetime
Start timestamp.
SourceInformation Class¶
- class asammdf.blocks.v4_blocks.SourceInformation(**kwargs: Unpack[SourceInformationKwargs])[source]¶
SourceInformationhas the following attributes, which are also available as dict-like key-value pairs.SIBLOCK fields:
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 that 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
Other attributes:
address- int : source information addresscomment- str : source commentname- str : source namepath- str : source path
FileHistory Class¶
- class asammdf.blocks.v4_blocks.FileHistory(**kwargs: Unpack[FileHistoryKwargs])[source]¶
FileHistoryhas the following attributes, which are also available as dict-like key-value pairs.FHBLOCK fields:
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 : timestamp 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
Other attributes:
address- int : file history addresscomment- str : history comment
- property time_stamp: datetime¶
Getter and setter of the file history timestamp.
- Returns:
- timestampdatetime.datetime
Start timestamp.
TextBlock Class¶
- class asammdf.blocks.v4_blocks.TextBlock(**kwargs: Unpack[TextBlockKwargs])[source]¶
Common TXBLOCK and MDBLOCK class.
TextBlockhas the following attributes, which are also available as dict-like key-value pairs.TXBLOCK fields:
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
Other attributes:
address- int : text block address
- Parameters:
- addressint
Block address.
- streamhandle
File handle.
- metabool
Flag to set the block type to MDBLOCK for dynamically created objects; default is False.
- textbytes/str
Text content for dynamically created objects.
EventBlock Class¶
- class asammdf.blocks.v4_blocks.EventBlock(**kwargs: Unpack[EventBlockKwargs])[source]¶
EventBlockhas the following attributes, which are also available as dict-like key-value pairs.EVBLOCK fields:
id- bytes : block ID; always b’##EV’reserved0- int : reserved bytesblock_len- int : block bytes sizelinks_nr- int : number of linksnext_ev_addr- int : address of next EVBLOCKparent_ev_addr- int : address of parent EVLBOCKrange_start_ev_addr- int : address of EVBLOCK that is the start of the range for which this event is the endname_addr- int : address of TXBLOCK that contains the event namecomment_addr- int : address of TXBLOCK/MDBLOCK that contains the event commentscope_<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 eventevent_type- int : integer code for event typesync_type- int : integer code for event sync typerange_type- int : integer code for event range typecause- int : integer code for event causeflags- int : event flagsreserved1- int : reserved bytesscope_nr- int : number of scopes referenced by this eventattachment_nr- int : number of attachments referenced by this eventcreator_index- int : index of FHBLOCKsync_base- int : timestamp base valuesync_factor- float : timestamp factor
Other attributes:
address- int : event block addresscomment- str : event commentname- str : event nameparent- int : index of event block that is the parent for the current eventrange_start- int : index of event block that is the start of the range for which the current event is the endscopes- list : list of (group index, channel index) or channel group index that define the scope of the current event