[add] cb for overwriteFilter, else filter automatically again

This commit is contained in:
Marcel Paffrath 2018-02-22 16:03:11 +01:00
parent bff888c98a
commit b076ee90fa
4 changed files with 63 additions and 24 deletions

View File

@ -75,7 +75,7 @@ from pylot.core.util.dataprocessing import read_metadata, restitute_data
from pylot.core.util.utils import fnConstructor, getLogin, \ from pylot.core.util.utils import fnConstructor, getLogin, \
full_range, readFilterInformation, trim_station_components, check4gaps, make_pen, pick_color_plt, \ full_range, readFilterInformation, trim_station_components, check4gaps, make_pen, pick_color_plt, \
pick_linestyle_plt, remove_underscores, check4doubled, identifyPhaseID, excludeQualityClasses, has_spe, \ pick_linestyle_plt, remove_underscores, check4doubled, identifyPhaseID, excludeQualityClasses, has_spe, \
check4rotated, transform_colors_mpl, transform_colors_mpl_str check4rotated, transform_colors_mpl, transform_colors_mpl_str, getAutoFilteroptions
from pylot.core.util.event import Event from pylot.core.util.event import Event
from pylot.core.io.location import create_creation_info, create_event from pylot.core.io.location import create_creation_info, create_event
from pylot.core.util.widgets import FilterOptionsDialog, NewEventDlg, \ from pylot.core.util.widgets import FilterOptionsDialog, NewEventDlg, \
@ -182,6 +182,8 @@ class MainWindow(QMainWindow):
settings.setValue("data/dataRoot", dirname) settings.setValue("data/dataRoot", dirname)
if settings.value('compclass', None) is None: if settings.value('compclass', None) is None:
settings.setValue('compclass', SetChannelComponents()) settings.setValue('compclass', SetChannelComponents())
if settings.value('useGuiFilter') is None:
settings.setValue('useGuiFilter', False)
if settings.value('output/Format', None) is None: if settings.value('output/Format', None) is None:
outformat = QInputDialog.getText(self, outformat = QInputDialog.getText(self,
"Enter output format (*.xml, *.cnv, *.obs):", "Enter output format (*.xml, *.cnv, *.obs):",
@ -1888,15 +1890,8 @@ class MainWindow(QMainWindow):
#self.drawPicks() #self.drawPicks()
#self.draw() #self.draw()
def getAutoPickFilter(self, phase): def getAutoFilteroptions(self, phase):
filtername = {'P': 'bpz2', return getAutoFilteroptions(phase, self._inputs)
'S': 'bph2'}
if not phase in filtername.keys():
print('autoPickParameter: No filter options for phase {}.'.format(phase))
return
freqmin, freqmax = self._inputs.get(filtername[phase])
filteroptions = FilterOptions(type='bandpass', freq=[freqmin, freqmax], order=4) # order=4 default from obspy
return filteroptions
def adjustFilterOptions(self): def adjustFilterOptions(self):
fstring = "Filter Options" fstring = "Filter Options"

View File

@ -1 +1 @@
2e5e-dirty bff88-dirty

View File

@ -13,7 +13,7 @@ from obspy.core import AttribDict
from obspy.signal.rotate import rotate2zne from obspy.signal.rotate import rotate2zne
from obspy.io.xseed.utils import SEEDParserException from obspy.io.xseed.utils import SEEDParserException
from pylot.core.io.inputs import PylotParameter from pylot.core.io.inputs import PylotParameter, FilterOptions
from pylot.styles import style_settings from pylot.styles import style_settings
from scipy.interpolate import splrep, splev from scipy.interpolate import splrep, splev
@ -31,6 +31,15 @@ def _pickle_method(m):
else: else:
return getattr, (m.im_self, m.im_func.func_name) return getattr, (m.im_self, m.im_func.func_name)
def getAutoFilteroptions(phase, parameter):
filtername = {'P': 'bpz2',
'S': 'bph2'}
if not phase in filtername.keys():
print('autoPickParameter: No filter options for phase {}.'.format(phase))
return
freqmin, freqmax = parameter.get(filtername[phase])
filteroptions = FilterOptions(type='bandpass', freq=[freqmin, freqmax], order=4) # order=4 default from obspy
return filteroptions
def readDefaultFilterInformation(fname): def readDefaultFilterInformation(fname):
""" """

View File

@ -49,7 +49,7 @@ from pylot.core.util.utils import prepTimeAxis, full_range, scaleWFData, \
demeanTrace, isSorted, findComboBoxIndex, clims, pick_linestyle_plt, pick_color_plt, \ demeanTrace, isSorted, findComboBoxIndex, clims, pick_linestyle_plt, pick_color_plt, \
check4rotated, check4doubled, check4gaps, remove_underscores, find_horizontals, identifyPhase, \ check4rotated, check4doubled, check4gaps, remove_underscores, find_horizontals, identifyPhase, \
loopIdentifyPhase, trim_station_components, transformFilteroptions2String, \ loopIdentifyPhase, trim_station_components, transformFilteroptions2String, \
identifyPhaseID, real_Bool, pick_color identifyPhaseID, real_Bool, pick_color, getAutoFilteroptions
from autoPyLoT import autoPyLoT from autoPyLoT import autoPyLoT
from pylot.core.util.thread import Thread from pylot.core.util.thread import Thread
@ -1847,12 +1847,19 @@ class PickDlg(QDialog):
def getUser(self): def getUser(self):
return self._user return self._user
def getFilterOptions(self, phase): def getFilterOptions(self, phase, gui_filter=False):
options = self.filteroptions[self.getPhaseID(phase)] settings = QSettings()
if type(options) == dict: phaseID = self.getPhaseID(phase)
return FilterOptions(**options)
if real_Bool(settings.value('useGuiFilter')) or gui_filter:
filteroptions = self.filteroptions[phaseID]
else: else:
return options filteroptions = getAutoFilteroptions(phaseID, self.parameter).parseFilterOptions()
if type(filteroptions) == dict:
return FilterOptions(**filteroptions)
else:
return filteroptions
def getXLims(self): def getXLims(self):
return self.cur_xlim return self.cur_xlim
@ -2045,11 +2052,15 @@ class PickDlg(QDialog):
xlims = [ini_pick - x_res, ini_pick + x_res] xlims = [ini_pick - x_res, ini_pick + x_res]
ylims = list(np.array([-.5, .5]) + [0, len(data)-1]) ylims = list(np.array([-.5, .5]) + [0, len(data)-1])
title = self.getStation() + ' picking mode'
if filterphase:
filtops_str = transformFilteroptions2String(filteroptions)
title += ' | Filteroptions: {}'.format(filtops_str)
plot_additional = bool(self.compareChannel.currentText()) plot_additional = bool(self.compareChannel.currentText())
additional_channel = self.compareChannel.currentText() additional_channel = self.compareChannel.currentText()
self.multicompfig.plotWFData(wfdata=data, self.multicompfig.plotWFData(wfdata=data,
title=self.getStation() + title=title,
' picking mode',
zoomx=xlims, zoomx=xlims,
zoomy=ylims, zoomy=ylims,
noiselevel=noiselevels, noiselevel=noiselevels,
@ -2075,7 +2086,7 @@ class PickDlg(QDialog):
# get filter parameter for the phase to be picked # get filter parameter for the phase to be picked
filterphase = self.currentFilterPhase() filterphase = self.currentFilterPhase()
filteroptions = self.getFilterOptions(self.getPhaseID(filterphase)).parseFilterOptions() filteroptions = self.getFilterOptions(filterphase).parseFilterOptions()
# copy and filter data for earliest and latest possible picks # copy and filter data for earliest and latest possible picks
wfdata = self.getWFData().copy().select(channel=channel) wfdata = self.getWFData().copy().select(channel=channel)
@ -2401,7 +2412,7 @@ class PickDlg(QDialog):
if filter: if filter:
filtoptions = None filtoptions = None
if phase: if phase:
filtoptions = self.getFilterOptions(self.getPhaseID(phase)).parseFilterOptions() filtoptions = self.getFilterOptions(self.getPhaseID(phase), gui_filter=True).parseFilterOptions()
# if self.filterActionP.isChecked() or self.filterActionS.isChecked(): # if self.filterActionP.isChecked() or self.filterActionS.isChecked():
# if not phase: # if not phase:
@ -4480,8 +4491,8 @@ class FilterOptionsDialog(QDialog):
'S': FilterOptions()} 'S': FilterOptions()}
self.setWindowTitle(titleString) self.setWindowTitle(titleString)
self.filterOptionWidgets = {'P': FilterOptionsWidget(self.filterOptions['P'], self.parent().getAutoPickFilter('P')), self.filterOptionWidgets = {'P': FilterOptionsWidget(self.filterOptions['P'], self.parent().getAutoFilteroptions('P')),
'S': FilterOptionsWidget(self.filterOptions['S'], self.parent().getAutoPickFilter('S'))} 'S': FilterOptionsWidget(self.filterOptions['S'], self.parent().getAutoFilteroptions('S'))}
self.setupUi() self.setupUi()
self.updateUi() self.updateUi()
self.connectButtons() self.connectButtons()
@ -4492,6 +4503,14 @@ class FilterOptionsDialog(QDialog):
self.groupBoxes = {'P': QtGui.QGroupBox('P Filter'), self.groupBoxes = {'P': QtGui.QGroupBox('P Filter'),
'S': QtGui.QGroupBox('S Filter')} 'S': QtGui.QGroupBox('S Filter')}
settings = QSettings()
overwriteFilter = real_Bool(settings.value('useGuiFilter'))
self.overwriteFilterCheckbox = QCheckBox('Overwrite filteroptions')
self.overwriteFilterCheckbox.setToolTip('Overwrite filter settings for refined pick with GUI settings')
self.overwriteFilterCheckbox.setChecked(overwriteFilter)
self.overwriteFilterCheckbox.clicked.connect(self.toggleFilterOverwrite)
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok |
QDialogButtonBox.Cancel) QDialogButtonBox.Cancel)
@ -4504,9 +4523,25 @@ class FilterOptionsDialog(QDialog):
box_layout.addWidget(self.filterOptionWidgets[phase]) box_layout.addWidget(self.filterOptionWidgets[phase])
self.main_layout.addLayout(self.filter_layout) self.main_layout.addLayout(self.filter_layout)
self.main_layout.addWidget(self.overwriteFilterCheckbox)
self.main_layout.addWidget(self.buttonBox) self.main_layout.addWidget(self.buttonBox)
self.setLayout(self.main_layout) self.setLayout(self.main_layout)
def toggleFilterOverwrite(self):
if self.overwriteFilterCheckbox.isChecked():
qmb = QMessageBox(self, icon=QMessageBox.Warning,
text='Warning: Overwriting automatic filter settings'
' for final pick will contaminate comparability'
' of automatic and manual picks! Continue?')
qmb.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
qmb.setDefaultButton(QMessageBox.Yes)
ret = qmb.exec_()
if not ret == qmb.Yes:
self.overwriteFilterCheckbox.setChecked(False)
settings = QSettings()
settings.setValue('useGuiFilter', self.overwriteFilterCheckbox.isChecked())
def connectButtons(self): def connectButtons(self):
self.buttonBox.accepted.connect(self.accept) self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject) self.buttonBox.rejected.connect(self.reject)