From a8522d0fae9c31778fd9150f1764d9cb1a62d6e9 Mon Sep 17 00:00:00 2001 From: Marcel Paffrath Date: Tue, 2 Aug 2016 11:54:28 +0200 Subject: [PATCH 1/6] pre code cleanup --- pylot/core/active/ActiveSeismoPick3D_GUI.py | 111 +------------- pylot/core/active/gui/windows.py | 156 ++++++++++++++------ 2 files changed, 117 insertions(+), 150 deletions(-) diff --git a/pylot/core/active/ActiveSeismoPick3D_GUI.py b/pylot/core/active/ActiveSeismoPick3D_GUI.py index 558fddc8..f71f0bf6 100755 --- a/pylot/core/active/ActiveSeismoPick3D_GUI.py +++ b/pylot/core/active/ActiveSeismoPick3D_GUI.py @@ -9,8 +9,7 @@ matplotlib.rcParams['backend.qt4']='PySide' from PySide import QtCore, QtGui from pylot.core.active import activeSeismoPick, surveyUtils, fmtomoUtils, seismicArrayPreparation from pylot.core.active.gui.asp3d_layout import * -from pylot.core.active.gui.vtk_tools_layout import * -from pylot.core.active.gui.windows import Gen_SeisArray, Gen_Survey_from_SA, Gen_Survey_from_SR, Call_autopicker, Call_FMTOMO +from pylot.core.active.gui.windows import Gen_SeisArray, Gen_Survey_from_SA, Gen_Survey_from_SR, Call_autopicker, Call_FMTOMO, Call_VTK_dialog from pylot.core.active.gui.windows import openFile, saveFile, browseDir, getMaxCPU from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas @@ -43,6 +42,7 @@ class gui_control(object): self.gssr = None self.autopicker = None self.fmtomo = None + self.vtktools = None def setInitStates(self): self.setPickState(False) @@ -369,111 +369,10 @@ class gui_control(object): def startVTKtools(self): - vtk_tools = QtGui.QDialog(self.mainwindow) - ui = Ui_vtk_tools() - ui.setupUi(vtk_tools) - - self.vtk_tools_ui = ui - self.connectButtons_vtk_tools() - self.openVTKdialog(ui, vtk_tools) - - - def openVTKdialog(self, ui, vtk_tools): - vtk_tools.exec_() - - - def connectButtons_vtk_tools(self): - QtCore.QObject.connect(self.vtk_tools_ui.pushButton_vg, QtCore.SIGNAL("clicked()"), self.chooseVgrid) - QtCore.QObject.connect(self.vtk_tools_ui.pushButton_vgref, QtCore.SIGNAL("clicked()"), self.chooseVgridref) - QtCore.QObject.connect(self.vtk_tools_ui.pushButton_rays, QtCore.SIGNAL("clicked()"), self.chooseRaysIn) - QtCore.QObject.connect(self.vtk_tools_ui.pushButton_raysout, QtCore.SIGNAL("clicked()"), self.chooseRaysOutDir) - QtCore.QObject.connect(self.vtk_tools_ui.pushButton_vtkout, QtCore.SIGNAL("clicked()"), self.newFileVTK) - QtCore.QObject.connect(self.vtk_tools_ui.pushButton_parav, QtCore.SIGNAL("clicked()"), self.openFileParaview) - QtCore.QObject.connect(self.vtk_tools_ui.start_vg, QtCore.SIGNAL("clicked()"), self.startvgvtk) - QtCore.QObject.connect(self.vtk_tools_ui.start_rays, QtCore.SIGNAL("clicked()"), self.startraysvtk) - QtCore.QObject.connect(self.vtk_tools_ui.radioButton_rel, QtCore.SIGNAL("clicked()"), self.activateVgref) - QtCore.QObject.connect(self.vtk_tools_ui.radioButton_abs, QtCore.SIGNAL("clicked()"), self.deactivateVgref) - - - def openFileParaview(self): - os.system('paraview %s &'%self.vtk_tools_ui.lineEdit_vgout.text()) - - - def activateVgref(self): - self.vtk_tools_ui.lineEdit_vgref.setEnabled(True) - self.vtk_tools_ui.pushButton_vgref.setEnabled(True) - - - def deactivateVgref(self): - self.vtk_tools_ui.lineEdit_vgref.setEnabled(False) - self.vtk_tools_ui.pushButton_vgref.setEnabled(False) - - - def checkVgStartButton(self): - ui = self.vtk_tools_ui - if ui.radioButton_rel.isChecked(): - if ui.lineEdit_vg.text() != '' and ui.lineEdit_vgref.text() != '': - ui.start_vg.setEnabled(True) - else: - ui.start_vg.setEnabled(False) - if ui.radioButton_abs.isChecked(): - if ui.lineEdit_vg.text() != '': - ui.start_vg.setEnabled(True) - else: - ui.start_vg.setEnabled(False) - - - def checkRaysStartButton(self): - ui = self.vtk_tools_ui - if ui.lineEdit_rays.text() != '' and ui.lineEdit_raysout.text() != '': - ui.start_rays.setEnabled(True) + if self.vtktools is None: + self.vtktools = Call_VTK_dialog(self.mainwindow) else: - ui.start_rays.setEnabled(False) - - - def chooseVgrid(self): - self.vtk_tools_ui.lineEdit_vg.setText(openFile()) - self.checkVgStartButton() - - - def chooseVgridref(self): - self.vtk_tools_ui.lineEdit_vgref.setText(openFile()) - self.checkVgStartButton() - - - def chooseRaysIn(self): - self.vtk_tools_ui.lineEdit_rays.setText(openFile()) - self.checkRaysStartButton() - - - def chooseRaysOutDir(self): - self.vtk_tools_ui.lineEdit_raysout.setText(browseDir()) - self.checkRaysStartButton() - - - def startvgvtk(self): - ui = self.vtk_tools_ui - if ui.lineEdit_vgout.text() == '': - if not self.printDialogMessage('Please specify output filename.'): - return - if ui.radioButton_abs.isChecked(): - fmtomoUtils.vgrids2VTK(inputfile = ui.lineEdit_vg.text(), - outputfile = ui.lineEdit_vgout.text(), - absOrRel='abs') - elif ui.radioButton_rel.isChecked(): - fmtomoUtils.vgrids2VTK(inputfile = ui.lineEdit_vg.text(), - outputfile = ui.lineEdit_vgout.text(), - absOrRel='rel', - inputfileref = ui.lineEdit_vgref.text()) - - - def startraysvtk(self): - ui = self.vtk_tools_ui - fmtomoUtils.rays2VTK(ui.lineEdit_rays.text(), ui.lineEdit_raysout.text()) - - - def newFileVTK(self): - self.vtk_tools_ui.lineEdit_vgout.setText(saveFile()) + self.vtktools.start_dialog() def postprocessing(self): diff --git a/pylot/core/active/gui/windows.py b/pylot/core/active/gui/windows.py index 8756fafe..531734ce 100644 --- a/pylot/core/active/gui/windows.py +++ b/pylot/core/active/gui/windows.py @@ -8,6 +8,8 @@ from generate_survey_layout_minimal import Ui_generate_survey_minimal from generate_seisarray_layout import Ui_generate_seisarray from picking_parameters_layout import Ui_picking_parameters from fmtomo_parameters_layout import Ui_fmtomo_parameters +from pylot.core.active.gui.vtk_tools_layout import Ui_vtk_tools + import numpy as np import matplotlib @@ -62,9 +64,7 @@ class Gen_SeisArray(object): self.connectButtons() def start_dialog(self): - self.init_last_selection() if self.qdialog.exec_(): - self.refresh_selection() if self.ui.radioButton_interpolatable.isChecked(): self.seisarray = seismicArrayPreparation.SeisArray(self.recfile, True) elif self.ui.radioButton_normal.isChecked(): @@ -75,19 +75,8 @@ class Gen_SeisArray(object): self.seisarray.addMeasuredTopographyPoints(self.ptsfile) self.executed = True else: - self.refresh_selection() self.executed = False - def refresh_selection(self): - self.srcfile = self.ui.lineEdit_src.text() - self.recfile = self.ui.lineEdit_rec.text() - self.ptsfile = self.ui.lineEdit_pts.text() - - def init_last_selection(self): - self.ui.lineEdit_src.setText(self.srcfile) - self.ui.lineEdit_rec.setText(self.recfile) - self.ui.lineEdit_pts.setText(self.ptsfile) - def get_seisarray(self): if self.seisarray is not None: return self.seisarray @@ -128,27 +117,14 @@ class Gen_Survey_from_SA(object): self.connectButtons() def start_dialog(self): - self.init_last_selection() if self.qdialog.exec_(): - self.refresh_selection() self.survey = activeSeismoPick.Survey(self.obsdir, seisArray = self.seisarray, useDefaultParas = True, fstart = self.fstart, fend = self.fend) self.executed = True else: - self.refresh_selection() self.executed = False - def refresh_selection(self): - self.obsdir = self.ui.lineEdit_obs.text() - self.fstart = self.ui.fstart.text() - self.fend = self.ui.fend.text() - - def init_last_selection(self): - self.ui.lineEdit_obs.setText(self.obsdir) - self.ui.fstart.setText(self.fstart) - self.ui.fend.setText(self.fend) - def get_survey(self): return self.survey @@ -180,31 +156,14 @@ class Gen_Survey_from_SR(object): self.connectButtons() def start_dialog(self): - self.init_last_selection() if self.qdialog.exec_(): - self.refresh_selection() self.survey = activeSeismoPick.Survey(self.obsdir, self.srcfile, self.recfile, useDefaultParas = True, fstart = self.fstart, fend = self.fend) self.executed = True else: - self.refresh_selection() self.executed = False - def refresh_selection(self): - self.obsdir = self.ui.lineEdit_obs.text() - self.srcfile = self.ui.lineEdit_src.text() - self.recfile = self.ui.lineEdit_rec.text() - self.fstart = self.ui.fstart.text() - self.fend = self.ui.fend.text() - - def init_last_selection(self): - self.ui.lineEdit_obs.setText(self.obsdir) - self.ui.lineEdit_src.setText(self.srcfile) - self.ui.lineEdit_rec.setText(self.recfile) - self.ui.fstart.setText(self.fstart) - self.ui.fend.setText(self.fend) - def get_survey(self): return self.survey @@ -223,7 +182,6 @@ class Gen_Survey_from_SR(object): self.ui.lineEdit_rec.setText(openFile('Open receiverfile.')) - class Call_autopicker(object): def __init__(self, mainwindow, survey): self.mainwindow = mainwindow @@ -456,5 +414,115 @@ class Call_FMTOMO(object): self.ui.simuldir.setText(browseDir()) +class Call_VTK_dialog(object): + def __init__(self, mainwindow): + self.mainwindow = mainwindow + self.init_dialog() + #self.refresh_selection() + self.start_dialog() + def init_dialog(self): + qdialog = QtGui.QDialog(self.mainwindow) + ui = Ui_vtk_tools() + ui.setupUi(qdialog) + self.ui = ui + self.qdialog = qdialog + self.connectButtons() + def start_dialog(self): + #self.init_last_selection() + self.qdialog.exec_() + #self.refresh_selection() + + # def refresh_selection(self): + # self.vg = self.ui.lineEdit_vg.text() + # self.vgout = self.ui.lineEdit_vgout.text() + # self.rays = self.ui.lineEdit_rays.text() + # self.raysout = self.ui.lineEdit_raysout.text() + + # def init_last_selection(self): + # self.ui.lineEdit_vg.setText(self.vg) + # self.ui.lineEdit_vgout.setText(self.vgout) + # self.ui.lineEdit_rays.setText(self.rays) + # self.ui.lineEdit_raysout.setText(self.raysout) + + def checkVgStartButton(self): + ui = self.ui + if ui.radioButton_rel.isChecked(): + if ui.lineEdit_vg.text() != '' and ui.lineEdit_vgref.text() != '': + ui.start_vg.setEnabled(True) + else: + ui.start_vg.setEnabled(False) + if ui.radioButton_abs.isChecked(): + if ui.lineEdit_vg.text() != '': + ui.start_vg.setEnabled(True) + else: + ui.start_vg.setEnabled(False) + + def checkRaysStartButton(self): + ui = self.ui + if ui.lineEdit_rays.text() != '' and ui.lineEdit_raysout.text() != '': + ui.start_rays.setEnabled(True) + else: + ui.start_rays.setEnabled(False) + + def connectButtons(self): + QtCore.QObject.connect(self.ui.pushButton_vg, QtCore.SIGNAL("clicked()"), self.chooseVgrid) + QtCore.QObject.connect(self.ui.pushButton_vgref, QtCore.SIGNAL("clicked()"), self.chooseVgridref) + QtCore.QObject.connect(self.ui.pushButton_rays, QtCore.SIGNAL("clicked()"), self.chooseRaysIn) + QtCore.QObject.connect(self.ui.pushButton_raysout, QtCore.SIGNAL("clicked()"), self.chooseRaysOutDir) + QtCore.QObject.connect(self.ui.pushButton_vtkout, QtCore.SIGNAL("clicked()"), self.newFileVTK) + QtCore.QObject.connect(self.ui.pushButton_parav, QtCore.SIGNAL("clicked()"), self.openFileParaview) + QtCore.QObject.connect(self.ui.start_vg, QtCore.SIGNAL("clicked()"), self.startvgvtk) + QtCore.QObject.connect(self.ui.start_rays, QtCore.SIGNAL("clicked()"), self.startraysvtk) + QtCore.QObject.connect(self.ui.radioButton_rel, QtCore.SIGNAL("clicked()"), self.activateVgref) + QtCore.QObject.connect(self.ui.radioButton_abs, QtCore.SIGNAL("clicked()"), self.deactivateVgref) + + def openFileParaview(self): + os.system('paraview %s &'%self.ui.lineEdit_vgout.text()) + + def activateVgref(self): + self.ui.lineEdit_vgref.setEnabled(True) + self.ui.pushButton_vgref.setEnabled(True) + + def deactivateVgref(self): + self.ui.lineEdit_vgref.setEnabled(False) + self.ui.pushButton_vgref.setEnabled(False) + + def chooseVgrid(self): + self.ui.lineEdit_vg.setText(openFile()) + self.checkVgStartButton() + + def chooseVgridref(self): + self.ui.lineEdit_vgref.setText(openFile()) + self.checkVgStartButton() + + def chooseRaysIn(self): + self.ui.lineEdit_rays.setText(openFile()) + self.checkRaysStartButton() + + def chooseRaysOutDir(self): + self.ui.lineEdit_raysout.setText(browseDir()) + self.checkRaysStartButton() + + def startvgvtk(self): + ui = self.ui + if ui.lineEdit_vgout.text() == '': + return + if ui.radioButton_abs.isChecked(): + fmtomoUtils.vgrids2VTK(inputfile = ui.lineEdit_vg.text(), + outputfile = ui.lineEdit_vgout.text(), + absOrRel='abs') + elif ui.radioButton_rel.isChecked(): + fmtomoUtils.vgrids2VTK(inputfile = ui.lineEdit_vg.text(), + outputfile = ui.lineEdit_vgout.text(), + absOrRel='rel', + inputfileref = ui.lineEdit_vgref.text()) + + def startraysvtk(self): + ui = self.ui + fmtomoUtils.rays2VTK(ui.lineEdit_rays.text(), ui.lineEdit_raysout.text()) + + def newFileVTK(self): + self.ui.lineEdit_vgout.setText(saveFile()) + From c13bdd2cf2669976bf457fc9687b1760dc2f6dda Mon Sep 17 00:00:00 2001 From: Marcel Paffrath Date: Tue, 2 Aug 2016 12:21:25 +0200 Subject: [PATCH 2/6] code cleanup --- pylot/core/active/ActiveSeismoPick3D_GUI.py | 43 ------------ pylot/core/active/gui/windows.py | 78 ++++++++------------- 2 files changed, 31 insertions(+), 90 deletions(-) diff --git a/pylot/core/active/ActiveSeismoPick3D_GUI.py b/pylot/core/active/ActiveSeismoPick3D_GUI.py index f71f0bf6..a2669789 100755 --- a/pylot/core/active/ActiveSeismoPick3D_GUI.py +++ b/pylot/core/active/ActiveSeismoPick3D_GUI.py @@ -93,7 +93,6 @@ class gui_control(object): self.setConnected2SurveyState(False) self.setSeisArrayState(True) - def gen_survey(self): if self.checkSurveyState(): if not self.continueDialogExists('Survey'): @@ -126,13 +125,11 @@ class gui_control(object): self.setSeisArrayState(True) self.setConnected2SurveyState(True) - def initNewSurvey(self): self.survey.setArtificialPick(0, 0) # artificial pick at source origin self.setSurveyState(True) self.setPickState(False) - def addArrayPlot(self): self.seisArrayFigure = Figure() self.seisArrayCanvas = FigureCanvas(self.seisArrayFigure) @@ -140,13 +137,11 @@ class gui_control(object): self.seisArrayToolbar = NavigationToolbar(self.seisArrayCanvas, self.mainwindow) self.mainUI.verticalLayout_tr1.addWidget(self.seisArrayToolbar) - def addSurfacePlot(self): self.surfaceFigure = Figure() self.surfaceCanvas = FigureCanvas(self.surfaceFigure) self.mainUI.horizontalLayout_tr.addWidget(self.surfaceCanvas) - def addStatPlots(self): self.statFigure_left = Figure() self.statCanvas_left = FigureCanvas(self.statFigure_left) @@ -154,7 +149,6 @@ class gui_control(object): self.statToolbar_left = NavigationToolbar(self.statCanvas_left, self.mainwindow) self.mainUI.verticalLayout_br1.addWidget(self.statToolbar_left) - self.statFigure_right = Figure() self.statCanvas_right = FigureCanvas(self.statFigure_right) self.mainUI.verticalLayout_br2.addWidget(self.statCanvas_right) @@ -163,7 +157,6 @@ class gui_control(object): self.addItems2StatsComboBox() - def addItems2StatsComboBox(self): self.mainUI.comboBox_stats.insertItem(0, 'picked traces') self.mainUI.comboBox_stats.insertItem(1, 'mean SNR') @@ -172,7 +165,6 @@ class gui_control(object): self.mainUI.comboBox_stats.insertItem(4, 'median SPE') self.enablePickedTools(False) - def addItems2ShotsComboBox(self): shotnumbers = self.survey.data.keys() shotnumbers.sort() @@ -180,7 +172,6 @@ class gui_control(object): self.mainUI.comboBox_shots.insertItem(index, 'Shot: %s'%shotnumber) self.mainUI.comboBox_shots.setMaxCount(len(shotnumbers)) - def increaseShotnumber(self): currentIndex = self.mainUI.comboBox_shots.currentIndex() maxindex = self.mainUI.comboBox_shots.maxCount() - 1 @@ -189,7 +180,6 @@ class gui_control(object): else: self.mainUI.comboBox_shots.setCurrentIndex(currentIndex + 1) - def decreaseShotnumber(self): currentIndex = self.mainUI.comboBox_shots.currentIndex() maxindex = self.mainUI.comboBox_shots.maxCount() - 1 @@ -203,20 +193,16 @@ class gui_control(object): shotnumber = int(self.mainUI.comboBox_shots.currentText().split()[1]) self.survey.data[shotnumber].matshow() - def addArrayAxes(self): self.seisArrayAx = self.seisArrayFigure.add_subplot(111) - def addSurfaceAxes(self): self.surfaceAx = self.surfaceFigure.add_subplot(111, projection = '3d') - def addStatAxes(self): self.statAx_left = self.statFigure_left.add_subplot(111) self.statAx_right = self.statFigure_right.add_subplot(111) - def enablePickedTools(self, bool, twoDim = False): self.mainUI.comboBox_stats.setEnabled(bool) self.statToolbar_left.setEnabled(bool) @@ -229,31 +215,26 @@ class gui_control(object): if bool == False: self.mainUI.comboBox_shots.clear() - def replotArray(self): self.seisArrayFigure.clf() self.addArrayAxes() self.plotArray() self.seisArrayCanvas.draw() - def replotSurface(self): self.surfaceFigure.clf() self.addSurfaceAxes() self.plotSurface() self.surfaceCanvas.draw() - def plotArray(self): self.seisarray.plotArray2D(self.seisArrayAx, highlight_measured = True, plot_topo = True, twoDim = self.seisarray.twoDim) - def plotSurface(self): if not self.seisarray.twoDim: self.seisarray.plotSurface3D(ax = self.surfaceAx, exag = True) self.seisarray.plotArray3D(ax = self.surfaceAx, legend = False, markersize = 3) - def InitPickedWidgets(self): if self.checkPickState(): surveyUtils.plotScatterStats4Receivers(self.survey, self.mainUI.comboBox_stats.currentText(), @@ -262,7 +243,6 @@ class gui_control(object): self.statAx_right, twoDim = self.survey.twoDim) self.addItems2ShotsComboBox() - def refreshPickedWidgets(self): self.statFigure_left.clf() self.statFigure_right.clf() @@ -271,7 +251,6 @@ class gui_control(object): self.statCanvas_left.draw() self.statCanvas_right.draw() - def printSurveyTextbox(self, init = True): if init == True: surveytup = (0, 0, 0, 0) @@ -287,7 +266,6 @@ class gui_control(object): string = surveyTitle + surveyText self.mainUI.textBox_survey.setText(string) - def printSeisArrayTextbox(self, init = True): if init == True: seistup = (0, 0, 0) @@ -302,7 +280,6 @@ class gui_control(object): string = seisArrayTitle + seisArrayText self.mainUI.textBox_seisarray.setText(string) - def interpolate_receivers(self): if not self.checkSeisArrayState(): self.printDialogMessage('No Seismic Array defined.') @@ -310,7 +287,6 @@ class gui_control(object): self.seisarray.interpolateAll() self.refreshSeisArrayWidgets() - def refreshSeisArrayWidgets(self): self.replotArray() self.replotSurface() @@ -333,7 +309,6 @@ class gui_control(object): self.printSurveyTextbox(init = False) print('Connected Seismic Array to active Survey object.') - def startPicker(self): if not self.checkSurveyState(): self.printDialogMessage('No Survey defined.') @@ -351,7 +326,6 @@ class gui_control(object): self.setPickState(True) self.printSurveyTextbox(init = False) - def startFMTOMO(self): if not self.checkSurveyState(): self.printDialogMessage('No Survey defined.') @@ -374,7 +348,6 @@ class gui_control(object): else: self.vtktools.start_dialog() - def postprocessing(self): if not self.checkSurveyState(): self.printDialogMessage('No Survey defined.') @@ -419,7 +392,6 @@ class gui_control(object): self.setSeisArrayState(False) self.printDialogMessage('Loaded Survey.') - def load_seisarray(self): disconnect = False if self.checkSeisArrayState(): @@ -450,7 +422,6 @@ class gui_control(object): self.seisarray = seisarray self.setSeisArrayState(True) - def save_seisarray(self): if not self.checkSeisArrayState(): self.printDialogMessage('No Seismic Array defined.') @@ -460,7 +431,6 @@ class gui_control(object): return self.seisarray.saveSeisArray(filename) - def save_survey(self): if not self.checkSurveyState(): self.printDialogMessage('No Survey defined.') @@ -470,7 +440,6 @@ class gui_control(object): return self.survey.saveSurvey(filename) - def setSurveyState(self, state): if state == True: self.mainUI.survey_active.setPixmap(self.applypixmap) @@ -478,21 +447,18 @@ class gui_control(object): elif state == False: self.mainUI.survey_active.setPixmap(self.cancelpixmap) - def checkSurveyState(self): if self.survey == None: return False else: return True - def checkSeisArrayState(self): if self.seisarray == None: return False else: return True - def setPickState(self, state): if state == True and self.checkSurveyState(): self.mainUI.picked_active.setPixmap(self.applypixmap) @@ -510,7 +476,6 @@ class gui_control(object): self.enablePickedTools(False) self.survey.picked = False - def setSeisArrayState(self, state): if state == True: self.mainUI.seisarray_active.setPixmap(self.applypixmap) @@ -522,14 +487,12 @@ class gui_control(object): if self.seisArrayFigure is not None: self.seisArrayFigure.clf() - def setConnected2SurveyState(self, state): if state == True: self.mainUI.seisarray_on_survey_active.setPixmap(self.applypixmap) elif state == False: self.mainUI.seisarray_on_survey_active.setPixmap(self.cancelpixmap) - def checkConnected2SurveyState(self): if self.checkSurveyState(): if self.survey.seisarray != None: @@ -537,14 +500,12 @@ class gui_control(object): else: return False - def checkPickState(self): if not self.survey: self.printDialogMessage('No Survey defined.') return return self.survey.picked - def printDialogMessage(self, message): qmb = QtGui.QMessageBox() qmb.setText(message) @@ -552,7 +513,6 @@ class gui_control(object): qmb.setIcon(QtGui.QMessageBox.Warning) qmb.exec_() - def continueDialogExists(self, name): qmb = QtGui.QMessageBox() qmb.setText('%s object already exists. Overwrite?'%name) @@ -564,7 +524,6 @@ class gui_control(object): else: return False - def continueDialogMessage(self, message): qmb = QtGui.QMessageBox() qmb.setText(message) @@ -576,7 +535,6 @@ class gui_control(object): else: return False - def exitApp(self): QtCore.QCoreApplication.instance().quit() @@ -590,4 +548,3 @@ if __name__ == "__main__": gui = gui_control() sys.exit(app.exec_()) - diff --git a/pylot/core/active/gui/windows.py b/pylot/core/active/gui/windows.py index 531734ce..ba780e34 100644 --- a/pylot/core/active/gui/windows.py +++ b/pylot/core/active/gui/windows.py @@ -45,6 +45,7 @@ def getMaxCPU(): import multiprocessing return multiprocessing.cpu_count() + class Gen_SeisArray(object): def __init__(self, mainwindow): self.mainwindow = mainwindow @@ -65,6 +66,7 @@ class Gen_SeisArray(object): def start_dialog(self): if self.qdialog.exec_(): + self.refresh_selection() if self.ui.radioButton_interpolatable.isChecked(): self.seisarray = seismicArrayPreparation.SeisArray(self.recfile, True) elif self.ui.radioButton_normal.isChecked(): @@ -75,8 +77,14 @@ class Gen_SeisArray(object): self.seisarray.addMeasuredTopographyPoints(self.ptsfile) self.executed = True else: + self.refresh_selection() self.executed = False + def refresh_selection(self): + self.srcfile = self.ui.lineEdit_src.text() + self.recfile = self.ui.lineEdit_rec.text() + self.ptsfile = self.ui.lineEdit_pts.text() + def get_seisarray(self): if self.seisarray is not None: return self.seisarray @@ -96,7 +104,6 @@ class Gen_SeisArray(object): self.ui.lineEdit_pts.setText(openFile('Open measured points file.')) - class Gen_Survey_from_SA(object): def __init__(self, mainwindow, seisarray): self.mainwindow = mainwindow @@ -118,13 +125,20 @@ class Gen_Survey_from_SA(object): def start_dialog(self): if self.qdialog.exec_(): + self.refresh_selection() self.survey = activeSeismoPick.Survey(self.obsdir, seisArray = self.seisarray, useDefaultParas = True, fstart = self.fstart, fend = self.fend) self.executed = True else: + self.refresh_selection() self.executed = False + def refresh_selection(self): + self.obsdir = self.ui.lineEdit_obs.text() + self.fstart = self.ui.fstart.text() + self.fend = self.ui.fend.text() + def get_survey(self): return self.survey @@ -157,13 +171,22 @@ class Gen_Survey_from_SR(object): def start_dialog(self): if self.qdialog.exec_(): + self.refresh_selection() self.survey = activeSeismoPick.Survey(self.obsdir, self.srcfile, self.recfile, useDefaultParas = True, fstart = self.fstart, fend = self.fend) self.executed = True else: + self.refresh_selection() self.executed = False + def refresh_selection(self): + self.obsdir = self.ui.lineEdit_obs.text() + self.srcfile = self.ui.lineEdit_src.text() + self.recfile = self.ui.lineEdit_rec.text() + self.fstart = self.ui.fstart.text() + self.fend = self.ui.fend.text() + def get_survey(self): return self.survey @@ -256,7 +279,6 @@ class Call_autopicker(object): self.snrCanvas.draw() def start_dialog(self): - self.init_last_selection() self.plotDynSNR() if self.qdialog.exec_(): self.refresh_selection() @@ -294,19 +316,6 @@ class Call_autopicker(object): self.p1 = float(self.ui.p1.value()) self.p2 = float(self.ui.p2.value()) - def init_last_selection(self): - self.ui.ncores.setValue(self.ncores) - self.ui.lineEdit_vmin.setText(str(self.vmin)) - self.ui.lineEdit_vmax.setText(str(self.vmax)) - self.ui.slider_folm.setValue(self.folm) - self.ui.checkBox_AIC.setChecked(self.AIC) - self.ui.lineEdit_aicleft.setText(str(self.aicwindow[0])) - self.ui.lineEdit_aicright.setText(str(self.aicwindow[1])) - self.ui.shift_snr.setValue(self.shiftSNR) - self.ui.shift_snr.setValue(self.shiftDist) - self.ui.p1.setValue(self.p1) - self.ui.p2.setValue(self.p2) - def connectButtons(self): QtCore.QObject.connect(self.ui.slider_folm, QtCore.SIGNAL("valueChanged(int)"), self.refreshFolm) QtCore.QObject.connect(self.ui.shift_snr, QtCore.SIGNAL("valueChanged(int)"), self.plotDynSNR) @@ -324,7 +333,6 @@ class Call_autopicker(object): self.ui.lineEdit_rec.setText(openFile('Open receiverfile.')) - class Call_FMTOMO(object): def __init__(self, mainwindow, survey): self.mainwindow = mainwindow @@ -343,7 +351,6 @@ class Call_FMTOMO(object): self.connectButtons() def start_dialog(self): - self.init_last_selection() if self.qdialog.exec_(): self.refresh_selection() @@ -383,22 +390,6 @@ class Call_FMTOMO(object): self.simuldir = self.ui.simuldir.text() self.picks_dir = os.path.join(self.simuldir, 'picks') - def init_last_selection(self): - self.ui.fmtomo_dir.setText(self.fmtomo_dir) - self.ui.nIter.setValue(self.nIter) - self.ui.nproc.setValue(self.nproc) - self.ui.btop.setText(str(self.btop)) - self.ui.bbot.setText(str(self.bbot)) - self.ui.pgrid_x.setValue(self.propgrid[0]) - self.ui.pgrid_y.setValue(self.propgrid[1]) - self.ui.pgrid_z.setValue(self.propgrid[2]) - self.ui.invgrid_x.setValue(self.vgrid[0]) - self.ui.invgrid_y.setValue(self.vgrid[1]) - self.ui.invgrid_z.setValue(self.vgrid[2]) - self.ui.cushion.setValue(self.cushionfactor) - self.ui.customgrid.setText(self.customgrid) - self.ui.simuldir.setText(self.simuldir) - def connectButtons(self): QtCore.QObject.connect(self.ui.browse_tomodir, QtCore.SIGNAL("clicked()"), self.chooseFMTOMOdir) QtCore.QObject.connect(self.ui.browse_customgrid, QtCore.SIGNAL("clicked()"), self.chooseCustomgrid) @@ -418,7 +409,7 @@ class Call_VTK_dialog(object): def __init__(self, mainwindow): self.mainwindow = mainwindow self.init_dialog() - #self.refresh_selection() + self.refresh_selection() self.start_dialog() def init_dialog(self): @@ -430,22 +421,15 @@ class Call_VTK_dialog(object): self.connectButtons() def start_dialog(self): - #self.init_last_selection() self.qdialog.exec_() - #self.refresh_selection() + self.refresh_selection() - # def refresh_selection(self): - # self.vg = self.ui.lineEdit_vg.text() - # self.vgout = self.ui.lineEdit_vgout.text() - # self.rays = self.ui.lineEdit_rays.text() - # self.raysout = self.ui.lineEdit_raysout.text() + def refresh_selection(self): + self.vg = self.ui.lineEdit_vg.text() + self.vgout = self.ui.lineEdit_vgout.text() + self.rays = self.ui.lineEdit_rays.text() + self.raysout = self.ui.lineEdit_raysout.text() - # def init_last_selection(self): - # self.ui.lineEdit_vg.setText(self.vg) - # self.ui.lineEdit_vgout.setText(self.vgout) - # self.ui.lineEdit_rays.setText(self.rays) - # self.ui.lineEdit_raysout.setText(self.raysout) - def checkVgStartButton(self): ui = self.ui if ui.radioButton_rel.isChecked(): From 471cfe755befb213dc9b5d7582d44e244517123d Mon Sep 17 00:00:00 2001 From: Sebastianw Wehling-Benatelli Date: Wed, 3 Aug 2016 13:28:54 +0200 Subject: [PATCH 3/6] [fix] be sure to start the external programs in the right directory --- pylot/core/active/fmtomoUtils.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pylot/core/active/fmtomoUtils.py b/pylot/core/active/fmtomoUtils.py index ea69637a..19be28b0 100644 --- a/pylot/core/active/fmtomoUtils.py +++ b/pylot/core/active/fmtomoUtils.py @@ -49,7 +49,8 @@ class Tomo3d(object): os.system('ln -s %s %s'%(filename, linkname)) def buildObsdata(self): - os.system('obsdata') + p = subprocess.Popen(os.path.join(self.cwd, 'obsdata'), shell=True) + os.waitpid(p.pid) os.system('mv sources.in sourcesref.in') def defFMMParas(self): @@ -57,9 +58,9 @@ class Tomo3d(object): Initiates parameters for the forward calculation. ''' # Name of fast marching program - self.fmm = '{0}/fm3d'.format(self.cwd) + self.fmm = os.path.join(self.cwd, 'fm3d') # Name of program calculating Frechet derivatives - self.frechgen = '{0}/frechgen'.format(self.cwd) + self.frechgen = os.path.join(self.cwd, 'frechgen') # Name of current velocity/inversion grid self.cvg = 'vgrids.in' # Name of current interfaces grid @@ -116,7 +117,7 @@ class Tomo3d(object): Default: pwd ''' if directory == None: - directory = os.path.join(os.getcwd(), self.simuldir) + directory = self.simuldir os.chdir(directory) self.cwd = directory From 3efb237452a060f3b2de76affcab0b92c96e84ea Mon Sep 17 00:00:00 2001 From: Marcel Paffrath Date: Thu, 4 Aug 2016 10:35:09 +0200 Subject: [PATCH 4/6] fix: wait for process obsdata (p.wait()) --- pylot/core/active/fmtomoUtils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pylot/core/active/fmtomoUtils.py b/pylot/core/active/fmtomoUtils.py index 19be28b0..7fc5cfb6 100644 --- a/pylot/core/active/fmtomoUtils.py +++ b/pylot/core/active/fmtomoUtils.py @@ -50,13 +50,14 @@ class Tomo3d(object): def buildObsdata(self): p = subprocess.Popen(os.path.join(self.cwd, 'obsdata'), shell=True) - os.waitpid(p.pid) + p.wait() os.system('mv sources.in sourcesref.in') def defFMMParas(self): ''' Initiates parameters for the forward calculation. ''' + # Comments coppied from FMTOMO. # Name of fast marching program self.fmm = os.path.join(self.cwd, 'fm3d') # Name of program calculating Frechet derivatives From 30049baf9434e2f5954bbb9f7d097169e98d2a4e Mon Sep 17 00:00:00 2001 From: Marcel Paffrath Date: Thu, 4 Aug 2016 12:16:25 +0200 Subject: [PATCH 5/6] added constant SNR possibility (plotting), changed replotting structure --- pylot/core/active/gui/asp3d_layout.py | 2 +- .../active/gui/fmtomo_parameters_layout.py | 2 +- .../active/gui/generate_seisarray_layout.py | 2 +- .../core/active/gui/generate_survey_layout.py | 2 +- .../gui/generate_survey_layout_minimal.py | 2 +- .../active/gui/picking_parameters_layout.py | 43 ++++++- pylot/core/active/gui/vtk_tools_layout.py | 2 +- pylot/core/active/gui/windows.py | 117 ++++++++++++++---- 8 files changed, 137 insertions(+), 35 deletions(-) diff --git a/pylot/core/active/gui/asp3d_layout.py b/pylot/core/active/gui/asp3d_layout.py index f958fdee..792b0a0f 100644 --- a/pylot/core/active/gui/asp3d_layout.py +++ b/pylot/core/active/gui/asp3d_layout.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'asp3d_layout.ui' # -# Created: Wed Jul 27 11:15:05 2016 +# Created: Thu Aug 4 12:07:57 2016 # by: pyside-uic 0.2.15 running on PySide 1.2.2 # # WARNING! All changes made in this file will be lost! diff --git a/pylot/core/active/gui/fmtomo_parameters_layout.py b/pylot/core/active/gui/fmtomo_parameters_layout.py index 59db2dc4..43cd767a 100644 --- a/pylot/core/active/gui/fmtomo_parameters_layout.py +++ b/pylot/core/active/gui/fmtomo_parameters_layout.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'fmtomo_parameters_layout.ui' # -# Created: Wed Jul 27 11:15:05 2016 +# Created: Thu Aug 4 12:07:57 2016 # by: pyside-uic 0.2.15 running on PySide 1.2.2 # # WARNING! All changes made in this file will be lost! diff --git a/pylot/core/active/gui/generate_seisarray_layout.py b/pylot/core/active/gui/generate_seisarray_layout.py index 3116febb..0b9e7048 100644 --- a/pylot/core/active/gui/generate_seisarray_layout.py +++ b/pylot/core/active/gui/generate_seisarray_layout.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'generate_seisarray_layout.ui' # -# Created: Wed Jul 27 11:15:06 2016 +# Created: Thu Aug 4 12:07:57 2016 # by: pyside-uic 0.2.15 running on PySide 1.2.2 # # WARNING! All changes made in this file will be lost! diff --git a/pylot/core/active/gui/generate_survey_layout.py b/pylot/core/active/gui/generate_survey_layout.py index cdfbb769..99791120 100644 --- a/pylot/core/active/gui/generate_survey_layout.py +++ b/pylot/core/active/gui/generate_survey_layout.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'generate_survey_layout.ui' # -# Created: Wed Jul 27 11:15:06 2016 +# Created: Thu Aug 4 12:07:57 2016 # by: pyside-uic 0.2.15 running on PySide 1.2.2 # # WARNING! All changes made in this file will be lost! diff --git a/pylot/core/active/gui/generate_survey_layout_minimal.py b/pylot/core/active/gui/generate_survey_layout_minimal.py index 34939458..223b6018 100644 --- a/pylot/core/active/gui/generate_survey_layout_minimal.py +++ b/pylot/core/active/gui/generate_survey_layout_minimal.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'generate_survey_layout_minimal.ui' # -# Created: Wed Jul 27 11:15:06 2016 +# Created: Thu Aug 4 12:07:57 2016 # by: pyside-uic 0.2.15 running on PySide 1.2.2 # # WARNING! All changes made in this file will be lost! diff --git a/pylot/core/active/gui/picking_parameters_layout.py b/pylot/core/active/gui/picking_parameters_layout.py index 272dd630..3844fd64 100644 --- a/pylot/core/active/gui/picking_parameters_layout.py +++ b/pylot/core/active/gui/picking_parameters_layout.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'picking_parameters_layout.ui' # -# Created: Wed Jul 27 11:15:06 2016 +# Created: Thu Aug 4 12:07:57 2016 # by: pyside-uic 0.2.15 running on PySide 1.2.2 # # WARNING! All changes made in this file will be lost! @@ -12,7 +12,7 @@ from PySide import QtCore, QtGui class Ui_picking_parameters(object): def setupUi(self, picking_parameters): picking_parameters.setObjectName("picking_parameters") - picking_parameters.resize(400, 700) + picking_parameters.resize(422, 798) picking_parameters.setMinimumSize(QtCore.QSize(0, 700)) self.verticalLayout_4 = QtGui.QVBoxLayout(picking_parameters) self.verticalLayout_4.setObjectName("verticalLayout_4") @@ -156,9 +156,35 @@ class Ui_picking_parameters(object): self.line.setFrameShadow(QtGui.QFrame.Sunken) self.line.setObjectName("line") self.verticalLayout_snr.addWidget(self.line) + self.horizontalLayout_9 = QtGui.QHBoxLayout() + self.horizontalLayout_9.setObjectName("horizontalLayout_9") self.label_8 = QtGui.QLabel(picking_parameters) self.label_8.setObjectName("label_8") - self.verticalLayout_snr.addWidget(self.label_8) + self.horizontalLayout_9.addWidget(self.label_8) + self.radioButton_const = QtGui.QRadioButton(picking_parameters) + self.radioButton_const.setChecked(True) + self.radioButton_const.setObjectName("radioButton_const") + self.horizontalLayout_9.addWidget(self.radioButton_const) + self.radioButton_dyn = QtGui.QRadioButton(picking_parameters) + self.radioButton_dyn.setObjectName("radioButton_dyn") + self.horizontalLayout_9.addWidget(self.radioButton_dyn) + self.verticalLayout_snr.addLayout(self.horizontalLayout_9) + self.horizontalLayout_10 = QtGui.QHBoxLayout() + self.horizontalLayout_10.setObjectName("horizontalLayout_10") + self.label_13 = QtGui.QLabel(picking_parameters) + self.label_13.setObjectName("label_13") + self.horizontalLayout_10.addWidget(self.label_13) + self.doubleSpinBox_constSNR = QtGui.QDoubleSpinBox(picking_parameters) + self.doubleSpinBox_constSNR.setMaximumSize(QtCore.QSize(100, 16777215)) + self.doubleSpinBox_constSNR.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.doubleSpinBox_constSNR.setDecimals(1) + self.doubleSpinBox_constSNR.setMinimum(1.0) + self.doubleSpinBox_constSNR.setMaximum(10000.0) + self.doubleSpinBox_constSNR.setSingleStep(0.1) + self.doubleSpinBox_constSNR.setProperty("value", 8.0) + self.doubleSpinBox_constSNR.setObjectName("doubleSpinBox_constSNR") + self.horizontalLayout_10.addWidget(self.doubleSpinBox_constSNR) + self.verticalLayout_snr.addLayout(self.horizontalLayout_10) self.gridLayout_2 = QtGui.QGridLayout() self.gridLayout_2.setObjectName("gridLayout_2") self.label_9 = QtGui.QLabel(picking_parameters) @@ -185,22 +211,26 @@ class Ui_picking_parameters(object): self.p2.setDecimals(6) self.p2.setMinimum(-100.0) self.p2.setMaximum(100.0) - self.p2.setSingleStep(0.0001) + self.p2.setSingleStep(0.001) self.p2.setProperty("value", -0.0007) self.p2.setObjectName("p2") self.gridLayout_2.addWidget(self.p2, 2, 3, 1, 1) self.shift_dist = QtGui.QSpinBox(picking_parameters) + self.shift_dist.setMinimum(-10000) self.shift_dist.setMaximum(10000) self.shift_dist.setProperty("value", 30) self.shift_dist.setObjectName("shift_dist") self.gridLayout_2.addWidget(self.shift_dist, 1, 1, 1, 1) self.shift_snr = QtGui.QSpinBox(picking_parameters) + self.shift_snr.setMinimum(-10000) self.shift_snr.setMaximum(10000) self.shift_snr.setProperty("value", 100) self.shift_snr.setObjectName("shift_snr") self.gridLayout_2.addWidget(self.shift_snr, 1, 3, 1, 1) self.verticalLayout_snr.addLayout(self.gridLayout_2) self.verticalLayout_4.addLayout(self.verticalLayout_snr) + spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.verticalLayout_4.addItem(spacerItem) self.vlayout_plot = QtGui.QVBoxLayout() self.vlayout_plot.setObjectName("vlayout_plot") self.verticalLayout_4.addLayout(self.vlayout_plot) @@ -236,7 +266,10 @@ class Ui_picking_parameters(object): "(only if AIC checked)", None, QtGui.QApplication.UnicodeUTF8)) self.lineEdit_aicleft.setText(QtGui.QApplication.translate("picking_parameters", "15", None, QtGui.QApplication.UnicodeUTF8)) self.lineEdit_aicright.setText(QtGui.QApplication.translate("picking_parameters", "0", None, QtGui.QApplication.UnicodeUTF8)) - self.label_8.setText(QtGui.QApplication.translate("picking_parameters", "SNR threshold (advanced)", None, QtGui.QApplication.UnicodeUTF8)) + self.label_8.setText(QtGui.QApplication.translate("picking_parameters", "SNR threshold", None, QtGui.QApplication.UnicodeUTF8)) + self.radioButton_const.setText(QtGui.QApplication.translate("picking_parameters", "constant", None, QtGui.QApplication.UnicodeUTF8)) + self.radioButton_dyn.setText(QtGui.QApplication.translate("picking_parameters", "dynamic (advanced)", None, QtGui.QApplication.UnicodeUTF8)) + self.label_13.setText(QtGui.QApplication.translate("picking_parameters", "Constant SNR threshold:", None, QtGui.QApplication.UnicodeUTF8)) self.label_9.setText(QtGui.QApplication.translate("picking_parameters", "Shift distance", None, QtGui.QApplication.UnicodeUTF8)) self.label_10.setText(QtGui.QApplication.translate("picking_parameters", "p1", None, QtGui.QApplication.UnicodeUTF8)) self.label_11.setText(QtGui.QApplication.translate("picking_parameters", "Shift SNR", None, QtGui.QApplication.UnicodeUTF8)) diff --git a/pylot/core/active/gui/vtk_tools_layout.py b/pylot/core/active/gui/vtk_tools_layout.py index 3bef8448..48ad19de 100644 --- a/pylot/core/active/gui/vtk_tools_layout.py +++ b/pylot/core/active/gui/vtk_tools_layout.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'vtk_tools_layout.ui' # -# Created: Wed Jul 27 11:15:06 2016 +# Created: Thu Aug 4 12:07:57 2016 # by: pyside-uic 0.2.15 running on PySide 1.2.2 # # WARNING! All changes made in this file will be lost! diff --git a/pylot/core/active/gui/windows.py b/pylot/core/active/gui/windows.py index ba780e34..7fe16d75 100644 --- a/pylot/core/active/gui/windows.py +++ b/pylot/core/active/gui/windows.py @@ -210,8 +210,12 @@ class Call_autopicker(object): self.mainwindow = mainwindow self.survey = survey self.maxSRdist = None + self.dists_p = [] + self.snr_p = [] + self.lines = [] self.init_dialog() - self.refresh_selection() + self.refresh_selection() + self.enableDynSNR(False) self.start_dialog() def init_dialog(self): @@ -221,7 +225,7 @@ class Call_autopicker(object): ui.ncores.setMaximum(getMaxCPU()) self.ui = ui self.qdialog = qdialog - self.initDynSNRplot() + self.initSNRplot() self.connectButtons() def getMaxSRdist(self): @@ -235,14 +239,14 @@ class Call_autopicker(object): self.maxSRdist = max(SRdists) return self.maxSRdist - def initDynSNRplot(self): + def initSNRplot(self): self.snrFig = Figure() self.snrCanvas = FigureCanvas(self.snrFig) self.ui.vlayout_plot.addWidget(self.snrCanvas) self.snrToolbar = NavigationToolbar(self.snrCanvas, self.mainwindow) self.ui.vlayout_plot.addWidget(self.snrToolbar) - def plotDynSNR(self): + def prepFigure(self, refresh = True): fig = self.snrFig if fig.axes == []: ax = fig.add_subplot(111) @@ -252,34 +256,96 @@ class Call_autopicker(object): ax = fig.axes[0] xlim = ax.get_xlim() ylim = ax.get_ylim() - ax.clear() + #ax.clear() + if not refresh: + self.plotPicks(ax) + else: + for line in self.lines: + line.remove() + self.lines = [] + + return fig, ax, xlim, ylim + + def finishFigure(self, ax, xlim, ylim): + ax.set_xlim(xlim) + ax.set_ylim(ylim) + + def finishNewFigure(self, ax): + xlim = None + ylim = None + ax.set_xlabel('Distance [m]') + ax.set_ylabel('SNR') + return xlim, ylim + + def plotPicks(self, ax): + if self.survey.picked: + if self.dists_p == [] or self.snr_p == []: + for shot in self.survey.data.values(): + for traceID in shot.getTraceIDlist(): + self.dists_p.append(shot.getDistance(traceID)) + self.snr_p.append(shot.getSNR(traceID)[0]) + + ax.scatter(self.dists_p, self.snr_p, s = 0.5, c='k') + + def plotConstSNR(self, refresh = True): + fig, ax, xlim, ylim = self.prepFigure(refresh) + + snrthreshold = float(self.ui.doubleSpinBox_constSNR.text()) + line = ax.hlines(snrthreshold, 0, self.getMaxSRdist(), 'b') + self.lines.append(line) + + if refresh == False: + xlim, ylim = self.finishNewFigure(ax) + + self.finishFigure(ax, xlim, ylim) + self.snrCanvas.draw() + + def plotDynSNR(self, refresh = True): + fig, ax, xlim, ylim = self.prepFigure(refresh) snrthresholds = [] - dists_p = []; snr_p = [] shiftSNR = float(self.ui.shift_snr.value()) shiftDist = float(self.ui.shift_dist.value()) p1 = float(self.ui.p1.value()) p2 = float(self.ui.p2.value()) dists = np.arange(0, self.getMaxSRdist() + 1, 1) - if self.survey.picked: - for shot in self.survey.data.values(): - for traceID in shot.getTraceIDlist(): - dists_p.append(shot.getDistance(traceID)) - snr_p.append(shot.getSNR(traceID)[0]) - - ax.scatter(dists_p, snr_p, s = 0.5, c='k') - + for dist in dists: dist += shiftDist snrthresholds.append(surveyUtils.snr_fit_func(surveyUtils.get_fit_fn(p1, p2), dist, shiftSNR)) - ax.plot(dists, snrthresholds) - ax.set_xlabel('Distance [m]') - ax.set_ylabel('SNR') - ax.set_xlim(xlim) - ax.set_ylim(ylim) + self.lines = ax.plot(dists, snrthresholds, 'b') + + if refresh == False: + xlim, ylim = self.finishNewFigure(ax) + + self.finishFigure(ax, xlim, ylim) self.snrCanvas.draw() + def plotSNR(self, refresh = True): + if self.ui.radioButton_const.isChecked(): + self.plotConstSNR(refresh) + if self.ui.radioButton_dyn.isChecked(): + self.plotDynSNR(refresh) + + def snr_toggle(self): + if self.ui.radioButton_const.isChecked(): + self.enableDynSNR(False) + self.enableConstSNR(True) + if self.ui.radioButton_dyn.isChecked(): + self.enableConstSNR(False) + self.enableDynSNR(True) + self.plotSNR(refresh = True) + + def enableDynSNR(self, bool): + self.ui.shift_dist.setEnabled(bool) + self.ui.shift_snr.setEnabled(bool) + self.ui.p1.setEnabled(bool) + self.ui.p2.setEnabled(bool) + + def enableConstSNR(self, bool): + self.ui.doubleSpinBox_constSNR.setEnabled(bool) + def start_dialog(self): - self.plotDynSNR() + self.plotSNR(refresh = False) if self.qdialog.exec_(): self.refresh_selection() @@ -318,10 +384,13 @@ class Call_autopicker(object): def connectButtons(self): QtCore.QObject.connect(self.ui.slider_folm, QtCore.SIGNAL("valueChanged(int)"), self.refreshFolm) - QtCore.QObject.connect(self.ui.shift_snr, QtCore.SIGNAL("valueChanged(int)"), self.plotDynSNR) - QtCore.QObject.connect(self.ui.shift_dist, QtCore.SIGNAL("valueChanged(int)"), self.plotDynSNR) - QtCore.QObject.connect(self.ui.p1, QtCore.SIGNAL("valueChanged(double)"), self.plotDynSNR) - QtCore.QObject.connect(self.ui.p2, QtCore.SIGNAL("valueChanged(double)"), self.plotDynSNR) + QtCore.QObject.connect(self.ui.shift_snr, QtCore.SIGNAL("valueChanged(int)"), self.plotSNR) + QtCore.QObject.connect(self.ui.shift_dist, QtCore.SIGNAL("valueChanged(int)"), self.plotSNR) + QtCore.QObject.connect(self.ui.p1, QtCore.SIGNAL("valueChanged(double)"), self.plotSNR) + QtCore.QObject.connect(self.ui.p2, QtCore.SIGNAL("valueChanged(double)"), self.plotSNR) + QtCore.QObject.connect(self.ui.doubleSpinBox_constSNR, QtCore.SIGNAL("valueChanged(double)"), self.plotSNR) + QtCore.QObject.connect(self.ui.radioButton_const, QtCore.SIGNAL("clicked()"), self.snr_toggle) + QtCore.QObject.connect(self.ui.radioButton_dyn, QtCore.SIGNAL("clicked()"), self.snr_toggle) def chooseObsdir(self): self.ui.lineEdit_obs.setText(browseDir('Choose observation directory.')) From 4c42e9ceb572656c3077dc98689616e0a25a260b Mon Sep 17 00:00:00 2001 From: Marcel Paffrath Date: Thu, 4 Aug 2016 14:17:22 +0200 Subject: [PATCH 6/6] bugfixes, added fullscreen mode --- pylot/core/active/ActiveSeismoPick3D_GUI.py | 12 +++++++- pylot/core/active/gui/asp3d_layout.py | 15 ++++++++-- .../active/gui/fmtomo_parameters_layout.py | 2 +- .../active/gui/generate_seisarray_layout.py | 2 +- .../core/active/gui/generate_survey_layout.py | 2 +- .../gui/generate_survey_layout_minimal.py | 2 +- .../active/gui/picking_parameters_layout.py | 2 +- pylot/core/active/gui/vtk_tools_layout.py | 2 +- pylot/core/active/gui/windows.py | 28 +++++++++++++++---- 9 files changed, 52 insertions(+), 15 deletions(-) diff --git a/pylot/core/active/ActiveSeismoPick3D_GUI.py b/pylot/core/active/ActiveSeismoPick3D_GUI.py index a2669789..eec13af5 100755 --- a/pylot/core/active/ActiveSeismoPick3D_GUI.py +++ b/pylot/core/active/ActiveSeismoPick3D_GUI.py @@ -64,11 +64,18 @@ class gui_control(object): QtCore.QObject.connect(self.mainUI.actionStart_FMTOMO_Simulation, QtCore.SIGNAL("triggered()"), self.startFMTOMO) QtCore.QObject.connect(self.mainUI.actionVTK_Visualization, QtCore.SIGNAL("triggered()"), self.startVTKtools) QtCore.QObject.connect(self.mainUI.actionExit, QtCore.SIGNAL("triggered()"), self.exitApp) + QtCore.QObject.connect(self.mainUI.actionFullscreen, QtCore.SIGNAL("triggered()"), self.fullscreen) QtCore.QObject.connect(self.mainUI.comboBox_stats, QtCore.SIGNAL("activated(int)"), self.refreshPickedWidgets) QtCore.QObject.connect(self.mainUI.shot_left, QtCore.SIGNAL("clicked()"), self.decreaseShotnumber) QtCore.QObject.connect(self.mainUI.shot_right, QtCore.SIGNAL("clicked()"), self.increaseShotnumber) QtCore.QObject.connect(self.mainUI.plot_shot, QtCore.SIGNAL("clicked()"), self.plotShot) + def fullscreen(self): + if self.mainUI.actionFullscreen.isChecked(): + MainWindow.showFullScreen() + else: + MainWindow.showNormal() + def gen_seisarray(self): disconnect = False if self.checkSeisArrayState(): @@ -104,6 +111,7 @@ class gui_control(object): self.gssa = Gen_Survey_from_SA(self.mainwindow, self.seisarray) else: self.gssa.start_dialog() + self.update_seisarray(self.seisarray) if self.gssa.executed: self.survey = self.gssa.get_survey() self.initNewSurvey() @@ -321,6 +329,7 @@ class gui_control(object): self.autopicker = Call_autopicker(self.mainwindow, self.survey) else: self.autopicker.start_dialog() + self.autopicker.update_survey(self.survey) if self.autopicker.executed: self.setPickState(True) @@ -338,6 +347,7 @@ class gui_control(object): self.fmtomo = Call_FMTOMO(self.mainwindow, self.survey) else: self.fmtomo.start_dialog() + self.fmtomo.update_survey(self.survey) #if self.fmtomo.executed: @@ -544,7 +554,7 @@ if __name__ == "__main__": MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow() ui.setupUi(MainWindow) - MainWindow.show() + MainWindow.showMaximized() gui = gui_control() sys.exit(app.exec_()) diff --git a/pylot/core/active/gui/asp3d_layout.py b/pylot/core/active/gui/asp3d_layout.py index 792b0a0f..0d5553c6 100644 --- a/pylot/core/active/gui/asp3d_layout.py +++ b/pylot/core/active/gui/asp3d_layout.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'asp3d_layout.ui' # -# Created: Thu Aug 4 12:07:57 2016 +# Created: Thu Aug 4 13:55:47 2016 # by: pyside-uic 0.2.15 running on PySide 1.2.2 # # WARNING! All changes made in this file will be lost! @@ -13,7 +13,7 @@ class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.setEnabled(True) - MainWindow.resize(1029, 1074) + MainWindow.resize(1280, 1024) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) @@ -273,7 +273,7 @@ class Ui_MainWindow(object): self.gridLayout.addLayout(self.formLayout, 0, 0, 1, 1) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(MainWindow) - self.menubar.setGeometry(QtCore.QRect(0, 0, 1029, 23)) + self.menubar.setGeometry(QtCore.QRect(0, 0, 1280, 23)) self.menubar.setObjectName("menubar") self.menuFile = QtGui.QMenu(self.menubar) self.menuFile.setObjectName("menuFile") @@ -287,6 +287,8 @@ class Ui_MainWindow(object): self.menuSimulation.setObjectName("menuSimulation") self.menuTools = QtGui.QMenu(self.menubar) self.menuTools.setObjectName("menuTools") + self.menuView = QtGui.QMenu(self.menubar) + self.menuView.setObjectName("menuView") MainWindow.setMenuBar(self.menubar) self.statusbar = QtGui.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") @@ -321,6 +323,9 @@ class Ui_MainWindow(object): self.actionSeismic_Array = QtGui.QAction(MainWindow) self.actionSeismic_Array.setEnabled(False) self.actionSeismic_Array.setObjectName("actionSeismic_Array") + self.actionFullscreen = QtGui.QAction(MainWindow) + self.actionFullscreen.setCheckable(True) + self.actionFullscreen.setObjectName("actionFullscreen") self.menuFile.addSeparator() self.menuFile.addAction(self.actionExit) self.menuSeismic_Array.addAction(self.actionGenerate_new_Seismic_Array) @@ -336,12 +341,14 @@ class Ui_MainWindow(object): self.menuPicking.addAction(self.actionPostprocessing) self.menuSimulation.addAction(self.actionStart_FMTOMO_Simulation) self.menuTools.addAction(self.actionVTK_Visualization) + self.menuView.addAction(self.actionFullscreen) self.menubar.addAction(self.menuFile.menuAction()) self.menubar.addAction(self.menuSurvey.menuAction()) self.menubar.addAction(self.menuSeismic_Array.menuAction()) self.menubar.addAction(self.menuPicking.menuAction()) self.menubar.addAction(self.menuSimulation.menuAction()) self.menubar.addAction(self.menuTools.menuAction()) + self.menubar.addAction(self.menuView.menuAction()) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) @@ -365,6 +372,7 @@ class Ui_MainWindow(object): self.menuPicking.setTitle(QtGui.QApplication.translate("MainWindow", "Picking", None, QtGui.QApplication.UnicodeUTF8)) self.menuSimulation.setTitle(QtGui.QApplication.translate("MainWindow", "Inversion", None, QtGui.QApplication.UnicodeUTF8)) self.menuTools.setTitle(QtGui.QApplication.translate("MainWindow", "Tools", None, QtGui.QApplication.UnicodeUTF8)) + self.menuView.setTitle(QtGui.QApplication.translate("MainWindow", "View", None, QtGui.QApplication.UnicodeUTF8)) self.actionLoad_Seismic_Array.setText(QtGui.QApplication.translate("MainWindow", "Load Seismic Array", None, QtGui.QApplication.UnicodeUTF8)) self.actionSave_Seismic_Array.setText(QtGui.QApplication.translate("MainWindow", "Save Seismic Array", None, QtGui.QApplication.UnicodeUTF8)) self.actionLoad_Survey.setText(QtGui.QApplication.translate("MainWindow", "Load Survey", None, QtGui.QApplication.UnicodeUTF8)) @@ -379,4 +387,5 @@ class Ui_MainWindow(object): self.actionStart_FMTOMO_Simulation.setText(QtGui.QApplication.translate("MainWindow", "Start FMTOMO Simulation", None, QtGui.QApplication.UnicodeUTF8)) self.actionVTK_Visualization.setText(QtGui.QApplication.translate("MainWindow", "VTK Visualization", None, QtGui.QApplication.UnicodeUTF8)) self.actionSeismic_Array.setText(QtGui.QApplication.translate("MainWindow", "Seismic Array", None, QtGui.QApplication.UnicodeUTF8)) + self.actionFullscreen.setText(QtGui.QApplication.translate("MainWindow", "Fullscreen", None, QtGui.QApplication.UnicodeUTF8)) diff --git a/pylot/core/active/gui/fmtomo_parameters_layout.py b/pylot/core/active/gui/fmtomo_parameters_layout.py index 43cd767a..ab987e0b 100644 --- a/pylot/core/active/gui/fmtomo_parameters_layout.py +++ b/pylot/core/active/gui/fmtomo_parameters_layout.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'fmtomo_parameters_layout.ui' # -# Created: Thu Aug 4 12:07:57 2016 +# Created: Thu Aug 4 13:55:47 2016 # by: pyside-uic 0.2.15 running on PySide 1.2.2 # # WARNING! All changes made in this file will be lost! diff --git a/pylot/core/active/gui/generate_seisarray_layout.py b/pylot/core/active/gui/generate_seisarray_layout.py index 0b9e7048..94a35c79 100644 --- a/pylot/core/active/gui/generate_seisarray_layout.py +++ b/pylot/core/active/gui/generate_seisarray_layout.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'generate_seisarray_layout.ui' # -# Created: Thu Aug 4 12:07:57 2016 +# Created: Thu Aug 4 13:55:47 2016 # by: pyside-uic 0.2.15 running on PySide 1.2.2 # # WARNING! All changes made in this file will be lost! diff --git a/pylot/core/active/gui/generate_survey_layout.py b/pylot/core/active/gui/generate_survey_layout.py index 99791120..87e435c3 100644 --- a/pylot/core/active/gui/generate_survey_layout.py +++ b/pylot/core/active/gui/generate_survey_layout.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'generate_survey_layout.ui' # -# Created: Thu Aug 4 12:07:57 2016 +# Created: Thu Aug 4 13:55:47 2016 # by: pyside-uic 0.2.15 running on PySide 1.2.2 # # WARNING! All changes made in this file will be lost! diff --git a/pylot/core/active/gui/generate_survey_layout_minimal.py b/pylot/core/active/gui/generate_survey_layout_minimal.py index 223b6018..17d6352b 100644 --- a/pylot/core/active/gui/generate_survey_layout_minimal.py +++ b/pylot/core/active/gui/generate_survey_layout_minimal.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'generate_survey_layout_minimal.ui' # -# Created: Thu Aug 4 12:07:57 2016 +# Created: Thu Aug 4 13:55:47 2016 # by: pyside-uic 0.2.15 running on PySide 1.2.2 # # WARNING! All changes made in this file will be lost! diff --git a/pylot/core/active/gui/picking_parameters_layout.py b/pylot/core/active/gui/picking_parameters_layout.py index 3844fd64..db9ccc8c 100644 --- a/pylot/core/active/gui/picking_parameters_layout.py +++ b/pylot/core/active/gui/picking_parameters_layout.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'picking_parameters_layout.ui' # -# Created: Thu Aug 4 12:07:57 2016 +# Created: Thu Aug 4 13:55:47 2016 # by: pyside-uic 0.2.15 running on PySide 1.2.2 # # WARNING! All changes made in this file will be lost! diff --git a/pylot/core/active/gui/vtk_tools_layout.py b/pylot/core/active/gui/vtk_tools_layout.py index 48ad19de..de492841 100644 --- a/pylot/core/active/gui/vtk_tools_layout.py +++ b/pylot/core/active/gui/vtk_tools_layout.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'vtk_tools_layout.ui' # -# Created: Thu Aug 4 12:07:57 2016 +# Created: Thu Aug 4 13:55:47 2016 # by: pyside-uic 0.2.15 running on PySide 1.2.2 # # WARNING! All changes made in this file will be lost! diff --git a/pylot/core/active/gui/windows.py b/pylot/core/active/gui/windows.py index 7fe16d75..1b7c61e4 100644 --- a/pylot/core/active/gui/windows.py +++ b/pylot/core/active/gui/windows.py @@ -134,6 +134,9 @@ class Gen_Survey_from_SA(object): self.refresh_selection() self.executed = False + def update_seisarray(self, seisarray): + self.seisarray = seisarray + def refresh_selection(self): self.obsdir = self.ui.lineEdit_obs.text() self.fstart = self.ui.fstart.text() @@ -238,6 +241,9 @@ class Call_autopicker(object): SRdists.append(shot.getDistance(traceID)) self.maxSRdist = max(SRdists) return self.maxSRdist + + def update_survey(self, survey): + self.survey = survey def initSNRplot(self): self.snrFig = Figure() @@ -260,12 +266,15 @@ class Call_autopicker(object): if not refresh: self.plotPicks(ax) else: - for line in self.lines: - line.remove() - self.lines = [] + self.clear_lines() return fig, ax, xlim, ylim + def clear_lines(self): + for line in self.lines: + line.remove() + self.lines = [] + def finishFigure(self, ax, xlim, ylim): ax.set_xlim(xlim) ax.set_ylim(ylim) @@ -297,7 +306,9 @@ class Call_autopicker(object): if refresh == False: xlim, ylim = self.finishNewFigure(ax) - self.finishFigure(ax, xlim, ylim) + if self.survey.picked: + self.finishFigure(ax, xlim, ylim) + self.snrCanvas.draw() def plotDynSNR(self, refresh = True): @@ -317,7 +328,9 @@ class Call_autopicker(object): if refresh == False: xlim, ylim = self.finishNewFigure(ax) - self.finishFigure(ax, xlim, ylim) + if self.survey.picked: + self.finishFigure(ax, xlim, ylim) + self.snrCanvas.draw() def plotSNR(self, refresh = True): @@ -363,9 +376,11 @@ class Call_autopicker(object): #QtGui.qApp.processEvents() # test self.executed = True + self.clear_lines() else: self.refresh_selection() self.executed = False + self.clear_lines() def refreshFolm(self): self.ui.label_folm.setText('%s %%'%self.ui.slider_folm.value()) @@ -446,6 +461,9 @@ class Call_FMTOMO(object): self.refresh_selection() self.executed = False + def update_survey(self, survey): + self.survey = survey + def refresh_selection(self): self.fmtomo_dir = self.ui.fmtomo_dir.text() self.nIter = int(self.ui.nIter.value())