2014-03-13 13:27:34 +01:00
|
|
|
#!/usr/bin/env python
|
2014-03-31 12:57:08 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
PyLoT: Main program
|
|
|
|
===================
|
|
|
|
PyLoT is a seismic data processing software capable of picking seismic
|
|
|
|
phases (symmetric and asymmetric error assignment), exporting these to
|
|
|
|
several common phase data formats and post process the data, e.g. locating
|
|
|
|
events, via external localization software.
|
|
|
|
Additionally PyLoT is meant as an interface to autoPyLoT which can
|
|
|
|
automatically pick seismic phases, if the parameters have properly been
|
|
|
|
chosen for the particular data set.
|
|
|
|
|
2014-11-28 09:19:16 +01:00
|
|
|
Some icons are out of a free of charge icon set, which can be found here:
|
|
|
|
https://www.iconfinder.com/iconsets/flavour
|
|
|
|
|
2014-03-31 12:57:08 +02:00
|
|
|
:author:
|
|
|
|
Sebastian Wehling-Benatelli
|
|
|
|
:copyright:
|
|
|
|
The PyLoT Development Team (https://ariadne.geophysik.rub.de/trac/PyLoT)
|
|
|
|
:license:
|
|
|
|
GNU Lesser General Public License, Version 3
|
|
|
|
(http://www.gnu.org/copyleft/lesser.html)
|
|
|
|
"""
|
2014-01-09 10:43:40 +01:00
|
|
|
|
|
|
|
import sys
|
2014-12-04 05:13:32 +01:00
|
|
|
|
2015-02-16 10:24:17 +01:00
|
|
|
from PySide.QtCore import QCoreApplication, QSettings, Signal, QFile, QFileInfo
|
|
|
|
from PySide.QtGui import QMainWindow, QInputDialog, QIcon, QFileDialog, \
|
|
|
|
QWidget, QHBoxLayout, QStyle, QKeySequence, QLabel, QFrame, QAction, \
|
|
|
|
QDialog, QErrorMessage, QApplication
|
|
|
|
from obspy.core import UTCDateTime
|
|
|
|
|
|
|
|
from pylot.core.read import Data, FilterOptions
|
|
|
|
from pylot.core.util import _getVersionString, FILTERDEFAULTS, fnConstructor, \
|
2015-03-01 10:31:49 +01:00
|
|
|
checkurl, FormatError, FilterOptionsDialog, \
|
2015-02-17 13:17:01 +01:00
|
|
|
NewEventDlg, createEvent, MPLWidget, PropertiesDlg, HelpForm, \
|
2015-03-04 11:52:04 +01:00
|
|
|
DatastructureError, createAction, getLogin
|
2015-02-13 11:12:47 +01:00
|
|
|
from pylot.core.util.structure import DATASTRUCTURE
|
2014-12-04 05:13:32 +01:00
|
|
|
|
2014-01-09 10:43:40 +01:00
|
|
|
|
2015-02-16 10:24:17 +01:00
|
|
|
|
2014-01-09 10:43:40 +01:00
|
|
|
# Version information
|
|
|
|
__version__ = _getVersionString()
|
|
|
|
|
2014-03-13 13:27:34 +01:00
|
|
|
|
2014-01-10 05:45:03 +01:00
|
|
|
class MainWindow(QMainWindow):
|
2014-12-08 10:26:14 +01:00
|
|
|
closing = Signal()
|
|
|
|
|
2014-01-10 05:45:03 +01:00
|
|
|
def __init__(self, parent=None):
|
|
|
|
super(MainWindow, self).__init__(parent)
|
2014-03-13 13:27:34 +01:00
|
|
|
|
2015-03-04 11:52:04 +01:00
|
|
|
|
|
|
|
self.createAction = createAction
|
2015-02-13 11:17:18 +01:00
|
|
|
self.dirty = False
|
2014-11-28 11:15:49 +01:00
|
|
|
settings = QSettings()
|
2014-12-08 10:26:14 +01:00
|
|
|
if settings.value("user/FullName", None) is None:
|
|
|
|
fulluser = QInputDialog.getText(self, "Enter Name:", "Full name")
|
|
|
|
settings.setValue("user/FullName", fulluser)
|
2015-03-04 11:52:04 +01:00
|
|
|
settings.setValue("user/Login", getLogin())
|
2014-12-08 10:26:14 +01:00
|
|
|
settings.sync()
|
|
|
|
self.recentEvents = settings.value("data/recentEvents", [])
|
2015-02-13 11:17:18 +01:00
|
|
|
self.fnames = None
|
2015-02-13 11:12:47 +01:00
|
|
|
self.dataStructure = DATASTRUCTURE[
|
2015-03-04 11:52:04 +01:00
|
|
|
settings.value("data/Structure", "PILOT")]()
|
2014-11-28 11:15:49 +01:00
|
|
|
self.seismicPhase = str(settings.value("phase", "P"))
|
2015-02-04 14:50:49 +01:00
|
|
|
self.dispComponent = str(settings.value("plotting/dispComponent", "Z"))
|
2014-12-08 10:26:14 +01:00
|
|
|
if settings.value("data/dataRoot", None) is None:
|
2015-01-29 08:53:01 +01:00
|
|
|
dirname = QFileDialog().getExistingDirectory(
|
|
|
|
caption='Choose data root ...')
|
2014-12-08 10:26:14 +01:00
|
|
|
settings.setValue("data/dataRoot", dirname)
|
2014-12-01 12:36:23 +01:00
|
|
|
settings.sync()
|
2014-11-28 11:15:49 +01:00
|
|
|
|
2015-03-01 10:31:49 +01:00
|
|
|
self.filteroptions = {}
|
2014-03-13 13:27:34 +01:00
|
|
|
|
2015-03-01 10:31:49 +01:00
|
|
|
# UI has to be set up before(!) children widgets are about to show up
|
2015-02-16 10:25:51 +01:00
|
|
|
self.setupUi()
|
|
|
|
|
|
|
|
# initialize event data
|
2015-02-13 11:14:17 +01:00
|
|
|
if self.recentEvents:
|
|
|
|
lastEvent = self.getLastEvent()
|
|
|
|
self.data = Data(self, lastEvent)
|
|
|
|
else:
|
|
|
|
self.data = Data(self)
|
2015-02-16 10:25:51 +01:00
|
|
|
|
|
|
|
# load and display waveform data
|
|
|
|
self.loadWaveformData()
|
2014-12-08 10:26:14 +01:00
|
|
|
self.dirty = False
|
2014-03-28 05:25:46 +01:00
|
|
|
self.loadData()
|
|
|
|
self.updateFilterOptions()
|
2015-02-17 13:17:01 +01:00
|
|
|
|
|
|
|
|
|
|
|
def setupUi(self):
|
|
|
|
|
2014-11-26 08:46:16 +01:00
|
|
|
try:
|
2015-01-29 08:53:01 +01:00
|
|
|
self.startTime = min(
|
|
|
|
[tr.stats.starttime for tr in self.data.wfdata])
|
2014-11-26 08:46:16 +01:00
|
|
|
except:
|
|
|
|
self.startTime = UTCDateTime()
|
2014-03-28 05:25:46 +01:00
|
|
|
|
2015-03-01 10:31:49 +01:00
|
|
|
self.setWindowTitle("PyLoT - do seismic processing the python way")
|
2015-01-29 08:41:38 +01:00
|
|
|
self.setWindowIcon(QIcon(":/icon.ico"))
|
|
|
|
|
|
|
|
xlab = self.startTime.strftime('seconds since %d %b %Y %H:%M:%S (%Z)')
|
|
|
|
|
|
|
|
_widget = QWidget()
|
|
|
|
_layout = QHBoxLayout()
|
|
|
|
|
2015-02-07 09:03:03 +01:00
|
|
|
plottitle = "Overview: {0} components ".format(self.getComponent())
|
|
|
|
|
2015-02-16 10:31:25 +01:00
|
|
|
# create central matplotlib figure canvas widget
|
|
|
|
self.DataPlot = MPLWidget(parent=self, xlabel=xlab, ylabel=None,
|
2015-01-29 08:41:38 +01:00
|
|
|
title=plottitle)
|
2015-02-17 13:17:01 +01:00
|
|
|
|
2015-01-29 08:41:38 +01:00
|
|
|
_layout.addWidget(self.DataPlot)
|
|
|
|
|
|
|
|
openIcon = self.style().standardIcon(QStyle.SP_DirOpenIcon)
|
|
|
|
quitIcon = self.style().standardIcon(QStyle.SP_MediaStop)
|
|
|
|
saveIcon = self.style().standardIcon(QStyle.SP_DriveHDIcon)
|
|
|
|
helpIcon = self.style().standardIcon(QStyle.SP_DialogHelpButton)
|
|
|
|
newIcon = self.style().standardIcon(QStyle.SP_FileIcon)
|
|
|
|
newEventAction = self.createAction("&New event ...",
|
|
|
|
self.createNewEvent,
|
|
|
|
QKeySequence.New, newIcon,
|
|
|
|
"Create a new event.")
|
|
|
|
openEventAction = self.createAction("&Open event ...", self.loadData,
|
|
|
|
QKeySequence.Open, openIcon,
|
|
|
|
"Open an event.")
|
|
|
|
openEventAction.setData(None)
|
|
|
|
saveEventAction = self.createAction("&Save event ...", self.saveData,
|
|
|
|
QKeySequence.Save, saveIcon,
|
|
|
|
"Save actual event data.")
|
|
|
|
openWFDataAction = self.createAction("Open &waveforms ...",
|
2015-02-16 10:27:32 +01:00
|
|
|
self.loadWaveformData,
|
2015-01-29 08:41:38 +01:00
|
|
|
"Ctrl+W", QIcon(":/wfIcon.png"),
|
|
|
|
"""Open waveform data (event will
|
|
|
|
be closed).""")
|
|
|
|
|
|
|
|
prefsEventAction = self.createAction("Preferences", self.PyLoTprefs,
|
|
|
|
QKeySequence.Preferences,
|
|
|
|
QIcon(None),
|
|
|
|
"Edit PyLoT app preferences.")
|
|
|
|
quitAction = self.createAction("&Quit",
|
|
|
|
QCoreApplication.instance().quit,
|
|
|
|
QKeySequence.Close, quitIcon,
|
|
|
|
"Close event and quit PyLoT")
|
2015-02-20 08:30:17 +01:00
|
|
|
self.filterAction = self.createAction("&Filter ...", self.filterWaveformData,
|
2015-01-29 08:41:38 +01:00
|
|
|
"Ctrl+F", QIcon(":/filter.png"),
|
|
|
|
"""Toggle un-/filtered waveforms
|
|
|
|
to be displayed, according to the
|
|
|
|
desired seismic phase.""", True)
|
|
|
|
filterEditAction = self.createAction("&Filter parameter ...",
|
|
|
|
self.adjustFilterOptions,
|
|
|
|
"Alt+F", QIcon(None),
|
|
|
|
"""Adjust filter parameters.""")
|
2015-02-20 08:30:17 +01:00
|
|
|
self.selectPAction = self.createAction("&P", self.alterPhase, "Alt+P",
|
2015-01-29 08:41:38 +01:00
|
|
|
QIcon(":/picon.png"),
|
|
|
|
"Toggle P phase.", True)
|
2015-02-20 08:30:17 +01:00
|
|
|
self.selectSAction = self.createAction("&S", self.alterPhase, "Alt+S",
|
2015-01-29 08:41:38 +01:00
|
|
|
QIcon(":/sicon.png"),
|
|
|
|
"Toggle S phase", True)
|
|
|
|
printAction = self.createAction("&Print event ...",
|
|
|
|
self.printEvent, QKeySequence.Print,
|
|
|
|
QIcon(":/printer.png"),
|
|
|
|
"Print waveform overview.")
|
|
|
|
helpAction = self.createAction("&Help ...", self.helpHelp,
|
|
|
|
QKeySequence.HelpContents, helpIcon,
|
|
|
|
"""Show either the documentation
|
|
|
|
homepage (internet connection available),
|
|
|
|
or shipped documentation files.""")
|
|
|
|
self.fileMenu = self.menuBar().addMenu('&File')
|
|
|
|
self.fileMenuActions = (newEventAction, openEventAction,
|
|
|
|
saveEventAction, openWFDataAction, None,
|
|
|
|
prefsEventAction, quitAction)
|
|
|
|
self.fileMenu.aboutToShow.connect(self.updateFileMenu)
|
|
|
|
self.updateFileMenu()
|
|
|
|
|
|
|
|
self.editMenu = self.menuBar().addMenu('&Edit')
|
2015-02-20 08:30:17 +01:00
|
|
|
editActions = (self.filterAction, filterEditAction, None,
|
|
|
|
self.selectPAction, self.selectSAction, None,
|
|
|
|
printAction)
|
2015-02-23 14:47:38 +01:00
|
|
|
self.addActions(self.editMenu, editActions)
|
2015-01-29 08:41:38 +01:00
|
|
|
|
|
|
|
self.helpMenu = self.menuBar().addMenu('&Help')
|
|
|
|
helpActions = (helpAction, )
|
2015-02-23 14:47:38 +01:00
|
|
|
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)
|
2015-01-29 08:41:38 +01:00
|
|
|
|
|
|
|
self.eventLabel = QLabel()
|
|
|
|
self.eventLabel.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken)
|
|
|
|
status = self.statusBar()
|
|
|
|
status.setSizeGripEnabled(False)
|
|
|
|
status.addPermanentWidget(self.eventLabel)
|
|
|
|
status.showMessage("Ready", 500)
|
|
|
|
|
|
|
|
_widget.setLayout(_layout)
|
|
|
|
self.setCentralWidget(_widget)
|
2014-10-27 11:57:34 +01:00
|
|
|
|
2014-11-27 10:13:17 +01:00
|
|
|
|
2014-12-01 12:37:52 +01:00
|
|
|
def updateFileMenu(self):
|
|
|
|
|
|
|
|
self.fileMenu.clear()
|
2015-01-20 13:44:35 +01:00
|
|
|
for action in self.fileMenuActions[:-1]:
|
|
|
|
if action is None:
|
|
|
|
self.fileMenu.addSeparator()
|
|
|
|
else:
|
|
|
|
self.fileMenu.addAction(action)
|
|
|
|
try:
|
2015-02-13 11:15:48 +01:00
|
|
|
current = self.data.getID()
|
2015-01-20 13:44:35 +01:00
|
|
|
except AttributeError:
|
|
|
|
current = None
|
2014-12-01 12:37:52 +01:00
|
|
|
recentEvents = []
|
|
|
|
for eventID in self.recentEvents:
|
|
|
|
fname = fnConstructor(eventID)
|
|
|
|
if eventID != current and QFile.exists(fname):
|
|
|
|
recentEvents.append(eventID)
|
2015-02-13 11:16:20 +01:00
|
|
|
recentEvents.reverse()
|
|
|
|
self.recentEvents = recentEvents[0:5]
|
|
|
|
settings = QSettings()
|
|
|
|
settings.setValue()
|
2014-12-01 12:37:52 +01:00
|
|
|
if recentEvents:
|
|
|
|
for i, eventID in enumerate(recentEvents):
|
|
|
|
fname = fnConstructor(eventID)
|
|
|
|
action = QAction(QIcon(":/icon.png"),
|
|
|
|
"&{0} {1}".format(i + 1,
|
|
|
|
QFileInfo(fname).fileName()),
|
|
|
|
self)
|
|
|
|
action.setData(fname)
|
2015-02-16 10:28:28 +01:00
|
|
|
self.connect(action, Signal("triggered()"),
|
2014-12-01 12:37:52 +01:00
|
|
|
self.loadData)
|
|
|
|
self.fileMenu.addAction(action)
|
|
|
|
self.fileMenu.addSeparator()
|
|
|
|
self.fileMenu.addAction(self.fileMenuActions[-1])
|
|
|
|
|
|
|
|
def loadData(self, fname=None):
|
|
|
|
if fname is None:
|
2015-02-07 09:05:08 +01:00
|
|
|
try:
|
2015-02-16 10:30:35 +01:00
|
|
|
self.data = Data(self, evtdata=self.fname)
|
2015-02-07 09:05:08 +01:00
|
|
|
except AttributeError:
|
|
|
|
action = self.sender()
|
|
|
|
if isinstance(action, QAction):
|
|
|
|
if action.data() is None:
|
2015-03-01 10:31:49 +01:00
|
|
|
filt = "Supported event formats (*.mat *.qml *.xml *.kor *.evt)"
|
|
|
|
caption = "Open an event file"
|
2015-02-23 14:35:00 +01:00
|
|
|
fname = QFileDialog().getOpenFileName(self,
|
2015-02-16 10:30:35 +01:00
|
|
|
caption=caption,
|
|
|
|
filter=filt)
|
2015-02-23 14:35:00 +01:00
|
|
|
self.fname = fname[0]
|
2015-02-07 09:05:08 +01:00
|
|
|
else:
|
|
|
|
self.fname = unicode(action.data().toString())
|
2014-12-01 12:37:52 +01:00
|
|
|
if not self.okToContinue():
|
|
|
|
return
|
2015-02-07 09:05:08 +01:00
|
|
|
else:
|
2014-12-17 12:16:32 +01:00
|
|
|
self.fname = fname
|
2015-02-16 10:30:35 +01:00
|
|
|
self.data = Data(self, evtdata=self.fname)
|
2014-11-26 08:46:16 +01:00
|
|
|
|
2015-02-13 11:23:01 +01:00
|
|
|
def getLastEvent(self):
|
|
|
|
return self.recentEvents[0]
|
|
|
|
|
2015-01-22 16:41:52 +01:00
|
|
|
def getWFFnames(self):
|
2015-01-26 21:11:53 +01:00
|
|
|
try:
|
|
|
|
evt = self.getData().getEvtData()
|
|
|
|
if evt.picks:
|
|
|
|
for pick in evt.picks:
|
2015-01-29 08:48:25 +01:00
|
|
|
try:
|
|
|
|
if pick.waveform_id is not None:
|
|
|
|
fname = pick.waveform_id.getSEEDstring()
|
|
|
|
if fname not in self.fnames:
|
|
|
|
self.fnames.append(fname)
|
|
|
|
except:
|
|
|
|
continue
|
2015-01-26 21:11:53 +01:00
|
|
|
else:
|
|
|
|
if self.dataStructure:
|
|
|
|
searchPath = self.dataStructure.expandDataPath()
|
2015-02-17 13:17:01 +01:00
|
|
|
fnames = QFileDialog.getOpenFileNames(self,
|
2015-02-16 10:31:25 +01:00
|
|
|
"Select waveform "
|
|
|
|
"files:",
|
2015-02-13 11:19:10 +01:00
|
|
|
dir=searchPath)
|
2015-02-20 08:37:21 +01:00
|
|
|
self.fnames = fnames[0]
|
2015-02-13 11:19:10 +01:00
|
|
|
|
2015-01-29 08:48:25 +01:00
|
|
|
else:
|
2015-02-17 13:17:01 +01:00
|
|
|
raise DatastructureError('not specified')
|
2015-01-29 08:48:25 +01:00
|
|
|
return self.fnames
|
2015-02-17 13:17:01 +01:00
|
|
|
except DatastructureError, e:
|
|
|
|
print e
|
2015-01-29 08:48:25 +01:00
|
|
|
props = PropertiesDlg(self)
|
|
|
|
if props.exec_() == QDialog.Accepted:
|
|
|
|
return self.getWFFnames()
|
|
|
|
else:
|
|
|
|
return
|
2015-01-22 16:41:52 +01:00
|
|
|
|
2014-11-28 11:15:49 +01:00
|
|
|
def saveData(self):
|
2014-12-17 12:16:32 +01:00
|
|
|
settings = QSettings()
|
|
|
|
exform = settings.value('data/exportFormat', 'None')
|
|
|
|
try:
|
|
|
|
self.data.exportEvent(self.fname, exform)
|
|
|
|
except FormatError:
|
|
|
|
return False
|
2015-02-20 08:36:20 +01:00
|
|
|
except AttributeError, e:
|
|
|
|
print 'warning: {0}'.format(e)
|
2015-02-18 15:30:24 +01:00
|
|
|
fname = QFileDialog.getSaveFileName(self, 'Save event')
|
2015-02-20 08:36:20 +01:00
|
|
|
fname = fname[0]
|
2015-02-13 11:24:27 +01:00
|
|
|
self.data.exportEvent(fname, exform)
|
2014-12-08 10:26:14 +01:00
|
|
|
return True
|
2014-11-28 11:15:49 +01:00
|
|
|
|
2015-02-07 09:03:03 +01:00
|
|
|
def getComponent(self):
|
|
|
|
return self.dispComponent
|
2014-03-28 22:26:15 +01:00
|
|
|
|
2014-11-13 11:27:52 +01:00
|
|
|
def getData(self):
|
|
|
|
return self.data
|
|
|
|
|
2015-03-04 11:52:04 +01:00
|
|
|
def getPlotWidget(self):
|
2014-11-13 11:27:52 +01:00
|
|
|
return self.DataPlot
|
|
|
|
|
2015-02-23 14:38:26 +01:00
|
|
|
def addActions(self, target, actions):
|
2015-01-22 16:41:52 +01:00
|
|
|
for action in actions:
|
2015-01-20 13:48:19 +01:00
|
|
|
if action is None:
|
2015-02-23 14:38:26 +01:00
|
|
|
target.addSeparator()
|
2015-01-20 13:48:19 +01:00
|
|
|
else:
|
2015-02-23 14:38:26 +01:00
|
|
|
target.addAction(action)
|
2015-01-20 13:48:19 +01:00
|
|
|
|
2014-12-01 12:41:13 +01:00
|
|
|
def okToContinue(self):
|
|
|
|
if self.dirty:
|
|
|
|
return self.saveData()
|
|
|
|
return True
|
2014-03-28 05:25:46 +01:00
|
|
|
|
2015-02-16 10:27:32 +01:00
|
|
|
def loadWaveformData(self):
|
2015-02-13 11:20:29 +01:00
|
|
|
if self.fnames and self.okToContinue():
|
|
|
|
self.dirty = True
|
|
|
|
self.data.setWFData(self.fnames)
|
|
|
|
elif self.fnames is None and self.okToContinue():
|
|
|
|
self.data.setWFData(self.getWFFnames())
|
2015-02-17 13:17:01 +01:00
|
|
|
self.plotWaveformData()
|
2015-01-29 08:48:25 +01:00
|
|
|
|
2015-02-17 13:17:01 +01:00
|
|
|
def plotWaveformData(self):
|
2015-03-04 11:52:04 +01:00
|
|
|
self.getData().plotWFData(self.getPlotWidget())
|
2014-03-19 12:24:41 +01:00
|
|
|
|
2015-02-17 13:17:01 +01:00
|
|
|
def filterWaveformData(self):
|
2014-12-09 05:25:43 +01:00
|
|
|
if self.getData():
|
2015-02-18 15:27:50 +01:00
|
|
|
def hasfreq(kwargs):
|
|
|
|
for key in kwargs.keys():
|
|
|
|
if not key.startswith('freq'):
|
|
|
|
return True
|
|
|
|
return False
|
2015-02-20 08:38:26 +01:00
|
|
|
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()
|
2015-02-20 08:35:26 +01:00
|
|
|
self.getData().filterWFData(kwargs)
|
2015-02-20 08:38:26 +01:00
|
|
|
else:
|
2015-02-20 08:35:26 +01:00
|
|
|
self.getData().resetWFData()
|
2015-02-20 08:38:26 +01:00
|
|
|
self.plotWaveformData()
|
2014-11-28 11:15:49 +01:00
|
|
|
|
2014-11-06 15:07:05 +01:00
|
|
|
def adjustFilterOptions(self):
|
2014-12-09 05:25:43 +01:00
|
|
|
filteroptions = None
|
2014-11-13 11:27:52 +01:00
|
|
|
fstring = "Filter Options ({0})".format(self.getSeismicPhase())
|
|
|
|
filterDlg = FilterOptionsDialog(titleString=fstring,
|
2014-11-06 15:07:05 +01:00
|
|
|
parent=self,
|
2014-11-13 11:27:52 +01:00
|
|
|
filterOptions=self.getFilterOptions())
|
2014-12-01 12:42:50 +01:00
|
|
|
if filterDlg.exec_():
|
2014-12-09 05:25:43 +01:00
|
|
|
filteroptions = filterDlg.getFilterOptions()
|
|
|
|
assert isinstance(filteroptions, FilterOptions)
|
|
|
|
self.setFilterOptions(filteroptions)
|
2014-11-13 11:27:52 +01:00
|
|
|
|
|
|
|
def getFilterOptions(self):
|
2015-03-01 10:31:49 +01:00
|
|
|
try:
|
|
|
|
return self.filteroptions[self.getSeismicPhase()]
|
|
|
|
except AttributeError, e:
|
|
|
|
print e
|
|
|
|
return FilterOptions(None, None, None)
|
|
|
|
|
|
|
|
def getFilters(self):
|
2014-11-13 11:27:52 +01:00
|
|
|
return self.filteroptions
|
|
|
|
|
2015-03-01 10:31:49 +01:00
|
|
|
def setFilterOptions(self, filterOptions, seismicPhase=None):
|
|
|
|
if seismicPhase is None:
|
|
|
|
self.getFilters()[self.getSeismicPhase()] = filterOptions
|
|
|
|
else:
|
|
|
|
self.getFilters()[seismicPhase] = filterOptions
|
|
|
|
|
2014-11-06 15:07:05 +01:00
|
|
|
|
2014-03-28 05:25:46 +01:00
|
|
|
def updateFilterOptions(self):
|
2014-10-27 12:04:01 +01:00
|
|
|
try:
|
2015-03-01 10:31:49 +01:00
|
|
|
settings = QSettings()
|
|
|
|
if settings.value("filterdefaults", None) is None and not self.getFilters():
|
|
|
|
for key, value in FILTERDEFAULTS.iteritems():
|
|
|
|
self.setFilterOptions(FilterOptions(**value), key)
|
|
|
|
elif settings.value("filterdefaults", None) is not None:
|
|
|
|
for key, value in settings.value("filterdefaults"):
|
|
|
|
self.setFilterOptions(FilterOptions(**value), key)
|
2014-11-06 15:07:05 +01:00
|
|
|
except Exception, e:
|
2014-11-28 09:19:16 +01:00
|
|
|
self.updateStatus('Error ...')
|
2014-11-28 11:15:49 +01:00
|
|
|
emsg = QErrorMessage(self)
|
|
|
|
emsg.showMessage('Error: {0}'.format(e))
|
2014-10-27 12:04:01 +01:00
|
|
|
else:
|
2015-02-23 14:46:18 +01:00
|
|
|
self.updateStatus('Filter loaded ... '
|
|
|
|
'[{0}: {1} Hz]'.format(self.getFilterOptions().getFilterType(), self.getFilterOptions().getFreq()))
|
2015-02-20 08:38:26 +01:00
|
|
|
if self.filterAction.isChecked():
|
|
|
|
self.filterWaveformData()
|
2014-03-28 22:26:15 +01:00
|
|
|
|
2014-11-13 11:27:52 +01:00
|
|
|
def getSeismicPhase(self):
|
|
|
|
return self.seismicPhase
|
|
|
|
|
2014-11-28 11:15:49 +01:00
|
|
|
def alterPhase(self):
|
|
|
|
pass
|
|
|
|
|
2014-11-13 11:27:52 +01:00
|
|
|
def setSeismicPhase(self, phase):
|
2014-11-28 09:19:16 +01:00
|
|
|
self.seismicPhase = self.seismicPhaseButtonGroup.getValue()
|
2015-02-23 14:46:18 +01:00
|
|
|
self.updateStatus('Seismic phase changed to '
|
|
|
|
'{0}'.format(self.getSeismicPhase()))
|
2014-11-13 11:27:52 +01:00
|
|
|
|
2014-04-01 16:46:10 +02:00
|
|
|
def updateStatus(self, message):
|
|
|
|
self.statusBar().showMessage(message, 5000)
|
2014-12-08 10:26:14 +01:00
|
|
|
if self.getData() is not None:
|
|
|
|
if not self.getData().isNew():
|
2015-01-29 08:53:01 +01:00
|
|
|
self.setWindowTitle(
|
|
|
|
"PyLoT - processing event %s[*]" % self.getData().getID())
|
2014-12-08 10:26:14 +01:00
|
|
|
elif self.getData().isNew():
|
|
|
|
self.setWindowTitle("PyLoT - New event [*]")
|
|
|
|
else:
|
2015-01-29 08:53:01 +01:00
|
|
|
self.setWindowTitle(
|
|
|
|
"PyLoT - seismic processing the python way[*]")
|
2014-12-08 10:26:14 +01:00
|
|
|
self.setWindowModified(self.dirty)
|
|
|
|
|
2014-04-01 16:46:10 +02:00
|
|
|
|
2014-11-28 11:15:49 +01:00
|
|
|
def printEvent(self):
|
|
|
|
pass
|
|
|
|
|
2015-01-22 16:41:52 +01:00
|
|
|
def createNewEvent(self):
|
|
|
|
if self.okToContinue():
|
|
|
|
new = NewEventDlg()
|
2015-01-23 10:21:34 +01:00
|
|
|
if new.exec_() != QDialog.Rejected:
|
2015-01-22 16:41:52 +01:00
|
|
|
evtpar = new.getValues()
|
2015-01-23 10:21:34 +01:00
|
|
|
self.data = Data(self, evtdata=createEvent(**evtpar))
|
|
|
|
self.dirty = True
|
2015-01-22 16:41:52 +01:00
|
|
|
|
2014-12-08 10:26:14 +01:00
|
|
|
def closeEvent(self, event):
|
|
|
|
if self.okToContinue():
|
|
|
|
self.closing.emit()
|
|
|
|
QMainWindow.closeEvent(self, event)
|
2014-11-28 11:15:49 +01:00
|
|
|
|
2014-12-17 06:33:34 +01:00
|
|
|
def PyLoTprefs(self):
|
|
|
|
props = PropertiesDlg(self)
|
|
|
|
if props.exec_():
|
|
|
|
return
|
|
|
|
|
2014-03-28 22:26:15 +01:00
|
|
|
def helpHelp(self):
|
2014-06-11 15:19:37 +02:00
|
|
|
if checkurl():
|
2015-01-29 08:53:01 +01:00
|
|
|
form = HelpForm(
|
|
|
|
'https://ariadne.geophysik.ruhr-uni-bochum.de/trac/PyLoT/wiki')
|
2014-06-11 15:19:37 +02:00
|
|
|
else:
|
|
|
|
form = HelpForm(':/help.html')
|
|
|
|
form.show()
|
2014-03-28 22:26:15 +01:00
|
|
|
|
2014-01-10 05:45:03 +01:00
|
|
|
|
2014-03-28 22:26:15 +01:00
|
|
|
def main():
|
2014-11-06 15:07:05 +01:00
|
|
|
# create the Qt application
|
2014-12-01 08:40:35 +01:00
|
|
|
pylot_app = QApplication(sys.argv[0])
|
2014-01-09 10:43:40 +01:00
|
|
|
|
2014-03-28 22:26:15 +01:00
|
|
|
# set Application Information
|
|
|
|
pylot_app.setOrganizationName("Ruhr-University Bochum / MAGS2")
|
|
|
|
pylot_app.setOrganizationDomain("rub.de")
|
|
|
|
pylot_app.setApplicationName("PyLoT")
|
2014-11-28 09:19:16 +01:00
|
|
|
pylot_app.setWindowIcon(QIcon(":/icon.ico"))
|
2014-03-28 22:26:15 +01:00
|
|
|
|
|
|
|
# create the main window
|
|
|
|
pylot_form = MainWindow()
|
2014-01-09 10:43:40 +01:00
|
|
|
|
2014-03-13 13:27:34 +01:00
|
|
|
# Show main window and run the app
|
2014-03-28 22:26:15 +01:00
|
|
|
pylot_form.show()
|
2014-12-08 10:26:14 +01:00
|
|
|
pylot_app.exec_()
|
2014-03-28 22:26:15 +01:00
|
|
|
|
2015-01-29 08:53:01 +01:00
|
|
|
|
2014-04-11 19:39:29 +02:00
|
|
|
if __name__ == "__main__":
|
2014-12-08 10:26:14 +01:00
|
|
|
sys.exit(main())
|