Skip to content
Snippets Groups Projects
Commit 19b0043f authored by Mads M. Pedersen's avatar Mads M. Pedersen
Browse files

made gtsdf similar to other formats in hawc2io and chaned htcFile to add...

made gtsdf similar to other formats in hawc2io and chaned htcFile to add OutputSection if name is output
parent c3f3b167
No related branches found
No related tags found
1 merge request!2Fw h2 wrapper
...@@ -159,7 +159,7 @@ class ReadHawc2(object): ...@@ -159,7 +159,7 @@ class ReadHawc2(object):
self._ReadSensorFile() self._ReadSensorFile()
elif FileName.lower().endswith('.hdf5') or os.path.isfile(self.FileName + ".hdf5"): elif FileName.lower().endswith('.hdf5') or os.path.isfile(self.FileName + ".hdf5"):
self.FileFormat = 'GTSDF' self.FileFormat = 'GTSDF'
self.ReadAll() self.ReadGtsdf()
else: else:
print ("unknown file: " + FileName) print ("unknown file: " + FileName)
################################################################################ ################################################################################
...@@ -197,14 +197,15 @@ class ReadHawc2(object): ...@@ -197,14 +197,15 @@ class ReadHawc2(object):
def ReadGtsdf(self): def ReadGtsdf(self):
self.t, data, info = gtsdf.load(self.FileName + '.hdf5') self.t, data, info = gtsdf.load(self.FileName + '.hdf5')
self.Time = self.t self.Time = self.t
self.ChInfo = [info['attribute_names'], self.ChInfo = [['Time'] + info['attribute_names'],
info['attribute_units'], ['s'] + info['attribute_units'],
info['attribute_descriptions']] ['Time'] + info['attribute_descriptions']]
self.NrCh = data.shape[1] self.NrCh = data.shape[1] + 1
self.NrSc = data.shape[0] self.NrSc = data.shape[0]
self.Freq = self.NrSc / self.Time self.Freq = self.NrSc / self.Time
self.FileFormat = 'GTSDF' self.FileFormat = 'GTSDF'
self.gtsdf_description = info['description'] self.gtsdf_description = info['description']
data = np.hstack([self.Time[:,np.newaxis], data])
return data return data
################################################################################ ################################################################################
# One stop call for reading all data formats # One stop call for reading all data formats
......
...@@ -131,7 +131,12 @@ class HTCContents(object): ...@@ -131,7 +131,12 @@ class HTCContents(object):
def add_section(self, name, allow_duplicate=False): def add_section(self, name, allow_duplicate=False):
if name in self and allow_duplicate is False: if name in self and allow_duplicate is False:
return self[name] return self[name]
section = HTCSection(name) if name == "output":
section = HTCOutputSection(name)
elif name.startswith("output_at_time"):
section = HTCOutputAtTimeSection(name)
else:
section = HTCSection(name)
self._add_contents(section) self._add_contents(section)
return section return section
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment