2015-06-19 09:08:28 +02:00
|
|
|
#!/usr/bin/python
|
2015-04-22 12:46:24 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2016-03-30 08:14:58 +02:00
|
|
|
from __future__ import print_function
|
2015-04-22 12:46:24 +02:00
|
|
|
import os
|
|
|
|
import argparse
|
2015-05-20 09:38:25 +02:00
|
|
|
import glob
|
2015-10-27 15:26:25 +01:00
|
|
|
import subprocess
|
2015-11-11 15:45:07 +01:00
|
|
|
import string
|
2015-12-03 14:55:07 +01:00
|
|
|
import numpy as np
|
2015-11-20 15:49:34 +01:00
|
|
|
from obspy.core import read, UTCDateTime
|
2015-07-10 09:22:58 +02:00
|
|
|
from pylot.core.read.data import Data
|
|
|
|
from pylot.core.read.inputs import AutoPickParameter
|
2015-04-29 06:29:08 +02:00
|
|
|
from pylot.core.util.structure import DATASTRUCTURE
|
2015-11-20 15:49:34 +01:00
|
|
|
from pylot.core.pick.autopick import autopickevent, iteratepicker
|
2015-11-17 17:03:59 +01:00
|
|
|
from pylot.core.loc.nll import *
|
2015-10-19 05:32:10 +02:00
|
|
|
from pylot.core.util.version import get_git_version as _getVersionString
|
2015-11-30 16:37:28 +01:00
|
|
|
from pylot.core.analysis.magnitude import M0Mw
|
2015-07-02 09:27:11 +02:00
|
|
|
|
2015-04-22 12:46:24 +02:00
|
|
|
__version__ = _getVersionString()
|
|
|
|
|
|
|
|
|
2015-05-20 09:43:32 +02:00
|
|
|
def autoPyLoT(inputfile):
|
2015-10-28 09:13:13 +01:00
|
|
|
"""
|
2015-04-29 06:29:08 +02:00
|
|
|
Determine phase onsets automatically utilizing the automatic picking
|
2015-06-19 09:08:28 +02:00
|
|
|
algorithms by Kueperkoch et al. 2010/2012.
|
2015-04-29 06:29:08 +02:00
|
|
|
|
|
|
|
:param inputfile: path to the input file containing all parameter
|
|
|
|
information for automatic picking (for formatting details, see.
|
|
|
|
`~pylot.core.read.input.AutoPickParameter`
|
|
|
|
:type inputfile: str
|
|
|
|
:return:
|
|
|
|
|
|
|
|
.. rubric:: Example
|
|
|
|
|
2015-10-28 09:13:13 +01:00
|
|
|
"""
|
2015-11-04 13:11:48 +01:00
|
|
|
splash = '''************************************\n
|
|
|
|
*********autoPyLoT starting*********\n
|
|
|
|
The Python picking and Location Tool\n
|
|
|
|
Version {version} 2015\n
|
|
|
|
\n
|
|
|
|
Authors:\n
|
|
|
|
S. Wehling-Benatelli (Ruhr-Universität Bochum)\n
|
|
|
|
L. Küperkoch (BESTEC GmbH, Landau i. d. Pfalz)\n
|
|
|
|
K. Olbert (Christian-Albrechts Universität zu Kiel)\n
|
|
|
|
***********************************'''.format(version=_getVersionString())
|
|
|
|
print(splash)
|
2015-05-20 09:38:25 +02:00
|
|
|
|
|
|
|
# reading parameter file
|
|
|
|
|
2015-04-22 12:46:24 +02:00
|
|
|
parameter = AutoPickParameter(inputfile)
|
2015-04-29 06:29:08 +02:00
|
|
|
|
2015-04-22 12:46:24 +02:00
|
|
|
data = Data()
|
|
|
|
|
2015-05-20 09:38:25 +02:00
|
|
|
# getting information on data structure
|
|
|
|
|
2015-04-29 06:29:08 +02:00
|
|
|
if parameter.hasParam('datastructure'):
|
|
|
|
datastructure = DATASTRUCTURE[parameter.getParam('datastructure')]()
|
2016-03-30 08:14:58 +02:00
|
|
|
dsfields = {'root': parameter.getParam('rootpath'),
|
|
|
|
'dpath': parameter.getParam('datapath'),
|
|
|
|
'dbase': parameter.getParam('database')}
|
2015-04-29 07:57:52 +02:00
|
|
|
|
2015-05-20 09:59:06 +02:00
|
|
|
exf = ['root', 'dpath', 'dbase']
|
|
|
|
|
|
|
|
if parameter.hasParam('eventID'):
|
|
|
|
dsfields['eventID'] = parameter.getParam('eventID')
|
|
|
|
exf.append('eventID')
|
2015-04-22 12:46:24 +02:00
|
|
|
|
2015-06-01 16:28:27 +02:00
|
|
|
datastructure.modifyFields(**dsfields)
|
2015-05-20 09:59:06 +02:00
|
|
|
datastructure.setExpandFields(exf)
|
2015-04-22 12:46:24 +02:00
|
|
|
|
2015-10-28 09:13:13 +01:00
|
|
|
# check if default location routine NLLoc is available
|
|
|
|
if parameter.hasParam('nllocbin'):
|
|
|
|
locflag = 1
|
|
|
|
# get NLLoc-root path
|
|
|
|
nllocroot = parameter.getParam('nllocroot')
|
|
|
|
# get path to NLLoc executable
|
|
|
|
nllocbin = parameter.getParam('nllocbin')
|
|
|
|
nlloccall = '%s/NLLoc' % nllocbin
|
2015-11-04 13:11:48 +01:00
|
|
|
# get name of phase file
|
2015-10-28 09:13:13 +01:00
|
|
|
phasef = parameter.getParam('phasefile')
|
|
|
|
phasefile = '%s/obs/%s' % (nllocroot, phasef)
|
|
|
|
# get name of NLLoc-control file
|
2015-11-18 10:27:42 +01:00
|
|
|
ctrf = parameter.getParam('ctrfile')
|
|
|
|
ctrfile = '%s/run/%s' % (nllocroot, ctrf)
|
|
|
|
# pattern of NLLoc ttimes from location grid
|
2015-10-28 09:13:13 +01:00
|
|
|
ttpat = parameter.getParam('ttpatter')
|
2015-11-18 10:27:42 +01:00
|
|
|
# pattern of NLLoc-output file
|
2015-10-28 09:13:13 +01:00
|
|
|
nllocoutpatter = parameter.getParam('outpatter')
|
2016-03-30 08:14:58 +02:00
|
|
|
maxnumit = 3 # maximum number of iterations for re-picking
|
2015-10-28 09:13:13 +01:00
|
|
|
else:
|
|
|
|
locflag = 0
|
2015-12-01 15:39:28 +01:00
|
|
|
print(" !!! ")
|
|
|
|
print("!!No location routine available, autoPyLoT is running in non-location mode!!")
|
|
|
|
print("!!No source parameter estimation possible!!")
|
|
|
|
print(" !!! ")
|
2015-10-27 10:00:16 +01:00
|
|
|
|
2015-07-10 09:22:58 +02:00
|
|
|
# multiple event processing
|
2015-05-29 16:26:31 +02:00
|
|
|
# read each event in database
|
2015-05-20 09:38:25 +02:00
|
|
|
datapath = datastructure.expandDataPath()
|
2015-05-20 09:59:06 +02:00
|
|
|
if not parameter.hasParam('eventID'):
|
2015-05-29 16:26:31 +02:00
|
|
|
for event in [events for events in glob.glob(os.path.join(datapath, '*')) if os.path.isdir(events)]:
|
2015-05-20 11:29:55 +02:00
|
|
|
data.setWFData(glob.glob(os.path.join(datapath, event, '*')))
|
2015-11-04 13:11:48 +01:00
|
|
|
print('Working on event %s' % event)
|
|
|
|
print(data)
|
2015-10-28 09:13:13 +01:00
|
|
|
wfdat = data.getWFData() # all available streams
|
2015-06-01 16:28:27 +02:00
|
|
|
##########################################################
|
2015-07-10 09:22:58 +02:00
|
|
|
# !automated picking starts here!
|
|
|
|
picks = autopickevent(wfdat, parameter)
|
2015-12-10 12:02:32 +01:00
|
|
|
finalpicks = picks
|
2015-10-27 15:26:25 +01:00
|
|
|
##########################################################
|
2015-10-28 09:13:13 +01:00
|
|
|
# locating
|
|
|
|
if locflag == 1:
|
|
|
|
# write phases to NLLoc-phase file
|
2015-11-17 17:03:59 +01:00
|
|
|
picksExport(picks, 'NLLoc', phasefile)
|
2015-10-28 09:13:13 +01:00
|
|
|
|
2015-11-04 16:52:39 +01:00
|
|
|
# For locating the event the NLLoc-control file has to be modified!
|
2016-03-30 08:14:58 +02:00
|
|
|
evID = event[string.rfind(event, "/") + 1: len(events) - 1]
|
2015-11-18 10:27:42 +01:00
|
|
|
nllocout = '%s_%s' % (evID, nllocoutpatter)
|
|
|
|
# create comment line for NLLoc-control file
|
|
|
|
modifyInputFile(ctrf, nllocroot, nllocout, phasef, ttpat)
|
2015-10-28 09:13:13 +01:00
|
|
|
|
|
|
|
# locate the event
|
2015-11-18 10:27:42 +01:00
|
|
|
locate(nlloccall, ctrfile)
|
2015-11-12 17:21:04 +01:00
|
|
|
|
2015-11-18 10:27:42 +01:00
|
|
|
# !iterative picking if traces remained unpicked or occupied with bad picks!
|
2015-11-12 17:21:04 +01:00
|
|
|
# get theoretical onset times for picks with weights >= 4
|
2015-11-20 15:49:34 +01:00
|
|
|
# in order to reprocess them using smaller time windows around theoretical onset
|
|
|
|
# get stations with bad onsets
|
|
|
|
badpicks = []
|
|
|
|
for key in picks:
|
2016-03-30 08:14:58 +02:00
|
|
|
if picks[key]['P']['weight'] >= 4 or picks[key]['S']['weight'] >= 4:
|
|
|
|
badpicks.append([key, picks[key]['P']['mpp']])
|
2015-11-20 15:49:34 +01:00
|
|
|
|
|
|
|
if len(badpicks) == 0:
|
2016-03-30 08:14:58 +02:00
|
|
|
print("autoPyLoT: No bad onsets found, thus no iterative picking necessary!")
|
2015-12-01 15:39:28 +01:00
|
|
|
# get NLLoc-location file
|
|
|
|
locsearch = '%s/loc/%s.????????.??????.grid?.loc.hyp' % (nllocroot, nllocout)
|
|
|
|
if len(glob.glob(locsearch)) > 0:
|
|
|
|
# get latest NLLoc-location file if several are available
|
2016-03-30 08:14:58 +02:00
|
|
|
nllocfile = max(glob.glob(locsearch), key=os.path.getctime)
|
2015-12-01 15:39:28 +01:00
|
|
|
# calculating seismic moment Mo and moment magnitude Mw
|
2016-03-30 08:14:58 +02:00
|
|
|
finalpicks = M0Mw(wfdat, None, None, parameter.getParam('iplot'), \
|
|
|
|
nllocfile, picks, parameter.getParam('rho'), \
|
|
|
|
parameter.getParam('vp'), parameter.getParam('Qp'), \
|
|
|
|
parameter.getParam('invdir'))
|
2015-12-01 15:39:28 +01:00
|
|
|
else:
|
|
|
|
print("autoPyLoT: No NLLoc-location file available!")
|
|
|
|
print("No source parameter estimation possible!")
|
2015-11-20 15:49:34 +01:00
|
|
|
else:
|
|
|
|
# get theoretical P-onset times from NLLoc-location file
|
|
|
|
locsearch = '%s/loc/%s.????????.??????.grid?.loc.hyp' % (nllocroot, nllocout)
|
2015-11-23 16:38:52 +01:00
|
|
|
if len(glob.glob(locsearch)) > 0:
|
|
|
|
# get latest file if several are available
|
2016-03-30 08:14:58 +02:00
|
|
|
nllocfile = max(glob.glob(locsearch), key=os.path.getctime)
|
2015-11-23 16:38:52 +01:00
|
|
|
nlloccounter = 0
|
2016-03-30 08:14:58 +02:00
|
|
|
while len(badpicks) > 0 and nlloccounter <= maxnumit:
|
2015-11-23 16:38:52 +01:00
|
|
|
nlloccounter += 1
|
|
|
|
if nlloccounter > maxnumit:
|
|
|
|
print("autoPyLoT: Number of maximum iterations reached, stop iterative picking!")
|
|
|
|
break
|
|
|
|
print("autoPyLoT: Starting with iteration No. %d ..." % nlloccounter)
|
|
|
|
picks = iteratepicker(wfdat, nllocfile, picks, badpicks, parameter)
|
|
|
|
# write phases to NLLoc-phase file
|
|
|
|
picksExport(picks, 'NLLoc', phasefile)
|
2015-12-03 14:55:07 +01:00
|
|
|
# remove actual NLLoc-location file to keep only the last
|
|
|
|
os.remove(nllocfile)
|
2015-11-23 16:38:52 +01:00
|
|
|
# locate the event
|
|
|
|
locate(nlloccall, ctrfile)
|
|
|
|
print("autoPyLoT: Iteration No. %d finished." % nlloccounter)
|
2015-12-01 15:39:28 +01:00
|
|
|
# get updated NLLoc-location file
|
2016-03-30 08:14:58 +02:00
|
|
|
nllocfile = max(glob.glob(locsearch), key=os.path.getctime)
|
2015-12-01 15:39:28 +01:00
|
|
|
# check for bad picks
|
2015-11-23 16:38:52 +01:00
|
|
|
badpicks = []
|
|
|
|
for key in picks:
|
2016-03-30 08:14:58 +02:00
|
|
|
if picks[key]['P']['weight'] >= 4 or picks[key]['S']['weight'] >= 4:
|
|
|
|
badpicks.append([key, picks[key]['P']['mpp']])
|
2015-11-23 16:38:52 +01:00
|
|
|
print("autoPyLoT: After iteration No. %d: %d bad onsets found ..." % (nlloccounter, \
|
2016-03-30 08:14:58 +02:00
|
|
|
len(badpicks)))
|
2015-11-23 16:38:52 +01:00
|
|
|
if len(badpicks) == 0:
|
|
|
|
print("autoPyLoT: No more bad onsets found, stop iterative picking!")
|
2015-12-01 15:39:28 +01:00
|
|
|
nlloccounter = maxnumit
|
|
|
|
|
|
|
|
# calculating seismic moment Mo and moment magnitude Mw
|
2016-03-30 08:14:58 +02:00
|
|
|
finalpicks = M0Mw(wfdat, None, None, parameter.getParam('iplot'), \
|
|
|
|
nllocfile, picks, parameter.getParam('rho'), \
|
|
|
|
parameter.getParam('vp'), parameter.getParam('Qp'), \
|
|
|
|
parameter.getParam('invdir'))
|
2015-12-03 14:55:07 +01:00
|
|
|
# get network moment magntiude
|
|
|
|
netMw = []
|
2016-03-30 08:14:58 +02:00
|
|
|
for key in finalpicks.getpicdic():
|
|
|
|
if finalpicks.getpicdic()[key]['P']['Mw'] is not None:
|
|
|
|
netMw.append(finalpicks.getpicdic()[key]['P']['Mw'])
|
2015-12-03 14:55:07 +01:00
|
|
|
netMw = np.median(netMw)
|
|
|
|
print("Network moment magnitude: %4.1f" % netMw)
|
2015-11-20 15:49:34 +01:00
|
|
|
else:
|
|
|
|
print("autoPyLoT: No NLLoc-location file available! Stop iteration!")
|
2015-10-27 15:26:25 +01:00
|
|
|
##########################################################
|
2015-11-05 08:51:50 +01:00
|
|
|
# write phase files for various location routines
|
|
|
|
# HYPO71
|
2015-12-03 14:55:07 +01:00
|
|
|
hypo71file = '%s/autoPyLoT_HYPO71.pha' % event
|
2015-12-10 12:02:32 +01:00
|
|
|
if hasattr(finalpicks, 'getpicdic'):
|
|
|
|
if finalpicks.getpicdic() is not None:
|
|
|
|
writephases(finalpicks.getpicdic(), 'HYPO71', hypo71file)
|
2016-04-11 13:59:32 +02:00
|
|
|
data.applyEVTData(finalpicks.getpicdic())
|
2015-12-10 12:02:32 +01:00
|
|
|
else:
|
|
|
|
writephases(picks, 'HYPO71', hypo71file)
|
2016-04-11 13:59:32 +02:00
|
|
|
data.applyEVTData(picks)
|
2015-12-03 14:55:07 +01:00
|
|
|
else:
|
|
|
|
writephases(picks, 'HYPO71', hypo71file)
|
2016-04-11 13:59:32 +02:00
|
|
|
data.applyEVTData(picks)
|
|
|
|
fnqml = '%s/autoPyLoT' % event
|
|
|
|
data.exportEvent(fnqml)
|
2015-10-27 15:26:25 +01:00
|
|
|
|
2015-11-12 17:21:04 +01:00
|
|
|
endsplash = '''------------------------------------------\n'
|
2016-03-30 08:14:58 +02:00
|
|
|
-----Finished event %s!-----\n'
|
2015-11-12 17:21:04 +01:00
|
|
|
------------------------------------------'''.format \
|
|
|
|
(version=_getVersionString()) % evID
|
|
|
|
print(endsplash)
|
|
|
|
if locflag == 0:
|
|
|
|
print("autoPyLoT was running in non-location mode!")
|
2015-06-01 16:28:27 +02:00
|
|
|
|
2015-06-19 09:08:28 +02:00
|
|
|
# single event processing
|
2015-05-20 09:59:06 +02:00
|
|
|
else:
|
2015-06-02 13:43:39 +02:00
|
|
|
data.setWFData(glob.glob(os.path.join(datapath, parameter.getParam('eventID'), '*')))
|
2016-03-30 08:14:58 +02:00
|
|
|
print("Working on event {0}".format(parameter.getParam('eventID')))
|
|
|
|
print(data)
|
2015-07-10 09:22:58 +02:00
|
|
|
|
2015-10-28 09:13:13 +01:00
|
|
|
wfdat = data.getWFData() # all available streams
|
2015-06-01 16:28:27 +02:00
|
|
|
##########################################################
|
2015-07-10 09:22:58 +02:00
|
|
|
# !automated picking starts here!
|
|
|
|
picks = autopickevent(wfdat, parameter)
|
2015-12-10 12:02:32 +01:00
|
|
|
finalpicks = picks
|
2015-10-27 15:26:25 +01:00
|
|
|
##########################################################
|
2015-10-28 09:13:13 +01:00
|
|
|
# locating
|
|
|
|
if locflag == 1:
|
|
|
|
# write phases to NLLoc-phase file
|
2015-11-17 17:03:59 +01:00
|
|
|
picksExport(picks, 'NLLoc', phasefile)
|
2015-10-28 09:13:13 +01:00
|
|
|
|
2015-11-04 16:52:39 +01:00
|
|
|
# For locating the event the NLLoc-control file has to be modified!
|
2015-11-18 10:27:42 +01:00
|
|
|
nllocout = '%s_%s' % (parameter.getParam('eventID'), nllocoutpatter)
|
|
|
|
# create comment line for NLLoc-control file
|
|
|
|
modifyInputFile(ctrf, nllocroot, nllocout, phasef, ttpat)
|
2015-10-28 09:13:13 +01:00
|
|
|
|
|
|
|
# locate the event
|
2015-11-18 10:27:42 +01:00
|
|
|
locate(nlloccall, ctrfile)
|
|
|
|
# !iterative picking if traces remained unpicked or occupied with bad picks!
|
2015-11-12 17:21:04 +01:00
|
|
|
# get theoretical onset times for picks with weights >= 4
|
2015-11-20 15:49:34 +01:00
|
|
|
# in order to reprocess them using smaller time windows around theoretical onset
|
|
|
|
# get stations with bad onsets
|
|
|
|
badpicks = []
|
|
|
|
for key in picks:
|
2016-03-30 08:14:58 +02:00
|
|
|
if picks[key]['P']['weight'] >= 4 or picks[key]['S']['weight'] >= 4:
|
|
|
|
badpicks.append([key, picks[key]['P']['mpp']])
|
2015-11-20 15:49:34 +01:00
|
|
|
|
|
|
|
if len(badpicks) == 0:
|
2016-03-30 08:14:58 +02:00
|
|
|
print("autoPyLoT: No bad onsets found, thus no iterative picking necessary!")
|
2015-12-01 15:39:28 +01:00
|
|
|
# get NLLoc-location file
|
|
|
|
locsearch = '%s/loc/%s.????????.??????.grid?.loc.hyp' % (nllocroot, nllocout)
|
|
|
|
if len(glob.glob(locsearch)) > 0:
|
|
|
|
# get latest NLLOc-location file if several are available
|
2016-03-30 08:14:58 +02:00
|
|
|
nllocfile = max(glob.glob(locsearch), key=os.path.getctime)
|
2015-12-01 15:39:28 +01:00
|
|
|
# calculating seismic moment Mo and moment magnitude Mw
|
2016-03-30 08:14:58 +02:00
|
|
|
finalpicks = M0Mw(wfdat, None, None, parameter.getParam('iplot'), \
|
|
|
|
nllocfile, picks, parameter.getParam('rho'), \
|
|
|
|
parameter.getParam('vp'), parameter.getParam('Qp'), \
|
|
|
|
parameter.getParam('invdir'))
|
2015-12-01 15:39:28 +01:00
|
|
|
else:
|
|
|
|
print("autoPyLoT: No NLLoc-location file available!")
|
|
|
|
print("No source parameter estimation possible!")
|
2015-11-20 15:49:34 +01:00
|
|
|
else:
|
|
|
|
# get theoretical P-onset times from NLLoc-location file
|
|
|
|
locsearch = '%s/loc/%s.????????.??????.grid?.loc.hyp' % (nllocroot, nllocout)
|
2015-11-23 16:38:52 +01:00
|
|
|
if len(glob.glob(locsearch)) > 0:
|
|
|
|
# get latest file if several are available
|
2016-03-30 08:14:58 +02:00
|
|
|
nllocfile = max(glob.glob(locsearch), key=os.path.getctime)
|
2015-11-23 16:38:52 +01:00
|
|
|
nlloccounter = 0
|
2016-03-30 08:14:58 +02:00
|
|
|
while len(badpicks) > 0 and nlloccounter <= maxnumit:
|
2015-11-23 16:38:52 +01:00
|
|
|
nlloccounter += 1
|
|
|
|
if nlloccounter > maxnumit:
|
|
|
|
print("autoPyLoT: Number of maximum iterations reached, stop iterative picking!")
|
|
|
|
break
|
|
|
|
print("autoPyLoT: Starting with iteration No. %d ..." % nlloccounter)
|
|
|
|
picks = iteratepicker(wfdat, nllocfile, picks, badpicks, parameter)
|
|
|
|
# write phases to NLLoc-phase file
|
|
|
|
picksExport(picks, 'NLLoc', phasefile)
|
2015-12-03 14:55:07 +01:00
|
|
|
# remove actual NLLoc-location file to keep only the last
|
|
|
|
os.remove(nllocfile)
|
2015-11-23 16:38:52 +01:00
|
|
|
# locate the event
|
|
|
|
locate(nlloccall, ctrfile)
|
|
|
|
print("autoPyLoT: Iteration No. %d finished." % nlloccounter)
|
2015-12-01 15:39:28 +01:00
|
|
|
# get updated NLLoc-location file
|
2016-03-30 08:14:58 +02:00
|
|
|
nllocfile = max(glob.glob(locsearch), key=os.path.getctime)
|
2015-12-01 15:39:28 +01:00
|
|
|
# check for bad picks
|
2015-11-23 16:38:52 +01:00
|
|
|
badpicks = []
|
|
|
|
for key in picks:
|
2016-03-30 08:14:58 +02:00
|
|
|
if picks[key]['P']['weight'] >= 4 or picks[key]['S']['weight'] >= 4:
|
|
|
|
badpicks.append([key, picks[key]['P']['mpp']])
|
2015-11-23 16:38:52 +01:00
|
|
|
print("autoPyLoT: After iteration No. %d: %d bad onsets found ..." % (nlloccounter, \
|
2016-03-30 08:14:58 +02:00
|
|
|
len(badpicks)))
|
2015-11-23 16:38:52 +01:00
|
|
|
if len(badpicks) == 0:
|
|
|
|
print("autoPyLoT: No more bad onsets found, stop iterative picking!")
|
2015-12-01 15:39:28 +01:00
|
|
|
nlloccounter = maxnumit
|
2016-03-30 08:14:58 +02:00
|
|
|
|
2015-12-01 15:39:28 +01:00
|
|
|
# calculating seismic moment Mo and moment magnitude Mw
|
2016-03-30 08:14:58 +02:00
|
|
|
finalpicks = M0Mw(wfdat, None, None, parameter.getParam('iplot'), \
|
|
|
|
nllocfile, picks, parameter.getParam('rho'), \
|
|
|
|
parameter.getParam('vp'), parameter.getParam('Qp'), \
|
|
|
|
parameter.getParam('invdir'))
|
2015-12-03 14:55:07 +01:00
|
|
|
# get network moment magntiude
|
|
|
|
netMw = []
|
2016-03-30 08:14:58 +02:00
|
|
|
for key in finalpicks.getpicdic():
|
|
|
|
if finalpicks.getpicdic()[key]['P']['Mw'] is not None:
|
|
|
|
netMw.append(finalpicks.getpicdic()[key]['P']['Mw'])
|
2015-12-03 14:55:07 +01:00
|
|
|
netMw = np.median(netMw)
|
|
|
|
print("Network moment magnitude: %4.1f" % netMw)
|
2015-11-20 15:49:34 +01:00
|
|
|
else:
|
|
|
|
print("autoPyLoT: No NLLoc-location file available! Stop iteration!")
|
2015-10-27 15:26:25 +01:00
|
|
|
##########################################################
|
2015-11-04 16:52:39 +01:00
|
|
|
# write phase files for various location routines
|
|
|
|
# HYPO71
|
|
|
|
hypo71file = '%s/%s/autoPyLoT_HYPO71.pha' % (datapath, parameter.getParam('eventID'))
|
2015-12-10 12:02:32 +01:00
|
|
|
if hasattr(finalpicks, 'getpicdic'):
|
|
|
|
if finalpicks.getpicdic() is not None:
|
|
|
|
writephases(finalpicks.getpicdic(), 'HYPO71', hypo71file)
|
2016-04-11 13:59:32 +02:00
|
|
|
data.applyEVTData(finalpicks.getpicdic())
|
2015-12-10 12:02:32 +01:00
|
|
|
else:
|
|
|
|
writephases(picks, 'HYPO71', hypo71file)
|
2016-04-11 13:59:32 +02:00
|
|
|
data.applyEVTData(picks)
|
2015-12-03 14:55:07 +01:00
|
|
|
else:
|
|
|
|
writephases(picks, 'HYPO71', hypo71file)
|
2016-04-11 13:59:32 +02:00
|
|
|
data.applyEVTData(picks)
|
|
|
|
fnqml = '%s/%s/autoPyLoT' % (datapath, parameter.getParam('eventID'))
|
|
|
|
data.exportEvent(fnqml)
|
2016-03-30 08:14:58 +02:00
|
|
|
|
2015-11-12 17:21:04 +01:00
|
|
|
endsplash = '''------------------------------------------\n'
|
2016-03-30 08:14:58 +02:00
|
|
|
-----Finished event %s!-----\n'
|
2015-11-12 17:21:04 +01:00
|
|
|
------------------------------------------'''.format \
|
|
|
|
(version=_getVersionString()) % parameter.getParam('eventID')
|
|
|
|
print(endsplash)
|
|
|
|
if locflag == 0:
|
|
|
|
print("autoPyLoT was running in non-location mode!")
|
2016-03-30 08:14:58 +02:00
|
|
|
|
2015-11-12 17:21:04 +01:00
|
|
|
endsp = '''####################################\n
|
|
|
|
************************************\n
|
|
|
|
*********autoPyLoT terminates*******\n
|
|
|
|
The Python picking and Location Tool\n
|
|
|
|
************************************'''.format(version=_getVersionString())
|
|
|
|
print(endsp)
|
2015-04-29 07:57:52 +02:00
|
|
|
|
2016-03-30 08:14:58 +02:00
|
|
|
|
2015-04-22 12:46:24 +02:00
|
|
|
if __name__ == "__main__":
|
2016-04-11 13:59:32 +02:00
|
|
|
from pylot.core.util.defaults import AUTOMATIC_DEFAULTS
|
2015-04-22 12:46:24 +02:00
|
|
|
# parse arguments
|
|
|
|
parser = argparse.ArgumentParser(
|
2015-07-10 09:22:58 +02:00
|
|
|
description='''autoPyLoT automatically picks phase onset times using higher order statistics,
|
2015-05-29 16:26:31 +02:00
|
|
|
autoregressive prediction and AIC''')
|
2015-04-22 12:46:24 +02:00
|
|
|
|
|
|
|
parser.add_argument('-i', '-I', '--inputfile', type=str,
|
|
|
|
action='store',
|
|
|
|
help='''full path to the file containing the input
|
|
|
|
parameters for autoPyLoT''',
|
2016-04-11 13:59:32 +02:00
|
|
|
default=AUTOMATIC_DEFAULTS
|
2015-04-22 12:46:24 +02:00
|
|
|
)
|
|
|
|
parser.add_argument('-v', '-V', '--version', action='version',
|
|
|
|
version='autoPyLoT ' + __version__,
|
|
|
|
help='show version information and exit')
|
|
|
|
|
|
|
|
cla = parser.parse_args()
|
|
|
|
|
2015-05-20 10:01:19 +02:00
|
|
|
autoPyLoT(str(cla.inputfile))
|