implementation of different data structure type handling
This commit is contained in:
parent
56a0563709
commit
5badf2ba34
31
autoPyLoT.py
31
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,24 +50,23 @@ 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}
|
||||
|
||||
expandMethod = dsem[datastructure.getName()]
|
||||
|
||||
data.setWFData(expandMethod())
|
||||
else:
|
||||
data.setWFData()
|
||||
# process each event in database
|
||||
datapath = datastructure.expandDataPath()
|
||||
for event in glob.glob(datapath):
|
||||
data.setWFData(os.path.join(datapath, event, '*'))
|
||||
print data
|
||||
|
||||
cfP = METHOD[meth](data.getWFData(), (tnoise, tsignal), thosmw, order)
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user