mdfinfo4 module documentation

Measured Data Format blocks paser for version 4.x

Platform and python version

With Unix and Windows for python 2.6+ and 3.2+

Created on Sun Dec 15 12:57:28 2013

Author:Aymeric Rateau

Dependencies

Attributes

PythonVersion : float
Python version currently running, needed for compatibility of both python 2.6+ and 3.2+

mdfinfo4 module

class mdfreader.mdfinfo4.ATBlock(fid, pointer)

Bases: dict

reads Attachment block and saves in class dict

Methods

clear()
copy()
fromkeys($type, iterable[, value]) Returns a new dict with keys from iterable and values equal to value.
get(k[,d])
items()
keys()
pop(k[,d]) If key is not found, d is returned if given, otherwise KeyError is raised
popitem() 2-tuple; but raise KeyError if D is empty.
setdefault(k[,d])
update([E, ]**F) If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()
class mdfreader.mdfinfo4.CABlock

Bases: dict

reads Channel Array block and saves in class dict

Methods

clear()
copy()
fromkeys($type, iterable[, value]) Returns a new dict with keys from iterable and values equal to value.
get(k[,d])
items()
keys()
load(byte_offset_base)
pop(k[,d]) If key is not found, d is returned if given, otherwise KeyError is raised
popitem() 2-tuple; but raise KeyError if D is empty.
read(fid, pointer)
setdefault(k[,d])
update([E, ]**F) If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()
write(fid)
load(byte_offset_base)
read(fid, pointer)
write(fid)
class mdfreader.mdfinfo4.CCBlock

Bases: dict

reads Channel Conversion block and saves in class dict

Methods

clear()
copy()
fromkeys($type, iterable[, value]) Returns a new dict with keys from iterable and values equal to value.
get(k[,d])
items()
keys()
pop(k[,d]) If key is not found, d is returned if given, otherwise KeyError is raised
popitem() 2-tuple; but raise KeyError if D is empty.
readCC(fid, pointer)
setdefault(k[,d])
update([E, ]**F) If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()
readCC(fid, pointer)
class mdfreader.mdfinfo4.CGBlock(fid=None, pointer=None)

Bases: dict

reads Channel Group block and saves in class dict

Methods

clear()
copy()
fromkeys($type, iterable[, value]) Returns a new dict with keys from iterable and values equal to value.
get(k[,d])
items()
keys()
pop(k[,d]) If key is not found, d is returned if given, otherwise KeyError is raised
popitem() 2-tuple; but raise KeyError if D is empty.
read(fid, pointer)
setdefault(k[,d])
update([E, ]**F) If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()
write(fid)
read(fid, pointer)
write(fid)
class mdfreader.mdfinfo4.CHBlock(fid, pointer)

Bases: dict

reads Channel Hierarchy block and saves in class dict

Methods

clear()
copy()
fromkeys($type, iterable[, value]) Returns a new dict with keys from iterable and values equal to value.
get(k[,d])
items()
keys()
pop(k[,d]) If key is not found, d is returned if given, otherwise KeyError is raised
popitem() 2-tuple; but raise KeyError if D is empty.
setdefault(k[,d])
update([E, ]**F) If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()
class mdfreader.mdfinfo4.CNBlock

Bases: dict

reads Channel block and saves in class dict

Methods

clear()
copy()
fromkeys($type, iterable[, value]) Returns a new dict with keys from iterable and values equal to value.
get(k[,d])
items()
keys()
pop(k[,d]) If key is not found, d is returned if given, otherwise KeyError is raised
popitem() 2-tuple; but raise KeyError if D is empty.
readCN(**kargs)
setdefault(k[,d])
update([E, ]**F) If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()
write(fid)
readCN(**kargs)
write(fid)
class mdfreader.mdfinfo4.CommentBlock

Bases: dict

reads or writes Comment block and saves in class dict

Methods

clear()
copy()
fromkeys($type, iterable[, value]) Returns a new dict with keys from iterable and values equal to value.
get(k[,d])
items()
keys()
load(data, MDType)
pop(k[,d]) If key is not found, d is returned if given, otherwise KeyError is raised
popitem() 2-tuple; but raise KeyError if D is empty.
readCM(**kargs) reads Comment block and saves in class dict Parameters ———- fid: file identifier pointer: int position in file MDType: str describes metadata type, (‘CN’, ‘unit’, ‘FH’, ‘SI’, ‘HD’, ‘CC’, ‘EV’)
setdefault(k[,d])
update([E, ]**F) If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()
write(fid)
load(data, MDType)
readCM(**kargs)

reads Comment block and saves in class dict Parameters ———- fid: file identifier pointer: int

position in file
MDType: str
describes metadata type, (‘CN’, ‘unit’, ‘FH’, ‘SI’, ‘HD’, ‘CC’, ‘EV’)

Notes

Can read xml (MD metadata) or text (TX) comments from several kind of blocks

write(fid)
class mdfreader.mdfinfo4.DGBlock(fid=None, pointer=None)

Bases: dict

reads Data Group block and saves in class dict

Methods

clear()
copy()
fromkeys($type, iterable[, value]) Returns a new dict with keys from iterable and values equal to value.
get(k[,d])
items()
keys()
pop(k[,d]) If key is not found, d is returned if given, otherwise KeyError is raised
popitem() 2-tuple; but raise KeyError if D is empty.
read(fid, pointer)
setdefault(k[,d])
update([E, ]**F) If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()
write(fid)
read(fid, pointer)
write(fid)
class mdfreader.mdfinfo4.DLBlock

Bases: dict

reads Data List block

Methods

clear()
copy()
fromkeys($type, iterable[, value]) Returns a new dict with keys from iterable and values equal to value.
get(k[,d])
items()
keys()
pop(k[,d]) If key is not found, d is returned if given, otherwise KeyError is raised
popitem() 2-tuple; but raise KeyError if D is empty.
read(fid, link_count)
setdefault(k[,d])
update([E, ]**F) If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()
write(fid, chunks, position)
read(fid, link_count)
write(fid, chunks, position)
class mdfreader.mdfinfo4.DTBlock() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

Bases: dict

Methods

clear()
copy()
fromkeys($type, iterable[, value]) Returns a new dict with keys from iterable and values equal to value.
get(k[,d])
items()
keys()
load(record_byte_offset, nRecords, pointer)
pop(k[,d]) If key is not found, d is returned if given, otherwise KeyError is raised
popitem() 2-tuple; but raise KeyError if D is empty.
setdefault(k[,d])
update([E, ]**F) If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()
write(fid, data)
load(record_byte_offset, nRecords, pointer)
write(fid, data)
class mdfreader.mdfinfo4.DZBlock

Bases: dict

reads Data List block

Methods

clear()
copy()
decompress_datablock(block, zip_type, …) decompress datablock.
fromkeys($type, iterable[, value]) Returns a new dict with keys from iterable and values equal to value.
get(k[,d])
items()
keys()
pop(k[,d]) If key is not found, d is returned if given, otherwise KeyError is raised
popitem() 2-tuple; but raise KeyError if D is empty.
read(fid)
setdefault(k[,d])
update([E, ]**F) If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()
write(fid, data, record_length)
static decompress_datablock(block, zip_type, zip_parameter, org_data_length)

decompress datablock.

Parameters:

block : bytes

raw data compressed

zip_type : int

0 for non transposed, 1 for transposed data

zip_parameter : int

first dimension of matrix to be transposed

org_data_length : int

uncompressed data length

Returns:

uncompressed raw data

read(fid)
write(fid, data, record_length)
class mdfreader.mdfinfo4.EVBlock(fid, pointer)

Bases: dict

reads Event block and saves in class dict

Methods

clear()
copy()
fromkeys($type, iterable[, value]) Returns a new dict with keys from iterable and values equal to value.
get(k[,d])
items()
keys()
pop(k[,d]) If key is not found, d is returned if given, otherwise KeyError is raised
popitem() 2-tuple; but raise KeyError if D is empty.
setdefault(k[,d])
update([E, ]**F) If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()
class mdfreader.mdfinfo4.FHBlock(fid=None, pointer=None)

Bases: dict

reads File History block and save in class dict

Methods

clear()
copy()
fromkeys($type, iterable[, value]) Returns a new dict with keys from iterable and values equal to value.
get(k[,d])
items()
keys()
pop(k[,d]) If key is not found, d is returned if given, otherwise KeyError is raised
popitem() 2-tuple; but raise KeyError if D is empty.
read(fid, pointer)
setdefault(k[,d])
update([E, ]**F) If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()
write(fid)
read(fid, pointer)
write(fid)
class mdfreader.mdfinfo4.HDBlock(fid=None, pointer=64)

Bases: dict

reads Header block and save in class dict

Methods

clear()
copy()
fromkeys($type, iterable[, value]) Returns a new dict with keys from iterable and values equal to value.
get(k[,d])
items()
keys()
pop(k[,d]) If key is not found, d is returned if given, otherwise KeyError is raised
popitem() 2-tuple; but raise KeyError if D is empty.
read([fid, pointer])
setdefault(k[,d])
update([E, ]**F) If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()
write(fid)
read(fid=None, pointer=64)
write(fid)
class mdfreader.mdfinfo4.HLBlock

Bases: dict

reads Header List block

Methods

clear()
copy()
fromkeys($type, iterable[, value]) Returns a new dict with keys from iterable and values equal to value.
get(k[,d])
items()
keys()
load(record_byte_offset, nRecords, position)
pop(k[,d]) If key is not found, d is returned if given, otherwise KeyError is raised
popitem() 2-tuple; but raise KeyError if D is empty.
read(fid)
setdefault(k[,d])
update([E, ]**F) If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()
write(fid, data)
load(record_byte_offset, nRecords, position)
read(fid)
write(fid, data)
class mdfreader.mdfinfo4.IDBlock(fid=None)

Bases: dict

reads or writes ID Block

Methods

