introducing new attribute __name to the datastructure objects. Used in autoPyLoT to distinguish between structure types.

This commit is contained in:
Sebastian Wehling-Benatelli 2015-04-29 06:29:08 +02:00
parent 8bf9b55288
commit 0760c2fe3a
2 changed files with 46 additions and 7 deletions

View File

@ -7,22 +7,49 @@ import argparse
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
from pylot.core.pick.CharFuns import HOScf, AICcf
from pylot.core.util.structure import DATASTRUCTURE
__version__ = _getVersionString() __version__ = _getVersionString()
METHOD = {'HOS':HOScf, 'AIC':AICcf}
def autoPyLoT(fnames, inputfile): def autoPyLoT(fnames, inputfile):
'''
Determine phase onsets automatically utilizing the automatic picking
algorithm by Kueperkoch et al. 2011.
:param fnames: list of strings containing the paths or urls to the
waveform data to be picked
:type fnames: list
:param inputfile: path to the input file containing all parameter
information for automatic picking (for formatting details, see.
`~pylot.core.read.input.AutoPickParameter`
:type inputfile: str
:return:
.. rubric:: Example
'''
parameter = AutoPickParameter(inputfile) parameter = AutoPickParameter(inputfile)
data = Data() data = Data()
data.setWFData(fnames)
print parameter.getParam('algoP') cfP = METHOD[parameter.getParam('algoP')]()
print(parameter) if parameter.hasParam('datastructure'):
datastructure = DATASTRUCTURE[parameter.getParam('datastructure')]()
print(data) def expandSDS(datastructure):
return datastructure.expandDataPath()
def expandPDS(datastructure):
return os.path.join(datastructure.expandDataPath(),'*')
dsem = {'PDS':expandPDS, 'SDS':expandSDS}
expandMethod = dsem[datastructure.getName()]
if __name__ == "__main__": if __name__ == "__main__":
# parse arguments # parse arguments

View File

@ -155,6 +155,7 @@ class GenericDataStructure(object):
def __init__(self, structexp='$R/$D/$E', folderdepth=2, **kwargs): def __init__(self, structexp='$R/$D/$E', folderdepth=2, **kwargs):
structureOptions = ('$R', '$D', '$E') structureOptions = ('$R', '$D', '$E')
self.__name = 'GDS'
structExpression = [] structExpression = []
depth = 0 depth = 0
while structexp is not os.path.sep: while structexp is not os.path.sep:
@ -180,6 +181,9 @@ class GenericDataStructure(object):
key = str(key).upper() key = str(key).upper()
self.__gdsFields[key] = value self.__gdsFields[key] = value
def getName(self):
return self.__name
def getFields(self): def getFields(self):
return self.__gdsFields return self.__gdsFields
@ -196,7 +200,9 @@ class PilotDataStructure(object):
def __init__(self, dataformat='GSE2', fsuffix='gse', def __init__(self, dataformat='GSE2', fsuffix='gse',
root='/data/Egelados/EVENT_DATA/LOCAL/', database='2006.01', root='/data/Egelados/EVENT_DATA/LOCAL/', database='2006.01',
**kwargs): **kwargs):
self.dataType = dataformat self.__name = 'PDS'
self.dataFormat = dataformat
self.dataType = 'waveform'
self.__pdsFields = {'ROOT': root, self.__pdsFields = {'ROOT': root,
'DATABASE': database, 'DATABASE': database,
'SUFFIX': fsuffix 'SUFFIX': fsuffix
@ -231,6 +237,9 @@ class PilotDataStructure(object):
def getFields(self): def getFields(self):
return self.__pdsFields return self.__pdsFields
def getName(self):
return self.__name
def expandDataPath(self): def expandDataPath(self):
datapath = os.path.join(self.getFields()['ROOT'], datapath = os.path.join(self.getFields()['ROOT'],
self.getFields()['DATABASE']) self.getFields()['DATABASE'])
@ -258,8 +267,8 @@ class SeiscompDataStructure(object):
} }
def __init__(self, dataType='waveform', sdate=None, edate=None, **kwargs): def __init__(self, dataType='waveform', sdate=None, edate=None, **kwargs):
# imports
from obspy.core import UTCDateTime self.__name = 'SDS'
def checkDate(date): def checkDate(date):
if not isinstance(date, UTCDateTime): if not isinstance(date, UTCDateTime):
@ -335,6 +344,9 @@ class SeiscompDataStructure(object):
def getFields(self): def getFields(self):
return self.__sdsFields return self.__sdsFields
def getName(self):
return self.__name
def expandDataPath(self): def expandDataPath(self):
fullChan = '{0}.{1}'.format(self.getFields()['CHAN'], self.getType()) fullChan = '{0}.{1}'.format(self.getFields()['CHAN'], self.getType())
dataPath = os.path.join(self.getFields()['SDSdir'], dataPath = os.path.join(self.getFields()['SDSdir'],