changed structure of active GUI code, autopicker window changed to class

This commit is contained in:
Marcel Paffrath 2016-07-26 14:48:08 +02:00
parent 3273709b54
commit 48c0dbacfb
13 changed files with 370 additions and 556 deletions

View File

@ -6,14 +6,11 @@ import matplotlib
matplotlib.use('Qt4Agg')
matplotlib.rcParams['backend.qt4']='PySide'
from PySide import QtCore, QtGui, QtCore
from asp3d_layout import *
from fmtomo_parameters_layout import *
from generate_survey_layout import *
from generate_survey_layout_minimal import *
from generate_seisarray_layout import *
from picking_parameters_layout import *
from vtk_tools_layout import *
from PySide import QtCore, QtGui
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 import activeSeismoPick, surveyUtils, fmtomoUtils, seismicArrayPreparation
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
@ -62,6 +59,7 @@ class gui_control(object):
self.gsa = None
self.gssa = None
self.gssr = None
self.autopicker = None
def setInitStates(self):
self.setPickState(False)
@ -88,186 +86,6 @@ class gui_control(object):
QtCore.QObject.connect(self.mainUI.shot_right, QtCore.SIGNAL("clicked()"), self.increaseShotnumber)
QtCore.QObject.connect(self.mainUI.plot_shot, QtCore.SIGNAL("clicked()"), self.plotShot)
class Gen_SeisArray(object):
def __init__(self, mainwindow):
self.mainwindow = mainwindow
self.seisarray = None
self.srcfile = None
self.recfile = None
self.ptsfile = None
self.init_dialog()
self.start_dialog()
def init_dialog(self):
qdialog = QtGui.QDialog(self.mainwindow)
ui = Ui_generate_seisarray()
ui.setupUi(qdialog)
self.ui = ui
self.qdialog = qdialog
self.connectButtons()
def start_dialog(self):
self.init_last_selection()
if self.qdialog.exec_():
self.refresh_filenames()
if self.ui.radioButton_interpolatable.isChecked():
self.seisarray = seismicArrayPreparation.SeisArray(self.recfile, True)
elif self.ui.radioButton_normal.isChecked():
self.seisarray = seismicArrayPreparation.SeisArray(self.recfile, False)
if len(self.srcfile) > 0:
self.seisarray.addSourceLocations(self.srcfile)
if len(self.ptsfile) > 0:
self.seisarray.addMeasuredTopographyPoints(self.ptsfile)
self.executed = True
else:
self.refresh_filenames()
self.executed = False
def refresh_filenames(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
def connectButtons(self):
QtCore.QObject.connect(self.ui.pushButton_rec, QtCore.SIGNAL("clicked()"), self.chooseMeasuredRec)
QtCore.QObject.connect(self.ui.pushButton_src, QtCore.SIGNAL("clicked()"), self.chooseMeasuredSrc)
QtCore.QObject.connect(self.ui.pushButton_obs, QtCore.SIGNAL("clicked()"), self.chooseMeasuredPts)
def chooseMeasuredSrc(self):
self.ui.lineEdit_src.setText(openFile('Open measured sources file.'))
def chooseMeasuredRec(self):
self.ui.lineEdit_rec.setText(openFile('Open measured receivers file.'))
def chooseMeasuredPts(self):
self.ui.lineEdit_pts.setText(openFile('Open measured points file.'))
class Gen_Survey_from_SA(object):
def __init__(self, mainwindow, seisarray):
self.mainwindow = mainwindow
self.seisarray = seisarray
self.survey = None
self.obsdir = None
self.fstart = 'shot'
self.fend = '.dat'
self.init_dialog()
self.start_dialog()
def init_dialog(self):
qdialog = QtGui.QDialog(self.mainwindow)
ui = Ui_generate_survey_minimal()
ui.setupUi(qdialog)
self.ui = ui
self.qdialog = qdialog
self.connectButtons()
def start_dialog(self):
self.init_last_selection()
if self.qdialog.exec_():
self.refresh_filenames()
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.executed = False
def refresh_filenames(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
def connectButtons(self):
QtCore.QObject.connect(self.ui.pushButton_obs, QtCore.SIGNAL("clicked()"), self.chooseObsdir)
def chooseObsdir(self):
self.ui.lineEdit_obs.setText(browseDir('Choose observation directory.'))
class Gen_Survey_from_SR(object):
def __init__(self, mainwindow):
self.mainwindow = mainwindow
self.survey = None
self.obsdir = None
self.srcfile = None
self.recfile = None
self.fstart = 'shot'
self.fend = '.dat'
self.init_dialog()
self.start_dialog()
def init_dialog(self):
qdialog = QtGui.QDialog(self.mainwindow)
ui = Ui_generate_survey()
ui.setupUi(qdialog)
self.ui = ui
self.qdialog = qdialog
self.connectButtons()
def start_dialog(self):
self.init_last_selection()
if self.qdialog.exec_():
self.refresh_filenames()
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.executed = False
def refresh_filenames(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
def connectButtons(self):
QtCore.QObject.connect(self.ui.pushButton_obs, QtCore.SIGNAL("clicked()"), self.chooseObsdir)
QtCore.QObject.connect(self.ui.pushButton_src, QtCore.SIGNAL("clicked()"), self.chooseSourcefile)
QtCore.QObject.connect(self.ui.pushButton_rec, QtCore.SIGNAL("clicked()"), self.chooseRecfile)
def chooseObsdir(self):
self.ui.lineEdit_obs.setText(browseDir('Choose observation directory.'))
def chooseSourcefile(self):
self.ui.lineEdit_src.setText(openFile('Open sourcefile.'))
def chooseRecfile(self):
self.ui.lineEdit_rec.setText(openFile('Open receiverfile.'))
def gen_seisarray(self):
disconnect = False
if self.checkSeisArrayState():
@ -282,7 +100,7 @@ class gui_control(object):
disconnect = True
if self.gsa is None:
self.gsa = self.Gen_SeisArray(self.mainwindow)
self.gsa = Gen_SeisArray(self.mainwindow)
else:
self.gsa.start_dialog()
@ -301,7 +119,7 @@ class gui_control(object):
if len(self.seisarray.getSourceCoordinates()) > 0:
if self.continueDialogMessage('Use geometry information of active Seismic Array?'):
if self.gssa is None:
self.gssa = self.Gen_Survey_from_SA(self.mainwindow, self.seisarray)
self.gssa = Gen_Survey_from_SA(self.mainwindow, self.seisarray)
else:
self.gssa.start_dialog()
if self.gssa.executed:
@ -315,7 +133,7 @@ class gui_control(object):
' because there are no sources given.'):
return
if self.gssr is None:
self.gssr = self.Gen_Survey_from_SR(self.mainwindow)
self.gssr = Gen_Survey_from_SR(self.mainwindow)
else:
self.gssr.start_dialog()
if self.gssr.executed:
@ -517,21 +335,6 @@ class gui_control(object):
self.printSeisArrayTextbox(init = False)
def getPickParameters(self, ui, Picking_parameters):
self.initDynSNRplot()
self.plotDynSNR()
if Picking_parameters.exec_():
ncores = int(ui.ncores.value())
vmin = float(ui.lineEdit_vmin.text())
vmax = float(ui.lineEdit_vmax.text())
folm = float(ui.slider_folm.value())/100.
print('folm =', folm)
AIC = ui.checkBox_AIC.isChecked()
aicwindow = (int(ui.lineEdit_aicleft.text()), int(ui.lineEdit_aicright.text()))
return ncores, vmin, vmax, folm, AIC, aicwindow
def connect2Survey(self):
if not self.checkSurveyState():
self.printDialogMessage('No Survey defined.')
@ -549,15 +352,11 @@ class gui_control(object):
print('Connected Seismic Array to active Survey object.')
def getMaxCPU(self):
def getMaxCPU(self): ### OLD
import multiprocessing
return multiprocessing.cpu_count()
def refreshFolm(self):
self.picker_ui.label_folm.setText('%s %%'%self.picker_ui.slider_folm.value())
def callPicker(self):
if not self.checkSurveyState():
self.printDialogMessage('No Survey defined.')
@ -565,87 +364,17 @@ class gui_control(object):
if self.checkPickState():
if not self.continueDialogMessage('Survey already picked. Continue?'):
return
Picking_parameters = QtGui.QDialog(self.mainwindow)
ui = Ui_picking_parameters()
ui.setupUi(Picking_parameters)
ui.ncores.setMaximum(self.getMaxCPU())
self.picker_ui = ui
QtCore.QObject.connect(self.picker_ui.slider_folm, QtCore.SIGNAL("valueChanged(int)"), self.refreshFolm)
QtCore.QObject.connect(self.picker_ui.shift_snr, QtCore.SIGNAL("valueChanged(int)"), self.plotDynSNR)
QtCore.QObject.connect(self.picker_ui.shift_dist, QtCore.SIGNAL("valueChanged(int)"), self.plotDynSNR)
QtCore.QObject.connect(self.picker_ui.p1, QtCore.SIGNAL("valueChanged(double)"), self.plotDynSNR)
QtCore.QObject.connect(self.picker_ui.p2, QtCore.SIGNAL("valueChanged(double)"), self.plotDynSNR)
try:
ncores, vmin, vmax, folm, AIC, aicwindow = self.getPickParameters(ui, Picking_parameters)
except TypeError:
return
if AIC == True:
HosAic = 'aic'
if self.autopicker is None:
self.autopicker = Call_autopicker(self.mainwindow, self.survey)
else:
HosAic = 'hos'
self.autopicker.start_dialog()
shiftSNR = float(self.picker_ui.shift_snr.value())
shiftDist = float(self.picker_ui.shift_dist.value())
p1 = float(self.picker_ui.p1.value())
p2 = float(self.picker_ui.p2.value())
surveyUtils.setDynamicFittedSNR(self.survey.getShotDict(), shiftdist = shiftDist,
shiftSNR = shiftSNR, p1 = p1, p2 = p2)
self.survey.pickAllShots(vmin = vmin, vmax = vmax,
folm = folm, HosAic = HosAic,
aicwindow = aicwindow, cores = ncores)
QtGui.qApp.processEvents() # test
if self.autopicker.executed:
self.setPickState(True)
self.printSurveyTextbox(init = False)
def plotDynSNR(self):
fig = self.snrFig
if fig.axes == []:
ax = fig.add_subplot(111)
xlim = None
ylim = None
else:
ax = fig.axes[0]
xlim = ax.get_xlim()
ylim = ax.get_ylim()
ax.clear()
snrthresholds = []
dists_p = []; snr_p = []
shiftSNR = float(self.picker_ui.shift_snr.value())
shiftDist = float(self.picker_ui.shift_dist.value())
p1 = float(self.picker_ui.p1.value())
p2 = float(self.picker_ui.p2.value())
dists = range(200) # CHANGE
if self.checkPickState():
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.snrCanvas.draw()
def initDynSNRplot(self):
self.snrFig = Figure()
self.snrCanvas = FigureCanvas(self.snrFig)
self.picker_ui.vlayout_plot.addWidget(self.snrCanvas)
self.snrToolbar = NavigationToolbar(self.snrCanvas, self.mainwindow)
self.picker_ui.vlayout_plot.addWidget(self.snrToolbar)
def startFMTOMO(self):
if not self.checkSurveyState():
self.printDialogMessage('No Survey defined.')
@ -703,7 +432,7 @@ class gui_control(object):
interpolationMethod = 'nearest'
self.survey.seisarray.generateFMTOMOinputFromArray(propgrid, vgrid, (bbot, btop), cushionfactor,
interpolationMethod, customgrid = customgrid,
writeVTK = False)
writeVTK = True)
os.chdir(cwd)
tomo = fmtomoUtils.Tomo3d(fmtomo_dir, simuldir)

View File

@ -1,2 +1,2 @@
# -*- coding: utf-8 -*-
__author__ = 'sebastianw'
__author__ = 'marcel'

View File

@ -1,264 +0,0 @@
# -*- coding: utf-8 -*-
import sys
from PySide import QtCore, QtGui
from pylot.core.active import activeSeismoPick
class Ui_ActiveSeismoPick3D(object):
def __init__(self):
self.survey = None
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(550, 350)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.addBrowseButtons()
self.addButtons()
self.addLineEdits()
self.addLabels()
MainWindow.setCentralWidget(self.centralwidget)
self.setMenubar(MainWindow)
self.menuPreferences = QtGui.QMenu(self.menubar)
self.menuPreferences.setObjectName("menuPreferences")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.menubar.addAction(self.menuPreferences.menuAction())
self.retranslateUi(MainWindow)
self.connectButtons()
def setMenubar(self, window):
self.menubar = QtGui.QMenuBar(window)
self.menubar.setGeometry(QtCore.QRect(0, 0, 603, 21))
self.menubar.setObjectName("menubar")
def connectButtons(self):
QtCore.QObject.connect(self.browseButton_rec, QtCore.SIGNAL("clicked()"), self.chooseReceiverfile)
QtCore.QObject.connect(self.browseButton_src, QtCore.SIGNAL("clicked()"), self.chooseSourcefile)
QtCore.QObject.connect(self.browseButton_obsdir, QtCore.SIGNAL("clicked()"), self.chooseObsdir)
QtCore.QObject.connect(self.start_picking, QtCore.SIGNAL("clicked()"), self.callPicker)
QtCore.QObject.connect(self.gen_survey, QtCore.SIGNAL("clicked()"), self.generateSurvey)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def addLabels(self):
self.label = QtGui.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(40, 70, 131, 20))
self.label.setObjectName("label")
self.label_2 = QtGui.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(40, 110, 131, 20))
self.label_2.setObjectName("label_2")
self.label_3 = QtGui.QLabel(self.centralwidget)
self.label_3.setGeometry(QtCore.QRect(40, 150, 131, 20))
self.label_3.setObjectName("label_3")
def addLineEdits(self):
self.receiverfile_lineEdit = QtGui.QLineEdit(self.centralwidget)
self.receiverfile_lineEdit.setGeometry(QtCore.QRect(192, 70, 231, 20))
self.receiverfile_lineEdit.setObjectName("receiverfile_lineEdit")
self.sourcefile_lineEdit = QtGui.QLineEdit(self.centralwidget)
self.sourcefile_lineEdit.setGeometry(QtCore.QRect(192, 110, 231, 20))
self.sourcefile_lineEdit.setObjectName("sourcefile_lineEdit")
self.obsdir_lineEdit = QtGui.QLineEdit(self.centralwidget)
self.obsdir_lineEdit.setGeometry(QtCore.QRect(192, 150, 231, 20))
self.obsdir_lineEdit.setText("")
self.obsdir_lineEdit.setObjectName("obsdir_lineEdit")
def addBrowseButtons(self):
self.browseButton_rec = QtGui.QPushButton(self.centralwidget)
self.browseButton_rec.setGeometry(QtCore.QRect(440, 70, 75, 23))
self.browseButton_rec.setObjectName("browseButton_rec")
self.browseButton_src = QtGui.QPushButton(self.centralwidget)
self.browseButton_src.setGeometry(QtCore.QRect(440, 110, 75, 23))
self.browseButton_src.setObjectName("browseButton_src")
self.browseButton_obsdir = QtGui.QPushButton(self.centralwidget)
self.browseButton_obsdir.setGeometry(QtCore.QRect(440, 150, 75, 23))
self.browseButton_obsdir.setObjectName("browseButton_obsdir")
def addButtons(self):
self.gen_survey = QtGui.QPushButton(self.centralwidget)
self.gen_survey.setGeometry(QtCore.QRect(80, 230, 61, 61))
self.gen_survey.setObjectName("gen_survey")
self.start_picking = QtGui.QPushButton(self.centralwidget)
self.start_picking.setGeometry(QtCore.QRect(160, 230, 61, 61))
self.start_picking.setObjectName("start_picking")
def addProgressBar(self):
self.progressBar = QtGui.QProgressBar(self.centralwidget)
self.progressBar.setGeometry(QtCore.QRect(470, 280, 118, 23))
self.progressBar.setObjectName("progressBar")
def updateProgressBar(self):
self.progressBar.setProperty("value", 24)
def browseFile(self):
dialog = QtGui.QFileDialog()
filename = dialog.getOpenFileName()
return filename[0]
def browseDir(self):
dialog = QtGui.QFileDialog()
directory = dialog.getExistingDirectory()
return directory
def chooseSourcefile(self):
self.sourcefile_lineEdit.setText(self.browseFile())
def chooseReceiverfile(self):
self.receiverfile_lineEdit.setText(self.browseFile())
def chooseObsdir(self):
self.obsdir_lineEdit.setText(self.browseDir())
def getSourcefile(self):
return self.sourcefile_lineEdit.text()
def getReceiverfile(self):
return self.receiverfile_lineEdit.text()
def getObsdir(self):
return self.obsdir_lineEdit.text()
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "ActiveSeismoPick3D", None, QtGui.QApplication.UnicodeUTF8))
self.browseButton_rec.setText(QtGui.QApplication.translate("MainWindow", "Browse", None, QtGui.QApplication.UnicodeUTF8))
self.browseButton_src.setText(QtGui.QApplication.translate("MainWindow", "Browse", None, QtGui.QApplication.UnicodeUTF8))
self.label.setText(QtGui.QApplication.translate("MainWindow", "Receiver File", None, QtGui.QApplication.UnicodeUTF8))
self.label_2.setText(QtGui.QApplication.translate("MainWindow", "Source File", None, QtGui.QApplication.UnicodeUTF8))
self.start_picking.setText(QtGui.QApplication.translate("MainWindow", "Start\n"
"Picking", None, QtGui.QApplication.UnicodeUTF8))
self.browseButton_obsdir.setText(QtGui.QApplication.translate("MainWindow", "Browse", None, QtGui.QApplication.UnicodeUTF8))
self.gen_survey.setText(QtGui.QApplication.translate("MainWindow", "Gemerate\nSurvey", None, QtGui.QApplication.UnicodeUTF8))
self.label_3.setText(QtGui.QApplication.translate("MainWindow", "Seismogram Directory", None, QtGui.QApplication.UnicodeUTF8))
self.menuPreferences.setTitle(QtGui.QApplication.translate("MainWindow", "Preferences", None, QtGui.QApplication.UnicodeUTF8))
def generateSurvey(self):
obsdir = self.getObsdir()
self.survey = activeSeismoPick.Survey(self.getObsdir(), self.getSourcefile(), self.getReceiverfile(),
useDefaultParas = True)
def callPicker(self):
Picking_parameters = QtGui.QDialog(self.centralwidget)
ui = Ui_Picking_parameters()
ui.setupUi(Picking_parameters)
ncores, vmin, vmax, folm, AIC, aicwindow = ui.getParameters(Picking_parameters)
if AIC == True:
HosAic = 'aic'
else:
HosAic = 'hos'
if self.survey is None:
print('Survey not defined.')
return
self.survey.pickAllShots(vmin = vmin, vmax = vmax,
folm = folm, HosAic = HosAic,
aicwindow = aicwindow, cores = ncores)
class Ui_Picking_parameters(object):
def setupUi(self, Picking_parameters):
Picking_parameters.setObjectName("Picking_parameters")
Picking_parameters.resize(300, 300)
self.gridLayoutWidget = QtGui.QWidget(Picking_parameters)
self.gridLayoutWidget.setGeometry(QtCore.QRect(20, 20, 250, 211))
self.gridLayoutWidget.setObjectName("gridLayoutWidget")
self.gridLayout = QtGui.QGridLayout(self.gridLayoutWidget)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setObjectName("gridLayout")
self.label_cores = QtGui.QLabel(self.gridLayoutWidget)
self.label_cores.setObjectName("label_cores")
self.gridLayout.addWidget(self.label_cores, 0, 0, 1, 1)
self.label_vmax = QtGui.QLabel(self.gridLayoutWidget)
self.label_vmax.setObjectName("label_vmax")
self.gridLayout.addWidget(self.label_vmax, 2, 0, 1, 1)
self.label_vmin = QtGui.QLabel(self.gridLayoutWidget)
self.label_vmin.setObjectName("label_vmin")
self.gridLayout.addWidget(self.label_vmin, 1, 0, 1, 1)
self.lineEdit_ncores = QtGui.QLineEdit(self.gridLayoutWidget)
self.lineEdit_ncores.setObjectName("lineEdit_ncores")
self.gridLayout.addWidget(self.lineEdit_ncores, 0, 1, 1, 1)
self.lineEdit_vmin = QtGui.QLineEdit(self.gridLayoutWidget)
self.lineEdit_vmin.setObjectName("lineEdit_vmin")
self.gridLayout.addWidget(self.lineEdit_vmin, 1, 1, 1, 1)
self.lineEdit_vmax = QtGui.QLineEdit(self.gridLayoutWidget)
self.lineEdit_vmax.setObjectName("lineEdit_vmax")
self.gridLayout.addWidget(self.lineEdit_vmax, 2, 1, 1, 1)
self.checkBox = QtGui.QCheckBox(self.gridLayoutWidget)
self.checkBox.setObjectName("checkBox")
self.gridLayout.addWidget(self.checkBox, 4, 1, 1, 1)
self.label_folm = QtGui.QLabel(self.gridLayoutWidget)
self.label_folm.setObjectName("label_folm")
self.gridLayout.addWidget(self.label_folm, 3, 0, 1, 1)
self.label_aic = QtGui.QLabel(self.gridLayoutWidget)
self.label_aic.setObjectName("label_aic")
self.gridLayout.addWidget(self.label_aic, 4, 0, 1, 1)
self.lineEdit_folm = QtGui.QLineEdit(self.gridLayoutWidget)
self.lineEdit_folm.setObjectName("lineEdit_folm")
self.gridLayout.addWidget(self.lineEdit_folm, 3, 1, 1, 1)
self.label_aicwindow = QtGui.QLabel(self.gridLayoutWidget)
self.label_aicwindow.setObjectName("label_aicwindow")
self.gridLayout.addWidget(self.label_aicwindow, 5, 0, 1, 1)
self.lineEdit_aicwindow = QtGui.QLineEdit(self.gridLayoutWidget)
self.lineEdit_aicwindow.setObjectName("lineEdit_aicwindow")
self.gridLayout.addWidget(self.lineEdit_aicwindow, 5, 1, 1, 1)
self.buttonBox = QtGui.QDialogButtonBox(Picking_parameters)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.buttonBox.setGeometry(QtCore.QRect(10, 240, 250, 32))
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), Picking_parameters.accept)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), Picking_parameters.reject)
self.retranslateUi(Picking_parameters)
QtCore.QMetaObject.connectSlotsByName(Picking_parameters)
def getParameters(self, Picking_parameters):
if Picking_parameters.exec_():
ncores = int(self.lineEdit_ncores.text())
vmin = float(self.lineEdit_vmin.text())
vmax = float(self.lineEdit_vmax.text())
folm = float(self.lineEdit_folm.text())
AIC = self.checkBox.isChecked()
aicwindow = [float(val) for val in self.lineEdit_aicwindow.text().split(',')]
return ncores, vmin, vmax, folm, AIC, tuple(aicwindow)
def retranslateUi(self, Picking_parameters):
Picking_parameters.setWindowTitle(QtGui.QApplication.translate("Picking_parameters", "Picking_parameters", None, QtGui.QApplication.UnicodeUTF8))
self.label_cores.setText(QtGui.QApplication.translate("Picking_parameters", "Number of cores", None, QtGui.QApplication.UnicodeUTF8))
self.label_vmax.setText(QtGui.QApplication.translate("Picking_parameters", "Vmax (default = 5000m/s)", None, QtGui.QApplication.UnicodeUTF8))
self.label_vmin.setText(QtGui.QApplication.translate("Picking_parameters", "Vmin (default = 333 m/s)", None, QtGui.QApplication.UnicodeUTF8))
self.lineEdit_ncores.setText(QtGui.QApplication.translate("Picking_parameters", "1", None, QtGui.QApplication.UnicodeUTF8))
self.lineEdit_vmin.setText(QtGui.QApplication.translate("Picking_parameters", "333", None, QtGui.QApplication.UnicodeUTF8))
self.lineEdit_vmax.setText(QtGui.QApplication.translate("Picking_parameters", "5000", None, QtGui.QApplication.UnicodeUTF8))
self.label_folm.setText(QtGui.QApplication.translate("Picking_parameters", "Fraction of local maximum\n"
"(default = 0.6)", None, QtGui.QApplication.UnicodeUTF8))
self.label_aic.setText(QtGui.QApplication.translate("Picking_parameters", "AIC", None, QtGui.QApplication.UnicodeUTF8))
self.lineEdit_folm.setText(QtGui.QApplication.translate("Picking_parameters", "0.6", None, QtGui.QApplication.UnicodeUTF8))
self.label_aicwindow.setText(QtGui.QApplication.translate("Picking_parameters", "AIC window (only if AIC\n"
" is checked)", None, QtGui.QApplication.UnicodeUTF8))
self.lineEdit_aicwindow.setText(QtGui.QApplication.translate("Picking_parameters", "15, 0", None, QtGui.QApplication.UnicodeUTF8))
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
MainWindow = QtGui.QMainWindow()
ui = Ui_ActiveSeismoPick3D()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())

