bugfix: undo filtering when checkbox is unchecked

code improvement: class PickDlg -> distinguish between setting the initial pick (for zooming) and setting the actual pick (phase onset); methods renamed -> setPick is now setIniPick and plotPick became setPick
This commit is contained in:
Sebastian Wehling-Benatelli 2015-04-06 11:42:21 +02:00
parent b243be8075
commit 043c45e02c
2 changed files with 32 additions and 16 deletions

View File

@ -376,6 +376,7 @@ class MainWindow(QMainWindow):
title = 'overview: {0} components'.format(zne_text[comp]) title = 'overview: {0} components'.format(zne_text[comp])
wfst = self.getData().getWFData().select(component=comp) wfst = self.getData().getWFData().select(component=comp)
self.getPlotWidget().plotWFData(wfdata=wfst, title=title) self.getPlotWidget().plotWFData(wfdata=wfst, title=title)
self.getPlotWidget().draw()
pos = self.getPlotWidget().getPlotDict().keys() pos = self.getPlotWidget().getPlotDict().keys()
labels = [int(act) for act in pos] labels = [int(act) for act in pos]
self.getPlotWidget().setYTickLabels(pos, labels) self.getPlotWidget().setYTickLabels(pos, labels)

View File

@ -22,7 +22,7 @@ from PySide.QtGui import QAction, QApplication,QComboBox, QDateTimeEdit,\
from PySide.QtCore import QSettings, Qt, QUrl, Signal, Slot from PySide.QtCore import QSettings, Qt, QUrl, Signal, Slot
from PySide.QtWebKit import QWebView from PySide.QtWebKit import QWebView
from obspy import Stream, UTCDateTime from obspy import Stream, UTCDateTime
from obspy.core.event import Pick 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
from pylot.core.util.defaults import OUTPUTFORMATS from pylot.core.util.defaults import OUTPUTFORMATS
@ -262,12 +262,13 @@ class PickDlg(QDialog):
# plot data # plot data
self.getPlotWidget().plotWFData(wfdata=self.getWFData(), self.getPlotWidget().plotWFData(wfdata=self.getWFData(),
title=self.getStation()) title=self.getStation())
self.apd = self.getWFData()
# set plot labels # set plot labels
self.setPlotLabels() self.setPlotLabels()
# connect button press event to an action # connect button press event to an action
self.cid = self.getPlotWidget().mpl_connect('button_press_event', self.setPick) self.cid = self.getPlotWidget().mpl_connect('button_press_event', self.setIniPick)
def setupUi(self): def setupUi(self):
@ -279,7 +280,8 @@ class PickDlg(QDialog):
self.filterAction = createAction(parent=self, text='Filter', self.filterAction = createAction(parent=self, text='Filter',
slot=self.filterWFData, slot=self.filterWFData,
icon=filter_icon, icon=filter_icon,
tip='Filter waveforms', tip='Toggle filtered/original'
' waveforms',
checkable=True) checkable=True)
self.selectPhase = QComboBox() self.selectPhase = QComboBox()
self.selectPhase.addItems(['Pn', 'Pg', 'P1', 'P2']) self.selectPhase.addItems(['Pn', 'Pg', 'P1', 'P2'])
@ -344,7 +346,13 @@ class PickDlg(QDialog):
def getPicks(self): def getPicks(self):
return self.picks return self.picks
def setPick(self, gui_event): def getAPD(self):
return self.apd
def updateAPD(self, wfdata):
self.apd = wfdata
def setIniPick(self, gui_event):
channel = self.getChannelID(round(gui_event.ydata)) channel = self.getChannelID(round(gui_event.ydata))
wfdata = self.selectWFData(channel) wfdata = self.selectWFData(channel)
@ -363,7 +371,7 @@ class PickDlg(QDialog):
'VLRW' : 15. 'VLRW' : 15.
} }
result = getSNR(wfdata, (5,.5,1), 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
@ -385,15 +393,16 @@ class PickDlg(QDialog):
' picking mode', ' picking mode',
zoomx=zoomx, zoomx=zoomx,
zoomy=zoomy) zoomy=zoomy)
self.updateAPD(wfdata)
self.getPlotWidget().axes.plot() self.getPlotWidget().axes.plot()
# reset labels # reset labels
self.setPlotLabels() self.setPlotLabels()
self.reconnect('button_press_event', self.plotPick) self.reconnect('button_press_event', self.setPick)
def plotPick(self, gui_event): def setPick(self, gui_event):
pick = gui_event.xdata pick = gui_event.xdata
ax = self.getPlotWidget().axes ax = self.getPlotWidget().axes
@ -403,9 +412,18 @@ class PickDlg(QDialog):
self.getPlotWidget().draw() self.getPlotWidget().draw()
def filterWFData(self): def filterWFData(self):
data = self.getWFData().copy().filter(type='bandpass', freqmin=.5, freqmax=15.) ax = self.getPlotWidget().axes
title = self.getStation() + ' (filtered)' ylims = ax.get_ylim()
self.getPlotWidget().plotWFData(wfdata=data, title=title) xlims = ax.get_xlim()
if self.filterAction.isChecked():
data = self.getAPD().copy()
data.filter(type='bandpass', freqmin=.5, freqmax=15.)
title = self.getStation() + ' (filtered)'
else:
data = self.getAPD().copy()
title = self.getStation()
self.getPlotWidget().plotWFData(wfdata=data, title=title, zoomx=xlims,
zoomy=ylims)
self.setPlotLabels() self.setPlotLabels()
def setPlotLabels(self): def setPlotLabels(self):
@ -418,12 +436,9 @@ class PickDlg(QDialog):
self.getPlotWidget().setYTickLabels(pos, labels) self.getPlotWidget().setYTickLabels(pos, labels)
def apply(self): def apply(self):
if self.getPicks(): picks = self.getPicks()
for phase, time in self.getPicks().iteritems(): for pick in picks:
ope_pick = Pick() print pick
ope_pick.time = time
ope_pick.phase_hint = phase
print ope_pick
def reject(self): def reject(self):
QDialog.reject(self) QDialog.reject(self)