implementation of different data structure type handling

This commit is contained in:
Sebastian Wehling-Benatelli 2015-05-20 09:38:25 +02:00
parent 56a0563709
commit 5badf2ba34
2 changed files with 22 additions and 14 deletions

View File

@ -4,6 +4,7 @@
import os import os
import argparse import argparse
import glob
from pylot.core.util import _getVersionString from pylot.core.util import _getVersionString
from pylot.core.read import Data, AutoPickParameter from pylot.core.read import Data, AutoPickParameter
@ -32,10 +33,15 @@ def autoPyLoT(fnames, inputfile):
.. rubric:: Example .. rubric:: Example
''' '''
# reading parameter file
parameter = AutoPickParameter(inputfile) parameter = AutoPickParameter(inputfile)
data = Data() data = Data()
# declaring parameter variables (only for convenience)
meth = parameter.getParam('algoP') meth = parameter.getParam('algoP')
tsnr1 = parameter.getParam('tsnr1') tsnr1 = parameter.getParam('tsnr1')
tsnr2 = parameter.getParam('tsnr2') tsnr2 = parameter.getParam('tsnr2')
@ -44,26 +50,25 @@ def autoPyLoT(fnames, inputfile):
order = parameter.getParam('hosorder') order = parameter.getParam('hosorder')
thosmw = parameter.getParam('tlta') thosmw = parameter.getParam('tlta')
# getting information on data structure
if parameter.hasParam('datastructure'): if parameter.hasParam('datastructure'):
datastructure = DATASTRUCTURE[parameter.getParam('datastructure')]() datastructure = DATASTRUCTURE[parameter.getParam('datastructure')]()
dsfields = {'root':parameter.getParam('rootpath')} #see TODO: in data.py dsfields = {'root':parameter.getParam('rootpath'),
datastructure.modifyFields(dsfields) 'dpath':parameter.getParam('datapath'),
'dbase':parameter.getParam('database')}
def expandSDS(datastructure): datastructure.modifyFields(**dsfields)
return datastructure.expandDataPath()
def expandPDS(datastructure): datastructure.setExpandFields(['root', 'dpath', 'dbase'])
return os.path.join(datastructure.expandDataPath(),'*')
dsem = {'PDS':expandPDS, 'SDS':expandSDS} # process each event in database
datapath = datastructure.expandDataPath()
for event in glob.glob(datapath):
data.setWFData(os.path.join(datapath, event, '*'))
print data
expandMethod = dsem[datastructure.getName()] cfP = METHOD[meth](data.getWFData(), (tnoise, tsignal), thosmw, order)
data.setWFData(expandMethod())
else:
data.setWFData()
cfP = METHOD[meth](data.getWFData(), (tnoise, tsignal), thosmw, order)
if __name__ == "__main__": if __name__ == "__main__":
# parse arguments # parse arguments

View File

@ -50,6 +50,9 @@ class Data(object):
self.cuttimes = None self.cuttimes = None
self.dirty = False self.dirty = False
def __str__(self):
return str(self.evtdata), '\n', str(self.wfdata)
def getParent(self): def getParent(self):
return self._parent return self._parent