changed structure of callFMTOMO to class
This commit is contained in:
parent
adfe9cc027
commit
638f552d6d
@ -9,9 +9,8 @@ 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.fmtomo_parameters_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
|
||||
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 openFile, saveFile, browseDir, getMaxCPU
|
||||
|
||||
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
|
||||
@ -36,10 +35,14 @@ class gui_control(object):
|
||||
self.mainUI.progressBar.setVisible(False)
|
||||
self.printSurveyTextbox()
|
||||
self.printSeisArrayTextbox()
|
||||
self.initWindowObjects()
|
||||
|
||||
def initWindowObjects(self):
|
||||
self.gsa = None
|
||||
self.gssa = None
|
||||
self.gssr = None
|
||||
self.autopicker = None
|
||||
self.fmtomo = None
|
||||
|
||||
def setInitStates(self):
|
||||
self.setPickState(False)
|
||||
@ -56,7 +59,7 @@ class gui_control(object):
|
||||
QtCore.QObject.connect(self.mainUI.actionConnect_to_Survey, QtCore.SIGNAL("triggered()"), self.connect2Survey)
|
||||
QtCore.QObject.connect(self.mainUI.actionInterpolate_Receivers, QtCore.SIGNAL("triggered()"), self.interpolate_receivers)
|
||||
QtCore.QObject.connect(self.mainUI.actionGenerate_new_Survey, QtCore.SIGNAL("triggered()"), self.gen_survey)
|
||||
QtCore.QObject.connect(self.mainUI.actionAutomatic_Picking, QtCore.SIGNAL("triggered()"), self.callPicker)
|
||||
QtCore.QObject.connect(self.mainUI.actionAutomatic_Picking, QtCore.SIGNAL("triggered()"), self.startPicker)
|
||||
QtCore.QObject.connect(self.mainUI.actionPostprocessing, QtCore.SIGNAL("triggered()"), self.postprocessing)
|
||||
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)
|
||||
@ -331,7 +334,7 @@ class gui_control(object):
|
||||
print('Connected Seismic Array to active Survey object.')
|
||||
|
||||
|
||||
def callPicker(self):
|
||||
def startPicker(self):
|
||||
if not self.checkSurveyState():
|
||||
self.printDialogMessage('No Survey defined.')
|
||||
return
|
||||
@ -356,14 +359,13 @@ class gui_control(object):
|
||||
if not self.checkPickState():
|
||||
self.printDialogMessage('Survey not picked.')
|
||||
return
|
||||
fmtomo_parameters = QtGui.QDialog(self.mainwindow)
|
||||
ui = Ui_fmtomo_parameters()
|
||||
ui.setupUi(fmtomo_parameters)
|
||||
ui.nproc.setMaximum(getMaxCPU())
|
||||
|
||||
self.fmtomo_parameters_ui = ui
|
||||
self.connectButtons_startFMTOMO()
|
||||
self.getFMTOMOparameters(ui, fmtomo_parameters)
|
||||
if self.fmtomo is None:
|
||||
self.fmtomo = Call_FMTOMO(self.mainwindow, self.survey)
|
||||
else:
|
||||
self.fmtomo.start_dialog()
|
||||
|
||||
#if self.fmtomo.executed:
|
||||
|
||||
|
||||
def startVTKtools(self):
|
||||
@ -380,45 +382,6 @@ class gui_control(object):
|
||||
vtk_tools.exec_()
|
||||
|
||||
|
||||
def getFMTOMOparameters(self, ui, fmtomo_parameters):
|
||||
if fmtomo_parameters.exec_():
|
||||
fmtomo_dir = ui.fmtomo_dir.text()
|
||||
nIter = int(ui.nIter.value())
|
||||
nproc = int(ui.nproc.value())
|
||||
btop = float(ui.btop.text())
|
||||
bbot = float(ui.bbot.text())
|
||||
propgrid = (int(ui.pgrid_x.text()), int(ui.pgrid_y.text()), int(ui.pgrid_z.text()))
|
||||
vgrid = (int(ui.invgrid_x.text()), int(ui.invgrid_y.text()), int(ui.invgrid_z.text()))
|
||||
cushionfactor = float(ui.cushion.text())/100.
|
||||
customgrid = ui.customgrid.text()
|
||||
simuldir = ui.simuldir.text()
|
||||
picks_dir = os.path.join(simuldir, 'picks')
|
||||
|
||||
if not os.path.isdir(picks_dir):
|
||||
err = os.mkdir(picks_dir)
|
||||
|
||||
self.survey.exportFMTOMO(picks_dir)
|
||||
|
||||
cwd = os.getcwd()
|
||||
interpolationMethod = 'linear'
|
||||
os.chdir(simuldir)
|
||||
if self.seisarray.twoDim:
|
||||
interpolationMethod = 'nearest'
|
||||
self.survey.seisarray.generateFMTOMOinputFromArray(propgrid, vgrid, (bbot, btop), cushionfactor,
|
||||
interpolationMethod, customgrid = customgrid,
|
||||
writeVTK = True)
|
||||
os.chdir(cwd)
|
||||
|
||||
tomo = fmtomoUtils.Tomo3d(fmtomo_dir, simuldir)
|
||||
tomo.runTOMO3D(nproc, nIter)
|
||||
|
||||
|
||||
def connectButtons_startFMTOMO(self):
|
||||
QtCore.QObject.connect(self.fmtomo_parameters_ui.browse_tomodir, QtCore.SIGNAL("clicked()"), self.chooseFMTOMOdir)
|
||||
QtCore.QObject.connect(self.fmtomo_parameters_ui.browse_customgrid, QtCore.SIGNAL("clicked()"), self.chooseCustomgrid)
|
||||
QtCore.QObject.connect(self.fmtomo_parameters_ui.browse_simuldir, QtCore.SIGNAL("clicked()"), self.chooseSimuldir)
|
||||
|
||||
|
||||
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)
|
||||
@ -513,22 +476,6 @@ class gui_control(object):
|
||||
self.vtk_tools_ui.lineEdit_vgout.setText(saveFile())
|
||||
|
||||
|
||||
def chooseFMTOMOdir(self):
|
||||
self.fmtomo_parameters_ui.fmtomo_dir.setText(browseDir())
|
||||
|
||||
|
||||
def chooseCustomgrid(self):
|
||||
self.fmtomo_parameters_ui.customgrid.setText(openFile())
|
||||
|
||||
|
||||
def chooseSimuldir(self):
|
||||
self.fmtomo_parameters_ui.simuldir.setText(browseDir())
|
||||
|
||||
|
||||
def chooseSeisarray(self):
|
||||
self.fmtomo_parameters_ui.seisarray.setText(openFile())
|
||||
|
||||
|
||||
def postprocessing(self):
|
||||
if not self.checkSurveyState():
|
||||
self.printDialogMessage('No Survey defined.')
|
||||
|
@ -1,11 +1,13 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
from PySide import QtCore, QtGui
|
||||
from pylot.core.active import surveyUtils, activeSeismoPick, seismicArrayPreparation
|
||||
from generate_survey_layout import *
|
||||
from generate_survey_layout_minimal import *
|
||||
from generate_seisarray_layout import *
|
||||
from picking_parameters_layout import *
|
||||
from pylot.core.active import surveyUtils, activeSeismoPick, seismicArrayPreparation, fmtomoUtils
|
||||
from generate_survey_layout import Ui_generate_survey
|
||||
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
|
||||
|
||||
import numpy as np
|
||||
import matplotlib
|
||||
@ -62,7 +64,7 @@ class Gen_SeisArray(object):
|
||||
def start_dialog(self):
|
||||
self.init_last_selection()
|
||||
if self.qdialog.exec_():
|
||||
self.refresh_filenames()
|
||||
self.refresh_selection()
|
||||
if self.ui.radioButton_interpolatable.isChecked():
|
||||
self.seisarray = seismicArrayPreparation.SeisArray(self.recfile, True)
|
||||
elif self.ui.radioButton_normal.isChecked():
|
||||
@ -73,10 +75,10 @@ class Gen_SeisArray(object):
|
||||
self.seisarray.addMeasuredTopographyPoints(self.ptsfile)
|
||||
self.executed = True
|
||||
else:
|
||||
self.refresh_filenames()
|
||||
self.refresh_selection()
|
||||
self.executed = False
|
||||
|
||||
def refresh_filenames(self):
|
||||
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()
|
||||
@ -128,16 +130,16 @@ class Gen_Survey_from_SA(object):
|
||||
def start_dialog(self):
|
||||
self.init_last_selection()
|
||||
if self.qdialog.exec_():
|
||||
self.refresh_filenames()
|
||||
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_filenames()
|
||||
self.refresh_selection()
|
||||
self.executed = False
|
||||
|
||||
def refresh_filenames(self):
|
||||
def refresh_selection(self):
|
||||
self.obsdir = self.ui.lineEdit_obs.text()
|
||||
self.fstart = self.ui.fstart.text()
|
||||
self.fend = self.ui.fend.text()
|
||||
@ -180,16 +182,16 @@ class Gen_Survey_from_SR(object):
|
||||
def start_dialog(self):
|
||||
self.init_last_selection()
|
||||
if self.qdialog.exec_():
|
||||
self.refresh_filenames()
|
||||
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_filenames()
|
||||
self.refresh_selection()
|
||||
self.executed = False
|
||||
|
||||
def refresh_filenames(self):
|
||||
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()
|
||||
@ -347,9 +349,6 @@ class Call_autopicker(object):
|
||||
self.ui.p1.setValue(self.p1)
|
||||
self.ui.p2.setValue(self.p2)
|
||||
|
||||
def get_survey(self):
|
||||
return self.survey
|
||||
|
||||
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)
|
||||
@ -366,3 +365,96 @@ class Call_autopicker(object):
|
||||
def chooseRecfile(self):
|
||||
self.ui.lineEdit_rec.setText(openFile('Open receiverfile.'))
|
||||
|
||||
|
||||
|
||||
class Call_FMTOMO(object):
|
||||
def __init__(self, mainwindow, survey):
|
||||
self.mainwindow = mainwindow
|
||||
self.survey = survey
|
||||
self.init_dialog()
|
||||
self.refresh_selection()
|
||||
self.start_dialog()
|
||||
|
||||
def init_dialog(self):
|
||||
qdialog = QtGui.QDialog(self.mainwindow)
|
||||
ui = Ui_fmtomo_parameters()
|
||||
ui.setupUi(qdialog)
|
||||
ui.nproc.setMaximum(getMaxCPU())
|
||||
self.ui = ui
|
||||
self.qdialog = qdialog
|
||||
self.connectButtons()
|
||||
|
||||
def start_dialog(self):
|
||||
self.init_last_selection()
|
||||
if self.qdialog.exec_():
|
||||
self.refresh_selection()
|
||||
|
||||
if not os.path.isdir(self.picks_dir):
|
||||
err = os.mkdir(self.picks_dir) # error not handled yet
|
||||
|
||||
self.survey.exportFMTOMO(self.picks_dir)
|
||||
|
||||
cwd = os.getcwd()
|
||||
interpolationMethod = 'linear'
|
||||
os.chdir(self.simuldir)
|
||||
if self.survey.seisarray.twoDim:
|
||||
interpolationMethod = 'nearest'
|
||||
self.survey.seisarray.generateFMTOMOinputFromArray(self.propgrid, self.vgrid, (self.bbot, self.btop),
|
||||
self.cushionfactor/100., interpolationMethod,
|
||||
customgrid = self.customgrid, writeVTK = True)
|
||||
os.chdir(cwd)
|
||||
|
||||
tomo = fmtomoUtils.Tomo3d(self.fmtomo_dir, self.simuldir)
|
||||
tomo.runTOMO3D(self.nproc, self.nIter)
|
||||
|
||||
self.executed = True
|
||||
else:
|
||||
self.refresh_selection()
|
||||
self.executed = False
|
||||
|
||||
def refresh_selection(self):
|
||||
self.fmtomo_dir = self.ui.fmtomo_dir.text()
|
||||
self.nIter = int(self.ui.nIter.value())
|
||||
self.nproc = int(self.ui.nproc.value())
|
||||
self.btop = float(self.ui.btop.text())
|
||||
self.bbot = float(self.ui.bbot.text())
|
||||
self.propgrid = (int(self.ui.pgrid_x.value()), int(self.ui.pgrid_y.value()), int(self.ui.pgrid_z.value()))
|
||||
self.vgrid = (int(self.ui.invgrid_x.value()), int(self.ui.invgrid_y.value()), int(self.ui.invgrid_z.value()))
|
||||
self.cushionfactor = float(self.ui.cushion.value())
|
||||
self.customgrid = self.ui.customgrid.text()
|
||||
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)
|
||||
QtCore.QObject.connect(self.ui.browse_simuldir, QtCore.SIGNAL("clicked()"), self.chooseSimuldir)
|
||||
|
||||
def chooseFMTOMOdir(self):
|
||||
self.ui.fmtomo_dir.setText(browseDir())
|
||||
|
||||
def chooseCustomgrid(self):
|
||||
self.ui.customgrid.setText(openFile())
|
||||
|
||||
def chooseSimuldir(self):
|
||||
self.ui.simuldir.setText(browseDir())
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user