[ref #137] removing last bugs before closing feature

This commit is contained in:
Sebastian Wehling-Benatelli 2016-08-29 15:52:58 +02:00
parent 060bc1d0c8
commit ad91504211
3 changed files with 41 additions and 15 deletions

View File

@ -35,7 +35,7 @@ from PySide.QtCore import QCoreApplication, QSettings, Signal, QFile, \
from PySide.QtGui import QMainWindow, QInputDialog, QIcon, QFileDialog, \
QWidget, QHBoxLayout, QStyle, QKeySequence, QLabel, QFrame, QAction, \
QDialog, QErrorMessage, QApplication, QPixmap, QMessageBox, QSplashScreen, \
QActionGroup, QListWidget, QDockWidget
QActionGroup, QListWidget, QDockWidget, QLineEdit
import numpy as np
import subprocess
from obspy import UTCDateTime
@ -919,12 +919,24 @@ class MainWindow(QMainWindow):
infile = ans[0]
settings.setValue("{0}/inputFile".format(loctool), infile)
settings.sync()
outfile = settings.value("{0}/outputFile".format(loctool), None)
if loctool == 'nll':
ttt = settings.value("{0}/travelTimeTables", None)
ok = False
if ttt is None:
while not ok:
text, ok = QInputDialog.getText(self, 'Pattern for travel time tables',
'Base name of travel time tables',
echo=QLineEdit.Normal,
text="ttime")
ttt = text
outfile = settings.value("{0}/outputFile".format(loctool),
os.path.split(os.tempnam())[-1])
phasefile = os.path.split(os.tempnam())[-1]
phasepath = os.path.join(locroot, 'obs', phasefile)
locpath = os.path.join(locroot, 'loc', outfile)
lt.export(self.getPicks(), phasepath)
lt.modify_inputs(infile, locroot, outfile, phasefile, )
lt.modify_inputs(infile, locroot, outfile, phasefile, ttt)
try:
lt.locate(infile)
except RuntimeError as e:

View File

@ -117,7 +117,7 @@ def picksdict_from_pilot(fn):
except IndexError as e:
print(e.message + '\ntake two times the largest default error value')
spe = timeerrors[onset_name][-1] * 2
phases[onset_name] = dict(mpp=pick, spe=spe)
phases[onset_name] = dict(mpp=pick, spe=spe, weight=ierror)
picks[station] = phases
return picks
@ -395,7 +395,11 @@ def writephases(arrivals, fformat, filename):
for key in arrivals:
# P onsets
if arrivals[key]['P']:
fm = arrivals[key]['P']['fm']
try:
fm = arrivals[key]['P']['fm']
except KeyError as e:
print(e)
fm = None
if fm == None:
fm = '?'
onset = arrivals[key]['P']['mpp']
@ -407,10 +411,12 @@ def writephases(arrivals, fformat, filename):
ss = onset.second
ms = onset.microsecond
ss_ms = ss + ms / 1000000.0
if arrivals[key]['P']['weight'] < 4:
pweight = 1 # use pick
else:
pweight = 0 # do not use pick
pweight = 1 # use pick
try:
if arrivals[key]['P']['weight'] >= 4:
pweight = 0 # do not use pick
except KeyError as e:
print(e.message + '; no weight set during processing')
fid.write('%s ? ? ? P %s %d%02d%02d %02d%02d %7.4f GAU 0 0 0 0 %d \n' % (key,
fm,
year,
@ -421,7 +427,7 @@ def writephases(arrivals, fformat, filename):
ss_ms,
pweight))
# S onsets
if arrivals[key]['S']:
if arrivals[key].has_key('S') and arrivals[key]['S']:
fm = '?'
onset = arrivals[key]['S']['mpp']
year = onset.year
@ -432,10 +438,12 @@ def writephases(arrivals, fformat, filename):
ss = onset.second
ms = onset.microsecond
ss_ms = ss + ms / 1000000.0
if arrivals[key]['S']['weight'] < 4:
sweight = 1 # use pick
else:
sweight = 0 # do not use pick
sweight = 1 # use pick
try:
if arrivals[key]['S']['weight'] >= 4:
sweight = 0 # do not use pick
except KeyError as e:
print(str(e) + '; no weight set during processing')
fid.write('%s ? ? ? S %s %d%02d%02d %02d%02d %7.4f GAU 0 0 0 0 %d \n' % (key,
fm,
year,

View File

@ -3,6 +3,7 @@
import subprocess
import os
import glob
from obspy import read_events
from pylot.core.io.phases import writephases
from pylot.core.util.utils import getPatternLine, runProgram, which
@ -85,7 +86,12 @@ def locate(fnin):
raise RuntimeError(e.output)
def readLocation(fn):
def read_location(fn):
path, file = os.path.split(fn)
file = glob.glob1(path, file + '.[0-9]*.grid0.loc.hyp')
if len(file) > 1:
raise IOError('ambiguous location name {0}'.format(file))
fn = os.path.join(path, file[0])
return read_events(fn)