added SNR modification/plot

This commit is contained in:
Marcel Paffrath 2016-07-14 13:59:52 +02:00
parent 6ad78acc85
commit 8ee075c2b1
9 changed files with 148 additions and 28 deletions

View File

@ -111,7 +111,6 @@ class gui_control(object):
def initNewSurvey(self):
self.survey.setArtificialPick(0, 0) # artificial pick at source origin
surveyUtils.setDynamicFittedSNR(self.survey.getShotDict())
self.setSurveyState(True)
self.setPickState(False)
@ -147,7 +146,9 @@ class gui_control(object):
self.survey = activeSeismoPick.Survey(obsdir, srcfile, recfile,
useDefaultParas = True,
fstart = fstart, fend = fend)
self.setConnected2SurveyState(False)
self.setConnected2SurveyState(True)
self.seisarray = self.survey.seisarray
self.setSeisArrayState(True)
return True
def addArrayPlot(self):
@ -313,11 +314,15 @@ 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
@ -358,6 +363,10 @@ class gui_control(object):
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:
@ -368,12 +377,55 @@ class gui_control(object):
else:
HosAic = 'hos'
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
self.setPickState(True)
self.printSurveyTextbox(init = False)
def plotDynSNR(self):
fig = self.snrFig
fig.clear()
ax = fig.add_subplot(111)
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)
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')
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.')

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'asp3d_layout.ui'
#
# Created: Tue Jul 12 21:41:12 2016
# Created: Thu Jul 14 13:36:37 2016
# by: pyside-uic 0.2.15 running on PySide 1.2.2
#
# WARNING! All changes made in this file will be lost!

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'fmtomo_parameters_layout.ui'
#
# Created: Tue Jul 12 21:41:12 2016
# Created: Thu Jul 14 13:36:37 2016
# by: pyside-uic 0.2.15 running on PySide 1.2.2
#
# WARNING! All changes made in this file will be lost!

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'generate_seisarray_layout.ui'
#
# Created: Tue Jul 12 21:41:13 2016
# Created: Thu Jul 14 13:36:38 2016
# by: pyside-uic 0.2.15 running on PySide 1.2.2
#
# WARNING! All changes made in this file will be lost!

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'generate_survey_layout.ui'
#
# Created: Tue Jul 12 21:41:13 2016
# Created: Thu Jul 14 13:36:38 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_generate_survey(object):
def setupUi(self, generate_survey):
generate_survey.setObjectName("generate_survey")
generate_survey.resize(382, 211)
generate_survey.resize(382, 220)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap("../asp3d_icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
generate_survey.setWindowIcon(icon)
@ -50,6 +50,11 @@ class Ui_generate_survey(object):
self.verticalLayout_2.addLayout(self.gridLayout)
self.verticalLayout = QtGui.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout")
self.line_2 = QtGui.QFrame(generate_survey)
self.line_2.setFrameShape(QtGui.QFrame.HLine)
self.line_2.setFrameShadow(QtGui.QFrame.Sunken)
self.line_2.setObjectName("line_2")
self.verticalLayout.addWidget(self.line_2)
self.label = QtGui.QLabel(generate_survey)
self.label.setObjectName("label")
self.verticalLayout.addWidget(self.label)

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'generate_survey_layout_minimal.ui'
#
# Created: Tue Jul 12 21:41:13 2016
# Created: Thu Jul 14 13:36:38 2016
# by: pyside-uic 0.2.15 running on PySide 1.2.2
#
# WARNING! All changes made in this file will be lost!

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'picking_parameters_layout.ui'
#
# Created: Tue Jul 12 21:41:13 2016
# Created: Thu Jul 14 13:36:38 2016
# by: pyside-uic 0.2.15 running on PySide 1.2.2
#
# WARNING! All changes made in this file will be lost!
@ -12,10 +12,10 @@ from PySide import QtCore, QtGui
class Ui_picking_parameters(object):
def setupUi(self, picking_parameters):
picking_parameters.setObjectName("picking_parameters")
picking_parameters.resize(321, 254)
picking_parameters.setMinimumSize(QtCore.QSize(0, 0))
self.verticalLayout_3 = QtGui.QVBoxLayout(picking_parameters)
self.verticalLayout_3.setObjectName("verticalLayout_3")
picking_parameters.resize(400, 550)
picking_parameters.setMinimumSize(QtCore.QSize(0, 550))
self.verticalLayout_4 = QtGui.QVBoxLayout(picking_parameters)
self.verticalLayout_4.setObjectName("verticalLayout_4")
self.label_7 = QtGui.QLabel(picking_parameters)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
@ -28,7 +28,7 @@ class Ui_picking_parameters(object):
font.setBold(True)
self.label_7.setFont(font)
self.label_7.setObjectName("label_7")
self.verticalLayout_3.addWidget(self.label_7)
self.verticalLayout_4.addWidget(self.label_7)
self.horizontalLayout = QtGui.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.label = QtGui.QLabel(picking_parameters)
@ -45,7 +45,7 @@ class Ui_picking_parameters(object):
self.ncores.setMaximum(10000)
self.ncores.setObjectName("ncores")
self.horizontalLayout.addWidget(self.ncores)
self.verticalLayout_3.addLayout(self.horizontalLayout)
self.verticalLayout_4.addLayout(self.horizontalLayout)
self.horizontalLayout_3 = QtGui.QHBoxLayout()
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
self.verticalLayout_2 = QtGui.QVBoxLayout()
@ -78,7 +78,7 @@ class Ui_picking_parameters(object):
self.lineEdit_vmax.setObjectName("lineEdit_vmax")
self.verticalLayout.addWidget(self.lineEdit_vmax)
self.horizontalLayout_3.addLayout(self.verticalLayout)
self.verticalLayout_3.addLayout(self.horizontalLayout_3)
self.verticalLayout_4.addLayout(self.horizontalLayout_3)
self.horizontalLayout_4 = QtGui.QHBoxLayout()
self.horizontalLayout_4.setObjectName("horizontalLayout_4")
self.label_4 = QtGui.QLabel(picking_parameters)
@ -110,7 +110,7 @@ class Ui_picking_parameters(object):
self.label_folm.setObjectName("label_folm")
self.horizontalLayout_2.addWidget(self.label_folm)
self.horizontalLayout_4.addLayout(self.horizontalLayout_2)
self.verticalLayout_3.addLayout(self.horizontalLayout_4)
self.verticalLayout_4.addLayout(self.horizontalLayout_4)
self.horizontalLayout_5 = QtGui.QHBoxLayout()
self.horizontalLayout_5.setObjectName("horizontalLayout_5")
self.label_5 = QtGui.QLabel(picking_parameters)
@ -126,7 +126,7 @@ class Ui_picking_parameters(object):
self.checkBox_AIC.setChecked(True)
self.checkBox_AIC.setObjectName("checkBox_AIC")
self.horizontalLayout_5.addWidget(self.checkBox_AIC)
self.verticalLayout_3.addLayout(self.horizontalLayout_5)
self.verticalLayout_4.addLayout(self.horizontalLayout_5)
self.horizontalLayout_6 = QtGui.QHBoxLayout()
self.horizontalLayout_6.setObjectName("horizontalLayout_6")
self.label_6 = QtGui.QLabel(picking_parameters)
@ -148,12 +148,67 @@ class Ui_picking_parameters(object):
self.lineEdit_aicright.setObjectName("lineEdit_aicright")
self.horizontalLayout_7.addWidget(self.lineEdit_aicright)
self.horizontalLayout_6.addLayout(self.horizontalLayout_7)
self.verticalLayout_3.addLayout(self.horizontalLayout_6)
self.verticalLayout_4.addLayout(self.horizontalLayout_6)
self.verticalLayout_snr = QtGui.QVBoxLayout()
self.verticalLayout_snr.setObjectName("verticalLayout_snr")
self.line = QtGui.QFrame(picking_parameters)
self.line.setFrameShape(QtGui.QFrame.HLine)
self.line.setFrameShadow(QtGui.QFrame.Sunken)
self.line.setObjectName("line")
self.verticalLayout_snr.addWidget(self.line)
self.label_8 = QtGui.QLabel(picking_parameters)
self.label_8.setObjectName("label_8")
self.verticalLayout_snr.addWidget(self.label_8)
self.gridLayout_2 = QtGui.QGridLayout()
self.gridLayout_2.setObjectName("gridLayout_2")
self.label_9 = QtGui.QLabel(picking_parameters)
self.label_9.setObjectName("label_9")
self.gridLayout_2.addWidget(self.label_9, 1, 0, 1, 1)
self.label_10 = QtGui.QLabel(picking_parameters)
self.label_10.setObjectName("label_10")
self.gridLayout_2.addWidget(self.label_10, 2, 0, 1, 1)
self.p1 = QtGui.QDoubleSpinBox(picking_parameters)
self.p1.setDecimals(6)
self.p1.setMinimum(-100.0)
self.p1.setMaximum(100.0)
self.p1.setSingleStep(0.0001)
self.p1.setProperty("value", 0.004)
self.p1.setObjectName("p1")
self.gridLayout_2.addWidget(self.p1, 2, 1, 1, 1)
self.label_11 = QtGui.QLabel(picking_parameters)
self.label_11.setObjectName("label_11")
self.gridLayout_2.addWidget(self.label_11, 1, 2, 1, 1)
self.label_12 = QtGui.QLabel(picking_parameters)
self.label_12.setObjectName("label_12")
self.gridLayout_2.addWidget(self.label_12, 2, 2, 1, 1)
self.p2 = QtGui.QDoubleSpinBox(picking_parameters)
self.p2.setDecimals(6)
self.p2.setMinimum(-100.0)
self.p2.setMaximum(100.0)
self.p2.setSingleStep(0.0001)
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.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.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)
self.vlayout_plot = QtGui.QVBoxLayout()
self.vlayout_plot.setObjectName("vlayout_plot")
self.verticalLayout_4.addLayout(self.vlayout_plot)
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.verticalLayout_3.addWidget(self.buttonBox)
self.verticalLayout_4.addWidget(self.buttonBox)
self.retranslateUi(picking_parameters)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), picking_parameters.accept)
@ -167,7 +222,7 @@ class Ui_picking_parameters(object):
self.label.setText(QtGui.QApplication.translate("picking_parameters", "nproc [?]", None, QtGui.QApplication.UnicodeUTF8))
self.label_2.setToolTip(QtGui.QApplication.translate("picking_parameters", "Minimum permitted direct velocity (apparent velocity!).", None, QtGui.QApplication.UnicodeUTF8))
self.label_2.setText(QtGui.QApplication.translate("picking_parameters", "vmin [m/s] [?]", None, QtGui.QApplication.UnicodeUTF8))
self.lineEdit_vmin.setText(QtGui.QApplication.translate("picking_parameters", "333", None, QtGui.QApplication.UnicodeUTF8))
self.lineEdit_vmin.setText(QtGui.QApplication.translate("picking_parameters", "100", None, QtGui.QApplication.UnicodeUTF8))
self.label_3.setToolTip(QtGui.QApplication.translate("picking_parameters", "Maximum permitted direct velocity (apparent velocity!).", None, QtGui.QApplication.UnicodeUTF8))
self.label_3.setText(QtGui.QApplication.translate("picking_parameters", "vmax [m/s] [?]", None, QtGui.QApplication.UnicodeUTF8))
self.lineEdit_vmax.setText(QtGui.QApplication.translate("picking_parameters", "5000", None, QtGui.QApplication.UnicodeUTF8))
@ -181,4 +236,9 @@ 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_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))
self.label_12.setText(QtGui.QApplication.translate("picking_parameters", "p2", None, QtGui.QApplication.UnicodeUTF8))

