From d933c30148b0d1439316f4965917385c5b3eb031 Mon Sep 17 00:00:00 2001 From: Sebastian Wehling-Benatelli Date: Thu, 12 Nov 2015 09:25:33 +0100 Subject: [PATCH] [bugfix] now the whole line containing LOCFILES is replaced with a modified string using the getPatternLine utility function --- pylot/core/loc/nll.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/pylot/core/loc/nll.py b/pylot/core/loc/nll.py index f411906c..3ecd1211 100644 --- a/pylot/core/loc/nll.py +++ b/pylot/core/loc/nll.py @@ -2,8 +2,13 @@ # -*- coding: utf-8 -*- import subprocess +import os from obspy.core.event import readEvents 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): ''' @@ -16,7 +21,7 @@ def picksExport(picks, phasefile): # write phases to NLLoc-phase file writephases(picks, 'NLLoc', phasefile) -def modfiyInputFile(fn, root, outpath, phasefile, tttable): +def modfiyInputFile(fn, root, outpath, phasefn, tttn): ''' :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! # create comment line for NLLoc-control file NLLoc-output file print ("Modifying NLLoc-control file %s ..." % fn) - nllocout = '%s/loc/%s_%s' % (root, outpath) - locfiles = 'LOCFILES %s NLLOC_OBS %s %s 0' % (phasefile, tttable, nllocout) + nllocout = os.path.join(root,'loc', outpath) + 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') filedata = nllfile.read() if filedata.find(locfiles) < 0: # replace old command - filedata = filedata.replace('LOCFILES', locfiles) + filedata = filedata.replace(curlocfiles, locfiles) nllfile = open(fn, 'w') nllfile.write(filedata) - nllfile.close() + nllfile.close() def locate(call, fnin): '''