clear()
copy()
fromkeys($type, iterable[, value]) Returns a new dict with keys from iterable and values equal to value.
get(k[,d])
items()
keys()
pop(k[,d]) If key is not found, d is returned if given, otherwise KeyError is raised
popitem() 2-tuple; but raise KeyError if D is empty.
read(fid) reads IDBlock
setdefault(k[,d])
update([E, ]**F) If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()
write(fid) Writes IDBlock
read(fid)

reads IDBlock

write(fid)

Writes IDBlock

class mdfreader.mdfinfo4.SIBlock

Bases: dict

reads Source Information block and saves in class dict

Methods

clear()
copy()
fromkeys($type, iterable[, value]) Returns a new dict with keys from iterable and values equal to value.
get(k[,d])
items()
keys()
pop(k[,d]) If key is not found, d is returned if given, otherwise KeyError is raised
popitem() 2-tuple; but raise KeyError if D is empty.
readSI(fid, pointer)
setdefault(k[,d])
update([E, ]**F) If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()
readSI(fid, pointer)
class mdfreader.mdfinfo4.SRBlock(fid, pointer)

Bases: dict

reads Sample Reduction block and saves in class dict

Methods

clear()
copy()
fromkeys($type, iterable[, value]) Returns a new dict with keys from iterable and values equal to value.
get(k[,d])
items()
keys()
pop(k[,d]) If key is not found, d is returned if given, otherwise KeyError is raised
popitem() 2-tuple; but raise KeyError if D is empty.
setdefault(k[,d])
update([E, ]**F) If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()
class mdfreader.mdfinfo4.info4() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

Bases: dict

Methods

cleanDGinfo(dg) delete CN,CC and CG blocks related to data group
clear()
copy()
fromkeys($type, iterable[, value]) Returns a new dict with keys from iterable and values equal to value.
get(k[,d])
items()
keys()
listChannels4([fileName, fid]) Read MDF file and extract its complete structure
pop(k[,d]) If key is not found, d is returned if given, otherwise KeyError is raised
popitem() 2-tuple; but raise KeyError if D is empty.
readATBlock(fid, pointer) reads Attachment blocks
readCGBlock(fid, dg[, channelNameList, minimal]) reads Channel Group blocks
readCNBlock(fid, dg, cg[, channelNameList, …]) reads Channel blocks
readComposition(fid, dg, cg, MLSDChannels) check for composition of channels, arrays or structures
readDGBlock(fid[, channelNameList, minimal]) reads Data Group Blocks
readSRBlock(fid, pointer) reads Sample Reduction Blocks
readinfo(fid, minimal) read all file blocks except data
setdefault(k[,d])
unique_id(ndg, ncg, ncn) generate unique id tuples
update([E, ]**F) If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()
cleanDGinfo(dg)

delete CN,CC and CG blocks related to data group

Parameters:

dg : int

data group number

fid
fileName
listChannels4(fileName=None, fid=None)

Read MDF file and extract its complete structure

Parameters:

fileName : str

file name

Returns:

list of channel names contained in file

readATBlock(fid, pointer)

reads Attachment blocks

Parameters:

fid : float

file identifier

pointer : int

position of ATBlock in file

Returns:

Attachments Blocks in a dict

readCGBlock(fid, dg, channelNameList=False, minimal=0)

reads Channel Group blocks

Parameters:

fid : float

file identifier

dg : int

data group number

channelNameList : bool

Flag to reads only channel blocks for listChannels4 method

minimal: falg

to activate minimum content reading for raw data fetching

readCNBlock(fid, dg, cg, channelNameList=False, minimal=0)

reads Channel blocks

Parameters:

fid : float

file identifier

dg : int

data group number

cg : int

channel group number in data group

channelNameList : bool

Flag to reads only channel blocks for listChannels4 method

minimal: falg

to activate minimum content reading for raw data fetching

readComposition(fid, dg, cg, MLSDChannels)

check for composition of channels, arrays or structures

Parameters:

fid : float

file identifier

dg : int

data group number

cg : int

channel group number in data group

MLSDChannels : list of int

channel numbers

Returns:

MLSDChannels list of appended Maximum Length Sampling Data channels

readDGBlock(fid, channelNameList=False, minimal=0)

reads Data Group Blocks

Parameters:

fid : float

file identifier

channelNameList : bool

Flag to reads only channel blocks for listChannels4 method

minimal: falg

to activate minimum content reading for raw data fetching

readSRBlock(fid, pointer)

reads Sample Reduction Blocks

Parameters:

fid : float

file identifier

pointer : int

position of SRBlock in file

Returns:

Sample Reduction Blocks in a dict

readinfo(fid, minimal)

read all file blocks except data

Parameters:

fid : float

file identifier

minimal: falg

to activate minimum content reading for raw data fetching

unique_id(ndg, ncg, ncn)

generate unique id tuples

Parameters:

ndg : int

data group number

ncg: int

channel group number

ncn : int

channel number

Returns:

tuples: (data group number, channel group number, channel number),

(channel name, channel source, channel path), (group name, group source, group path)

zipfile