From 85925576139bd26c38f6d6c43ff6a341dc42d62e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludger=20K=C3=BCperkoch?= Date: Wed, 18 Nov 2015 10:28:46 +0100 Subject: [PATCH] Minor changes --- pylot/core/loc/nll.py | 46 +++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/pylot/core/loc/nll.py b/pylot/core/loc/nll.py index f45cbfe4..00ef8b02 100644 --- a/pylot/core/loc/nll.py +++ b/pylot/core/loc/nll.py @@ -12,54 +12,70 @@ __version__ = _getVersionString() def picksExport(picks, locrt, phasefile): ''' - Take dictionary and exports picking data to a NLLOC-obs without creating an ObsPy event object. + Take dictionary and exports picking data to a NLLOC-obs + 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, 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 and input parameter file and starts the location calculation. + Takes paths to NLLoc executable and input parameter file + 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])