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) % self.infile)
autopick_parameter = self._inputs autopick_parameter = self._inputs
self.addListItem(str(autopick_parameter)) self.addListItem(str(autopick_parameter))
ep = self.get_current_event_path().split('/')
eventid = ep[len(ep) - 1]
self.thread = AutoPickThread(parent=self, self.thread = AutoPickThread(parent=self,
func=autoPyLoT, func=autoPyLoT,
infile = self.infile, infile = self.infile,
fnames=self.fnames, fnames=self.fnames,
eventid=eventid,
savepath=self.autosave) savepath=self.autosave)
self.thread.message.connect(self.addListItem) self.thread.message.connect(self.addListItem)

View File

@ -8,7 +8,6 @@ import glob
import os import os
import datetime 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
import pylot.core.loc.hypo71 as hypo71 import pylot.core.loc.hypo71 as hypo71
import pylot.core.loc.velest as velest import pylot.core.loc.velest as velest
@ -29,7 +28,7 @@ from pylot.core.util.version import get_git_version as _getVersionString
__version__ = _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 Determine phase onsets automatically utilizing the automatic picking
algorithms by Kueperkoch et al. 2010/2012. 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'))) events = glob.glob(os.path.join(datapath, parameter.get('eventID')))
else: else:
# autoPyLoT was initialized from GUI # autoPyLoT was initialized from GUI
events = fnames events = [os.path.join(datapath, eventid)]
evID = eventid
locflag = 2
for event in events: for event in events:
if fnames == 'None': if fnames == 'None':
@ -162,14 +163,14 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, save
parameter.setParam(eventID=eventID) parameter.setParam(eventID=eventID)
else: else:
data.setWFData(fnames) data.setWFData(fnames)
event = savepath event = events[0]
now = datetime.datetime.now() #now = datetime.datetime.now()
evID = '%d%02d%02d%02d%02d' % (now.year, #evID = '%d%02d%02d%02d%02d' % (now.year,
now.month, # now.month,
now.day, # now.day,
now.hour, # now.hour,
now.minute) # now.minute)
parameter.setParam(eventID=evID) parameter.setParam(eventID=eventid)
wfdat = data.getWFData() # all available streams wfdat = data.getWFData() # all available streams
if not station == 'all': if not station == 'all':
wfdat = wfdat.select(station=station) wfdat = wfdat.select(station=station)
@ -178,6 +179,7 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, save
return return
wfdat = remove_underscores(wfdat) wfdat = remove_underscores(wfdat)
metadata = read_metadata(parameter.get('invdir')) metadata = read_metadata(parameter.get('invdir'))
print("Restitute data ...")
corr_dat = restitute_data(wfdat.copy(), *metadata) corr_dat = restitute_data(wfdat.copy(), *metadata)
print('Working on event %s. Stations: %s' % (event, station)) 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) picks = autopickevent(wfdat, parameter, iplot=iplot)
########################################################## ##########################################################
# locating # locating
if locflag == 1: if locflag > 0:
# write phases to NLLoc-phase file # write phases to NLLoc-phase file
nll.export(picks, phasefile, parameter) nll.export(picks, phasefile, parameter)
@ -282,23 +284,24 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, save
print("autoPyLoT: No more bad onsets found, stop iterative picking!") print("autoPyLoT: No more bad onsets found, stop iterative picking!")
nlloccounter = maxnumit nlloccounter = maxnumit
evt = read_events(nllocfile)[0] evt = read_events(nllocfile)[0]
# calculating seismic moment Mo and moment magnitude Mw if locflag < 2:
moment_mag = MomentMagnitude(corr_dat, evt, parameter.get('vp'), # calculating seismic moment Mo and moment magnitude Mw
parameter.get('Qp'), moment_mag = MomentMagnitude(corr_dat, evt, parameter.get('vp'),
parameter.get('rho'), True, \ parameter.get('Qp'),
iplot) parameter.get('rho'), True, \
# update pick with moment property values (w0, fc, Mo) iplot)
for station, props in moment_mag.moment_props.items(): # update pick with moment property values (w0, fc, Mo)
picks[station]['P'].update(props) for station, props in moment_mag.moment_props.items():
evt = moment_mag.updated_event() picks[station]['P'].update(props)
local_mag = RichterMagnitude(corr_dat, evt, evt = moment_mag.updated_event()
parameter.get('sstop'), True, \ local_mag = RichterMagnitude(corr_dat, evt,
iplot) parameter.get('sstop'), True, \
for station, amplitude in local_mag.amplitudes.items(): iplot)
picks[station]['S']['Ao'] = amplitude.generic_amplitude for station, amplitude in local_mag.amplitudes.items():
evt = local_mag.updated_event() picks[station]['S']['Ao'] = amplitude.generic_amplitude
net_mw = moment_mag.net_magnitude() evt = local_mag.updated_event()
print("Network moment magnitude: %4.1f" % net_mw.mag) net_mw = moment_mag.net_magnitude()
print("Network moment magnitude: %4.1f" % net_mw.mag)
else: else:
print("autoPyLoT: No NLLoc-location file available! Stop iteration!") print("autoPyLoT: No NLLoc-location file available! Stop iteration!")
locflag = 9 locflag = 9
@ -361,6 +364,9 @@ if __name__ == "__main__":
parser.add_argument('-f', '-F', '--fnames', type=str, parser.add_argument('-f', '-F', '--fnames', type=str,
action='store', action='store',
help='''optional, list of data file names''') 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', # parser.add_argument('-p', '-P', '--plot', action='store',
# help='show interactive plots') # help='show interactive plots')
parser.add_argument('-s', '-S', '--spath', type=str, parser.add_argument('-s', '-S', '--spath', type=str,
@ -373,4 +379,5 @@ if __name__ == "__main__":
cla = parser.parse_args() cla = parser.parse_args()
picks, mainFig = autoPyLoT(inputfile=str(cla.inputfile), 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) message = Signal(str)
finished = Signal() finished = Signal()
def __init__(self, parent, func, infile, fnames, savepath): def __init__(self, parent, func, infile, fnames, eventid, savepath):
super(AutoPickThread, self).__init__() super(AutoPickThread, self).__init__()
self.setParent(parent) self.setParent(parent)
self.func = func self.func = func
self.infile = infile self.infile = infile
self.fnames = fnames self.fnames = fnames
self.eventid = eventid
self.savepath = savepath self.savepath = savepath
def run(self): def run(self):
sys.stdout = 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") print("Autopicking finished!\n")