[bugfix] now the whole line containing LOCFILES is replaced with a modified string using the getPatternLine utility function
This commit is contained in:
parent
1f383579b4
commit
d933c30148
@ -2,8 +2,13 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import os
|
||||||
from obspy.core.event import readEvents
|
from obspy.core.event import readEvents
|
||||||
from pylot.core.pick.utils import writephases
|
from pylot.core.pick.utils import writephases
|
||||||
|
from pylot.core.util.utils import getPatternLine
|
||||||
|
from pylot.core.util.version import get_git_version as _getVersionString
|
||||||
|
|
||||||
|
__version__ = _getVersionString()
|
||||||
|
|
||||||
def picksExport(picks, phasefile):
|
def picksExport(picks, phasefile):
|
||||||
'''
|
'''
|
||||||
@ -16,7 +21,7 @@ def picksExport(picks, phasefile):
|
|||||||
# write phases to NLLoc-phase file
|
# write phases to NLLoc-phase file
|
||||||
writephases(picks, 'NLLoc', phasefile)
|
writephases(picks, 'NLLoc', phasefile)
|
||||||
|
|
||||||
def modfiyInputFile(fn, root, outpath, phasefile, tttable):
|
def modfiyInputFile(fn, root, outpath, phasefn, tttn):
|
||||||
'''
|
'''
|
||||||
|
|
||||||
:param fn:
|
:param fn:
|
||||||
@ -29,18 +34,21 @@ def modfiyInputFile(fn, root, outpath, phasefile, tttable):
|
|||||||
# For locating the event we have to modify the NLLoc-control file!
|
# For locating the event we have to modify the NLLoc-control file!
|
||||||
# create comment line for NLLoc-control file NLLoc-output file
|
# create comment line for NLLoc-control file NLLoc-output file
|
||||||
print ("Modifying NLLoc-control file %s ..." % fn)
|
print ("Modifying NLLoc-control file %s ..." % fn)
|
||||||
nllocout = '%s/loc/%s_%s' % (root, outpath)
|
nllocout = os.path.join(root,'loc', outpath)
|
||||||
locfiles = 'LOCFILES %s NLLOC_OBS %s %s 0' % (phasefile, tttable, nllocout)
|
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
|
# modification of NLLoc-control file
|
||||||
|
curlocfiles = getPatternLine(fn, 'LOCFILES')
|
||||||
nllfile = open(fn, 'r')
|
nllfile = open(fn, 'r')
|
||||||
filedata = nllfile.read()
|
filedata = nllfile.read()
|
||||||
if filedata.find(locfiles) < 0:
|
if filedata.find(locfiles) < 0:
|
||||||
# replace old command
|
# replace old command
|
||||||
filedata = filedata.replace('LOCFILES', locfiles)
|
filedata = filedata.replace(curlocfiles, locfiles)
|
||||||
nllfile = open(fn, 'w')
|
nllfile = open(fn, 'w')
|
||||||
nllfile.write(filedata)
|
nllfile.write(filedata)
|
||||||
nllfile.close()
|
nllfile.close()
|
||||||
|
|
||||||
def locate(call, fnin):
|
def locate(call, fnin):
|
||||||
'''
|
'''
|
||||||
|
Loading…
Reference in New Issue
Block a user