[add] P and S Filter options for main window
[bugfix] wforiginal not pre-processed
This commit is contained in:
parent
c7dc1481a1
commit
185cc14e38
103
PyLoT.py
103
PyLoT.py
@ -274,6 +274,10 @@ class MainWindow(QMainWindow):
|
|||||||
print_icon.addPixmap(QPixmap(':/icons/printer.png'))
|
print_icon.addPixmap(QPixmap(':/icons/printer.png'))
|
||||||
self.filter_icon = QIcon()
|
self.filter_icon = QIcon()
|
||||||
self.filter_icon.addPixmap(QPixmap(':/icons/filter.png'))
|
self.filter_icon.addPixmap(QPixmap(':/icons/filter.png'))
|
||||||
|
self.filter_icon_p = QIcon()
|
||||||
|
self.filter_icon_p.addPixmap(QPixmap(':/icons/filter_p.png'))
|
||||||
|
self.filter_icon_s = QIcon()
|
||||||
|
self.filter_icon_s.addPixmap(QPixmap(':/icons/filter_s.png'))
|
||||||
z_icon = QIcon()
|
z_icon = QIcon()
|
||||||
z_icon.addPixmap(QPixmap(':/icons/key_Z.png'))
|
z_icon.addPixmap(QPixmap(':/icons/key_Z.png'))
|
||||||
n_icon = QIcon()
|
n_icon = QIcon()
|
||||||
@ -368,12 +372,20 @@ class MainWindow(QMainWindow):
|
|||||||
self.setParameter,
|
self.setParameter,
|
||||||
None, paraIcon,
|
None, paraIcon,
|
||||||
"Modify Parameter")
|
"Modify Parameter")
|
||||||
self.filterAction = self.createAction(self, "&Filter ...",
|
self.filterActionP = createAction(parent=self, text='Apply P Filter',
|
||||||
self.filterWaveformData,
|
slot=self.filterP,
|
||||||
"Ctrl+F", self.filter_icon,
|
icon=self.filter_icon_p,
|
||||||
"""Toggle un-/filtered waveforms
|
tip='Toggle filtered/original'
|
||||||
to be displayed, according to the
|
' waveforms',
|
||||||
desired seismic phase.""", True)
|
checkable=True,
|
||||||
|
shortcut='Ctrl+F')
|
||||||
|
self.filterActionS = createAction(parent=self, text='Apply S Filter',
|
||||||
|
slot=self.filterS,
|
||||||
|
icon=self.filter_icon_s,
|
||||||
|
tip='Toggle filtered/original'
|
||||||
|
' waveforms',
|
||||||
|
checkable=True,
|
||||||
|
shortcut='Shift+F')
|
||||||
filterEditAction = self.createAction(self, "&Filter parameter ...",
|
filterEditAction = self.createAction(self, "&Filter parameter ...",
|
||||||
self.adjustFilterOptions,
|
self.adjustFilterOptions,
|
||||||
"Alt+F", self.filter_icon,
|
"Alt+F", self.filter_icon,
|
||||||
@ -502,8 +514,8 @@ class MainWindow(QMainWindow):
|
|||||||
self.updateFileMenu()
|
self.updateFileMenu()
|
||||||
|
|
||||||
self.editMenu = self.menuBar().addMenu('&Edit')
|
self.editMenu = self.menuBar().addMenu('&Edit')
|
||||||
editActions = (self.filterAction, filterEditAction, None,
|
editActions = (self.filterActionP, self.filterActionS, filterEditAction, None,
|
||||||
self.selectPAction, self.selectSAction, None,
|
#self.selectPAction, self.selectSAction, None,
|
||||||
self.inventoryAction, self.initMapAction, None,
|
self.inventoryAction, self.initMapAction, None,
|
||||||
prefsEventAction)
|
prefsEventAction)
|
||||||
#printAction) #TODO: print event?
|
#printAction) #TODO: print event?
|
||||||
@ -1415,7 +1427,8 @@ class MainWindow(QMainWindow):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def getStime(self):
|
def getStime(self):
|
||||||
return self._stime
|
if self.get_data():
|
||||||
|
return full_range(self.get_data().getWFData())[0]
|
||||||
|
|
||||||
def addActions(self, target, actions):
|
def addActions(self, target, actions):
|
||||||
for action in actions:
|
for action in actions:
|
||||||
@ -1589,18 +1602,9 @@ class MainWindow(QMainWindow):
|
|||||||
# else:
|
# else:
|
||||||
# ans = False
|
# ans = False
|
||||||
self.fnames = self.getWFFnames_from_eventbox()
|
self.fnames = self.getWFFnames_from_eventbox()
|
||||||
self.data.setWFData(self.fnames)
|
self.data.setWFData(self.fnames,
|
||||||
wfdat = self.data.getWFData() # all available streams
|
checkRotated=True,
|
||||||
# remove possible underscores in station names
|
metadata=self.metadata)
|
||||||
wfdat = remove_underscores(wfdat)
|
|
||||||
# check for gaps and doubled channels
|
|
||||||
check4gaps(wfdat)
|
|
||||||
check4doubled(wfdat)
|
|
||||||
# check for stations with rotated components
|
|
||||||
wfdat = check4rotated(wfdat, self.metadata, verbosity=0)
|
|
||||||
# trim station components to same start value
|
|
||||||
trim_station_components(wfdat, trim_start=True, trim_end=False)
|
|
||||||
self._stime = full_range(self.get_data().getWFData())[0]
|
|
||||||
|
|
||||||
def connectWFplotEvents(self):
|
def connectWFplotEvents(self):
|
||||||
'''
|
'''
|
||||||
@ -1759,18 +1763,19 @@ class MainWindow(QMainWindow):
|
|||||||
self.disableSaveEventAction()
|
self.disableSaveEventAction()
|
||||||
self.draw()
|
self.draw()
|
||||||
|
|
||||||
def plotWaveformDataThread(self):
|
def plotWaveformDataThread(self, filter=True):
|
||||||
'''
|
'''
|
||||||
Open a modal thread to plot current waveform data.
|
Open a modal thread to plot current waveform data.
|
||||||
'''
|
'''
|
||||||
self.clearWaveformDataPlot()
|
self.clearWaveformDataPlot()
|
||||||
self.wfp_thread = Thread(self, self.plotWaveformData,
|
self.wfp_thread = Thread(self, self.plotWaveformData,
|
||||||
|
arg=filter,
|
||||||
progressText='Plotting waveform data...',
|
progressText='Plotting waveform data...',
|
||||||
pb_widget=self.mainProgressBarWidget)
|
pb_widget=self.mainProgressBarWidget)
|
||||||
self.wfp_thread.finished.connect(self.finishWaveformDataPlot)
|
self.wfp_thread.finished.connect(self.finishWaveformDataPlot)
|
||||||
self.wfp_thread.start()
|
self.wfp_thread.start()
|
||||||
|
|
||||||
def plotWaveformData(self):
|
def plotWaveformData(self, filter=True):
|
||||||
'''
|
'''
|
||||||
Plot waveform data to current plotWidget.
|
Plot waveform data to current plotWidget.
|
||||||
'''
|
'''
|
||||||
@ -1782,8 +1787,10 @@ 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():
|
if self.filterActionP.isChecked() and filter:
|
||||||
self.filterWaveformData(plot=False)
|
self.filterWaveformData(plot=False, phase='P')
|
||||||
|
elif self.filterActionS.isChecked() and filter:
|
||||||
|
self.filterWaveformData(plot=False, phase='S')
|
||||||
# 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()
|
||||||
@ -1823,19 +1830,45 @@ 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, plot=True):
|
def filterP(self):
|
||||||
|
self.filterActionS.setChecked(False)
|
||||||
|
if self.filterActionP.isChecked():
|
||||||
|
self.filterWaveformData(phase='P')
|
||||||
|
else:
|
||||||
|
self.resetWFData()
|
||||||
|
|
||||||
|
def filterS(self):
|
||||||
|
self.filterActionP.setChecked(False)
|
||||||
|
if self.filterActionS.isChecked():
|
||||||
|
self.filterWaveformData(phase='S')
|
||||||
|
else:
|
||||||
|
self.resetWFData()
|
||||||
|
|
||||||
|
def resetWFData(self):
|
||||||
|
self.get_data().resetWFData()
|
||||||
|
self.plotWaveformDataThread()
|
||||||
|
|
||||||
|
def filterWaveformData(self, plot=True, phase=None):
|
||||||
if self.get_data():
|
if self.get_data():
|
||||||
if self.getFilterOptions() and self.filterAction.isChecked():
|
if not phase:
|
||||||
kwargs = self.getFilterOptions()[self.getSeismicPhase()].parseFilterOptions()
|
if self.filterActionP.isChecked():
|
||||||
|
phase = 'P'
|
||||||
|
elif self.filterActionS.isChecked():
|
||||||
|
phase = 'S'
|
||||||
|
if self.getFilterOptions():
|
||||||
|
if (phase == 'P' and self.filterActionP.isChecked()) or (phase == 'S' and self.filterActionS.isChecked()):
|
||||||
|
kwargs = self.getFilterOptions()[phase].parseFilterOptions()
|
||||||
self.pushFilterWF(kwargs)
|
self.pushFilterWF(kwargs)
|
||||||
elif self.filterAction.isChecked():
|
else:
|
||||||
|
self.get_data().resetWFData()
|
||||||
|
elif self.filterActionP.isChecked() or self.filterActionS.isChecked():
|
||||||
self.adjustFilterOptions()
|
self.adjustFilterOptions()
|
||||||
else:
|
else:
|
||||||
self.get_data().resetWFData()
|
self.get_data().resetWFData()
|
||||||
if plot:
|
if plot:
|
||||||
self.plotWaveformDataThread()
|
self.plotWaveformDataThread(filter=False)
|
||||||
self.drawPicks()
|
#self.drawPicks()
|
||||||
self.draw()
|
#self.draw()
|
||||||
|
|
||||||
def adjustFilterOptions(self):
|
def adjustFilterOptions(self):
|
||||||
fstring = "Filter Options"
|
fstring = "Filter Options"
|
||||||
@ -1844,7 +1877,7 @@ class MainWindow(QMainWindow):
|
|||||||
if self.filterDlg.exec_():
|
if self.filterDlg.exec_():
|
||||||
filteroptions = self.filterDlg.getFilterOptions()
|
filteroptions = self.filterDlg.getFilterOptions()
|
||||||
self.setFilterOptions(filteroptions)
|
self.setFilterOptions(filteroptions)
|
||||||
if self.filterAction.isChecked():
|
if self.filterActionP.isChecked() or self.filterActionS.isChecked():
|
||||||
kwargs = self.getFilterOptions()[self.getSeismicPhase()].parseFilterOptions()
|
kwargs = self.getFilterOptions()[self.getSeismicPhase()].parseFilterOptions()
|
||||||
self.pushFilterWF(kwargs)
|
self.pushFilterWF(kwargs)
|
||||||
self.plotWaveformDataThread()
|
self.plotWaveformDataThread()
|
||||||
@ -1925,7 +1958,7 @@ class MainWindow(QMainWindow):
|
|||||||
# '[{0}: {1} Hz]'.format(
|
# '[{0}: {1} Hz]'.format(
|
||||||
# self.getFilterOptions().getFilterType(),
|
# self.getFilterOptions().getFilterType(),
|
||||||
# self.getFilterOptions().getFreq()))
|
# self.getFilterOptions().getFreq()))
|
||||||
# if self.filterAction.isChecked():
|
# if self.filterActionP.isChecked() or self.filterActionS.isChecked():
|
||||||
# self.filterWaveformData()
|
# self.filterWaveformData()
|
||||||
|
|
||||||
def getSeismicPhase(self):
|
def getSeismicPhase(self):
|
||||||
@ -2018,7 +2051,7 @@ 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():
|
if self.filterActionP.isChecked() or self.filterActionS.isChecked():
|
||||||
pickDlg.currentPhase = self.getSeismicPhase()
|
pickDlg.currentPhase = self.getSeismicPhase()
|
||||||
pickDlg.filterWFData()
|
pickDlg.filterWFData()
|
||||||
pickDlg.nextStation.setChecked(nextStation)
|
pickDlg.nextStation.setChecked(nextStation)
|
||||||
|
@ -1 +1 @@
|
|||||||
0ebc-dirty
|
c7dc-dirty
|
||||||
|
@ -12,7 +12,8 @@ from pylot.core.io.phases import readPILOTEvent, picks_from_picksdict, \
|
|||||||
picksdict_from_pilot, merge_picks
|
picksdict_from_pilot, merge_picks
|
||||||
from pylot.core.util.errors import FormatError, OverwriteError
|
from pylot.core.util.errors import FormatError, OverwriteError
|
||||||
from pylot.core.util.event import Event
|
from pylot.core.util.event import Event
|
||||||
from pylot.core.util.utils import fnConstructor, full_range
|
from pylot.core.util.utils import fnConstructor, full_range, remove_underscores, check4gaps, check4doubled, \
|
||||||
|
check4rotated, trim_station_components
|
||||||
import pylot.core.loc.velest as velest
|
import pylot.core.loc.velest as velest
|
||||||
|
|
||||||
|
|
||||||
@ -367,7 +368,7 @@ class Data(object):
|
|||||||
data.filter(**kwargs)
|
data.filter(**kwargs)
|
||||||
self.dirty = True
|
self.dirty = True
|
||||||
|
|
||||||
def setWFData(self, fnames):
|
def setWFData(self, fnames, checkRotated=False, metadata=None):
|
||||||
"""
|
"""
|
||||||
Clear current waveform data and set given waveform data
|
Clear current waveform data and set given waveform data
|
||||||
:param fnames: waveform data names to append
|
:param fnames: waveform data names to append
|
||||||
@ -379,10 +380,26 @@ class Data(object):
|
|||||||
self.appendWFData(fnames)
|
self.appendWFData(fnames)
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
# various pre-processing steps:
|
||||||
|
# remove possible underscores in station names
|
||||||
|
self.wfdata = remove_underscores(self.wfdata)
|
||||||
|
# check for gaps and doubled channels
|
||||||
|
check4gaps(self.wfdata)
|
||||||
|
check4doubled(self.wfdata)
|
||||||
|
# check for stations with rotated components
|
||||||
|
if checkRotated and metadata is not None:
|
||||||
|
self.wfdata = check4rotated(self.wfdata, metadata, verbosity=0)
|
||||||
|
# trim station components to same start value
|
||||||
|
trim_station_components(self.wfdata, trim_start=True, trim_end=False)
|
||||||
|
|
||||||
|
# make a copy of original data
|
||||||
self.wforiginal = self.getWFData().copy()
|
self.wforiginal = self.getWFData().copy()
|
||||||
self.dirty = False
|
self.dirty = False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def appendWFData(self, fnames):
|
def appendWFData(self, fnames):
|
||||||
"""
|
"""
|
||||||
Read waveform data from fnames and append it to current wf data
|
Read waveform data from fnames and append it to current wf data
|
||||||
|
@ -24,7 +24,7 @@ class Thread(QThread):
|
|||||||
if self.redirect_stdout:
|
if self.redirect_stdout:
|
||||||
sys.stdout = self
|
sys.stdout = self
|
||||||
try:
|
try:
|
||||||
if self.arg:
|
if self.arg is not None:
|
||||||
self.data = self.func(self.arg)
|
self.data = self.func(self.arg)
|
||||||
else:
|
else:
|
||||||
self.data = self.func()
|
self.data = self.func()
|
||||||
|
Loading…
Reference in New Issue
Block a user