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 os
|
|
|
|
import sys
|
2014-03-13 13:27:34 +01:00
|
|
|
from PySide.QtCore import *
|
|
|
|
from PySide.QtGui import *
|
2014-04-01 16:46:10 +02:00
|
|
|
from obspy.core import (read, UTCDateTime)
|
2014-11-06 15:07:05 +01:00
|
|
|
from pylot import *
|
2014-01-09 10:43:40 +01:00
|
|
|
from pylot.core.util import _getVersionString
|
2014-07-16 12:06:05 +02:00
|
|
|
from pylot.core.read import (Data,
|
|
|
|
FilterOptions)
|
2014-03-13 13:27:34 +01:00
|
|
|
from pylot.core.util import FILTERDEFAULTS
|
2014-12-01 12:34:44 +01:00
|
|
|
from pylot.core.util import fnConstructor
|
2014-03-31 12:57:08 +02:00
|
|
|
from pylot.core.util import checkurl
|
2014-06-10 16:37:07 +02:00
|
|
|
from pylot.core.util import (PickDlg,
|
2014-10-27 11:56:44 +01:00
|
|
|
FilterOptionsDialog,
|
2014-06-10 16:37:07 +02:00
|
|
|
PropertiesDlg,
|
|
|
|
MPLWidget,
|
|
|
|
HelpForm)
|
2014-11-13 11:27:52 +01:00
|
|
|
from pylot.core.util import layoutStationButtons
|
2014-11-26 08:46:16 +01:00
|
|
|
import qrc_resources
|
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-03-13 13:27:34 +01:00
|
|
|
|
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
|
|
|
|
2014-11-28 11:15:49 +01:00
|
|
|
settings = QSettings()
|
2014-12-01 12:36:23 +01:00
|
|
|
self.recentEvents = settings.value("recentEvents", [])
|
2014-11-28 11:15:49 +01:00
|
|
|
self.setWindowTitle("PyLoT - do seismic processing the pythonic way")
|
|
|
|
self.setWindowIcon(QIcon(":/icon.ico"))
|
|
|
|
self.seismicPhase = str(settings.value("phase", "P"))
|
2014-12-01 12:36:23 +01:00
|
|
|
if settings.value("dataRoot", None) is None:
|
|
|
|
dirname = QFileDialog().getExistingDirectory()
|
|
|
|
settings.setValue("dataRoot", dirname)
|
|
|
|
settings.sync()
|
2014-11-28 11:15:49 +01:00
|
|
|
|
2014-11-06 15:07:05 +01:00
|
|
|
# initialize filter parameter
|
2014-03-13 13:27:34 +01:00
|
|
|
filterOptionsP = FILTERDEFAULTS['P']
|
|
|
|
filterOptionsS = FILTERDEFAULTS['S']
|
2014-11-28 11:15:49 +01:00
|
|
|
print filterOptionsP, "\n", filterOptionsS
|
2014-03-13 13:27:34 +01:00
|
|
|
self.filterOptionsP = FilterOptions(**filterOptionsP)
|
|
|
|
self.filterOptionsS = FilterOptions(**filterOptionsS)
|
|
|
|
|
2014-11-06 15:07:05 +01:00
|
|
|
# initialize data
|
|
|
|
self.data = None
|
2014-03-28 05:25:46 +01:00
|
|
|
self.loadData()
|
|
|
|
self.updateFilterOptions()
|
2014-11-28 11:15:49 +01:00
|
|
|
print self.filteroptions
|
2014-11-26 08:46:16 +01:00
|
|
|
try:
|
|
|
|
self.startTime = min([tr.stats.starttime for tr in self.data.wfdata])
|
|
|
|
except:
|
|
|
|
self.startTime = UTCDateTime()
|
2014-03-28 05:25:46 +01:00
|
|
|
|
|
|
|
self.setupUi()
|
|
|
|
|
2014-10-27 11:57:34 +01:00
|
|
|
def _getCurrentPlotType(self):
|
|
|
|
return 'TestType'
|
|
|
|
|
2014-11-27 10:13:17 +01:00
|
|
|
def createAction(self, text, slot=None, shortcut=None, icon=None,
|
|
|
|
tip=None, checkable=False):
|
|
|
|
action = QAction(text, self)
|
|
|
|
if icon is not None:
|
|
|
|
action.setIcon(icon)
|
|
|
|
if shortcut is not None:
|
|
|
|
action.setShortcut(shortcut)
|
|
|
|
if tip is not None:
|
|
|
|
action.setToolTip(tip)
|
|
|
|
if slot is not None:
|
|
|
|
action.triggered.connect(slot)
|
|
|
|
if checkable:
|
|
|
|
action.setCheckable(True)
|
|
|
|
return action
|
|
|
|
|
2014-11-28 11:15:49 +01:00
|
|
|
def createMenus(self):
|
|
|
|
|
|
|
|
fileMenu = self.menuBar().addMenu("&File")
|
|
|
|
fileMenu.addAction(self.openEventAction)
|
|
|
|
fileMenu.addAction(self.saveEventAction)
|
|
|
|
fileMenu.addAction(self.printAction)
|
|
|
|
fileMenu.addSeparator()
|
|
|
|
fileMenu.addAction(self.quitAction)
|
|
|
|
|
|
|
|
editMenu = self.menuBar().addMenu("&Edit")
|
|
|
|
editMenu.addAction(self.filterAction)
|
|
|
|
editMenu.addAction(self.filterEditAction)
|
|
|
|
editMenu.addSeparator()
|
|
|
|
editMenu.addAction(self.selectPAction)
|
|
|
|
editMenu.addAction(self.selectSAction)
|
|
|
|
|
2014-03-28 22:26:15 +01:00
|
|
|
def loadData(self):
|
2014-11-26 08:46:16 +01:00
|
|
|
self.data = None
|
|
|
|
|
2014-11-28 11:15:49 +01:00
|
|
|
def saveData(self):
|
|
|
|
pass
|
|
|
|
|
2014-11-26 08:46:16 +01:00
|
|
|
def getComponent(self):
|
|
|
|
return self
|
2014-03-28 22:26:15 +01:00
|
|
|
|
2014-11-13 11:27:52 +01:00
|
|
|
def getData(self):
|
|
|
|
return self.data
|
|
|
|
|
|
|
|
def getDataWidget(self):
|
|
|
|
return self.DataPlot
|
|
|
|
|
2014-03-28 05:25:46 +01:00
|
|
|
def setupUi(self):
|
2014-11-28 09:19:16 +01:00
|
|
|
self.setWindowIcon(QIcon(":/icon.ico"))
|
2014-03-28 05:25:46 +01:00
|
|
|
|
2014-11-06 15:07:05 +01:00
|
|
|
xlab = self.startTime.strftime('seconds since %d %b %Y %H:%M:%S (%Z)')
|
2014-10-27 11:55:06 +01:00
|
|
|
plottitle = self._getCurrentPlotType()
|
2014-07-16 12:06:05 +02:00
|
|
|
|
2014-03-28 05:25:46 +01:00
|
|
|
# create central matplotlib figure widget
|
2014-07-16 12:06:05 +02:00
|
|
|
self.DataPlot = MPLWidget(parent=self,
|
|
|
|
xlabel=xlab,
|
2014-10-27 11:55:06 +01:00
|
|
|
ylabel=None,
|
|
|
|
title=plottitle)
|
2014-11-27 10:13:17 +01:00
|
|
|
|
|
|
|
self.setCentralWidget(self.getDataWidget())
|
|
|
|
|
2014-11-28 09:19:16 +01:00
|
|
|
openIcon = self.style().standardIcon(QStyle.SP_DirOpenIcon)
|
|
|
|
quitIcon = self.style().standardIcon(QStyle.SP_MediaStop)
|
2014-11-28 11:15:49 +01:00
|
|
|
saveIcon = self.style().standardIcon(QStyle.SP_DriveHDIcon)
|
2014-11-27 10:13:17 +01:00
|
|
|
self.openEventAction = self.createAction("&Open event ...",
|
|
|
|
self.loadData,
|
|
|
|
QKeySequence.Open,
|
2014-11-28 09:19:16 +01:00
|
|
|
openIcon,
|
2014-11-27 10:13:17 +01:00
|
|
|
"Open an event.")
|
2014-11-28 11:15:49 +01:00
|
|
|
self.saveEventAction = self.createAction("&Save event ...",
|
|
|
|
self.saveData,
|
|
|
|
QKeySequence.Save, saveIcon,
|
|
|
|
"Save actual event data.")
|
2014-12-01 08:40:35 +01:00
|
|
|
self.quitAction = self.createAction("&Quit",
|
|
|
|
QCoreApplication.instance().quit,
|
2014-11-27 10:13:17 +01:00
|
|
|
QKeySequence.Close,
|
2014-11-28 09:19:16 +01:00
|
|
|
quitIcon,
|
2014-11-27 10:13:17 +01:00
|
|
|
"Close event and quit PyLoT")
|
|
|
|
self.filterAction = self.createAction("&Filter ...", self.filterData,
|
2014-11-28 11:15:49 +01:00
|
|
|
"Ctrl+F", QIcon(":/filter.png"),
|
2014-11-27 10:13:17 +01:00
|
|
|
"""Toggle un-/filtered waveforms
|
2014-11-28 11:15:49 +01:00
|
|
|
to be displayed, according to the
|
2014-11-27 10:13:17 +01:00
|
|
|
desired seismic phase.""", True)
|
2014-12-01 08:40:35 +01:00
|
|
|
self.filterEditAction = self.createAction("&Filter parameter ...",
|
2014-11-28 11:15:49 +01:00
|
|
|
self.adjustFilterOptions,
|
|
|
|
"Alt+F", QIcon(None),
|
|
|
|
"""Adjust filter
|
|
|
|
parameters.""")
|
|
|
|
self.selectPAction = self.createAction("&P", self.alterPhase, "Alt+P",
|
|
|
|
QIcon(":/picon.png"),
|
|
|
|
"Toggle P phase.", True)
|
|
|
|
self.selectSAction = self.createAction("&S", self.alterPhase, "Alt+S",
|
|
|
|
QIcon(":/sicon.png"),
|
|
|
|
"Toggle S phase", True)
|
2014-11-28 09:19:16 +01:00
|
|
|
self.printAction = self.createAction("&Print event ...",
|
|
|
|
self.printEvent,
|
|
|
|
QKeySequence.Print,
|
|
|
|
QIcon(":/printer.png"),
|
|
|
|
"Print waveform overview.")
|
2014-11-28 11:15:49 +01:00
|
|
|
self.createMenus()
|
2014-03-28 05:25:46 +01:00
|
|
|
|
2014-04-01 16:46:10 +02:00
|
|
|
self.eventLabel = QLabel()
|
2014-11-27 10:13:17 +01:00
|
|
|
self.eventLabel.setFrameStyle(QFrame.StyledPanel|QFrame.Sunken)
|
2014-04-01 16:46:10 +02:00
|
|
|
status = self.statusBar()
|
|
|
|
status.setSizeGripEnabled(False)
|
|
|
|
status.addPermanentWidget(self.eventLabel)
|
2014-12-01 08:40:35 +01:00
|
|
|
status.showMessage("Ready", 500)
|
2014-04-01 16:46:10 +02:00
|
|
|
|
2014-11-28 11:15:49 +01:00
|
|
|
#statLayout = layoutStationButtons(self.getData(), self.getComponent())
|
|
|
|
#dataLayout = self.getDataWidget()
|
2014-03-28 05:25:46 +01:00
|
|
|
|
2014-11-28 11:15:49 +01:00
|
|
|
# maingrid = QGridLayout()
|
|
|
|
# maingrid.setSpacing(10)
|
|
|
|
# maingrid.addLayout(statLayout, 0, 0)
|
|
|
|
# maingrid.addWidget(dataLayout, 1, 0)
|
|
|
|
#self.setLayout(maingrid)
|
2014-03-28 05:25:46 +01:00
|
|
|
|
2014-07-16 12:06:05 +02:00
|
|
|
def plotData(self):
|
2014-11-26 08:46:16 +01:00
|
|
|
pass #self.data.plotData(self.DataPlot)
|
2014-03-19 12:24:41 +01:00
|
|
|
|
2014-11-28 11:15:49 +01:00
|
|
|
def filterData(self):
|
|
|
|
pass
|
|
|
|
|
2014-11-06 15:07:05 +01:00
|
|
|
def adjustFilterOptions(self):
|
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 08:40:35 +01:00
|
|
|
filterDlg.show()
|
|
|
|
filterDlg.closeEvent.connect(lambda: self.setFilterOptions(filterDlg.getFilterOptions()))
|
2014-11-13 11:27:52 +01:00
|
|
|
|
|
|
|
def getFilterOptions(self):
|
|
|
|
return self.filteroptions
|
|
|
|
|
|
|
|
def setFilterOptions(self, filterOptions):
|
|
|
|
cases = {'P':self.filterOptionsP,
|
|
|
|
'S':self.filterOptionsS}
|
|
|
|
cases[self.getSeismicPhase()] = filterOptions
|
|
|
|
self.updateFilterOptions()
|
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:
|
|
|
|
self.filteroptions = [self.filterOptionsP
|
|
|
|
if not self.seismicPhase == 'S'
|
2014-11-28 11:15:49 +01:00
|
|
|
else self.filterOptionsS][0]
|
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:
|
2014-11-28 09:19:16 +01:00
|
|
|
self.updateStatus('Filter loaded ...')
|
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()
|
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-11-28 11:15:49 +01:00
|
|
|
def printEvent(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def cleanUp(self):
|
2014-12-01 08:40:35 +01:00
|
|
|
self
|
|
|
|
return 0
|
2014-11-28 11:15:49 +01:00
|
|
|
|
2014-03-28 22:26:15 +01:00
|
|
|
def helpHelp(self):
|
2014-06-11 15:19:37 +02:00
|
|
|
if checkurl():
|
2014-07-03 10:18:42 +02: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-01 08:40:35 +01:00
|
|
|
sys.exit(pylot_app.exec_())
|
2014-03-28 22:26:15 +01:00
|
|
|
|
2014-04-11 19:39:29 +02:00
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|