View File

@ -1,5 +1,5 @@
from __future__ import print_function
import numpy as np
def readParameters(parfile, parameter):
"""
@ -90,10 +90,9 @@ def setDynamicFittedSNR(shot_dict, shiftdist=30, shiftSNR=100, p1=0.004, p2=-0.0
:type p2: float
:return:
"""
import numpy as np
minSNR = 2.5
# fit_fn = fitSNR4dist(shot_dict)
fit_fn = np.poly1d([p1, p2])
fit_fn = get_fit_fn(p1, p2)
for shot in shot_dict.values():
for traceID in shot.getTraceIDlist(): ### IMPROVE
dist = shot.getDistance(traceID) + shiftdist
@ -104,13 +103,17 @@ def setDynamicFittedSNR(shot_dict, shiftdist=30, shiftSNR=100, p1=0.004, p2=-0.0
shot.setSNRthreshold(traceID, minSNR)
else:
shot.setSNRthreshold(traceID, snrthreshold)
print("setDynamicFittedSNR: Finished setting of fitted SNR-threshold")
print("setDynamicFittedSNR: Finished setting of fitted SNR-threshold.\n"
"Parameters: ShiftDist = %s, ShiftSNR = %s, p1 = %s, p2 = %s"
%(shiftdist, shiftSNR, p1, p2))
def snr_fit_func(fit_fn, dist, shiftSNR):
import numpy as np
snrthreshold = (1 / (fit_fn(dist) ** 2)) - shiftSNR * np.exp(-0.05 * dist)
return snrthreshold
def get_fit_fn(p1, p2):
return np.poly1d([p1, p2])
def setConstantSNR(shot_dict, snrthreshold=2.5):
"""
Set a constant SNR value to all Seismicshots in a dictionary (e.g. survey.getShotDict()).

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'vtk_tools_layout.ui'
#
# Created: Tue Jul 12 21:41:13 2016
# Created: Thu Jul 14 13:36:38 2016
# by: pyside-uic 0.2.15 running on PySide 1.2.2
#
# WARNING! All changes made in this file will be lost!