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

View File

@ -33,6 +33,7 @@
<file>icons/Matlab_PILOT_icon.png</file>
<file>icons/printer.png</file>
<file>icons/delete.png</file>
<file>icons/key_A.png</file>
<file>icons/key_E.png</file>
<file>icons/key_N.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
:rtype: bool
"""
if value == 'True':
if value in ['True', 'true']:
return True
elif value == 'False':
elif value in ['False', 'false']:
return False
else:
return value

View File

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