Commit 0f2a23fb authored by Javier Quinteros's avatar Javier Quinteros

Minor changes in tdms.py

parent 745e8395
......@@ -132,8 +132,6 @@ class TDMS(object):
# Name of file
self.__filename = filename
# FIXME directory is not properly used and is giving an Error if !='.'
self.__directory = directory
# List of available files in the directory
......@@ -375,14 +373,14 @@ class TDMS(object):
try:
if self.sampling_rate is None:
self.sampling_rate = self.metadata[obj]['SamplingFrequency[Hz]']
except Exception:
except KeyError:
pass
try:
curstarttime = self.metadata[obj]['GPSTimeStamp']
if self.starttime is None:
self.starttime = self.metadata[obj]['GPSTimeStamp']
except Exception:
except KeyError:
pass
continue
......@@ -409,9 +407,6 @@ class TDMS(object):
self.metadata[obj]['sampling_rate'] = self.sampling_rate
self.metadata[obj]['starttime'] = curstarttime
# logs.debug('obj %s; datatype: %s; numValues: %s; size: %s' % (obj, datatype, result['numValues'],
# self.__data2mask[datatype][1]*result['numValues']))
# channelSize = self.__data2mask[datatype][1]*numValues
self.__readproperties(self.metadata[obj])
# Set the data type as numpy expects it
......@@ -478,7 +473,7 @@ class TDMS(object):
logs.debug('Length of channel: %d' % channellength)
# New or changed objects
newobjects = struct.unpack('%cI' % self.__endian, self.__fi.read(4))[0]
# newobjects = struct.unpack('%cI' % self.__endian, self.__fi.read(4))[0]
def __iter__(self):
"""Iterate through data (or metadata) and filter and decimate if requested"""
......@@ -527,7 +522,7 @@ class TDMS(object):
leftover = len(nodecimation[ch]) % 5
# outbuf[ch]['stats']['starttime'] += 1/outbuf[ch]['stats']['sampling_rate']
outbuf[ch]['stats']['npts'] = 1
yield (nodecimation[ch][-leftover::5], outbuf[ch]['stats'])
yield nodecimation[ch][-leftover::5], outbuf[ch]['stats']
logs.debug('Flushing: %s %s' % (nodecimation[ch][-leftover::5], outbuf[ch]['stats']))
del outbuf[ch]
# self.__buffer[ch] = None
......@@ -735,7 +730,7 @@ class TDMS(object):
# logs.debug('result: %s' % result)
return result
def __readproperties(self, result=dict()):
def __readproperties(self, result=None):
"""For each property, the following information is stored:
Name (string)
Data type (tdsDataType)
......@@ -743,6 +738,9 @@ class TDMS(object):
"""
logs = logging.getLogger('readproperties')
if result is None:
result = dict()
numprops = struct.unpack('%cI' % self.__endian, self.__fi.read(4))[0]
if numprops:
logs.debug('%s properties' % numprops)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment