Merge branch 'develop' of ariadne.geophysik.ruhr-uni-bochum.de:/data/git/pylot into develop

This commit is contained in:
Marcel Paffrath
2015-11-18 17:22:51 +01:00
5 changed files with 123 additions and 109 deletions

View File

@@ -10,54 +10,72 @@ from pylot.core.util.version import get_git_version as _getVersionString
__version__ = _getVersionString()
def picksExport(picks, phasefile):
def picksExport(picks, locrt, phasefile):
'''
Take <picks> dictionary and exports picking data to a NLLOC-obs <phasefile> without creating an ObsPy event object.
Take <picks> dictionary and exports picking data to a NLLOC-obs
<phasefile> without creating an ObsPy event object.
:param picks: picking data dictionary
:type picks: dict
:param locrt: choose location routine
:type locrt: str
:param phasefile: complete path to the exporting obs file
:type phasefile: str
'''
# write phases to NLLoc-phase file
writephases(picks, 'NLLoc', phasefile)
writephases(picks, locrt, phasefile)
def modfiyInputFile(fn, root, outpath, phasefn, tttn):
def modifyInputFile(ctrfn, root, nllocoutn, phasefn, tttn):
'''
:param ctrfn: name of NLLoc-control file
:type: str
:param fn:
:param root:
:param outpath:
:param phasefile:
:param tttable:
:return:
:param root: root path to NLLoc working directory
:type: str
:param nllocoutn: name of NLLoc-location output file
:type: str
:param phasefn: name of NLLoc-input phase file
:type: str
:param tttn: pattern of precalculated NLLoc traveltime tables
:type: str
'''
# For locating the event we have to modify the NLLoc-control file!
# For locating the event the NLLoc-control file has to be modified!
# create comment line for NLLoc-control file NLLoc-output file
print ("Modifying NLLoc-control file %s ..." % fn)
nllocout = os.path.join(root,'loc', outpath)
ctrfile = os.path.join(root, 'run', ctrfn)
nllocout = os.path.join(root,'loc', nllocoutn)
phasefile = os.path.join(root, 'obs', phasefn)
tttable = os.path.join(root, 'time', tttn)
locfiles = 'LOCFILES %s NLLOC_OBS %s %s 0\n' % (phasefile, tttable, nllocout)
# modification of NLLoc-control file
curlocfiles = getPatternLine(fn, 'LOCFILES')
nllfile = open(fn, 'r')
print ("Modifying NLLoc-control file %s ..." % ctrfile)
curlocfiles = getPatternLine(ctrfile, 'LOCFILES')
nllfile = open(ctrfile, 'r')
filedata = nllfile.read()
if filedata.find(locfiles) < 0:
# replace old command
filedata = filedata.replace(curlocfiles, locfiles)
nllfile = open(fn, 'w')
nllfile = open(ctrfile, 'w')
nllfile.write(filedata)
nllfile.close()
def locate(call, fnin):
'''
Takes paths to NLLoc executable <call> and input parameter file <fnin> and starts the location calculation.
Takes paths to NLLoc executable <call> and input parameter file <fnin>
and starts the location calculation.
:param call: full path to NLLoc executable
:type call: str
:param fnin: full path to input parameter file
:type fnin: str
'''
# locate the event
subprocess.call([call, fnin])

View File

@@ -764,11 +764,23 @@ def autopickstation(wfstream, pickparam):
lpickP = zdat[0].stats.starttime + lpickP
epickP = zdat[0].stats.starttime + epickP
mpickP = zdat[0].stats.starttime + mpickP
else:
# dummy values (start of seismic trace) in order to derive
# theoretical onset times for iteratve picking
lpickP = zdat[0].stats.starttime
epickP = zdat[0].stats.starttime
mpickP = zdat[0].stats.starttime
if mpickS is not None and epickS is not None and mpickS is not None:
lpickS = edat[0].stats.starttime + lpickS
epickS = edat[0].stats.starttime + epickS
mpickS = edat[0].stats.starttime + mpickS
else:
# dummy values (start of seismic trace) in order to derive
# theoretical onset times for iteratve picking
lpickS = edat[0].stats.starttime
epickS = edat[0].stats.starttime
mpickS = edat[0].stats.starttime
# create dictionary
# for P phase

View File

@@ -961,46 +961,58 @@ def writephases(arrivals, fformat, filename):
# write header
fid.write('# EQEVENT: Label: EQ001 Loc: X 0.00 Y 0.00 Z 10.00 OT 0.00 \n')
for key in arrivals:
if arrivals[key]['P']['weight'] < 4:
fm = arrivals[key]['P']['fm']
if fm == None:
fm = '?'
onset = arrivals[key]['P']['mpp']
year = onset.year
month = onset.month
day = onset.day
hh = onset.hour
mm = onset.minute
ss = onset.second
ms = onset.microsecond
ss_ms = ss + ms / 1000000.0
fid.write('%s ? ? ? P %s %d%02d%02d %02d%02d %7.4f GAU 0 0 0 0 1 \n' % (key,
fm,
year,
month,
day,
hh,
mm,
ss_ms))
if arrivals[key]['S']['weight'] < 4:
fm = '?'
onset = arrivals[key]['S']['mpp']
year = onset.year
month = onset.month
day = onset.day
hh = onset.hour
mm = onset.minute
ss = onset.second
ms = onset.microsecond
ss_ms = ss + ms / 1000000.0
fid.write('%s ? ? ? S %s %d%02d%02d %02d%02d %7.4f GAU 0 0 0 0 1 \n' % (key,
fm,
year,
month,
day,
hh,
mm,
ss_ms))
# P onsets
if arrivals[key]['P']:
fm = arrivals[key]['P']['fm']
if fm == None:
fm = '?'
onset = arrivals[key]['P']['mpp']
year = onset.year
month = onset.month
day = onset.day
hh = onset.hour
mm = onset.minute
ss = onset.second
ms = onset.microsecond
ss_ms = ss + ms / 1000000.0
if arrivals[key]['P']['weight'] < 4:
pweight = 1 # use pick
else:
pweight = 0 # do not use pick
fid.write('%s ? ? ? P %s %d%02d%02d %02d%02d %7.4f GAU 0 0 0 0 %d \n' % (key,
fm,
year,
month,
day,
hh,
mm,
ss_ms,
pweight))
# S onsets
if arrivals[key]['S']:
fm = '?'
onset = arrivals[key]['S']['mpp']
year = onset.year
month = onset.month
day = onset.day
hh = onset.hour
mm = onset.minute
ss = onset.second
ms = onset.microsecond
ss_ms = ss + ms / 1000000.0
if arrivals[key]['S']['weight'] < 4:
sweight = 1 # use pick
else:
sweight = 0 # do not use pick
fid.write('%s ? ? ? S %s %d%02d%02d %02d%02d %7.4f GAU 0 0 0 0 %d \n' % (key,
fm,
year,
month,
day,
hh,
mm,
ss_ms,
sweight))
fid.close()