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

@ -29,7 +29,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 +141,10 @@ 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 = eventid
event = eventid
evID = eventid
locflag = 2
for event in events:
if fnames == 'None':
@ -164,12 +167,12 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, save
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)
#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)
@ -192,7 +195,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,23 +285,24 @@ 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]
# calculating seismic moment Mo and moment magnitude Mw
moment_mag = MomentMagnitude(corr_dat, evt, parameter.get('vp'),
parameter.get('Qp'),
parameter.get('rho'), True, \
iplot)
# update pick with moment property values (w0, fc, Mo)
for station, props in moment_mag.moment_props.items():
picks[station]['P'].update(props)
evt = moment_mag.updated_event()
local_mag = RichterMagnitude(corr_dat, evt,
parameter.get('sstop'), True, \
iplot)
for station, amplitude in local_mag.amplitudes.items():
picks[station]['S']['Ao'] = amplitude.generic_amplitude
evt = local_mag.updated_event()
net_mw = moment_mag.net_magnitude()
print("Network moment magnitude: %4.1f" % net_mw.mag)
if locflag < 2:
# calculating seismic moment Mo and moment magnitude Mw
moment_mag = MomentMagnitude(corr_dat, evt, parameter.get('vp'),
parameter.get('Qp'),
parameter.get('rho'), True, \
iplot)
# update pick with moment property values (w0, fc, Mo)
for station, props in moment_mag.moment_props.items():
picks[station]['P'].update(props)
evt = moment_mag.updated_event()
local_mag = RichterMagnitude(corr_dat, evt,
parameter.get('sstop'), True, \
iplot)
for station, amplitude in local_mag.amplitudes.items():
picks[station]['S']['Ao'] = amplitude.generic_amplitude
evt = local_mag.updated_event()
net_mw = moment_mag.net_magnitude()
print("Network moment magnitude: %4.1f" % net_mw.mag)
else:
print("autoPyLoT: No NLLoc-location file available! Stop iteration!")
locflag = 9
@ -361,6 +365,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 +380,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

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

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