From ac99ec8a7614286e6b1da6ad5adec99faac37230 Mon Sep 17 00:00:00 2001 From: Sebastian Wehling-Benatelli Date: Wed, 24 Jun 2015 09:24:21 +0200 Subject: [PATCH 1/4] added static method to the FilterOptionsDialog in order to be able to directly get an filter object without having to create an dialog object in advance explicitly --- pylot/core/util/widgets.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index e69b2a92..a5e61da5 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -978,6 +978,13 @@ class FilterOptionsDialog(QDialog): def getFilterOptions(self): return self.filterOptions + @staticmethod + def getFilterObject(): + dlg = FilterOptionsDialog() + if dlg.exec_(): + return dlg.getFilterOptions() + return None + def accept(self): self.updateUi() QDialog.accept(self) From 8dd100792e164b438027d9dd336668d4aebca76c Mon Sep 17 00:00:00 2001 From: Sebastian Wehling-Benatelli Date: Wed, 24 Jun 2015 14:30:48 +0200 Subject: [PATCH 2/4] [bugfix] obspy filter function do not use order but corners as parameter name (keyword changed for argument parser) --- pylot/core/read/inputs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylot/core/read/inputs.py b/pylot/core/read/inputs.py index a4cdc3c9..a59ef071 100644 --- a/pylot/core/read/inputs.py +++ b/pylot/core/read/inputs.py @@ -209,7 +209,7 @@ class FilterOptions(object): def parseFilterOptions(self): if self.getFilterType(): robject = {'type':self.getFilterType()} - robject['order'] = self.getOrder() + robject['corners'] = self.getOrder() if len(self.getFreq()) > 1: robject['freqmin'] = self.getFreq()[0] robject['freqmax'] = self.getFreq()[1] From 0d3fb8be9381cf51f205b399db083646ff203c1b Mon Sep 17 00:00:00 2001 From: Sebastian Wehling-Benatelli Date: Wed, 24 Jun 2015 14:31:43 +0200 Subject: [PATCH 3/4] [bugfix] false indentation corrected (broken program logic fixed) --- pylot/core/util/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pylot/core/util/utils.py b/pylot/core/util/utils.py index 0c8a863e..3f2ba611 100644 --- a/pylot/core/util/utils.py +++ b/pylot/core/util/utils.py @@ -93,9 +93,9 @@ def getGlobalTimes(stream): for trace in stream: if trace.stats.starttime < min_start: min_start = trace.stats.starttime - if max_end is None or trace.stats.endtime > max_end: - max_end = trace.stats.endtime - return [min_start, max_end] + if max_end is None or trace.stats.endtime > max_end: + max_end = trace.stats.endtime + return min_start, max_end def createCreationInfo(agency_id=None, creation_time=None, author=None): From c840e07635c422167f41c25c98d0e2373d02039a Mon Sep 17 00:00:00 2001 From: Sebastian Wehling-Benatelli Date: Wed, 24 Jun 2015 14:33:19 +0200 Subject: [PATCH 4/4] filtering of the waveform in the picking window implemented (work in progress, still bugs inside which have to be located and fixed) --- pylot/core/util/widgets.py | 41 ++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index a5e61da5..9cb326a0 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -23,10 +23,9 @@ from PySide.QtGui import QAction, QApplication, QComboBox, QDateTimeEdit, \ from PySide.QtCore import QSettings, Qt, QUrl, Signal, Slot from PySide.QtWebKit import QWebView from obspy import Stream, UTCDateTime -from obspy.core.event import Pick, WaveformStreamID from pylot.core.read import FilterOptions from pylot.core.pick.utils import getSNR, earllatepicker, getnoisewin -from pylot.core.util.defaults import OUTPUTFORMATS +from pylot.core.util.defaults import OUTPUTFORMATS, FILTERDEFAULTS from pylot.core.util import prepTimeAxis, getGlobalTimes @@ -90,7 +89,7 @@ class MPLWidget(FigureCanvas): noiselevel=None): self.getAxes().cla() self.clearPlotDict() - wfstart = getGlobalTimes(wfdata)[0] + wfstart, wfend = getGlobalTimes(wfdata) for n, trace in enumerate(wfdata): channel = trace.stats.channel station = trace.stats.station @@ -109,7 +108,8 @@ class MPLWidget(FigureCanvas): ylabel = '' self.updateWidget(xlabel, ylabel, title) self.setPlotDict(n, (station, channel)) - self.axes.autoscale(tight=True) + self.setXLims([0, wfend - wfstart]) + self.setYLims([-0.5, n + 0.5]) if zoomx is not None: self.setXLims(zoomx) if zoomy is not None: @@ -168,6 +168,7 @@ class PickDlg(QDialog): self.rotate = rotate self.components = 'ZNE' self.picks = {} + self.filteroptions = FILTERDEFAULTS # initialize panning attributes self.press = None @@ -238,7 +239,8 @@ class PickDlg(QDialog): ' waveforms', checkable=True) self.selectPhase = QComboBox() - self.selectPhase.addItems([None, 'Pn', 'Pg', 'Sn', 'Sg']) + phaseitems = [None] + FILTERDEFAULTS.keys() + self.selectPhase.addItems(phaseitems) self.zoomAction = createAction(parent=self, text='Zoom', slot=self.zoom, icon=zoom_icon, @@ -320,7 +322,7 @@ class PickDlg(QDialog): self.disconnectMotionEvent() self.disconnectPressEvent() self.cidpress = self.connectPressEvent(self.setIniPick) - self.filterWFData(phase) + self.filterWFData() else: self.disconnectPressEvent() self.cidpress = self.connectPressEvent(self.panPress) @@ -340,6 +342,10 @@ class PickDlg(QDialog): def getChannelID(self, key): return self.getPlotWidget().getPlotDict()[int(key)][1] + def getFilterOptions(self, phase): + options = self.filteroptions[phase] + return FilterOptions(**options) + def getXLims(self): return self.cur_xlim @@ -565,19 +571,28 @@ class PickDlg(QDialog): ax.figure.canvas.draw() - def filterWFData(self, phase): + def filterWFData(self): self.updateCurrentLimits() data = self.getWFData().copy() old_title = self.getPlotWidget().getAxes().get_title() title = None + phase = self.selectPhase.currentText() if self.filterAction.isChecked(): - filteroptions = self.getFilterOptions(phase).parseFilterOptions() - data.filter(**filteroptions) - if old_title.endswith(')'): - title = old_title[:-1] + ', filtered)' + if phase: + filtoptions = self.getFilterOptions(phase).parseFilterOptions() else: - title = old_title + ' (filtered)' - if not title: + filtoptions = FilterOptionsDialog.getFilterObject() + filtoptions = filtoptions.parseFilterOptions() + if filtoptions is not None: + data.filter(**filtoptions) + if old_title.endswith(')'): + title = old_title[:-1] + ', filtered)' + else: + title = old_title + ' (filtered)' + else: + if old_title.endswith(' (filtered)'): + title = old_title.replace(' (filtered)', '') + if title is None: title = old_title self.getPlotWidget().plotWFData(wfdata=data, title=title, zoomx=self.getXLims(),