From 5badf2ba34d09b7f1bac6967ff80fee33b344dc3 Mon Sep 17 00:00:00 2001 From: Sebastian Wehling-Benatelli Date: Wed, 20 May 2015 09:38:25 +0200 Subject: [PATCH] implementation of different data structure type handling --- autoPyLoT.py | 33 +++++++++++++++++++-------------- pylot/core/read/data.py | 3 +++ 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/autoPyLoT.py b/autoPyLoT.py index 36cbf696..d10f1853 100755 --- a/autoPyLoT.py +++ b/autoPyLoT.py @@ -4,6 +4,7 @@ import os import argparse +import glob from pylot.core.util import _getVersionString from pylot.core.read import Data, AutoPickParameter @@ -32,10 +33,15 @@ def autoPyLoT(fnames, inputfile): .. rubric:: Example ''' + + # reading parameter file + parameter = AutoPickParameter(inputfile) data = Data() + # declaring parameter variables (only for convenience) + meth = parameter.getParam('algoP') tsnr1 = parameter.getParam('tsnr1') tsnr2 = parameter.getParam('tsnr2') @@ -44,26 +50,25 @@ def autoPyLoT(fnames, inputfile): order = parameter.getParam('hosorder') thosmw = parameter.getParam('tlta') + # getting information on data structure + if parameter.hasParam('datastructure'): datastructure = DATASTRUCTURE[parameter.getParam('datastructure')]() - dsfields = {'root':parameter.getParam('rootpath')} #see TODO: in data.py - datastructure.modifyFields(dsfields) + dsfields = {'root':parameter.getParam('rootpath'), + 'dpath':parameter.getParam('datapath'), + 'dbase':parameter.getParam('database')} - def expandSDS(datastructure): - return datastructure.expandDataPath() + datastructure.modifyFields(**dsfields) - def expandPDS(datastructure): - return os.path.join(datastructure.expandDataPath(),'*') + datastructure.setExpandFields(['root', 'dpath', 'dbase']) - 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()] - - data.setWFData(expandMethod()) - else: - data.setWFData() - - cfP = METHOD[meth](data.getWFData(), (tnoise, tsignal), thosmw, order) + cfP = METHOD[meth](data.getWFData(), (tnoise, tsignal), thosmw, order) if __name__ == "__main__": # parse arguments diff --git a/pylot/core/read/data.py b/pylot/core/read/data.py index 5ea1dfe2..126310d5 100644 --- a/pylot/core/read/data.py +++ b/pylot/core/read/data.py @@ -50,6 +50,9 @@ class Data(object): self.cuttimes = None self.dirty = False + def __str__(self): + return str(self.evtdata), '\n', str(self.wfdata) + def getParent(self): return self._parent