View File

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
__author__ = 'marcel'

View File

@ -0,0 +1,347 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from PySide import QtCore, QtGui
from generate_survey_layout import *
from generate_survey_layout_minimal import *
from generate_seisarray_layout import *
from pylot.core.active.gui.picking_parameters_layout import *
from pylot.core.active import surveyUtils
import numpy as np
import matplotlib
matplotlib.use('Qt4Agg')
matplotlib.rcParams['backend.qt4']='PySide'
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar
from matplotlib.figure import Figure
def getMaxCPU():
import multiprocessing
return multiprocessing.cpu_count()
class Gen_SeisArray(object):
def __init__(self, mainwindow):
self.mainwindow = mainwindow
self.seisarray = None
self.srcfile = None
self.recfile = None
self.ptsfile = None
self.init_dialog()
self.start_dialog()
def init_dialog(self):
qdialog = QtGui.QDialog(self.mainwindow)
ui = Ui_generate_seisarray()
ui.setupUi(qdialog)
self.ui = ui
self.qdialog = qdialog
self.connectButtons()
def start_dialog(self):
self.init_last_selection()
if self.qdialog.exec_():
self.refresh_filenames()
if self.ui.radioButton_interpolatable.isChecked():
self.seisarray = seismicArrayPreparation.SeisArray(self.recfile, True)
elif self.ui.radioButton_normal.isChecked():
self.seisarray = seismicArrayPreparation.SeisArray(self.recfile, False)
if len(self.srcfile) > 0:
self.seisarray.addSourceLocations(self.srcfile)
if len(self.ptsfile) > 0:
self.seisarray.addMeasuredTopographyPoints(self.ptsfile)
self.executed = True
else:
self.refresh_filenames()
self.executed = False
def refresh_filenames(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
def connectButtons(self):
QtCore.QObject.connect(self.ui.pushButton_rec, QtCore.SIGNAL("clicked()"), self.chooseMeasuredRec)
QtCore.QObject.connect(self.ui.pushButton_src, QtCore.SIGNAL("clicked()"), self.chooseMeasuredSrc)
QtCore.QObject.connect(self.ui.pushButton_obs, QtCore.SIGNAL("clicked()"), self.chooseMeasuredPts)
def chooseMeasuredSrc(self):
self.ui.lineEdit_src.setText(openFile('Open measured sources file.'))
def chooseMeasuredRec(self):
self.ui.lineEdit_rec.setText(openFile('Open measured receivers file.'))
def chooseMeasuredPts(self):
self.ui.lineEdit_pts.setText(openFile('Open measured points file.'))
class Gen_Survey_from_SA(object):
def __init__(self, mainwindow, seisarray):
self.mainwindow = mainwindow
self.seisarray = seisarray
self.survey = None
self.obsdir = None
self.fstart = 'shot'
self.fend = '.dat'
self.init_dialog()
self.start_dialog()
def init_dialog(self):
qdialog = QtGui.QDialog(self.mainwindow)
ui = Ui_generate_survey_minimal()
ui.setupUi(qdialog)
self.ui = ui
self.qdialog = qdialog
self.connectButtons()
def start_dialog(self):
self.init_last_selection()
if self.qdialog.exec_():
self.refresh_filenames()
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.executed = False
def refresh_filenames(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
def connectButtons(self):
QtCore.QObject.connect(self.ui.pushButton_obs, QtCore.SIGNAL("clicked()"), self.chooseObsdir)
def chooseObsdir(self):
self.ui.lineEdit_obs.setText(browseDir('Choose observation directory.'))
class Gen_Survey_from_SR(object):
def __init__(self, mainwindow):
self.mainwindow = mainwindow
self.survey = None
self.obsdir = None
self.srcfile = None
self.recfile = None
self.fstart = 'shot'
self.fend = '.dat'
self.init_dialog()
self.start_dialog()
def init_dialog(self):
qdialog = QtGui.QDialog(self.mainwindow)
ui = Ui_generate_survey()
ui.setupUi(qdialog)
self.ui = ui
self.qdialog = qdialog
self.connectButtons()
def start_dialog(self):
self.init_last_selection()
if self.qdialog.exec_():
self.refresh_filenames()
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.executed = False
def refresh_filenames(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
def connectButtons(self):
QtCore.QObject.connect(self.ui.pushButton_obs, QtCore.SIGNAL("clicked()"), self.chooseObsdir)
QtCore.QObject.connect(self.ui.pushButton_src, QtCore.SIGNAL("clicked()"), self.chooseSourcefile)
QtCore.QObject.connect(self.ui.pushButton_rec, QtCore.SIGNAL("clicked()"), self.chooseRecfile)
def chooseObsdir(self):
self.ui.lineEdit_obs.setText(browseDir('Choose observation directory.'))
def chooseSourcefile(self):
self.ui.lineEdit_src.setText(openFile('Open sourcefile.'))
def chooseRecfile(self):
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.init_dialog()
self.refresh_selection()
self.start_dialog()
def init_dialog(self):
qdialog = QtGui.QDialog(self.mainwindow)
ui = Ui_picking_parameters()
ui.setupUi(qdialog)
ui.ncores.setMaximum(getMaxCPU())
self.ui = ui
self.qdialog = qdialog
self.initDynSNRplot()
self.connectButtons()
def getMaxSRdist(self):
if self.maxSRdist is not None:
return self.maxSRdist
else:
SRdists = []
for shot in self.survey.data.values():
for traceID in shot.getTraceIDlist():
SRdists.append(shot.getDistance(traceID))
self.maxSRdist = max(SRdists)
return self.maxSRdist
def initDynSNRplot(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):
fig = self.snrFig
if fig.axes == []:
ax = fig.add_subplot(111)
xlim = None
ylim = None
else:
ax = fig.axes[0]
xlim = ax.get_xlim()
ylim = ax.get_ylim()
ax.clear()
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.snrCanvas.draw()
def start_dialog(self):
self.init_last_selection()
self.plotDynSNR()
if self.qdialog.exec_():
self.refresh_selection()
if self.AIC == True:
HosAic = 'aic'
else:
HosAic = 'hos'
surveyUtils.setDynamicFittedSNR(self.survey.getShotDict(), shiftdist = self.shiftDist,
shiftSNR = self.shiftSNR, p1 = self.p1, p2 = self.p2)
self.survey.pickAllShots(vmin = self.vmin, vmax = self.vmax,
folm = self.folm/100., HosAic = HosAic,
aicwindow = self.aicwindow, cores = self.ncores)
#QtGui.qApp.processEvents() # test
self.executed = True
else:
self.refresh_selection()
self.executed = False
def refreshFolm(self):
self.ui.label_folm.setText('%s %%'%self.ui.slider_folm.value())
def refresh_selection(self):
self.ncores = int(self.ui.ncores.value())
self.vmin = float(self.ui.lineEdit_vmin.text())
self.vmax = float(self.ui.lineEdit_vmax.text())
self.folm = float(self.ui.slider_folm.value())
self.AIC = self.ui.checkBox_AIC.isChecked()
self.aicwindow = (int(self.ui.lineEdit_aicleft.text()), int(self.ui.lineEdit_aicright.text()))
self.shiftSNR = float(self.ui.shift_snr.value())
self.shiftDist = float(self.ui.shift_dist.value())
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 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)
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)
def chooseObsdir(self):
self.ui.lineEdit_obs.setText(browseDir('Choose observation directory.'))
def chooseSourcefile(self):
self.ui.lineEdit_src.setText(openFile('Open sourcefile.'))
def chooseRecfile(self):
self.ui.lineEdit_rec.setText(openFile('Open receiverfile.'))

View File

@ -507,7 +507,7 @@ class SeisArray(object):
self.surface2VTK(interf2, filename='interface2.vtk')
self.receivers2VTK()
self.sources2VTK()
fmtomoUtils.vgrids2VTK()
#fmtomoUtils.vgrids2VTK()
def generateReceiversIn(self, outfilename='receivers.in'):
outfile = open(outfilename, 'w')