channel module documentation¶
Measured Data Format file reader module.
Platform and python version¶
With Unix and Windows for python 2.7 and 3.4+
Author: | Aymeric Rateau |
---|
Created on Wed Oct 04 21:13:28 2017
Dependencies¶
- Python >2.6, >3.4 <http://www.python.org>
- Numpy >1.6 <http://numpy.scipy.org>
Attributes¶
- PythonVersion : float
- Python version currently running, needed for compatibility of both python 2.6+ and 3.4+
channel module¶
-
class
mdfreader.channel.
Channel3
(info, dataGroup, channelGroup, channelNumber, recordIDnumber)¶ Bases:
object
Channel class gathers all about channel structure in a record
Attributes
name (str) Name of channel unit (str, default empty string) channel unit desc (str) channel description conversion (info class) conversion dictionnary channelNumber (int) channel number corresponding to mdfinfo3.info3 class signalDataType (int) signal type according to specification bitCount (int) number of bits used to store channel record nBytes (int) number of bytes (1 byte = 8 bits) taken by channel record dataFormat (str) numpy dtype as string CFormat (struct class instance) struct instance to convert from C Format byteOffset (int) position of channel record in complete record in bytes bitOffset (int) bit position of channel value inside byte in case of channel having bit count below 8 recAttributeName (str) channel name compliant to a valid python identifier (recarray attribute) RecordFormat (list of str) dtype format used for numpy.core.records functions ((name_title,name),str_stype) channelType (int) channel type posByteBeg (int) start position in number of bit of channel record in complete record posByteEnd (int) end position in number of bit of channel record in complete record bit_masking_needed (bool, default false) True if bit masking needed after data read Methods
__init__(info, dataGroup, channelGroup, channelNumber, recordIDnumber) constructor __str__() to print class attributes -
changeChannelName
(channelGroup)¶ In case of duplicate channel names within several channel groups for unsorted data, rename channel name
Parameters: channelGroup : int
channelGroup bumber
-
-
mdfreader.channel.
arrayformat4
(signalDataType, numberOfBytes)¶ function returning numpy style string from channel data type and number of bits
Parameters: signalDataType : int
channel data type according to specification
numberOfBytes : int
number of bytes taken by channel data in a record
Returns: endian, dataType : str
numpy dtype format used by numpy.core.records to read channel raw data
-
class
mdfreader.channel.
channel4
¶ Bases:
object
Methods
CABlock
(info)Extracts channel CA Block from info4 CANOpenOffset
()CANopen channel bytes offset CFormat
(info)channel data C format struct object CNBlock
(info)channel block Format
(info)channel data C format attachment
(fid, info)In case of sync channel attached to channel bitCount
(info)calculates channel number of bits bitOffset
(info)channel data bit offset in record bit_masking_needed
(info)Valid if bit masking need calc_byteOffset
(info)channel data bytes offset in record (without record id) calc_bytes
(info)calculates channel bytes number changeChannelName
(channelGroup)In case of duplicate channel names within several channel groups for unsorted data, rename channel name channelSyncType
(info)Extracts channel sync type from info4 channelType
(info)Extracts channel type from info4 conversion
(info)channel conversion CCBlock data
(info)returns data block pointer for VLSD, MLD or sync channels dataFormat
(info)channel numpy.core.records data format desc
(info)channel description has_invalid_bit
(info)invalid_bit
(info)extracts from info4 the channels valid bits positions isCABlock
(info)isnumeric
(info)check this is numeric channel from data type little_endian
(info)check if channel is little endian nativedataFormat
(info)numpy_format
(info)channel numpy.core.records data format posBitBeg
(info)channel data bit starting position in record posBitEnd
(info)channel data bit ending position in record posByteBeg
(info)channel data bytes starting position in record posByteEnd
(info)channel data bytes ending position in record recAttributeName
(info)clean up channel name from unauthorised characters recordIDsize
(info)Extracts record id size from info4 set
(info, dataGroup, channelGroup, channelNumber)channel initialisation setCANOpen
(info, dataGroup, channelGroup, …)CANOpen channel intialisation setInvalidBytes
(info, dataGroup, …)invalid_bytes channel initialisation signalDataType
(info[, byte_aligned])extract signal data type from info4 class unit
(info)channel unit -
CABlock
(info)¶ Extracts channel CA Block from info4
Parameters: info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
Returns: CABlock object from mdfinfo4 module
-
CANOpenOffset
()¶ CANopen channel bytes offset
Returns: integer, channel bytes offset
-
CFormat
(info)¶ channel data C format struct object
Parameters: info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
Returns: string data C format struct object
-
CNBlock
(info)¶ channel block
Parameters: info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
Returns: CNBlock class from mdfinfo4 module
-
Format
(info)¶ channel data C format
Parameters: info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
Returns: string data C format
-
VLSD_CG_Flag
¶
-
attachment
(fid, info)¶ In case of sync channel attached to channel
Parameters: fid : class
file identifier
info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
Returns: ATBlock class from mdfinfo4 module
-
bitCount
(info)¶ calculates channel number of bits
Parameters: info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
Returns: integer corresponding to channel number of bits
-
bitOffset
(info)¶ channel data bit offset in record
Parameters: info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
Returns: integer, channel bit offset
-
bit_masking_needed
(info)¶ Valid if bit masking need
Parameters: info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
Returns: boolean True if channel needs bit masking, otherwise False
-
byteOffset
¶
-
calc_byteOffset
(info)¶ channel data bytes offset in record (without record id)
Parameters: info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
Returns: integer, channel bytes offset
-
calc_bytes
(info)¶ calculates channel bytes number
Parameters: info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
Returns: number of bytes integer
-
changeChannelName
(channelGroup)¶ In case of duplicate channel names within several channel groups for unsorted data, rename channel name
Parameters: channelGroup : int
channelGroup bumber
-
channelGroup
¶
-
channelNumber
¶
-
channelSyncType
(info)¶ Extracts channel sync type from info4
Parameters: info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
Returns: integer corresponding to channel sync type
0 no sync, normal data
1 time
2 angle
3 distance
4 index
-
channelType
(info)¶ Extracts channel type from info4
Parameters: info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
Returns: integer describing channel type
0 normal channel
1 variable length
2 master channel
3 virtual master channel
4 sync channel
5 max length data
6 virtual data channel
-
conversion
(info)¶ channel conversion CCBlock
Parameters: info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
Returns: CCBlock
-
data
(info)¶ returns data block pointer for VLSD, MLD or sync channels
-
dataFormat
(info)¶ channel numpy.core.records data format
Parameters: info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
Returns: string data format
-
dataGroup
¶
-
desc
(info)¶ channel description
Parameters: info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
Returns: channel description string
-
has_invalid_bit
(info)¶
-
invalid_bit
(info)¶ extracts from info4 the channels valid bits positions
Parameters: info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
Returns: channel valid bit position
-
isCABlock
(info)¶
-
isnumeric
(info)¶ check this is numeric channel from data type
Parameters: info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
Returns: boolean, true if numeric channel, otherwise false
-
little_endian
(info)¶ check if channel is little endian
Parameters: info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
Returns: boolean
-
nBytes
¶
-
name
¶
-
nativedataFormat
(info)¶
-
numpy_format
(info)¶ channel numpy.core.records data format
Parameters: info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
Returns: endian, dataType : string data format
-
posBitBeg
(info)¶ channel data bit starting position in record
Parameters: info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
Returns: integer, channel bit starting position
-
posBitEnd
(info)¶ channel data bit ending position in record
Parameters: info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
Returns: integer, channel bit ending position
-
posByteBeg
(info)¶ channel data bytes starting position in record
Parameters: info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
Returns: integer, channel bytes starting position
-
posByteEnd
(info)¶ channel data bytes ending position in record
Parameters: info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
Returns: integer, channel bytes ending position
-
recAttributeName
(info)¶ clean up channel name from unauthorised characters
Parameters: info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
Returns: channel name compliant to python attributes names (for recarray)
-
recordIDsize
(info)¶ Extracts record id size from info4
Parameters: info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
Returns: integer describing record id size
0 no record id used
1 uint8
2 uint16
4 uint32
8 uint64
-
set
(info, dataGroup, channelGroup, channelNumber)¶ channel initialisation
Parameters: info : mdfinfo4.info4 class
dataGroup : int
data group number in mdfinfo4.info4 class
channelGroup : int
channel group number in mdfinfo4.info4 class
channelNumber : int
channel number in mdfinfo4.info4 class
-
setCANOpen
(info, dataGroup, channelGroup, channelNumber, name)¶ CANOpen channel intialisation
Parameters: info : mdfinfo4.info4 class
dataGroup : int
data group number in mdfinfo4.info4 class
channelGroup : int
channel group number in mdfinfo4.info4 class
channelNumber : int
channel number in mdfinfo4.info4 class
name : str
name of channel. Should be in (‘ms’, ‘day’, ‘days’, ‘hour’, ‘month’, ‘minute’, ‘year’)
-
setInvalidBytes
(info, dataGroup, channelGroup, channelNumber)¶ invalid_bytes channel initialisation
Parameters: info : mdfinfo4.info4 class
dataGroup : int
data group number in mdfinfo4.info4 class
channelGroup : int
channel group number in mdfinfo4.info4 class
channelNumber : int
channel number in mdfinfo4.info4 class
-
signalDataType
(info, byte_aligned=True)¶ extract signal data type from info4 class
Parameters: info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
byte_aligned : bool
flag activated if channel is part of a record byte aligned
Returns: integer corresponding to channel data type
0 unsigned integer little endian
1 unsigned integer big endian
2 signed integer little endian
3 signed integer big endian
4 float little endian
5 float big endian
6 string latin
7 string utf-8
9 string utf-16
10 byte array
11 mime sample
12 mime stream
13 CANopen date
14 CANopen time
-
type
¶
-
unit
(info)¶ channel unit
Parameters: info : mdfinfo4.info4 class
info4 class containing all MDF Blocks
Returns: channel unit string
-
-
mdfreader.channel.
datatypeformat4
(signalDataType, numberOfBytes)¶ function returning C format string from channel data type and number of bits
Parameters: signalDataType : int
channel data type according to specification
numberOfBytes : int
number of bytes taken by channel data in a record
Returns: dataType : str
C format used by fread to read channel raw data