[refs #137] some improvements in autoPyLoT and ongoing work in the QtPyLoT NLL implementation
This commit is contained in:
parent
e53dd99d75
commit
b29c7068e3
24
QtPyLoT.py
24
QtPyLoT.py
@ -37,6 +37,7 @@ from PySide.QtGui import QMainWindow, QInputDialog, QIcon, QFileDialog, \
|
|||||||
QDialog, QErrorMessage, QApplication, QPixmap, QMessageBox, QSplashScreen, \
|
QDialog, QErrorMessage, QApplication, QPixmap, QMessageBox, QSplashScreen, \
|
||||||
QActionGroup, QListWidget, QDockWidget
|
QActionGroup, QListWidget, QDockWidget
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
import subprocess
|
||||||
from obspy import UTCDateTime
|
from obspy import UTCDateTime
|
||||||
|
|
||||||
from pylot.core.io.data import Data
|
from pylot.core.io.data import Data
|
||||||
@ -630,6 +631,8 @@ class MainWindow(QMainWindow):
|
|||||||
ans = self.data.setWFData(self.fnames)
|
ans = self.data.setWFData(self.fnames)
|
||||||
elif self.fnames is None and self.okToContinue():
|
elif self.fnames is None and self.okToContinue():
|
||||||
ans = self.data.setWFData(self.getWFFnames())
|
ans = self.data.setWFData(self.getWFFnames())
|
||||||
|
else:
|
||||||
|
ans = False
|
||||||
self._stime = getGlobalTimes(self.getData().getWFData())[0]
|
self._stime = getGlobalTimes(self.getData().getWFData())[0]
|
||||||
if ans:
|
if ans:
|
||||||
self.plotWaveformData()
|
self.plotWaveformData()
|
||||||
@ -889,6 +892,12 @@ class MainWindow(QMainWindow):
|
|||||||
raise TypeError('Unknow picktype {0}'.format(picktype))
|
raise TypeError('Unknow picktype {0}'.format(picktype))
|
||||||
|
|
||||||
def locateEvent(self):
|
def locateEvent(self):
|
||||||
|
"""
|
||||||
|
locate event using the manually picked phases
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
if not self.okToContinue():
|
||||||
|
return
|
||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
# get location tool hook
|
# get location tool hook
|
||||||
loctool = settings.value("loc/tool", "nll")
|
loctool = settings.value("loc/tool", "nll")
|
||||||
@ -896,9 +905,22 @@ class MainWindow(QMainWindow):
|
|||||||
# get working directory
|
# get working directory
|
||||||
locroot = settings.value("{0}/rootPath".format(loctool), None)
|
locroot = settings.value("{0}/rootPath".format(loctool), None)
|
||||||
infile = settings.value("{0}/inputFile".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:
|
if locroot is None:
|
||||||
self.PyLoTprefs()
|
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):
|
def check4Loc(self):
|
||||||
return self.picksNum() > 4
|
return self.picksNum() > 4
|
||||||
|
26
autoPyLoT.py
26
autoPyLoT.py
@ -120,8 +120,8 @@ def autoPyLoT(inputfile):
|
|||||||
evID = event[string.rfind(event, "/") + 1: len(events) - 1]
|
evID = event[string.rfind(event, "/") + 1: len(events) - 1]
|
||||||
nllocout = '%s_%s' % (evID, nllocoutpatter)
|
nllocout = '%s_%s' % (evID, nllocoutpatter)
|
||||||
# create comment line for NLLoc-control file
|
# create comment line for NLLoc-control file
|
||||||
nll.modifyInputFile(ctrf, nllocroot, nllocout, phasef,
|
nll.modify_inputs(ctrf, nllocroot, nllocout, phasef,
|
||||||
ttpat)
|
ttpat)
|
||||||
|
|
||||||
# locate the event
|
# locate the event
|
||||||
nll.locate(ctrfile)
|
nll.locate(ctrfile)
|
||||||
@ -202,13 +202,9 @@ def autoPyLoT(inputfile):
|
|||||||
# write phase files for various location routines
|
# write phase files for various location routines
|
||||||
# HYPO71
|
# HYPO71
|
||||||
hypo71file = '%s/autoPyLoT_HYPO71.pha' % event
|
hypo71file = '%s/autoPyLoT_HYPO71.pha' % event
|
||||||
if hasattr(finalpicks, 'getpicdic'):
|
if hasattr(finalpicks, 'getpicdic') and finalpicks.getpicdic() is not None:
|
||||||
if finalpicks.getpicdic() is not None:
|
hsat.export(finalpicks.getpicdic(), hypo71file)
|
||||||
hsat.export(finalpicks.getpicdic(), hypo71file)
|
data.applyEVTData(finalpicks.getpicdic())
|
||||||
data.applyEVTData(finalpicks.getpicdic())
|
|
||||||
else:
|
|
||||||
hsat.export(picks, hypo71file)
|
|
||||||
data.applyEVTData(picks)
|
|
||||||
else:
|
else:
|
||||||
hsat.export(picks, hypo71file)
|
hsat.export(picks, hypo71file)
|
||||||
data.applyEVTData(picks)
|
data.applyEVTData(picks)
|
||||||
@ -243,7 +239,7 @@ def autoPyLoT(inputfile):
|
|||||||
# For locating the event the NLLoc-control file has to be modified!
|
# For locating the event the NLLoc-control file has to be modified!
|
||||||
nllocout = '%s_%s' % (parameter.get('eventID'), nllocoutpatter)
|
nllocout = '%s_%s' % (parameter.get('eventID'), nllocoutpatter)
|
||||||
# create comment line for NLLoc-control file
|
# 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
|
# locate the event
|
||||||
nll.locate(ctrfile)
|
nll.locate(ctrfile)
|
||||||
@ -323,13 +319,9 @@ def autoPyLoT(inputfile):
|
|||||||
# write phase files for various location routines
|
# write phase files for various location routines
|
||||||
# HYPO71
|
# HYPO71
|
||||||
hypo71file = '%s/%s/autoPyLoT_HYPO71.pha' % (datapath, parameter.get('eventID'))
|
hypo71file = '%s/%s/autoPyLoT_HYPO71.pha' % (datapath, parameter.get('eventID'))
|
||||||
if hasattr(finalpicks, 'getpicdic'):
|
if hasattr(finalpicks, 'getpicdic') and finalpicks.getpicdic() is not None:
|
||||||
if finalpicks.getpicdic() is not None:
|
hsat.export(finalpicks.getpicdic(), hypo71file)
|
||||||
hsat.export(finalpicks.getpicdic(), hypo71file)
|
data.applyEVTData(finalpicks.getpicdic())
|
||||||
data.applyEVTData(finalpicks.getpicdic())
|
|
||||||
else:
|
|
||||||
hsat.export(picks, hypo71file)
|
|
||||||
data.applyEVTData(picks)
|
|
||||||
else:
|
else:
|
||||||
hsat.export(picks, hypo71file)
|
hsat.export(picks, hypo71file)
|
||||||
data.applyEVTData(picks)
|
data.applyEVTData(picks)
|
||||||
|
@ -28,7 +28,7 @@ def export(picks, fnout):
|
|||||||
writephases(picks, 'NLLoc', 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
|
:param ctrfn: name of NLLoc-control file
|
||||||
:type: str
|
:type: str
|
||||||
@ -82,7 +82,7 @@ def locate(fnin):
|
|||||||
try:
|
try:
|
||||||
runProgram(exe_path, fnin)
|
runProgram(exe_path, fnin)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print(e.output)
|
raise RuntimeError(e.output)
|
||||||
|
|
||||||
|
|
||||||
def readLocation(fn):
|
def readLocation(fn):
|
||||||
|
Loading…
Reference in New Issue
Block a user