From becff26aef28f9d319eb9cc4a88422d2d0d8adc5 Mon Sep 17 00:00:00 2001 From: "aymeric.rateau@gmail.com" Date: Tue, 3 Feb 2015 00:09:59 +0000 Subject: [PATCH] mdf4reader: in case of several 'time' channels in different data groups, only one time remaining and overwritten so added datagroup number to master channel name --- mdf4reader.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/mdf4reader.py b/mdf4reader.py index d967d0f..8ffac30 100644 --- a/mdf4reader.py +++ b/mdf4reader.py @@ -542,6 +542,8 @@ def __init__(self, info, dataGroup, channelGroup, channelNumber, recordIDsize): if self.channelType==1: # if VSLD self.dataFormat=arrayformat4(0, self.bitCount ) self.maxLengthVLSDRecord=0 # initialises max length of SDBlock elements to 0 for later calculation + if self.channelType in (2, 3): # master channel, add datagroup number to avoid overwriting same sames like time + self.name+=str(dataGroup) self.RecordFormat=((self.name, convertName(self.name)), self.dataFormat) if not self.signalDataType in (13, 14): # processed by several channels if not self.channelType==1: # if VSLD @@ -933,9 +935,9 @@ def read4( self, fileName=None, info = None, multiProc = False, channelList=None buf.addRecord(temp) for channel in info['CNBlock'][dataGroup][channelGroup].keys(): if info['CNBlock'][dataGroup][channelGroup][channel]['cn_type'] in (2, 3): - masterDataGroup[dataGroup]=info['CNBlock'][dataGroup][channelGroup][channel]['name'] + masterDataGroup[dataGroup]=info['CNBlock'][dataGroup][channelGroup][channel]['name']+str(dataGroup) - buf.read(channelList) + buf.read(channelList) # reads raw data with DATA and DATABlock classes # Convert channels to physical values OkBuf=len(buf)>0 and 'data' in buf[list(buf.keys())[0]] and buf[list(buf.keys())[0]]['data'] is not None @@ -965,6 +967,8 @@ def read4( self, fileName=None, info = None, multiProc = False, channelList=None for channelGroup in list(info['CGBlock'][dataGroup].keys()): for channel in list(info['CNBlock'][dataGroup][channelGroup].keys()): channelName = info['CNBlock'][dataGroup][channelGroup][channel]['name'] + if info['CNBlock'][dataGroup][channelGroup][channel]['cn_type'] in(2, 3): + channelName+=str(dataGroup) if channelName in L and len( L[channelName] ) != 0: if masterDataGroup: #master channel exist self.masterChannelList[masterDataGroup[dataGroup]].append(channelName) @@ -1318,8 +1322,10 @@ def convertChannelData4(channel, convert_tables=False): Parameters ---------------- - channelName : str - Name of channel + channelName : dict + channel dict containing keys like 'data', 'unit', 'comment' and potentially 'conversion' dict + convert_tables : bool + activates computation intensive loops for conversion with tables. Default is False Returns ----------- @@ -1367,7 +1373,7 @@ def linearConv(vect, cc_val): """ P1 = cc_val[0] P2 = cc_val[1] - return vect* P2 + P1 + return vect*P2 + P1 def rationalConv(vect, cc_val): """ apply rational conversion to data