Implented GUI dialog to select directory for autoPyLoT output.
This commit is contained in:
parent
4244047096
commit
94c1e85484
58
autoPyLoT.py
58
autoPyLoT.py
@ -6,7 +6,7 @@ from __future__ import print_function
|
|||||||
import argparse
|
import argparse
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
|
import datetime
|
||||||
from obspy import read_events
|
from obspy import read_events
|
||||||
|
|
||||||
import pylot.core.loc.hyposat as hyposat
|
import pylot.core.loc.hyposat as hyposat
|
||||||
@ -16,6 +16,7 @@ import pylot.core.loc.hypodd as hypodd
|
|||||||
import pylot.core.loc.focmec as focmec
|
import pylot.core.loc.focmec as focmec
|
||||||
import pylot.core.loc.hash as hash
|
import pylot.core.loc.hash as hash
|
||||||
import pylot.core.loc.nll as nll
|
import pylot.core.loc.nll as nll
|
||||||
|
#from PySide.QtGui import QWidget, QInputDialog
|
||||||
from pylot.core.analysis.magnitude import MomentMagnitude, RichterMagnitude
|
from pylot.core.analysis.magnitude import MomentMagnitude, RichterMagnitude
|
||||||
from pylot.core.io.data import Data
|
from pylot.core.io.data import Data
|
||||||
from pylot.core.io.inputs import AutoPickParameter
|
from pylot.core.io.inputs import AutoPickParameter
|
||||||
@ -28,7 +29,7 @@ from pylot.core.util.version import get_git_version as _getVersionString
|
|||||||
__version__ = _getVersionString()
|
__version__ = _getVersionString()
|
||||||
|
|
||||||
|
|
||||||
def autoPyLoT(inputfile):
|
def autoPyLoT(inputfile, fnames=None, savepath=None):
|
||||||
"""
|
"""
|
||||||
Determine phase onsets automatically utilizing the automatic picking
|
Determine phase onsets automatically utilizing the automatic picking
|
||||||
algorithms by Kueperkoch et al. 2010/2012.
|
algorithms by Kueperkoch et al. 2010/2012.
|
||||||
@ -48,9 +49,9 @@ def autoPyLoT(inputfile):
|
|||||||
Version {version} 2015\n
|
Version {version} 2015\n
|
||||||
\n
|
\n
|
||||||
Authors:\n
|
Authors:\n
|
||||||
S. Wehling-Benatelli (Ruhr-Universität Bochum)\n
|
S. Wehling-Benatelli (Ruhr-Universitaet Bochum)\n
|
||||||
L. Küperkoch (BESTEC GmbH, Landau i. d. Pfalz)\n
|
L. Kueperkoch (BESTEC GmbH, Landau i. d. Pfalz)\n
|
||||||
K. Olbert (Christian-Albrechts Universität zu Kiel)\n
|
K. Olbert (Christian-Albrechts Universitaet zu Kiel)\n
|
||||||
***********************************'''.format(version=_getVersionString())
|
***********************************'''.format(version=_getVersionString())
|
||||||
print(splash)
|
print(splash)
|
||||||
|
|
||||||
@ -70,7 +71,7 @@ def autoPyLoT(inputfile):
|
|||||||
|
|
||||||
exf = ['root', 'dpath', 'dbase']
|
exf = ['root', 'dpath', 'dbase']
|
||||||
|
|
||||||
if parameter.hasParam('eventID'):
|
if parameter.hasParam('eventID') and fnames == 'None':
|
||||||
dsfields['eventID'] = parameter.get('eventID')
|
dsfields['eventID'] = parameter.get('eventID')
|
||||||
exf.append('eventID')
|
exf.append('eventID')
|
||||||
|
|
||||||
@ -104,14 +105,19 @@ def autoPyLoT(inputfile):
|
|||||||
print(" !!! ")
|
print(" !!! ")
|
||||||
|
|
||||||
datapath = datastructure.expandDataPath()
|
datapath = datastructure.expandDataPath()
|
||||||
if not parameter.hasParam('eventID'):
|
if fnames == 'None' and not parameter.hasParam('eventID'):
|
||||||
# multiple event processing
|
# multiple event processing
|
||||||
# read each event in database
|
# read each event in database
|
||||||
events = [events for events in glob.glob(os.path.join(datapath, '*')) if os.path.isdir(events)]
|
events = [events for events in glob.glob(os.path.join(datapath, '*')) if os.path.isdir(events)]
|
||||||
else:
|
elif fnames == 'None' and parameter.hasParam('eventID'):
|
||||||
# single event processing
|
# single event processing
|
||||||
events = glob.glob(os.path.join(datapath, parameter.get('eventID')))
|
events = glob.glob(os.path.join(datapath, parameter.get('eventID')))
|
||||||
|
else:
|
||||||
|
# autoPyLoT was initialized from GUI
|
||||||
|
events = fnames
|
||||||
|
|
||||||
for event in events:
|
for event in events:
|
||||||
|
if fnames == 'None':
|
||||||
data.setWFData(glob.glob(os.path.join(datapath, event, '*')))
|
data.setWFData(glob.glob(os.path.join(datapath, event, '*')))
|
||||||
evID = os.path.split(event)[-1]
|
evID = os.path.split(event)[-1]
|
||||||
# the following is necessary because within
|
# the following is necessary because within
|
||||||
@ -120,13 +126,30 @@ def autoPyLoT(inputfile):
|
|||||||
try:
|
try:
|
||||||
parameter.get('eventID')
|
parameter.get('eventID')
|
||||||
except:
|
except:
|
||||||
parameter.setParam(eventID=event)
|
now = datetime.datetime.now()
|
||||||
print('Working on event %s' % event)
|
eventID = '%d%02d%02d%02d%02d' % (now.year,
|
||||||
print(data)
|
now.month,
|
||||||
|
now.day,
|
||||||
|
now.hour,
|
||||||
|
now.minute)
|
||||||
|
parameter.setParam(eventID=eventID)
|
||||||
|
else:
|
||||||
|
data.setWFData(fnames)
|
||||||
|
event = savepath
|
||||||
|
now = datetime.datetime.now()
|
||||||
|
evID = '%d%02d%02d%02d%02d' % (now.year,
|
||||||
|
now.month,
|
||||||
|
now.day,
|
||||||
|
now.hour,
|
||||||
|
now.minute)
|
||||||
|
parameter.setParam(eventID=evID)
|
||||||
wfdat = data.getWFData() # all available streams
|
wfdat = data.getWFData() # all available streams
|
||||||
wfdat = remove_underscores(wfdat)
|
wfdat = remove_underscores(wfdat)
|
||||||
metadata = read_metadata(parameter.get('invdir'))
|
metadata = read_metadata(parameter.get('invdir'))
|
||||||
corr_dat, rest_flag = restitute_data(wfdat.copy(), *metadata)
|
corr_dat, rest_flag = restitute_data(wfdat.copy(), *metadata)
|
||||||
|
|
||||||
|
print('Working on event %s' % event)
|
||||||
|
print(data)
|
||||||
##########################################################
|
##########################################################
|
||||||
# !automated picking starts here!
|
# !automated picking starts here!
|
||||||
picks = autopickevent(wfdat, parameter)
|
picks = autopickevent(wfdat, parameter)
|
||||||
@ -283,7 +306,6 @@ def autoPyLoT(inputfile):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
from pylot.core.util.defaults import AUTOMATIC_DEFAULTS
|
|
||||||
# parse arguments
|
# parse arguments
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description='''autoPyLoT automatically picks phase onset times using higher order statistics,
|
description='''autoPyLoT automatically picks phase onset times using higher order statistics,
|
||||||
@ -292,13 +314,17 @@ if __name__ == "__main__":
|
|||||||
parser.add_argument('-i', '-I', '--inputfile', type=str,
|
parser.add_argument('-i', '-I', '--inputfile', type=str,
|
||||||
action='store',
|
action='store',
|
||||||
help='''full path to the file containing the input
|
help='''full path to the file containing the input
|
||||||
parameters for autoPyLoT''',
|
parameters for autoPyLoT''')
|
||||||
default=AUTOMATIC_DEFAULTS
|
parser.add_argument('-f', '-F', '--fnames', type=str,
|
||||||
)
|
action='store',
|
||||||
|
help='''optional, list of data file names''')
|
||||||
|
parser.add_argument('-s', '-S', '--spath', type=str,
|
||||||
|
action=store,
|
||||||
|
help='''optional, save path for autoPyLoT output''')
|
||||||
parser.add_argument('-v', '-V', '--version', action='version',
|
parser.add_argument('-v', '-V', '--version', action='version',
|
||||||
version='autoPyLoT ' + __version__,
|
version='autoPyLoT ' + __version__,
|
||||||
help='show version information and exit')
|
help='show version information and exit')
|
||||||
|
|
||||||
cla = parser.parse_args()
|
cla = parser.parse_args()
|
||||||
|
|
||||||
autoPyLoT(str(cla.inputfile))
|
autoPyLoT(str(cla.inputfile), str(cla.fnames), str(cla.spath))
|
||||||
|
Loading…
Reference in New Issue
Block a user