Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
		
						commit
						b72e16aaed
					
				| @ -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) | ||||
| @ -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(): | ||||
| @ -93,7 +100,6 @@ class gui_control(object): | ||||
|                 self.setConnected2SurveyState(False) | ||||
|             self.setSeisArrayState(True) | ||||
| 
 | ||||
| 
 | ||||
|     def gen_survey(self): | ||||
|         if self.checkSurveyState(): | ||||
|             if not self.continueDialogExists('Survey'): | ||||
| @ -105,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() | ||||
| @ -126,13 +133,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 +145,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 +157,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 +165,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 +173,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 +180,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 +188,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 +201,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 +223,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 +251,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 +259,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 +274,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 +288,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 +295,6 @@ class gui_control(object): | ||||
|         self.seisarray.interpolateAll() | ||||
|         self.refreshSeisArrayWidgets() | ||||
| 
 | ||||
| 
 | ||||
|     def refreshSeisArrayWidgets(self): | ||||
|         self.replotArray() | ||||
|         self.replotSurface() | ||||
| @ -333,7 +317,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.') | ||||
| @ -346,12 +329,12 @@ 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) | ||||
|             self.printSurveyTextbox(init = False) | ||||
| 
 | ||||
| 
 | ||||
|     def startFMTOMO(self): | ||||
|         if not self.checkSurveyState(): | ||||
|             self.printDialogMessage('No Survey defined.') | ||||
| @ -364,117 +347,16 @@ 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: | ||||
|          | ||||
| 
 | ||||
|     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): | ||||
|         if not self.checkSurveyState(): | ||||
| @ -520,7 +402,6 @@ class gui_control(object): | ||||
|             self.setSeisArrayState(False) | ||||
|             self.printDialogMessage('Loaded Survey.') | ||||
| 
 | ||||
| 
 | ||||
|     def load_seisarray(self): | ||||
|         disconnect = False | ||||
|         if self.checkSeisArrayState(): | ||||
| @ -551,7 +432,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.') | ||||
| @ -561,7 +441,6 @@ class gui_control(object): | ||||
|             return | ||||
|         self.seisarray.saveSeisArray(filename) | ||||
| 
 | ||||
| 
 | ||||
|     def save_survey(self): | ||||
|         if not self.checkSurveyState(): | ||||
|             self.printDialogMessage('No Survey defined.') | ||||
| @ -571,7 +450,6 @@ class gui_control(object): | ||||
|             return | ||||
|         self.survey.saveSurvey(filename) | ||||
| 
 | ||||
| 
 | ||||
|     def setSurveyState(self, state): | ||||
|         if state == True: | ||||
|             self.mainUI.survey_active.setPixmap(self.applypixmap) | ||||
| @ -579,21 +457,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) | ||||
| @ -611,7 +486,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) | ||||
| @ -623,14 +497,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: | ||||
| @ -638,14 +510,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) | ||||
| @ -653,7 +523,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) | ||||
| @ -665,7 +534,6 @@ class gui_control(object): | ||||
|         else: | ||||
|             return False | ||||
| 
 | ||||
| 
 | ||||
|     def continueDialogMessage(self, message): | ||||
|         qmb = QtGui.QMessageBox() | ||||
|         qmb.setText(message) | ||||
| @ -677,7 +545,6 @@ class gui_control(object): | ||||
|         else: | ||||
|             return False | ||||
| 
 | ||||
| 
 | ||||
|     def exitApp(self): | ||||
|         QtCore.QCoreApplication.instance().quit() | ||||
| 
 | ||||
| @ -687,8 +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_()) | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -49,17 +49,19 @@ 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) | ||||
|         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 = '{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 +118,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 | ||||
|  | ||||
| @ -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 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)) | ||||
| 
 | ||||
|  | ||||
| @ -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 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! | ||||
|  | ||||
| @ -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 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! | ||||
|  | ||||
| @ -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 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! | ||||
|  | ||||
| @ -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 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! | ||||
|  | ||||
| @ -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 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! | ||||
| @ -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)) | ||||
|  | ||||
| @ -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 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! | ||||
|  | ||||
| @ -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 | ||||
| @ -43,6 +45,7 @@ def getMaxCPU(): | ||||
|     import multiprocessing | ||||
|     return multiprocessing.cpu_count() | ||||
| 
 | ||||
| 
 | ||||
| class Gen_SeisArray(object): | ||||
|     def __init__(self, mainwindow): | ||||
|         self.mainwindow = mainwindow | ||||
| @ -62,7 +65,6 @@ 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(): | ||||
| @ -83,11 +85,6 @@ class Gen_SeisArray(object): | ||||
|         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 | ||||
| @ -107,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 | ||||
| @ -128,7 +124,6 @@ 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, | ||||
| @ -139,16 +134,14 @@ 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() | ||||
|         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,7 +173,6 @@ 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, | ||||
| @ -198,13 +190,6 @@ class Gen_Survey_from_SR(object): | ||||
|         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,14 +208,17 @@ 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 | ||||
|         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): | ||||
| @ -240,7 +228,7 @@ class Call_autopicker(object): | ||||
|         ui.ncores.setMaximum(getMaxCPU()) | ||||
|         self.ui = ui | ||||
|         self.qdialog = qdialog | ||||
|         self.initDynSNRplot() | ||||
|         self.initSNRplot() | ||||
|         self.connectButtons() | ||||
| 
 | ||||
|     def getMaxSRdist(self): | ||||
| @ -253,15 +241,18 @@ 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 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) | ||||
| @ -271,35 +262,103 @@ 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: | ||||
|             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) | ||||
| 
 | ||||
|     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) | ||||
| 
 | ||||
|         if self.survey.picked: | ||||
|             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) | ||||
| 
 | ||||
|         if self.survey.picked: | ||||
|             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.init_last_selection() | ||||
|         self.plotDynSNR() | ||||
|         self.plotSNR(refresh = False) | ||||
|         if self.qdialog.exec_(): | ||||
|             self.refresh_selection() | ||||
| 
 | ||||
| @ -317,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()) | ||||
| @ -336,25 +397,15 @@ 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) | ||||
|         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.')) | ||||
| @ -366,7 +417,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 | ||||
| @ -385,7 +435,6 @@ class Call_FMTOMO(object): | ||||
|         self.connectButtons() | ||||
|          | ||||
|     def start_dialog(self): | ||||
|         self.init_last_selection() | ||||
|         if self.qdialog.exec_(): | ||||
|             self.refresh_selection() | ||||
| 
 | ||||
| @ -412,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()) | ||||
| @ -425,22 +477,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) | ||||
| @ -456,5 +492,108 @@ 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.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 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()) | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user