Merge branch 'develop' of ariadne.geophysik.rub.de:/data/git/pylot into develop
This commit is contained in:
commit
16c07da6e4
82
QtPyLoT.py
82
QtPyLoT.py
@ -150,7 +150,7 @@ class MainWindow(QMainWindow):
|
|||||||
QCoreApplication.instance().quit,
|
QCoreApplication.instance().quit,
|
||||||
QKeySequence.Close, quitIcon,
|
QKeySequence.Close, quitIcon,
|
||||||
"Close event and quit PyLoT")
|
"Close event and quit PyLoT")
|
||||||
filterAction = self.createAction("&Filter ...", self.filterWaveformData,
|
self.filterAction = self.createAction("&Filter ...", self.filterWaveformData,
|
||||||
"Ctrl+F", QIcon(":/filter.png"),
|
"Ctrl+F", QIcon(":/filter.png"),
|
||||||
"""Toggle un-/filtered waveforms
|
"""Toggle un-/filtered waveforms
|
||||||
to be displayed, according to the
|
to be displayed, according to the
|
||||||
@ -159,10 +159,10 @@ class MainWindow(QMainWindow):
|
|||||||
self.adjustFilterOptions,
|
self.adjustFilterOptions,
|
||||||
"Alt+F", QIcon(None),
|
"Alt+F", QIcon(None),
|
||||||
"""Adjust filter parameters.""")
|
"""Adjust filter parameters.""")
|
||||||
selectPAction = self.createAction("&P", self.alterPhase, "Alt+P",
|
self.selectPAction = self.createAction("&P", self.alterPhase, "Alt+P",
|
||||||
QIcon(":/picon.png"),
|
QIcon(":/picon.png"),
|
||||||
"Toggle P phase.", True)
|
"Toggle P phase.", True)
|
||||||
selectSAction = self.createAction("&S", self.alterPhase, "Alt+S",
|
self.selectSAction = self.createAction("&S", self.alterPhase, "Alt+S",
|
||||||
QIcon(":/sicon.png"),
|
QIcon(":/sicon.png"),
|
||||||
"Toggle S phase", True)
|
"Toggle S phase", True)
|
||||||
printAction = self.createAction("&Print event ...",
|
printAction = self.createAction("&Print event ...",
|
||||||
@ -182,13 +182,24 @@ class MainWindow(QMainWindow):
|
|||||||
self.updateFileMenu()
|
self.updateFileMenu()
|
||||||
|
|
||||||
self.editMenu = self.menuBar().addMenu('&Edit')
|
self.editMenu = self.menuBar().addMenu('&Edit')
|
||||||
editActions = (filterAction, filterEditAction, None, selectPAction,
|
editActions = (self.filterAction, filterEditAction, None,
|
||||||
selectSAction, None, printAction)
|
self.selectPAction, self.selectSAction, None,
|
||||||
self.addMenuActions(self.editMenu, editActions)
|
printAction)
|
||||||
|
self.addActions(self.editMenu, editActions)
|
||||||
|
|
||||||
self.helpMenu = self.menuBar().addMenu('&Help')
|
self.helpMenu = self.menuBar().addMenu('&Help')
|
||||||
helpActions = (helpAction, )
|
helpActions = (helpAction, )
|
||||||
self.addMenuActions(self.helpMenu, helpActions)
|
self.addActions(self.helpMenu, helpActions)
|
||||||
|
|
||||||
|
fileToolBar = self.addToolBar("FileTools")
|
||||||
|
fileToolActions = (newEventAction, openEventAction, saveEventAction)
|
||||||
|
fileToolBar.setObjectName("FileTools")
|
||||||
|
self.addActions(fileToolBar, fileToolActions)
|
||||||
|
|
||||||
|
phaseToolBar = self.addToolBar("PhaseTools")
|
||||||
|
phaseToolActions = (self.selectPAction, self.selectSAction)
|
||||||
|
phaseToolBar.setObjectName("PhaseTools")
|
||||||
|
self.addActions(phaseToolBar, phaseToolActions)
|
||||||
|
|
||||||
self.eventLabel = QLabel()
|
self.eventLabel = QLabel()
|
||||||
self.eventLabel.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken)
|
self.eventLabel.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken)
|
||||||
@ -264,10 +275,10 @@ class MainWindow(QMainWindow):
|
|||||||
filt = "Supported event formats (*.mat *.qml *.xml " \
|
filt = "Supported event formats (*.mat *.qml *.xml " \
|
||||||
"*.kor *.evt)"
|
"*.kor *.evt)"
|
||||||
caption = 'Select event to open'
|
caption = 'Select event to open'
|
||||||
fname, = QFileDialog().getOpenFileName(self,
|
fname = QFileDialog().getOpenFileName(self,
|
||||||
caption=caption,
|
caption=caption,
|
||||||
filter=filt)
|
filter=filt)
|
||||||
self.fname = fname
|
self.fname = fname[0]
|
||||||
else:
|
else:
|
||||||
self.fname = unicode(action.data().toString())
|
self.fname = unicode(action.data().toString())
|
||||||
if not self.okToContinue():
|
if not self.okToContinue():
|
||||||
@ -298,7 +309,7 @@ class MainWindow(QMainWindow):
|
|||||||
"Select waveform "
|
"Select waveform "
|
||||||
"files:",
|
"files:",
|
||||||
dir=searchPath)
|
dir=searchPath)
|
||||||
self.fnames = fnames
|
self.fnames = fnames[0]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise DatastructureError('not specified')
|
raise DatastructureError('not specified')
|
||||||
@ -318,8 +329,10 @@ class MainWindow(QMainWindow):
|
|||||||
self.data.exportEvent(self.fname, exform)
|
self.data.exportEvent(self.fname, exform)
|
||||||
except FormatError:
|
except FormatError:
|
||||||
return False
|
return False
|
||||||
except AttributeError:
|
except AttributeError, e:
|
||||||
fname, = QFileDialog.getSaveFileName(self, 'Save event')
|
print 'warning: {0}'.format(e)
|
||||||
|
fname = QFileDialog.getSaveFileName(self, 'Save event')
|
||||||
|
fname = fname[0]
|
||||||
self.data.exportEvent(fname, exform)
|
self.data.exportEvent(fname, exform)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -332,12 +345,12 @@ class MainWindow(QMainWindow):
|
|||||||
def getDataWidget(self):
|
def getDataWidget(self):
|
||||||
return self.DataPlot
|
return self.DataPlot
|
||||||
|
|
||||||
def addMenuActions(self, menu, actions):
|
def addActions(self, target, actions):
|
||||||
for action in actions:
|
for action in actions:
|
||||||
if action is None:
|
if action is None:
|
||||||
menu.addSeparator()
|
target.addSeparator()
|
||||||
else:
|
else:
|
||||||
menu.addAction(action)
|
target.addAction(action)
|
||||||
|
|
||||||
def okToContinue(self):
|
def okToContinue(self):
|
||||||
if self.dirty:
|
if self.dirty:
|
||||||
@ -353,20 +366,30 @@ class MainWindow(QMainWindow):
|
|||||||
self.plotWaveformData()
|
self.plotWaveformData()
|
||||||
|
|
||||||
def plotWaveformData(self):
|
def plotWaveformData(self):
|
||||||
self.getData().plotData(self.getDataWidget())
|
self.getData().plotWFData(self.getDataWidget())
|
||||||
|
|
||||||
def filterWaveformData(self):
|
def filterWaveformData(self):
|
||||||
if self.getData():
|
if self.getData():
|
||||||
kwargs = {}
|
def hasfreq(kwargs):
|
||||||
freq = self.getFilterOptions().getFreq()
|
for key in kwargs.keys():
|
||||||
if len(freq) > 1:
|
if not key.startswith('freq'):
|
||||||
kwargs['freqmin'] = freq[0]
|
return True
|
||||||
kwargs['freqmax'] = freq[1]
|
return False
|
||||||
|
if self.filterAction.isChecked():
|
||||||
|
kwargs = {}
|
||||||
|
freq = self.getFilterOptions().getFreq()
|
||||||
|
if freq is not None and len(freq) > 1:
|
||||||
|
kwargs['freqmin'] = freq[0]
|
||||||
|
kwargs['freqmax'] = freq[1]
|
||||||
|
elif freq is not None and len(freq) == 1:
|
||||||
|
kwargs['freq'] = freq
|
||||||
|
if hasfreq(kwargs):
|
||||||
|
kwargs['type'] = self.getFilterOptions().getFilterType()
|
||||||
|
kwargs['corners'] = self.getFilterOptions().getOrder()
|
||||||
|
self.getData().filterWFData(kwargs)
|
||||||
else:
|
else:
|
||||||
kwargs['freq'] = freq
|
self.getData().resetWFData()
|
||||||
kwargs['type'] = self.getFilterOptions().getFilterType()
|
self.plotWaveformData()
|
||||||
kwargs['corners'] = self.filteroptions.getOrder()
|
|
||||||
self.getData().filter(kwargs)
|
|
||||||
|
|
||||||
def adjustFilterOptions(self):
|
def adjustFilterOptions(self):
|
||||||
filteroptions = None
|
filteroptions = None
|
||||||
@ -399,7 +422,10 @@ class MainWindow(QMainWindow):
|
|||||||
emsg = QErrorMessage(self)
|
emsg = QErrorMessage(self)
|
||||||
emsg.showMessage('Error: {0}'.format(e))
|
emsg.showMessage('Error: {0}'.format(e))
|
||||||
else:
|
else:
|
||||||
self.updateStatus('Filter loaded ...')
|
self.updateStatus('Filter loaded ... '
|
||||||
|
'[{0}: {1} Hz]'.format(self.getFilterOptions().getFilterType(), self.getFilterOptions().getFreq()))
|
||||||
|
if self.filterAction.isChecked():
|
||||||
|
self.filterWaveformData()
|
||||||
|
|
||||||
def getSeismicPhase(self):
|
def getSeismicPhase(self):
|
||||||
return self.seismicPhase
|
return self.seismicPhase
|
||||||
@ -409,6 +435,8 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
def setSeismicPhase(self, phase):
|
def setSeismicPhase(self, phase):
|
||||||
self.seismicPhase = self.seismicPhaseButtonGroup.getValue()
|
self.seismicPhase = self.seismicPhaseButtonGroup.getValue()
|
||||||
|
self.updateStatus('Seismic phase changed to '
|
||||||
|
'{0}'.format(self.getSeismicPhase()))
|
||||||
|
|
||||||
def updateStatus(self, message):
|
def updateStatus(self, message):
|
||||||
self.statusBar().showMessage(message, 5000)
|
self.statusBar().showMessage(message, 5000)
|
||||||
@ -421,10 +449,8 @@ class MainWindow(QMainWindow):
|
|||||||
else:
|
else:
|
||||||
self.setWindowTitle(
|
self.setWindowTitle(
|
||||||
"PyLoT - seismic processing the python way[*]")
|
"PyLoT - seismic processing the python way[*]")
|
||||||
self.setWindowTitle("PyLoT - seismic processing the python way[*]")
|
|
||||||
self.setWindowModified(self.dirty)
|
self.setWindowModified(self.dirty)
|
||||||
|
|
||||||
self.statusBar().showMessage(message, 5000)
|
|
||||||
|
|
||||||
def printEvent(self):
|
def printEvent(self):
|
||||||
pass
|
pass
|
||||||
|
@ -95,7 +95,7 @@ class Data(object):
|
|||||||
raise KeyError('''{0} export format
|
raise KeyError('''{0} export format
|
||||||
not implemented: {1}'''.format(evtformat, e))
|
not implemented: {1}'''.format(evtformat, e))
|
||||||
|
|
||||||
def plotData(self, widget):
|
def plotWFData(self, widget):
|
||||||
wfst = self.getWFData().select(component=self.getComp())
|
wfst = self.getWFData().select(component=self.getComp())
|
||||||
for n, trace in enumerate(wfst):
|
for n, trace in enumerate(wfst):
|
||||||
stime = trace.stats.starttime - self.getCutTimes()[0]
|
stime = trace.stats.starttime - self.getCutTimes()[0]
|
||||||
@ -104,7 +104,7 @@ class Data(object):
|
|||||||
nsamp = len(trace.data)
|
nsamp = len(trace.data)
|
||||||
tincr = trace.stats.delta
|
tincr = trace.stats.delta
|
||||||
time_ax = np.arange(stime, nsamp / srate, tincr)
|
time_ax = np.arange(stime, nsamp / srate, tincr)
|
||||||
trace.normalize()
|
trace.normalize(trace.data.max() * 2)
|
||||||
widget.axes.plot(time_ax, trace.data + n, 'k')
|
widget.axes.plot(time_ax, trace.data + n, 'k')
|
||||||
xlabel = 'seconds since {0}'.format(self.getCutTimes()[0])
|
xlabel = 'seconds since {0}'.format(self.getCutTimes()[0])
|
||||||
ylabel = ''
|
ylabel = ''
|
||||||
@ -121,7 +121,7 @@ class Data(object):
|
|||||||
except:
|
except:
|
||||||
return 'smi:bug/pylot/1234'
|
return 'smi:bug/pylot/1234'
|
||||||
|
|
||||||
def filter(self, kwargs):
|
def filterWFData(self, kwargs):
|
||||||
self.getWFData().filter(**kwargs)
|
self.getWFData().filter(**kwargs)
|
||||||
self.dirty = True
|
self.dirty = True
|
||||||
|
|
||||||
@ -130,17 +130,28 @@ class Data(object):
|
|||||||
self.wforiginal = None
|
self.wforiginal = None
|
||||||
if fnames is not None:
|
if fnames is not None:
|
||||||
self.appendWFData(fnames)
|
self.appendWFData(fnames)
|
||||||
self.orig = self.getWFData().copy()
|
self.wforiginal = self.getWFData().copy()
|
||||||
self.dirty = False
|
self.dirty = False
|
||||||
|
|
||||||
def appendWFData(self, fnames):
|
def appendWFData(self, fnames):
|
||||||
if self.dirty is not False:
|
assert isinstance(fnames, list), "input parameter 'fnames' is " \
|
||||||
|
"supposed to be of type 'list' " \
|
||||||
|
"but is actually".format(type(fnames))
|
||||||
|
if self.dirty:
|
||||||
self.resetWFData()
|
self.resetWFData()
|
||||||
|
|
||||||
|
warnmsg = ''
|
||||||
for fname in fnames:
|
for fname in fnames:
|
||||||
try:
|
try:
|
||||||
self.wfdata += read(fname)
|
self.wfdata += read(fname)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
self.wfdata += read(fname, format='GSE2')
|
try:
|
||||||
|
self.wfdata += read(fname, format='GSE2')
|
||||||
|
except Exception:
|
||||||
|
warnmsg += '{0}\n'.format(fname)
|
||||||
|
if warnmsg:
|
||||||
|
warnmsg = 'WARNING: unable to read\n' + warnmsg
|
||||||
|
print warnmsg
|
||||||
|
|
||||||
def getWFData(self):
|
def getWFData(self):
|
||||||
return self.wfdata
|
return self.wfdata
|
||||||
@ -351,6 +362,5 @@ class SeiscompDataStructure(object):
|
|||||||
self.getFields()['NET'],
|
self.getFields()['NET'],
|
||||||
self.getFields()['STA'],
|
self.getFields()['STA'],
|
||||||
fullChan,
|
fullChan,
|
||||||
'*{0}'.format(self.getFields()['DAY'])
|
'*{0}'.format(self.getFields()['DAY']))
|
||||||
)
|
|
||||||
return dataPath
|
return dataPath
|
||||||
|
@ -52,6 +52,7 @@ class MPLWidget(FigureCanvas):
|
|||||||
self.figure = Figure()
|
self.figure = Figure()
|
||||||
self.canvas = FigureCanvas(self.figure)
|
self.canvas = FigureCanvas(self.figure)
|
||||||
self.axes = self.figure.add_subplot(111)
|
self.axes = self.figure.add_subplot(111)
|
||||||
|
self.axes.autoscale(tight=True)
|
||||||
|
|
||||||
self.updateWidget(xlabel, ylabel, title)
|
self.updateWidget(xlabel, ylabel, title)
|
||||||
|
|
||||||
@ -109,8 +110,7 @@ class PropertiesDlg(QDialog):
|
|||||||
|
|
||||||
def accept(self, *args, **kwargs):
|
def accept(self, *args, **kwargs):
|
||||||
self.apply()
|
self.apply()
|
||||||
self.destroy()
|
QDialog.accept(self)
|
||||||
return self.accepted
|
|
||||||
|
|
||||||
def apply(self):
|
def apply(self):
|
||||||
for widint in range(self.tabWidget.count()):
|
for widint in range(self.tabWidget.count()):
|
||||||
@ -307,15 +307,15 @@ class FilterOptionsDialog(QDialog):
|
|||||||
self.freqminSpinBox.setRange(5e-7, 1e6)
|
self.freqminSpinBox.setRange(5e-7, 1e6)
|
||||||
self.freqminSpinBox.setDecimals(2)
|
self.freqminSpinBox.setDecimals(2)
|
||||||
self.freqminSpinBox.setSuffix(' Hz')
|
self.freqminSpinBox.setSuffix(' Hz')
|
||||||
self.freqminSpinBox.setValue(self.getFilterOptions().getFreq[0])
|
self.freqminSpinBox.setValue(self.getFilterOptions().getFreq()[0])
|
||||||
self.freqmaxLabel = QLabel()
|
self.freqmaxLabel = QLabel()
|
||||||
self.freqmaxLabel.setText("maximum:")
|
self.freqmaxLabel.setText("maximum:")
|
||||||
self.freqmaxSpinBox = QDoubleSpinBox()
|
self.freqmaxSpinBox = QDoubleSpinBox()
|
||||||
self.freqmaxSpinBox.setRange(5e-7, 1e6)
|
self.freqmaxSpinBox.setRange(5e-7, 1e6)
|
||||||
self.freqmaxSpinBox.setDecimals(2)
|
self.freqmaxSpinBox.setDecimals(2)
|
||||||
self.freqmaxSpinBox.setSuffix(' Hz')
|
self.freqmaxSpinBox.setSuffix(' Hz')
|
||||||
if self.filterOptions.filterType in ['bandpass', 'bandstop']:
|
if self.getFilterOptions().getFilterType() in ['bandpass', 'bandstop']:
|
||||||
self.freqmaxSpinBox.setValue(self.getFilterOptions().getFreq[1])
|
self.freqmaxSpinBox.setValue(self.getFilterOptions().getFreq()[1])
|
||||||
|
|
||||||
typeOptions = ["bandpass", "bandstop", "lowpass", "highpass"]
|
typeOptions = ["bandpass", "bandstop", "lowpass", "highpass"]
|
||||||
|
|
||||||
@ -369,10 +369,10 @@ class FilterOptionsDialog(QDialog):
|
|||||||
self.freqmaxLabel.setEnabled(True)
|
self.freqmaxLabel.setEnabled(True)
|
||||||
self.freqmaxSpinBox.setEnabled(True)
|
self.freqmaxSpinBox.setEnabled(True)
|
||||||
|
|
||||||
self.filterOptions.filterType = self.selectTypeCombo.currentText()
|
self.getFilterOptions().setFilterType(self.selectTypeCombo.currentText())
|
||||||
freq = []
|
freq = []
|
||||||
freq.append(self.freqminSpinBox.value())
|
freq.append(self.freqminSpinBox.value())
|
||||||
if self.filterOptions.filterType in ['bandpass', 'bandstop']:
|
if self.getFilterOptions().getFilterType() in ['bandpass', 'bandstop']:
|
||||||
if self.freqminSpinBox.value() > self.freqmaxSpinBox.value():
|
if self.freqminSpinBox.value() > self.freqmaxSpinBox.value():
|
||||||
QMessageBox.warning(self, "Value error",
|
QMessageBox.warning(self, "Value error",
|
||||||
"Maximum frequency must be at least the "
|
"Maximum frequency must be at least the "
|
||||||
@ -382,8 +382,8 @@ class FilterOptionsDialog(QDialog):
|
|||||||
self.freqmaxSpinBox.setFocus()
|
self.freqmaxSpinBox.setFocus()
|
||||||
return
|
return
|
||||||
freq.append(self.freqmaxSpinBox.value())
|
freq.append(self.freqmaxSpinBox.value())
|
||||||
self.filterOptions.freq = freq
|
self.getFilterOptions().setFreq(freq)
|
||||||
self.filterOptions.order = self.orderSpinBox.value()
|
self.getFilterOptions().setOrder(self.orderSpinBox.value())
|
||||||
|
|
||||||
def getFilterOptions(self):
|
def getFilterOptions(self):
|
||||||
return self.filterOptions
|
return self.filterOptions
|
||||||
|
Loading…
Reference in New Issue
Block a user