Re-initialized autoPyLoT from GUI, new input parameter eventid to make sure processing the right event. Buggy!

This commit is contained in:
Ludger Küperkoch 2017-05-19 12:30:03 +02:00
parent e911262c3e
commit 4767add68f
4 changed files with 42 additions and 31 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

@ -29,7 +29,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 +141,10 @@ 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 = eventid
event = eventid
evID = eventid
locflag = 2
for event in events: for event in events:
if fnames == 'None': if fnames == 'None':
@ -164,12 +167,12 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, save
data.setWFData(fnames) data.setWFData(fnames)
event = savepath event = savepath
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)
@ -192,7 +195,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,6 +285,7 @@ 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]
if locflag < 2:
# calculating seismic moment Mo and moment magnitude Mw # calculating seismic moment Mo and moment magnitude Mw
moment_mag = MomentMagnitude(corr_dat, evt, parameter.get('vp'), moment_mag = MomentMagnitude(corr_dat, evt, parameter.get('vp'),
parameter.get('Qp'), parameter.get('Qp'),
@ -361,6 +365,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 +380,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

@ -1 +1 @@
cf971-dirty e911-dirty

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")