zooming for 3-component window changed now zooming is done by using the mouse wheel
bugfix: calculation of the snr corrected
This commit is contained in:
parent
67dd66535a
commit
7816e6342f
@ -293,7 +293,8 @@ def getSNR(X, TSNR, t1):
|
|||||||
'''
|
'''
|
||||||
Function to calculate SNR of certain part of seismogram relative to
|
Function to calculate SNR of certain part of seismogram relative to
|
||||||
given time (onset) out of given noise and signal windows. A safety gap
|
given time (onset) out of given noise and signal windows. A safety gap
|
||||||
between noise and signal part can be set. Returns SNR and SNR [dB].
|
between noise and signal part can be set. Returns SNR and SNR [dB] and
|
||||||
|
noiselevel.
|
||||||
|
|
||||||
:param: X, time series (seismogram)
|
:param: X, time series (seismogram)
|
||||||
:type: `~obspy.core.stream.Stream`
|
:type: `~obspy.core.stream.Stream`
|
||||||
@ -324,9 +325,10 @@ def getSNR(X, TSNR, t1):
|
|||||||
return
|
return
|
||||||
|
|
||||||
#calculate ratios
|
#calculate ratios
|
||||||
noiselevel = np.mean(abs(x[inoise]))
|
noiselevel = np.sqrt(np.mean(np.square(x[inoise])))
|
||||||
SNR = max(abs(x[isignal])) / noiselevel
|
signallevel = np.sqrt(np.mean(np.square(x[isignal])))
|
||||||
SNRdB = 20 * np.log10(SNR)
|
SNR = signallevel / noiselevel
|
||||||
|
SNRdB = 10 * np.log10(SNR)
|
||||||
|
|
||||||
return SNR, SNRdB, noiselevel
|
return SNR, SNRdB, noiselevel
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ from PySide.QtWebKit import QWebView
|
|||||||
from obspy import Stream, UTCDateTime
|
from obspy import Stream, UTCDateTime
|
||||||
from obspy.core.event import Pick, WaveformStreamID
|
from obspy.core.event import Pick, WaveformStreamID
|
||||||
from pylot.core.read import FilterOptions
|
from pylot.core.read import FilterOptions
|
||||||
from pylot.core.pick.utils import getSNR
|
from pylot.core.pick.utils import getSNR, earllatepicker
|
||||||
from pylot.core.util.defaults import OUTPUTFORMATS
|
from pylot.core.util.defaults import OUTPUTFORMATS
|
||||||
from pylot.core.util import prepTimeAxis, getGlobalTimes
|
from pylot.core.util import prepTimeAxis, getGlobalTimes
|
||||||
|
|
||||||
@ -85,7 +85,8 @@ class MPLWidget(FigureCanvas):
|
|||||||
def setParent(self, parent):
|
def setParent(self, parent):
|
||||||
self._parent = parent
|
self._parent = parent
|
||||||
|
|
||||||
def plotWFData(self, wfdata, title=None, zoomx=None, zoomy=None):
|
def plotWFData(self, wfdata, title=None, zoomx=None, zoomy=None,
|
||||||
|
noiselevel=None):
|
||||||
self.axes.cla()
|
self.axes.cla()
|
||||||
self.clearPlotDict()
|
self.clearPlotDict()
|
||||||
wfstart = getGlobalTimes(wfdata)[0]
|
wfstart = getGlobalTimes(wfdata)[0]
|
||||||
@ -100,6 +101,11 @@ class MPLWidget(FigureCanvas):
|
|||||||
trace.detrend('demean')
|
trace.detrend('demean')
|
||||||
trace.normalize(trace.data.max() * 2)
|
trace.normalize(trace.data.max() * 2)
|
||||||
self.axes.plot(time_ax, trace.data + n, 'k')
|
self.axes.plot(time_ax, trace.data + n, 'k')
|
||||||
|
if noiselevel is not None:
|
||||||
|
self.axes.plot([time_ax[0], time_ax[-1]],
|
||||||
|
[noiselevel, noiselevel], '--k')
|
||||||
|
self.axes.plot([time_ax[0], time_ax[-1]],
|
||||||
|
[-noiselevel, -noiselevel], '--k')
|
||||||
xlabel = 'seconds since {0}'.format(wfstart)
|
xlabel = 'seconds since {0}'.format(wfstart)
|
||||||
ylabel = ''
|
ylabel = ''
|
||||||
self.updateWidget(xlabel, ylabel, title)
|
self.updateWidget(xlabel, ylabel, title)
|
||||||
@ -381,6 +387,11 @@ class PickDlg(QDialog):
|
|||||||
self.disconnectScrollEvent()
|
self.disconnectScrollEvent()
|
||||||
self.disconnectMotionEvent()
|
self.disconnectMotionEvent()
|
||||||
self.reconnectPressEvent(self.setIniPick)
|
self.reconnectPressEvent(self.setIniPick)
|
||||||
|
else:
|
||||||
|
self.cidpress = self.connectPressEvent(self.panPress)
|
||||||
|
self.cidmotion = self.connectMotionEvent()
|
||||||
|
self.cidrelease = self.connectReleaseEvent()
|
||||||
|
self.cidscroll = self.connectScrollEvent()
|
||||||
|
|
||||||
def getComponents(self):
|
def getComponents(self):
|
||||||
return self.components
|
return self.components
|
||||||
@ -446,7 +457,7 @@ class PickDlg(QDialog):
|
|||||||
'VLRW' : 15.
|
'VLRW' : 15.
|
||||||
}
|
}
|
||||||
|
|
||||||
result = getSNR(wfdata, (10., 2., 1.5), ini_pick)
|
result = getSNR(wfdata, (5., .5, 1.), ini_pick)
|
||||||
|
|
||||||
snr = result[0]
|
snr = result[0]
|
||||||
noiselevel = result[2] * 1.5
|
noiselevel = result[2] * 1.5
|
||||||
@ -467,19 +478,32 @@ class PickDlg(QDialog):
|
|||||||
title=self.getStation() +
|
title=self.getStation() +
|
||||||
' picking mode',
|
' picking mode',
|
||||||
zoomx=zoomx,
|
zoomx=zoomx,
|
||||||
zoomy=zoomy)
|
zoomy=zoomy,
|
||||||
|
noiselevel=noiselevel)
|
||||||
|
|
||||||
self.updateAPD(wfdata)
|
self.updateAPD(wfdata)
|
||||||
|
|
||||||
# reset labels
|
# reset labels
|
||||||
self.setPlotLabels()
|
self.setPlotLabels()
|
||||||
|
|
||||||
def setPick(self, gui_event):
|
def setPick(self, gui_event):
|
||||||
pick = gui_event.xdata
|
# setting pick
|
||||||
|
pick = gui_event.xdata # get pick time relative to the traces timeaxis not to the global
|
||||||
|
channel = self.getChannelID(round(gui_event.ydata))
|
||||||
|
|
||||||
|
wfdata = self.getAPD().copy().select(channel=channel)
|
||||||
|
# get earliest and latest possible pick
|
||||||
|
[epp, lpp, pickerror] = earllatepicker(wfdata, 1.5, (5., .5, 1.), pick, 1)
|
||||||
|
|
||||||
|
# plotting picks
|
||||||
ax = self.getPlotWidget().axes
|
ax = self.getPlotWidget().axes
|
||||||
|
|
||||||
ylims = ax.get_ylim()
|
ylims = ax.get_ylim()
|
||||||
|
|
||||||
ax.plot([pick, pick], ylims, 'r--')
|
ax.plot([pick, pick], ylims, 'r--')
|
||||||
|
ax.plot([epp, epp], ylims, 'c--')
|
||||||
|
ax.plot([lpp, lpp], ylims, 'm--')
|
||||||
|
|
||||||
self.getPlotWidget().draw()
|
self.getPlotWidget().draw()
|
||||||
|
|
||||||
def panPress(self, gui_event):
|
def panPress(self, gui_event):
|
||||||
|
Loading…
Reference in New Issue
Block a user