Merge branch 'develop' into feature/additional_channel_display

This commit is contained in:
Marcel Paffrath 2018-01-09 15:37:01 +01:00
commit 7c61c7c471
8 changed files with 6268 additions and 77 deletions

View File

@ -187,6 +187,8 @@ class MainWindow(QMainWindow):
"Enter output format (*.xml, *.cnv, *.obs):", "Enter output format (*.xml, *.cnv, *.obs):",
"Format") "Format")
settings.setValue("output/Format", outformat) settings.setValue("output/Format", outformat)
if settings.value('autoFilter', None) is None:
settings.setValue('autoFilter', True)
settings.sync() settings.sync()
# setup UI # setup UI
@ -1748,6 +1750,8 @@ class MainWindow(QMainWindow):
comp = self.getComponent() comp = self.getComponent()
title = 'section: {0} components'.format(zne_text[comp]) title = 'section: {0} components'.format(zne_text[comp])
wfst = self.get_data().getWFData() wfst = self.get_data().getWFData()
if self.filterAction.isChecked():
self.filterWaveformData(plot=False)
# wfst = self.get_data().getWFData().select(component=comp) # wfst = self.get_data().getWFData().select(component=comp)
# wfst += self.get_data().getWFData().select(component=alter_comp) # wfst += self.get_data().getWFData().select(component=alter_comp)
plotWidget = self.getPlotWidget() plotWidget = self.getPlotWidget()
@ -1787,7 +1791,7 @@ class MainWindow(QMainWindow):
def pushFilterWF(self, param_args): def pushFilterWF(self, param_args):
self.get_data().filterWFData(param_args) self.get_data().filterWFData(param_args)
def filterWaveformData(self): def filterWaveformData(self, plot=True):
if self.get_data(): if self.get_data():
if self.getFilterOptions() and self.filterAction.isChecked(): if self.getFilterOptions() and self.filterAction.isChecked():
kwargs = self.getFilterOptions()[self.getSeismicPhase()].parseFilterOptions() kwargs = self.getFilterOptions()[self.getSeismicPhase()].parseFilterOptions()
@ -1796,9 +1800,10 @@ class MainWindow(QMainWindow):
self.adjustFilterOptions() self.adjustFilterOptions()
else: else:
self.get_data().resetWFData() self.get_data().resetWFData()
self.plotWaveformDataThread() if plot:
self.drawPicks() self.plotWaveformDataThread()
self.draw() self.drawPicks()
self.draw()
def adjustFilterOptions(self): def adjustFilterOptions(self):
fstring = "Filter Options" fstring = "Filter Options"
@ -1971,7 +1976,7 @@ class MainWindow(QMainWindow):
if not station: if not station:
return return
self.update_status('picking on station {0}'.format(station)) self.update_status('picking on station {0}'.format(station))
data = self.get_data().getWFData() data = self.get_data().getOriginalWFData().copy()
event = self.get_current_event() event = self.get_current_event()
pickDlg = PickDlg(self, parameter=self._inputs, pickDlg = PickDlg(self, parameter=self._inputs,
data=data.select(station=station), data=data.select(station=station),
@ -1980,6 +1985,9 @@ class MainWindow(QMainWindow):
autopicks=self.getPicksOnStation(station, 'auto'), autopicks=self.getPicksOnStation(station, 'auto'),
metadata=self.metadata, event=event, metadata=self.metadata, event=event,
filteroptions=self.filteroptions) filteroptions=self.filteroptions)
if self.filterAction.isChecked():
pickDlg.currentPhase = self.getSeismicPhase()
pickDlg.filterWFData()
pickDlg.nextStation.setChecked(nextStation) pickDlg.nextStation.setChecked(nextStation)
if pickDlg.exec_(): if pickDlg.exec_():
if pickDlg._dirty: if pickDlg._dirty:

View File

@ -33,6 +33,7 @@
<file>icons/Matlab_PILOT_icon.png</file> <file>icons/Matlab_PILOT_icon.png</file>
<file>icons/printer.png</file> <file>icons/printer.png</file>
<file>icons/delete.png</file> <file>icons/delete.png</file>
<file>icons/key_A.png</file>
<file>icons/key_E.png</file> <file>icons/key_E.png</file>
<file>icons/key_N.png</file> <file>icons/key_N.png</file>
<file>icons/key_P.png</file> <file>icons/key_P.png</file>

