introducing new attribute __name to the datastructure objects. Used in autoPyLoT to distinguish between structure types.
This commit is contained in:
parent
8bf9b55288
commit
0760c2fe3a
35
autoPyLoT.py
35
autoPyLoT.py
@ -7,22 +7,49 @@ import argparse
|
||||
|
||||
from pylot.core.util import _getVersionString
|
||||
from pylot.core.read import Data, AutoPickParameter
|
||||
from pylot.core.pick.CharFuns import HOScf, AICcf
|
||||
from pylot.core.util.structure import DATASTRUCTURE
|
||||
|
||||
|
||||
__version__ = _getVersionString()
|
||||
|
||||
METHOD = {'HOS':HOScf, 'AIC':AICcf}
|
||||
|
||||
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)
|
||||
|
||||
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__":
|
||||
# parse arguments
|
||||
|
@ -155,6 +155,7 @@ class GenericDataStructure(object):
|
||||
|
||||
def __init__(self, structexp='$R/$D/$E', folderdepth=2, **kwargs):
|
||||
structureOptions = ('$R', '$D', '$E')
|
||||
self.__name = 'GDS'
|
||||
structExpression = []
|
||||
depth = 0
|
||||
while structexp is not os.path.sep:
|
||||
@ -180,6 +181,9 @@ class GenericDataStructure(object):
|
||||
key = str(key).upper()
|
||||
self.__gdsFields[key] = value
|
||||
|
||||
def getName(self):
|
||||
return self.__name
|
||||
|
||||
def getFields(self):
|
||||
return self.__gdsFields
|
||||
|
||||
@ -196,7 +200,9 @@ class PilotDataStructure(object):
|
||||
def __init__(self, dataformat='GSE2', fsuffix='gse',
|
||||
root='/data/Egelados/EVENT_DATA/LOCAL/', database='2006.01',
|
||||
**kwargs):
|
||||
self.dataType = dataformat
|
||||
self.__name = 'PDS'
|
||||
self.dataFormat = dataformat
|
||||
self.dataType = 'waveform'
|
||||
self.__pdsFields = {'ROOT': root,
|
||||
'DATABASE': database,
|
||||
'SUFFIX': fsuffix
|
||||
@ -231,6 +237,9 @@ class PilotDataStructure(object):
|
||||
def getFields(self):
|
||||
return self.__pdsFields
|
||||
|
||||
def getName(self):
|
||||
return self.__name
|
||||
|
||||
def expandDataPath(self):
|
||||
datapath = os.path.join(self.getFields()['ROOT'],
|
||||
self.getFields()['DATABASE'])
|
||||
@ -258,8 +267,8 @@ class SeiscompDataStructure(object):
|
||||
}
|
||||
|
||||
def __init__(self, dataType='waveform', sdate=None, edate=None, **kwargs):
|
||||
# imports
|
||||
from obspy.core import UTCDateTime
|
||||
|
||||
self.__name = 'SDS'
|
||||
|
||||
def checkDate(date):
|
||||
if not isinstance(date, UTCDateTime):
|
||||
@ -335,6 +344,9 @@ class SeiscompDataStructure(object):
|
||||
def getFields(self):
|
||||
return self.__sdsFields
|
||||
|
||||
def getName(self):
|
||||
return self.__name
|
||||
|
||||
def expandDataPath(self):
|
||||
fullChan = '{0}.{1}'.format(self.getFields()['CHAN'], self.getType())
|
||||
dataPath = os.path.join(self.getFields()['SDSdir'],
|
||||
|
Loading…
Reference in New Issue
Block a user