Commit 745e8395 authored by Javier Quinteros's avatar Javier Quinteros

Add attributes to the metadata collected for each channel

parent 723fa537
......@@ -354,6 +354,7 @@ class TDMS(object):
numobjects = struct.unpack('%cI' % self.__endian, self.__fi.read(4))[0]
logs.debug('Number of objects in metadata: %s' % numobjects)
curstarttime = None
datatype = None
numchannels = 0
# chunkSize = 0
......@@ -378,6 +379,7 @@ class TDMS(object):
pass
try:
curstarttime = self.metadata[obj]['GPSTimeStamp']
if self.starttime is None:
self.starttime = self.metadata[obj]['GPSTimeStamp']
except Exception:
......@@ -404,8 +406,10 @@ class TDMS(object):
logs.error('Array length MUST be 1! Actual value: %s' % arraylen)
self.metadata[obj]['datatype'] = self.__data2mask[datatype][0]
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'],
# 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])
......@@ -438,6 +442,13 @@ class TDMS(object):
# Calculate endtime based on the number of samples declared and the sampling rate
self.endtime = self.starttime + datetime.timedelta(seconds=(self.__samples-1)/self.sampling_rate)
for obj in self.metadata:
if not self.metadata[obj]['data']:
continue
self.metadata[obj]['samples'] = self.__samples
self.metadata[obj]['endtime'] = curstarttime + \
datetime.timedelta(seconds=(self.__samples - 1) / self.sampling_rate)
# Sample to start extraction from based on the initial datetime of the file (__twstart)
# print(self.__twstart, self.starttime)
......
......@@ -401,8 +401,8 @@ class StationAPI(object):
lon = None
elev = None
samprate = None
stt = t.starttime
ent = t.endtime
# stt = t.starttime
# ent = t.endtime
for data in t:
if lat is None:
lat = data[latkey]
......@@ -417,6 +417,8 @@ class StationAPI(object):
# yield json.dumps(data, default=datetime.isoformat)
if data['data']:
stt = data['starttime']
ent = data['endtime']
if level == 'station':
text = 'XX|%s||FH1|%s|%s|%s|SiteName|%s|%s\n' %\
(data['id'], lat, lon, elev, stt.isoformat(), ent.isoformat())
......
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