Introduced option for running autoPyLoT without location routine, if parameter nllocbin in autoPyLoT.in is not set.
This commit is contained in:
parent
43d243e0a1
commit
fc319f7162
146
autoPyLoT.py
146
autoPyLoT.py
@ -6,8 +6,7 @@ import os
|
|||||||
import argparse
|
import argparse
|
||||||
import glob
|
import glob
|
||||||
import subprocess
|
import subprocess
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
import pdb
|
|
||||||
from obspy.core import read
|
from obspy.core import read
|
||||||
from pylot.core.read.data import Data
|
from pylot.core.read.data import Data
|
||||||
from pylot.core.read.inputs import AutoPickParameter
|
from pylot.core.read.inputs import AutoPickParameter
|
||||||
@ -20,7 +19,7 @@ __version__ = _getVersionString()
|
|||||||
|
|
||||||
|
|
||||||
def autoPyLoT(inputfile):
|
def autoPyLoT(inputfile):
|
||||||
'''
|
"""
|
||||||
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.
|
||||||
|
|
||||||
@ -32,7 +31,7 @@ def autoPyLoT(inputfile):
|
|||||||
|
|
||||||
.. rubric:: Example
|
.. rubric:: Example
|
||||||
|
|
||||||
'''
|
"""
|
||||||
print '************************************'
|
print '************************************'
|
||||||
print '*********autoPyLoT starting*********'
|
print '*********autoPyLoT starting*********'
|
||||||
print 'The Python picking and Location Tool'
|
print 'The Python picking and Location Tool'
|
||||||
@ -57,9 +56,9 @@ def autoPyLoT(inputfile):
|
|||||||
|
|
||||||
if parameter.hasParam('datastructure'):
|
if parameter.hasParam('datastructure'):
|
||||||
datastructure = DATASTRUCTURE[parameter.getParam('datastructure')]()
|
datastructure = DATASTRUCTURE[parameter.getParam('datastructure')]()
|
||||||
dsfields = {'root':parameter.getParam('rootpath'),
|
dsfields = {'root' :parameter.getParam('rootpath'),
|
||||||
'dpath':parameter.getParam('datapath'),
|
'dpath' :parameter.getParam('datapath'),
|
||||||
'dbase':parameter.getParam('database')}
|
'dbase' :parameter.getParam('database')}
|
||||||
|
|
||||||
exf = ['root', 'dpath', 'dbase']
|
exf = ['root', 'dpath', 'dbase']
|
||||||
|
|
||||||
@ -70,25 +69,28 @@ def autoPyLoT(inputfile):
|
|||||||
datastructure.modifyFields(**dsfields)
|
datastructure.modifyFields(**dsfields)
|
||||||
datastructure.setExpandFields(exf)
|
datastructure.setExpandFields(exf)
|
||||||
|
|
||||||
# get path to inventory or dataless-seed file with station meta data
|
# check if default location routine NLLoc is available
|
||||||
invdir = parameter.getParam('invdir')
|
if parameter.hasParam('nllocbin'):
|
||||||
|
locflag = 1
|
||||||
# get NLLoc-root path
|
# get NLLoc-root path
|
||||||
nllocroot = parameter.getParam('nllocroot')
|
nllocroot = parameter.getParam('nllocroot')
|
||||||
# get path to NLLoc executable
|
# get path to NLLoc executable
|
||||||
nllocbin = parameter.getParam('nllocbin')
|
nllocbin = parameter.getParam('nllocbin')
|
||||||
nlloccall = '%s/NLLoc' % nllocbin
|
nlloccall = '%s/NLLoc' % nllocbin
|
||||||
# get name of phase file
|
# get name of phase file
|
||||||
phasef = parameter.getParam('phasefile')
|
phasef = parameter.getParam('phasefile')
|
||||||
phasefile = '%s/obs/%s' % (nllocroot, phasef)
|
phasefile = '%s/obs/%s' % (nllocroot, phasef)
|
||||||
# get name of NLLoc-control file
|
# get name of NLLoc-control file
|
||||||
locf = parameter.getParam('locfile')
|
locf = parameter.getParam('locfile')
|
||||||
locfile = '%s/run/%s' % (nllocroot, locf)
|
locfile = '%s/run/%s' % (nllocroot, locf)
|
||||||
# patter of NLLoc ttimes from location grid
|
# patter of NLLoc ttimes from location grid
|
||||||
ttpat = parameter.getParam('ttpatter')
|
ttpat = parameter.getParam('ttpatter')
|
||||||
ttpatter = '%s/time/%s' % (nllocroot, ttpat)
|
ttpatter = '%s/time/%s' % (nllocroot, ttpat)
|
||||||
# patter of NLLoc-output file
|
# patter of NLLoc-output file
|
||||||
nllocoutpatter = parameter.getParam('outpatter')
|
nllocoutpatter = parameter.getParam('outpatter')
|
||||||
|
else:
|
||||||
|
locflag = 0
|
||||||
|
print ("!!No location routine available, autoPyLoT just picks the events without locating them!!")
|
||||||
|
|
||||||
|
|
||||||
# multiple event processing
|
# multiple event processing
|
||||||
@ -97,37 +99,39 @@ def autoPyLoT(inputfile):
|
|||||||
if not parameter.hasParam('eventID'):
|
if not parameter.hasParam('eventID'):
|
||||||
for event in [events for events in glob.glob(os.path.join(datapath, '*')) if os.path.isdir(events)]:
|
for event in [events for events in glob.glob(os.path.join(datapath, '*')) if os.path.isdir(events)]:
|
||||||
data.setWFData(glob.glob(os.path.join(datapath, event, '*')))
|
data.setWFData(glob.glob(os.path.join(datapath, event, '*')))
|
||||||
print 'Working on event %s' %event
|
print 'Working on event %s' % event
|
||||||
print data
|
print data
|
||||||
|
|
||||||
wfdat = data.getWFData() # all available streams
|
wfdat = data.getWFData() # all available streams
|
||||||
##########################################################
|
##########################################################
|
||||||
# !automated picking starts here!
|
# !automated picking starts here!
|
||||||
picks = autopickevent(wfdat, parameter)
|
picks = autopickevent(wfdat, parameter)
|
||||||
|
|
||||||
# write phases to NLLoc-phase file
|
|
||||||
writephases(picks, 'NLLoc', phasefile)
|
|
||||||
|
|
||||||
##########################################################
|
##########################################################
|
||||||
# For locating the events we have to modify the NLLoc-control file!
|
# locating
|
||||||
# create comment line for NLLoc-control file
|
if locflag == 1:
|
||||||
# NLLoc-output file
|
# write phases to NLLoc-phase file
|
||||||
nllocout = '%s/loc/%s_%s' % (nllocroot, event, nllocoutpatter)
|
writephases(picks, 'NLLoc', phasefile)
|
||||||
locfiles = 'LOCFILES %s NLLOC_OBS %s %s 0' % (phasefile, ttpatter, nllocout)
|
|
||||||
print ("Modifying NLLoc-control file %s ..." % locfile)
|
|
||||||
# modification of NLLoc-control file
|
|
||||||
filedata = None
|
|
||||||
nllfile = open(locfile, 'r')
|
|
||||||
filedata = nllfile.read()
|
|
||||||
if filedata.find(locfiles) < 0:
|
|
||||||
# replace old command
|
|
||||||
filedata = filedata.replace('LOCFILES', locfiles)
|
|
||||||
nllfile = open(locfile, 'w')
|
|
||||||
nllfile.write(filedata)
|
|
||||||
nllfile.close()
|
|
||||||
|
|
||||||
# locate the event
|
# For locating the events we have to modify the NLLoc-control file!
|
||||||
subprocess.call([nlloccall, locfile])
|
# create comment line for NLLoc-control file
|
||||||
|
# NLLoc-output file
|
||||||
|
nllocout = '%s/loc/%s_%s' % (nllocroot, event, nllocoutpatter)
|
||||||
|
locfiles = 'LOCFILES %s NLLOC_OBS %s %s 0' % (phasefile, ttpatter, nllocout)
|
||||||
|
print ("Modifying NLLoc-control file %s ..." % locfile)
|
||||||
|
# modification of NLLoc-control file
|
||||||
|
filedata = None
|
||||||
|
nllfile = open(locfile, 'r')
|
||||||
|
filedata = nllfile.read()
|
||||||
|
if filedata.find(locfiles) < 0:
|
||||||
|
# replace old command
|
||||||
|
filedata = filedata.replace('LOCFILES', locfiles)
|
||||||
|
nllfile = open(locfile, 'w')
|
||||||
|
nllfile.write(filedata)
|
||||||
|
nllfile.close()
|
||||||
|
|
||||||
|
# locate the event
|
||||||
|
subprocess.call([nlloccall, locfile])
|
||||||
##########################################################
|
##########################################################
|
||||||
|
|
||||||
print '------------------------------------------'
|
print '------------------------------------------'
|
||||||
@ -140,33 +144,35 @@ def autoPyLoT(inputfile):
|
|||||||
print 'Working on event ', parameter.getParam('eventID')
|
print 'Working on event ', parameter.getParam('eventID')
|
||||||
print data
|
print data
|
||||||
|
|
||||||
wfdat = data.getWFData() # all available streams
|
wfdat = data.getWFData() # all available streams
|
||||||
##########################################################
|
##########################################################
|
||||||
# !automated picking starts here!
|
# !automated picking starts here!
|
||||||
picks = autopickevent(wfdat, parameter)
|
picks = autopickevent(wfdat, parameter)
|
||||||
|
|
||||||
# write phases to NLLoc-phase file
|
|
||||||
writephases(picks, 'NLLoc', phasefile)
|
|
||||||
|
|
||||||
##########################################################
|
##########################################################
|
||||||
# For locating the event we have to modify the NLLoc-control file!
|
# locating
|
||||||
# create comment line for NLLoc-control file NLLoc-output file
|
if locflag == 1:
|
||||||
nllocout = '%s/loc/%s_%s' % (nllocroot, parameter.getParam('eventID'), nllocoutpatter)
|
# write phases to NLLoc-phase file
|
||||||
locfiles = 'LOCFILES %s NLLOC_OBS %s %s 0' % (phasefile, ttpatter, nllocout)
|
writephases(picks, 'NLLoc', phasefile)
|
||||||
print ("Modifying NLLoc-control file %s ..." % locfile)
|
|
||||||
# modification of NLLoc-control file
|
|
||||||
filedata = None
|
|
||||||
nllfile = open(locfile, 'r')
|
|
||||||
filedata = nllfile.read()
|
|
||||||
if filedata.find(locfiles) < 0:
|
|
||||||
# replace old command
|
|
||||||
filedata = filedata.replace('LOCFILES', locfiles)
|
|
||||||
nllfile = open(locfile, 'w')
|
|
||||||
nllfile.write(filedata)
|
|
||||||
nllfile.close()
|
|
||||||
|
|
||||||
# locate the event
|
# For locating the event we have to modify the NLLoc-control file!
|
||||||
subprocess.call([nlloccall, locfile])
|
# create comment line for NLLoc-control file NLLoc-output file
|
||||||
|
nllocout = '%s/loc/%s_%s' % (nllocroot, parameter.getParam('eventID'), nllocoutpatter)
|
||||||
|
locfiles = 'LOCFILES %s NLLOC_OBS %s %s 0' % (phasefile, ttpatter, nllocout)
|
||||||
|
print ("Modifying NLLoc-control file %s ..." % locfile)
|
||||||
|
# modification of NLLoc-control file
|
||||||
|
filedata = None
|
||||||
|
nllfile = open(locfile, 'r')
|
||||||
|
filedata = nllfile.read()
|
||||||
|
if filedata.find(locfiles) < 0:
|
||||||
|
# replace old command
|
||||||
|
filedata = filedata.replace('LOCFILES', locfiles)
|
||||||
|
nllfile = open(locfile, 'w')
|
||||||
|
nllfile.write(filedata)
|
||||||
|
nllfile.close()
|
||||||
|
|
||||||
|
# locate the event
|
||||||
|
subprocess.call([nlloccall, locfile])
|
||||||
##########################################################
|
##########################################################
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user