[refs #137] some improvements in autoPyLoT and ongoing work in the QtPyLoT NLL implementation

This commit is contained in:
Sebastian Wehling-Benatelli 2016-08-25 21:32:41 +02:00
parent e53dd99d75
commit b29c7068e3
3 changed files with 34 additions and 20 deletions

View File

@ -37,6 +37,7 @@ from PySide.QtGui import QMainWindow, QInputDialog, QIcon, QFileDialog, \
QDialog, QErrorMessage, QApplication, QPixmap, QMessageBox, QSplashScreen, \
QActionGroup, QListWidget, QDockWidget
import numpy as np
import subprocess
from obspy import UTCDateTime
from pylot.core.io.data import Data
@ -630,6 +631,8 @@ class MainWindow(QMainWindow):
ans = self.data.setWFData(self.fnames)
elif self.fnames is None and self.okToContinue():
ans = self.data.setWFData(self.getWFFnames())
else:
ans = False
self._stime = getGlobalTimes(self.getData().getWFData())[0]
if ans:
self.plotWaveformData()
@ -889,6 +892,12 @@ class MainWindow(QMainWindow):
raise TypeError('Unknow picktype {0}'.format(picktype))
def locateEvent(self):
"""
locate event using the manually picked phases
:return:
"""
if not self.okToContinue():
return
settings = QSettings()
# get location tool hook
loctool = settings.value("loc/tool", "nll")
@ -896,9 +905,22 @@ class MainWindow(QMainWindow):
# get working directory
locroot = settings.value("{0}/rootPath".format(loctool), None)
infile = settings.value("{0}/inputFile".format(loctool), None)
lt.locate(infile)
outfile = settings.value("{0}/outputFile".format(loctool), None)
phasepath = os.tempnam(os.path.join(locroot, 'obs'), loctool)
locpath = os.path.join(locroot, 'loc', outfile)
lt.export(self.getPicks(), phasepath)
phasefile = os.path.split(phasepath)[-1]
args = lt.modify_inputs(infile, locroot, outfile, phasefile, )
if locroot is None:
self.PyLoTprefs()
try:
lt.locate(infile)
except RuntimeError as e:
print(e.message)
finally:
os.remove(phasepath)
self.getData().applyEVTData(lt.read_location(locpath), type='event')
def check4Loc(self):
return self.picksNum() > 4

View File

@ -120,8 +120,8 @@ def autoPyLoT(inputfile):
evID = event[string.rfind(event, "/") + 1: len(events) - 1]
nllocout = '%s_%s' % (evID, nllocoutpatter)
# create comment line for NLLoc-control file
nll.modifyInputFile(ctrf, nllocroot, nllocout, phasef,
ttpat)
nll.modify_inputs(ctrf, nllocroot, nllocout, phasef,
ttpat)
# locate the event
nll.locate(ctrfile)
@ -202,13 +202,9 @@ def autoPyLoT(inputfile):
# write phase files for various location routines
# HYPO71
hypo71file = '%s/autoPyLoT_HYPO71.pha' % event
if hasattr(finalpicks, 'getpicdic'):
if finalpicks.getpicdic() is not None:
hsat.export(finalpicks.getpicdic(), hypo71file)
data.applyEVTData(finalpicks.getpicdic())
else:
hsat.export(picks, hypo71file)
data.applyEVTData(picks)
if hasattr(finalpicks, 'getpicdic') and finalpicks.getpicdic() is not None:
hsat.export(finalpicks.getpicdic(), hypo71file)
data.applyEVTData(finalpicks.getpicdic())
else:
hsat.export(picks, hypo71file)
data.applyEVTData(picks)
@ -243,7 +239,7 @@ def autoPyLoT(inputfile):
# For locating the event the NLLoc-control file has to be modified!
nllocout = '%s_%s' % (parameter.get('eventID'), nllocoutpatter)
# create comment line for NLLoc-control file
nll.modifyInputFile(ctrf, nllocroot, nllocout, phasef, ttpat)
nll.modify_inputs(ctrf, nllocroot, nllocout, phasef, ttpat)
# locate the event
nll.locate(ctrfile)
@ -323,13 +319,9 @@ def autoPyLoT(inputfile):
# write phase files for various location routines
# HYPO71
hypo71file = '%s/%s/autoPyLoT_HYPO71.pha' % (datapath, parameter.get('eventID'))
if hasattr(finalpicks, 'getpicdic'):
if finalpicks.getpicdic() is not None:
hsat.export(finalpicks.getpicdic(), hypo71file)
data.applyEVTData(finalpicks.getpicdic())
else:
hsat.export(picks, hypo71file)
data.applyEVTData(picks)
if hasattr(finalpicks, 'getpicdic') and finalpicks.getpicdic() is not None:
hsat.export(finalpicks.getpicdic(), hypo71file)
data.applyEVTData(finalpicks.getpicdic())
else:
hsat.export(picks, hypo71file)
data.applyEVTData(picks)

View File

@ -28,7 +28,7 @@ def export(picks, fnout):
writephases(picks, 'NLLoc', fnout)
def modifyInputFile(ctrfn, root, nllocoutn, phasefn, tttn):
def modify_inputs(ctrfn, root, nllocoutn, phasefn, tttn):
'''
:param ctrfn: name of NLLoc-control file
:type: str
@ -82,7 +82,7 @@ def locate(fnin):
try:
runProgram(exe_path, fnin)
except subprocess.CalledProcessError as e:
print(e.output)
raise RuntimeError(e.output)
def readLocation(fn):