Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
Marcel Paffrath 2017-05-19 13:54:33 +02:00
commit 5a3b77dc7b
3 changed files with 43 additions and 33 deletions

View File

@ -1311,11 +1311,13 @@ class MainWindow(QMainWindow):
% self.infile)
autopick_parameter = self._inputs
self.addListItem(str(autopick_parameter))
ep = self.get_current_event_path().split('/')
eventid = ep[len(ep) - 1]
self.thread = AutoPickThread(parent=self,
func=autoPyLoT,
infile = self.infile,
fnames=self.fnames,
eventid=eventid,
savepath=self.autosave)
self.thread.message.connect(self.addListItem)

View File

@ -8,7 +8,6 @@ import glob
import os
import datetime
from obspy import read_events
import pylot.core.loc.hyposat as hyposat
import pylot.core.loc.hypo71 as hypo71
import pylot.core.loc.velest as velest
@ -29,7 +28,7 @@ from pylot.core.util.version import get_git_version as _getVersionString
__version__ = _getVersionString()
def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, savepath=None, station='all', iplot=0):
def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, eventid=None, savepath=None, station='all', iplot=0):
"""
Determine phase onsets automatically utilizing the automatic picking
algorithms by Kueperkoch et al. 2010/2012.
@ -141,7 +140,9 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, save
events = glob.glob(os.path.join(datapath, parameter.get('eventID')))
else:
# autoPyLoT was initialized from GUI
events = fnames
events = [os.path.join(datapath, eventid)]
evID = eventid
locflag = 2
for event in events:
if fnames == 'None':
@ -162,14 +163,14 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, save
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)
event = events[0]
#now = datetime.datetime.now()
#evID = '%d%02d%02d%02d%02d' % (now.year,
# now.month,
# now.day,
# now.hour,
# now.minute)
parameter.setParam(eventID=eventid)
wfdat = data.getWFData() # all available streams
if not station == 'all':
wfdat = wfdat.select(station=station)
@ -178,6 +179,7 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, save
return
wfdat = remove_underscores(wfdat)
metadata = read_metadata(parameter.get('invdir'))
print("Restitute data ...")
corr_dat = restitute_data(wfdat.copy(), *metadata)
print('Working on event %s. Stations: %s' % (event, station))
@ -192,7 +194,7 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, save
picks = autopickevent(wfdat, parameter, iplot=iplot)
##########################################################
# locating
if locflag == 1:
if locflag > 0:
# write phases to NLLoc-phase file
nll.export(picks, phasefile, parameter)
@ -282,6 +284,7 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, save
print("autoPyLoT: No more bad onsets found, stop iterative picking!")
nlloccounter = maxnumit
evt = read_events(nllocfile)[0]
if locflag < 2:
# calculating seismic moment Mo and moment magnitude Mw
moment_mag = MomentMagnitude(corr_dat, evt, parameter.get('vp'),
parameter.get('Qp'),
@ -361,6 +364,9 @@ if __name__ == "__main__":
parser.add_argument('-f', '-F', '--fnames', type=str,
action='store',
help='''optional, list of data file names''')
parser.add_argument('-e', '-E', '--eventid', type=str,
action='store',
help='''optional, event ID''')
# parser.add_argument('-p', '-P', '--plot', action='store',
# help='show interactive plots')
parser.add_argument('-s', '-S', '--spath', type=str,
@ -373,4 +379,5 @@ if __name__ == "__main__":
cla = parser.parse_args()
picks, mainFig = autoPyLoT(inputfile=str(cla.inputfile),
fnames=str(cla.fnames), savepath=str(cla.spath))
fnames=str(cla.fnames), eventid=str(cla.eventid),
savepath=str(cla.spath))

View File

@ -8,18 +8,19 @@ class AutoPickThread(QThread):
message = Signal(str)
finished = Signal()
def __init__(self, parent, func, infile, fnames, savepath):
def __init__(self, parent, func, infile, fnames, eventid, savepath):
super(AutoPickThread, self).__init__()
self.setParent(parent)
self.func = func
self.infile = infile
self.fnames = fnames
self.eventid = eventid
self.savepath = savepath
def run(self):
sys.stdout = self
picks = self.func(self.infile, self.fnames, self.savepath)
picks = self.func(None, None, self.infile, self.fnames, self.eventid, self.savepath)
print("Autopicking finished!\n")