BIN
icons/key_A.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1 +1 @@
c393-dirty 440c-dirty

View File

@ -327,9 +327,9 @@ def real_Bool(value):
:return: true boolean value :return: true boolean value
:rtype: bool :rtype: bool
""" """
if value == 'True': if value in ['True', 'true']:
return True return True
elif value == 'False': elif value in ['False', 'false']:
return False return False
else: else:
return value return value

View File

@ -18,7 +18,7 @@ import numpy as np
from matplotlib.figure import Figure from matplotlib.figure import Figure
from pylot.core.util.utils import find_horizontals, identifyPhase, loopIdentifyPhase, trim_station_components, \ from pylot.core.util.utils import find_horizontals, identifyPhase, loopIdentifyPhase, trim_station_components, \
identifyPhaseID, check4rotated identifyPhaseID, check4rotated, real_Bool, pick_color
try: try:
from matplotlib.backends.backend_qt4agg import FigureCanvas from matplotlib.backends.backend_qt4agg import FigureCanvas
@ -1177,7 +1177,7 @@ class PickDlg(QDialog):
else: else:
self.filteroptions = FILTERDEFAULTS self.filteroptions = FILTERDEFAULTS
self.pick_block = False self.pick_block = False
self.nextStation = QtGui.QCheckBox('Continue with next station.') self.nextStation = QtGui.QCheckBox('Continue with next station ')
self.additionalChannel = QtGui.QCheckBox('Additional Channel') self.additionalChannel = QtGui.QCheckBox('Additional Channel')
self.additionalChannel.stateChanged.connect(self.resetPlot) self.additionalChannel.stateChanged.connect(self.resetPlot)
@ -1243,6 +1243,7 @@ class PickDlg(QDialog):
# init pick delete (with right click) # init pick delete (with right click)
self.connect_pick_delete() self.connect_pick_delete()
self.setWindowTitle('Pickwindow on station: {}'.format(self.getStation())) self.setWindowTitle('Pickwindow on station: {}'.format(self.getStation()))
self.setWindowState(QtCore.Qt.WindowMaximized)
def setupUi(self): def setupUi(self):
menuBar = QtGui.QMenuBar(self) menuBar = QtGui.QMenuBar(self)
@ -1261,6 +1262,8 @@ class PickDlg(QDialog):
filter_icon_p.addPixmap(QPixmap(':/icons/filter_p.png')) filter_icon_p.addPixmap(QPixmap(':/icons/filter_p.png'))
filter_icon_s = QIcon() filter_icon_s = QIcon()
filter_icon_s.addPixmap(QPixmap(':/icons/filter_s.png')) filter_icon_s.addPixmap(QPixmap(':/icons/filter_s.png'))
key_a_icon = QIcon()
key_a_icon.addPixmap(QPixmap(':/icons/key_A.png'))
zoom_icon = QIcon() zoom_icon = QIcon()
zoom_icon.addPixmap(QPixmap(':/icons/zoom_in.png')) zoom_icon.addPixmap(QPixmap(':/icons/zoom_in.png'))
home_icon = QIcon() home_icon = QIcon()
@ -1282,13 +1285,19 @@ class PickDlg(QDialog):
tip='Toggle filtered/original' tip='Toggle filtered/original'
' waveforms', ' waveforms',
checkable=True, checkable=True,
shortcut='Shift+S') shortcut='Shift+F')
self.autoFilterAction = createAction(parent=self, text='Automatic Filtering',
slot=self.toggleAutoFilter,
icon=key_a_icon,
tip='Filter automatically before initial pick',
checkable=True,
shortcut='Ctrl+A')
self.zoomAction = createAction(parent=self, text='Zoom', self.zoomAction = createAction(parent=self, text='Zoom',
slot=self.zoom, icon=zoom_icon, slot=self.zoom, icon=zoom_icon,
tip='Zoom into waveform', tip='Zoom into waveform',
checkable=True) checkable=True)
self.resetZoomAction = createAction(parent=self, text='Home', self.resetZoomAction = createAction(parent=self, text='Home',
slot=self.multicompfig.resetZoom, icon=home_icon, slot=self.resetPlot, icon=home_icon,
tip='Reset zoom to original limits') tip='Reset zoom to original limits')
self.resetPicksAction = createAction(parent=self, text='Delete Picks', self.resetPicksAction = createAction(parent=self, text='Delete Picks',
slot=self.delPicks, icon=del_icon, slot=self.delPicks, icon=del_icon,
@ -1296,6 +1305,9 @@ class PickDlg(QDialog):
self.addPickPhases(menuBar) self.addPickPhases(menuBar)
settings = QSettings()
self.autoFilterAction.setChecked(real_Bool(settings.value('autoFilter')))
# create other widget elements # create other widget elements
phaseitems = [None] + list(FILTERDEFAULTS.keys()) phaseitems = [None] + list(FILTERDEFAULTS.keys())
@ -1330,6 +1342,7 @@ class PickDlg(QDialog):
# fill toolbar with content # fill toolbar with content
_dialtoolbar.addAction(self.filterActionP) _dialtoolbar.addAction(self.filterActionP)
_dialtoolbar.addAction(self.filterActionS) _dialtoolbar.addAction(self.filterActionS)
_dialtoolbar.addAction(self.autoFilterAction)
_dialtoolbar.addWidget(self.p_button) _dialtoolbar.addWidget(self.p_button)
_dialtoolbar.addWidget(self.s_button) _dialtoolbar.addWidget(self.s_button)
_dialtoolbar.addAction(self.zoomAction) _dialtoolbar.addAction(self.zoomAction)
@ -1337,6 +1350,7 @@ class PickDlg(QDialog):
_dialtoolbar.addAction(self.resetZoomAction) _dialtoolbar.addAction(self.resetZoomAction)
_dialtoolbar.addSeparator() _dialtoolbar.addSeparator()
_dialtoolbar.addAction(self.resetPicksAction) _dialtoolbar.addAction(self.resetPicksAction)
_dialtoolbar.addSeparator()
if self._embedded: if self._embedded:
manu_label = QLabel('Manual Onsets:') manu_label = QLabel('Manual Onsets:')
manu_label.setStyleSheet('QLabel {' manu_label.setStyleSheet('QLabel {'
@ -1347,6 +1361,7 @@ class PickDlg(QDialog):
_dialtoolbar.addWidget(self.reject_button) _dialtoolbar.addWidget(self.reject_button)
else: else:
_dialtoolbar.addWidget(self.nextStation) _dialtoolbar.addWidget(self.nextStation)
_dialtoolbar.addSeparator()
est_label = QLabel('Estimated onsets:') est_label = QLabel('Estimated onsets:')
est_label.setStyleSheet('QLabel {' est_label.setStyleSheet('QLabel {'
'padding:2px;' 'padding:2px;'
@ -1510,9 +1525,8 @@ class PickDlg(QDialog):
phaseSelect = {'P': self.p_phase_select, phaseSelect = {'P': self.p_phase_select,
'S': self.s_phase_select} 'S': self.s_phase_select}
nHotkey = 4 # max hotkeys per phase hotkeys = {'P': [1, 2, 3, 4, 'q', 'w', 'e', 'r'],
hotkey = 1 # start hotkey 'S': [5, 6, 7, 8, 't', 'z', 'u', 'i']}
# loop over P and S (use explicit list instead of iter over dict.keys to keep order) # loop over P and S (use explicit list instead of iter over dict.keys to keep order)
for phaseIndex, phaseID in enumerate(['P', 'S']): for phaseIndex, phaseID in enumerate(['P', 'S']):
@ -1521,11 +1535,11 @@ class PickDlg(QDialog):
# remove zeros # remove zeros
phase = phase.strip() phase = phase.strip()
# add hotkeys # add hotkeys
if not index >= nHotkey: try:
shortcut = str(hotkey) shortcut = str(hotkeys[phaseID][index])
hotkey += 1 except IndexError:
else:
shortcut = None shortcut = None
# create action and add to menu # create action and add to menu
# phase name transferred using lambda function # phase name transferred using lambda function
slot = lambda phase=phase, phaseID=phaseID: phaseSelect[phaseID](phase) slot = lambda phase=phase, phaseID=phaseID: phaseSelect[phaseID](phase)
@ -1544,6 +1558,7 @@ class PickDlg(QDialog):
filterMenu = menuBar.addMenu('Filter') filterMenu = menuBar.addMenu('Filter')
filterMenu.addAction(self.filterActionP) filterMenu.addAction(self.filterActionP)
filterMenu.addAction(self.filterActionS) filterMenu.addAction(self.filterActionS)
filterMenu.addAction(self.autoFilterAction)
filterMenu.addAction(filterOptionsAction) filterMenu.addAction(filterOptionsAction)
def filterOptions(self): def filterOptions(self):
@ -1558,6 +1573,7 @@ class PickDlg(QDialog):
def p_phase_select(self, phase): def p_phase_select(self, phase):
if not self.p_button.isChecked(): if not self.p_button.isChecked():
self.p_button.setEnabled(True)
self.p_button.setChecked(True) self.p_button.setChecked(True)
self.p_button.setText(phase) self.p_button.setText(phase)
else: else:
@ -1569,6 +1585,7 @@ class PickDlg(QDialog):
def s_phase_select(self, phase): def s_phase_select(self, phase):
if not self.s_button.isChecked(): if not self.s_button.isChecked():
self.s_button.setEnabled(True)
self.s_button.setChecked(True) self.s_button.setChecked(True)
self.s_button.setText(phase) self.s_button.setText(phase)
else: else:
@ -1595,14 +1612,16 @@ class PickDlg(QDialog):
self.leave_picking_mode() self.leave_picking_mode()
def init_p_pick(self): def init_p_pick(self):
self.set_button_border_color(self.p_button, 'yellow') color = pick_color('manual', 'P')
self.activatePicking() self.set_button_border_color(self.p_button, color)
self.currentPhase = str(self.p_button.text()) self.currentPhase = str(self.p_button.text())
self.activatePicking()
def init_s_pick(self): def init_s_pick(self):
self.set_button_border_color(self.s_button, 'yellow') color = pick_color('manual', 'S')
self.activatePicking() self.set_button_border_color(self.s_button, color)
self.currentPhase = str(self.s_button.text()) self.currentPhase = str(self.s_button.text())
self.activatePicking()
def getPhaseID(self, phase): def getPhaseID(self, phase):
return identifyPhaseID(phase) return identifyPhaseID(phase)
@ -1643,23 +1662,25 @@ class PickDlg(QDialog):
self.currentPhase = None self.currentPhase = None
self.reset_p_button() self.reset_p_button()
self.reset_s_button() self.reset_s_button()
self.multicompfig.plotWFData(wfdata=self.getWFData(), self.resetPlot()
title=self.getStation(),
plot_additional=self.additionalChannel.isChecked())
self.drawAllPicks()
self.drawArrivals()
self.setPlotLabels()
self.resetZoomAction.trigger()
self.deactivatePicking() self.deactivatePicking()
def activatePicking(self): def activatePicking(self):
self.multicompfig.set_frame_color('yellow') phase = self.currentPhase
color = pick_color_plt('manual', self.getPhaseID(phase))
self.multicompfig.set_frame_color(color)
self.multicompfig.set_frame_linewidth(1.5) self.multicompfig.set_frame_linewidth(1.5)
if self.zoomAction.isChecked(): if self.zoomAction.isChecked():
self.zoomAction.trigger() self.zoomAction.trigger()
self.multicompfig.disconnectEvents() self.multicompfig.disconnectEvents()
self.cidpress = self.multicompfig.connectPressEvent(self.setIniPick) self.cidpress = self.multicompfig.connectPressEvent(self.setIniPick)
self.filterWFData() if not self.filterActionP.isChecked() and not self.filterActionS.isChecked():
if self.autoFilterAction.isChecked():
self.filterWFData()
else:
self.draw()
else:
self.draw()
#self.pick_block = self.togglePickBlocker() #self.pick_block = self.togglePickBlocker()
self.disconnect_pick_delete() self.disconnect_pick_delete()
@ -1820,13 +1841,13 @@ class PickDlg(QDialog):
if filteroptions: if filteroptions:
try: try:
data.filter(**filteroptions) data.filter(**filteroptions)
wfdata.filter(**filteroptions) #wfdata.filter(**filteroptions)# MP MP removed filtering of original data
except ValueError as e: except ValueError as e:
self.qmb = QtGui.QMessageBox(QtGui.QMessageBox.Icon.Information, self.qmb = QtGui.QMessageBox(QtGui.QMessageBox.Icon.Information,
'Denied', 'setIniPickP: Could not filter waveform: {}'.format(e)) 'Denied', 'setIniPickP: Could not filter waveform: {}'.format(e))
self.qmb.show() self.qmb.show()
result = getSNR(wfdata, (noise_win, gap_win, signal_win), ini_pick - stime_diff, itrace) result = getSNR(data, (noise_win, gap_win, signal_win), ini_pick - stime_diff, itrace)
snr = result[0] snr = result[0]
noiselevel = result[2] noiselevel = result[2]
@ -2156,13 +2177,20 @@ class PickDlg(QDialog):
return not self.pick_block return not self.pick_block
def filterWFData(self, phase=None): def filterWFData(self, phase=None):
if not phase:
phase = self.currentPhase
if self.getPhaseID(phase) == 'P':
self.filterActionP.setChecked(True)
self.filterP()
elif self.getPhaseID(phase) == 'S':
self.filterActionS.setChecked(True)
self.filterS()
return
self.plotWFData(phase=phase, filter=True) self.plotWFData(phase=phase, filter=True)
def plotWFData(self, phase=None, filter=False): def plotWFData(self, phase=None, filter=False):
if self.pick_block: if self.pick_block:
return return
if not phase:
phase = self.currentPhase
self.cur_xlim = self.multicompfig.axes[0].get_xlim() self.cur_xlim = self.multicompfig.axes[0].get_xlim()
self.cur_ylim = self.multicompfig.axes[0].get_ylim() self.cur_ylim = self.multicompfig.axes[0].get_ylim()
#self.multicompfig.updateCurrentLimits() #self.multicompfig.updateCurrentLimits()
@ -2180,7 +2208,7 @@ class PickDlg(QDialog):
if filtoptions is not None: if filtoptions is not None:
data.filter(**filtoptions) data.filter(**filtoptions)
title += '({} filtered'.format(filtoptions['type']) title += '({} filtered - '.format(filtoptions['type'])
for key, value in filtoptions.items(): for key, value in filtoptions.items():
if key == 'type': if key == 'type':
continue continue
@ -2208,7 +2236,14 @@ class PickDlg(QDialog):
else: else:
self.resetPlot() self.resetPlot()
def toggleAutoFilter(self):
settings = QSettings()
settings.setValue('autoFilter', self.autoFilterAction.isChecked())
def resetPlot(self): def resetPlot(self):
if self.autoFilterAction.isChecked():
self.filterActionP.setChecked(False)
self.filterActionS.setChecked(False)
self.resetZoom() self.resetZoom()
data = self.getWFData().copy() data = self.getWFData().copy()
#title = self.multicompfig.axes[0].get_title() #title = self.multicompfig.axes[0].get_title()
@ -2225,6 +2260,8 @@ class PickDlg(QDialog):
ax = self.multicompfig.axes[0] ax = self.multicompfig.axes[0]
self.setXLims(self.multicompfig.getGlobalLimits(ax, 'x')) self.setXLims(self.multicompfig.getGlobalLimits(ax, 'x'))
self.setYLims(self.multicompfig.getGlobalLimits(ax, 'y')) self.setYLims(self.multicompfig.getGlobalLimits(ax, 'y'))
if not self.zoomAction.isChecked():
self.multicompfig.connectEvents()
def setPlotLabels(self): def setPlotLabels(self):
@ -2247,6 +2284,7 @@ class PickDlg(QDialog):
self.figToolBar.zoom() self.figToolBar.zoom()
else: else:
self.figToolBar.zoom() self.figToolBar.zoom()
self.multicompfig.connectEvents()
def draw(self): def draw(self):
self.multicompfig.draw() self.multicompfig.draw()