[Bugfix, not fixed completly] Locating event possible now out of GUI, class export obsolete? updateEvent still buggy!

This commit is contained in:
Ludger Küperkoch 2017-06-30 17:20:18 +02:00
parent 74393432da
commit 532a90a61f

View File

@ -1037,17 +1037,25 @@ class MainWindow(QMainWindow):
self.set_fname(self.get_data().getEventFileName(), type) self.set_fname(self.get_data().getEventFileName(), type)
return self.get_fnames(type) return self.get_fnames(type)
def saveData(self): def saveData(self, directory=None, outformat=None):
def getSavePath(e): def getSavePath(e, directory, outformat):
print('warning: {0}'.format(e)) print('warning: {0}'.format(e))
if not directory:
dlgflag = 1
directory = self.get_current_event_path() directory = self.get_current_event_path()
else:
dlgflag = 0
eventname = self.get_current_event_name() eventname = self.get_current_event_name()
filename = 'PyLoT_'+eventname filename = 'PyLoT_'+eventname
outpath = os.path.join(directory, filename) outpath = os.path.join(directory, filename)
title = 'Save pick data ...' title = 'Save pick data ...'
if not outformat:
outformat = settings.value('output/Format') outformat = settings.value('output/Format')
outformat = outformat[0:4] outformat = outformat[0:4]
else:
selected_filter = "NonLinLoc observation file (*.obs)"
fname = outpath
if outformat == '.obs': if outformat == '.obs':
file_filter = "NonLinLoc observation file (*.obs)" file_filter = "NonLinLoc observation file (*.obs)"
elif outformat == '.cnv': elif outformat == '.cnv':
@ -1055,6 +1063,7 @@ class MainWindow(QMainWindow):
elif outformat == '.xml': elif outformat == '.xml':
file_filter = "QuakeML file (*.xml)" file_filter = "QuakeML file (*.xml)"
if dlgflag == 1:
fname, selected_filter = QFileDialog.getSaveFileName(self, fname, selected_filter = QFileDialog.getSaveFileName(self,
title, title,
outpath, outpath,
@ -1090,9 +1099,9 @@ class MainWindow(QMainWindow):
try: try:
self.get_data().exportEvent(fbasename, exform) self.get_data().exportEvent(fbasename, exform)
except FormatError as e: except FormatError as e:
fbasename, exform = getSavePath(e) fbasename, exform = getSavePath(e, directory, outformat)
except AttributeError as e: except AttributeError as e:
fbasename, exform = getSavePath(e) fbasename, exform = getSavePath(e, directory, outformat)
# catch all possible cases before going on # catch all possible cases before going on
if not fbasename: if not fbasename:
@ -1962,11 +1971,14 @@ class MainWindow(QMainWindow):
outfile = settings.value("{0}/outputFile".format(loctool), outfile = settings.value("{0}/outputFile".format(loctool),
os.path.split(os.tempnam())[-1]) os.path.split(os.tempnam())[-1])
phasefile = os.path.split(os.tempnam())[-1] obsdir = os.path.join(locroot, 'obs')
self.saveData(directory=obsdir, outformat='.obs')
eventname = self.get_current_event_name()
filename = 'PyLoT_'+eventname
locpath = os.path.join(locroot, 'loc', filename)
phasefile = os.path.join(obsdir, filename + '.obs')
phasepath = os.path.join(locroot, 'obs', phasefile) phasepath = os.path.join(locroot, 'obs', phasefile)
locpath = os.path.join(locroot, 'loc', outfile) lt.modify_inputs(infile, locroot, filename, phasefile, ttt)
lt.export(self.getPicks(), phasepath, self.project.parameter)
lt.modify_inputs(infile, locroot, outfile, phasefile, ttt)
try: try:
lt.locate(infile) lt.locate(infile)
except RuntimeError as e: except RuntimeError as e:
@ -1975,7 +1987,7 @@ class MainWindow(QMainWindow):
os.remove(phasepath) os.remove(phasepath)
self.get_data().applyEVTData(lt.read_location(locpath), typ='event') self.get_data().applyEVTData(lt.read_location(locpath), typ='event')
self.get_data().applyEVTData(self.calc_magnitude(), typ='event') #self.get_data().applyEVTData(self.calc_magnitude(), typ='event')
def init_array_tab(self): def init_array_tab(self):
''' '''