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
|
|
|
|
2015-07-18 16:11:20 +02:00
|
|
|
import os, sys
|
2015-07-06 09:51:59 +02:00
|
|
|
import matplotlib
|
|
|
|
|
|
|
|
matplotlib.use('Qt4Agg')
|
|
|
|
matplotlib.rcParams['backend.qt4'] = 'PySide'
|
2014-12-04 05:13:32 +01:00
|
|
|
|
2015-03-11 12:05:52 +01:00
|
|
|
from PySide.QtCore import QCoreApplication, QSettings, Signal, QFile, \
|
|
|
|
QFileInfo, Qt
|
2015-02-16 10:24:17 +01:00
|
|
|
from PySide.QtGui import QMainWindow, QInputDialog, QIcon, QFileDialog, \
|
|
|
|
QWidget, QHBoxLayout, QStyle, QKeySequence, QLabel, QFrame, QAction, \
|
2015-07-07 14:21:11 +02:00
|
|
|
QDialog, QErrorMessage, QApplication, QPixmap, QMessageBox, QSplashScreen, \
|
2015-07-10 09:22:58 +02:00
|
|
|
QActionGroup, QListWidget, QDockWidget
|
2015-07-07 10:39:51 +02:00
|
|
|
import numpy as np
|
2015-09-03 13:21:46 +02:00
|
|
|
from obspy import UTCDateTime, readEvents
|
2015-02-16 10:24:17 +01:00
|
|
|
|
2015-07-10 09:22:58 +02:00
|
|
|
from pylot.core.read.data import Data
|
|
|
|
from pylot.core.read.inputs import FilterOptions, AutoPickParameter
|
|
|
|
from pylot.core.pick.autopick import autopickevent
|
|
|
|
from pylot.core.util.defaults import FILTERDEFAULTS
|
2015-08-27 12:55:34 +02:00
|
|
|
from pylot.core.util.errors import FormatError, DatastructureError,\
|
|
|
|
OverwriteError
|
2015-07-10 09:22:58 +02:00
|
|
|
from pylot.core.util.connection import checkurl
|
|
|
|
from pylot.core.util.utils import fnConstructor, createEvent, getLogin,\
|
2015-07-13 06:39:25 +02:00
|
|
|
createCreationInfo, getGlobalTimes
|
2015-07-10 09:22:58 +02:00
|
|
|
from pylot.core.util.widgets import FilterOptionsDialog, NewEventDlg,\
|
|
|
|
MPLWidget, PropertiesDlg, HelpForm, createAction, PickDlg
|
2015-02-13 11:12:47 +01:00
|
|
|
from pylot.core.util.structure import DATASTRUCTURE
|
2015-07-14 08:10:49 +02:00
|
|
|
from pylot.core.util.thread import AutoPickThread
|
2015-07-10 09:22:58 +02:00
|
|
|
from pylot.core.util.version import get_git_version as _getVersionString
|
2015-04-02 18:36:21 +02:00
|
|
|
import icons_rc
|
2015-02-16 10:24:17 +01:00
|
|
|
|
2015-06-11 10:07:21 +02:00
|
|
|
|
2014-01-10 05:45:03 +01:00
|
|
|
class MainWindow(QMainWindow):
|
2015-09-18 09:54:29 +02:00
|
|
|
__version__ = _getVersionString()
|
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
|
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())
|
2015-03-06 09:03:04 +01:00
|
|
|
if settings.value("agency_id", None) is None:
|
2015-06-11 10:07:21 +02:00
|
|
|
agency = QInputDialog.getText(self,
|
|
|
|
"Enter authority name (e.g. BUG):",
|
|
|
|
"Authority")
|
2015-03-11 12:05:52 +01:00
|
|
|
settings.setValue("agency_id", agency)
|
2014-12-08 10:26:14 +01:00
|
|
|
self.recentEvents = settings.value("data/recentEvents", [])
|
2015-08-31 13:37:18 +02:00
|
|
|
self.fname = None
|
2015-02-13 11:17:18 +01:00
|
|
|
self.fnames = None
|
2015-06-23 13:22:30 +02:00
|
|
|
structure_setting = settings.value("data/Structure", "PILOT")
|
|
|
|
self.dataStructure = DATASTRUCTURE[structure_setting]()
|
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)
|
2015-03-06 09:03:04 +01:00
|
|
|
settings.sync()
|
2014-11-28 11:15:49 +01:00
|
|
|
|
2015-03-01 10:31:49 +01:00
|
|
|
self.filteroptions = {}
|
2015-03-09 11:21:33 +01:00
|
|
|
self.pickDlgs = {}
|
2015-07-07 10:32:56 +02:00
|
|
|
self.picks = {}
|
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
|
2014-12-08 10:26:14 +01:00
|
|
|
self.dirty = False
|
2014-03-28 05:25:46 +01:00
|
|
|
self.loadData()
|
2015-08-31 13:37:18 +02:00
|
|
|
self.loadWaveformData()
|
2014-03-28 05:25:46 +01:00
|
|
|
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-04-02 18:36:21 +02:00
|
|
|
pylot_icon = QIcon()
|
2015-07-07 11:21:06 +02:00
|
|
|
pylot_icon.addPixmap(QPixmap(':/icons/pylot.png'))
|
2015-04-02 18:36:21 +02:00
|
|
|
|
2015-03-01 10:31:49 +01:00
|
|
|
self.setWindowTitle("PyLoT - do seismic processing the python way")
|
2015-04-02 18:36:21 +02:00
|
|
|
self.setWindowIcon(pylot_icon)
|
2015-01-29 08:41:38 +01:00
|
|
|
|
2015-03-29 08:07:46 +02:00
|
|
|
xlab = self.startTime.strftime('seconds since %Y/%m/%d %H:%M:%S (%Z)')
|
2015-01-29 08:41:38 +01:00
|
|
|
|
|
|
|
_widget = QWidget()
|
2015-03-11 12:05:52 +01:00
|
|
|
_widget.setCursor(Qt.CrossCursor)
|
2015-01-29 08:41:38 +01:00
|
|
|
_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-07-07 10:45:42 +02:00
|
|
|
self.DataPlot.mpl_connect('button_press_event',
|
|
|
|
self.pickOnStation)
|
|
|
|
self.DataPlot.mpl_connect('axes_enter_event',
|
|
|
|
lambda event: self.tutorUser())
|
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)
|
2015-04-02 18:36:21 +02:00
|
|
|
|
|
|
|
# create resource icons
|
|
|
|
p_icon = QIcon()
|
2015-07-07 10:31:39 +02:00
|
|
|
p_icon.addPixmap(QPixmap(':/icons/key_P.png'))
|
2015-04-02 18:36:21 +02:00
|
|
|
s_icon = QIcon()
|
2015-07-07 10:31:39 +02:00
|
|
|
s_icon.addPixmap(QPixmap(':/icons/key_S.png'))
|
2015-04-02 18:36:21 +02:00
|
|
|
print_icon = QIcon()
|
|
|
|
print_icon.addPixmap(QPixmap(':/icons/printer.png'))
|
2015-07-07 10:31:39 +02:00
|
|
|
filter_icon = QIcon()
|
|
|
|
filter_icon.addPixmap(QPixmap(':/icons/filter.png'))
|
2015-07-07 14:21:11 +02:00
|
|
|
z_icon = QIcon()
|
2015-07-09 11:37:03 +02:00
|
|
|
z_icon.addPixmap(QPixmap(':/icons/key_Z.png'))
|
2015-07-07 14:21:11 +02:00
|
|
|
n_icon = QIcon()
|
2015-07-09 11:37:03 +02:00
|
|
|
n_icon.addPixmap(QPixmap(':/icons/key_N.png'))
|
2015-07-07 14:21:11 +02:00
|
|
|
e_icon = QIcon()
|
2015-07-09 11:37:03 +02:00
|
|
|
e_icon.addPixmap(QPixmap(':/icons/key_E.png'))
|
|
|
|
auto_icon = QIcon()
|
|
|
|
auto_icon.addPixmap(QPixmap(':/icons/sync.png'))
|
2015-04-02 18:36:21 +02:00
|
|
|
|
2015-03-04 15:40:25 +01:00
|
|
|
newEventAction = self.createAction(self, "&New event ...",
|
2015-01-29 08:41:38 +01:00
|
|
|
self.createNewEvent,
|
|
|
|
QKeySequence.New, newIcon,
|
|
|
|
"Create a new event.")
|
2015-03-11 12:05:52 +01:00
|
|
|
openEventAction = self.createAction(self, "&Open event ...",
|
|
|
|
self.loadData, QKeySequence.Open,
|
|
|
|
openIcon, "Open an event.")
|
2015-01-29 08:41:38 +01:00
|
|
|
openEventAction.setData(None)
|
2015-03-11 12:05:52 +01:00
|
|
|
saveEventAction = self.createAction(self, "&Save event ...",
|
|
|
|
self.saveData, QKeySequence.Save,
|
|
|
|
saveIcon, "Save actual event data.")
|
2015-03-04 15:40:25 +01:00
|
|
|
openWFDataAction = self.createAction(self, "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).""")
|
2015-03-11 12:05:52 +01:00
|
|
|
prefsEventAction = self.createAction(self, "Preferences",
|
|
|
|
self.PyLoTprefs,
|
2015-01-29 08:41:38 +01:00
|
|
|
QKeySequence.Preferences,
|
|
|
|
QIcon(None),
|
|
|
|
"Edit PyLoT app preferences.")
|
2015-03-04 15:40:25 +01:00
|
|
|
quitAction = self.createAction(self, "&Quit",
|
2015-01-29 08:41:38 +01:00
|
|
|
QCoreApplication.instance().quit,
|
|
|
|
QKeySequence.Close, quitIcon,
|
|
|
|
"Close event and quit PyLoT")
|
2015-06-11 10:07:21 +02:00
|
|
|
self.filterAction = self.createAction(self, "&Filter ...",
|
|
|
|
self.filterWaveformData,
|
2015-07-07 10:31:39 +02:00
|
|
|
"Ctrl+F", filter_icon,
|
2015-06-11 10:07:21 +02:00
|
|
|
"""Toggle un-/filtered waveforms
|
2015-01-29 08:41:38 +01:00
|
|
|
to be displayed, according to the
|
|
|
|
desired seismic phase.""", True)
|
2015-03-04 15:40:25 +01:00
|
|
|
filterEditAction = self.createAction(self, "&Filter parameter ...",
|
2015-01-29 08:41:38 +01:00
|
|
|
self.adjustFilterOptions,
|
|
|
|
"Alt+F", QIcon(None),
|
|
|
|
"""Adjust filter parameters.""")
|
2015-06-11 10:07:21 +02:00
|
|
|
self.selectPAction = self.createAction(self, "&P", self.alterPhase,
|
|
|
|
"Alt+P",
|
|
|
|
p_icon,
|
|
|
|
"Toggle P phase.", True)
|
|
|
|
self.selectSAction = self.createAction(self, "&S", self.alterPhase,
|
|
|
|
"Alt+S",
|
|
|
|
s_icon,
|
|
|
|
"Toggle S phase", True)
|
2015-03-04 15:40:25 +01:00
|
|
|
printAction = self.createAction(self, "&Print event ...",
|
2015-01-29 08:41:38 +01:00
|
|
|
self.printEvent, QKeySequence.Print,
|
2015-04-02 18:36:21 +02:00
|
|
|
print_icon,
|
2015-01-29 08:41:38 +01:00
|
|
|
"Print waveform overview.")
|
2015-03-04 15:40:25 +01:00
|
|
|
helpAction = self.createAction(self, "&Help ...", self.helpHelp,
|
2015-01-29 08:41:38 +01:00
|
|
|
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')
|
2015-06-11 10:07:21 +02:00
|
|
|
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)
|
|
|
|
|
2015-10-30 08:37:00 +01:00
|
|
|
# phaseToolBar = self.addToolBar("PhaseTools")
|
|
|
|
# phaseToolActions = (self.selectPAction, self.selectSAction)
|
|
|
|
# phaseToolBar.setObjectName("PhaseTools")
|
|
|
|
# self.addActions(phaseToolBar, phaseToolActions)
|
2015-01-29 08:41:38 +01:00
|
|
|
|
2015-07-07 14:21:11 +02:00
|
|
|
# create button group for component selection
|
|
|
|
|
|
|
|
componentGroup = QActionGroup(self)
|
|
|
|
componentGroup.setExclusive(True)
|
|
|
|
|
|
|
|
z_action = self.createAction(parent=componentGroup, text='Z',
|
|
|
|
slot=self.plotZ, shortcut='Alt+Z',
|
|
|
|
icon=z_icon, tip='Display the vertical (Z)'
|
|
|
|
' component.',
|
|
|
|
checkable=True)
|
|
|
|
z_action.setChecked(True)
|
|
|
|
|
|
|
|
n_action = self.createAction(parent=componentGroup, text='N',
|
|
|
|
slot=self.plotN, shortcut='Alt+N',
|
|
|
|
icon=n_icon,
|
|
|
|
tip='Display the north-south (N) '
|
|
|
|
'component.', checkable=True)
|
|
|
|
|
|
|
|
e_action = self.createAction(parent=componentGroup, text='E',
|
|
|
|
slot=self.plotE, shortcut='Alt+E',
|
|
|
|
icon=e_icon,
|
|
|
|
tip='Display the east-west (E) component.',
|
|
|
|
checkable=True)
|
|
|
|
|
|
|
|
componentToolBar = self.addToolBar("ComponentSelection")
|
|
|
|
componentActions = (z_action, n_action, e_action)
|
|
|
|
componentToolBar.setObjectName("PhaseTools")
|
|
|
|
self.addActions(componentToolBar, componentActions)
|
|
|
|
|
2015-07-09 11:37:03 +02:00
|
|
|
auto_pick = self.createAction(parent=self, text='autoPick',
|
|
|
|
slot=self.autoPick, shortcut='Alt+Ctrl+A',
|
|
|
|
icon=auto_icon, tip='Automatically pick'
|
|
|
|
' the entire dataset'
|
2015-10-19 11:25:15 +02:00
|
|
|
' displayed!')
|
2015-07-09 11:37:03 +02:00
|
|
|
|
|
|
|
autoPickToolBar = self.addToolBar("autoPyLoT")
|
|
|
|
autoPickActions = (auto_pick,)
|
|
|
|
self.addActions(autoPickToolBar, autoPickActions)
|
|
|
|
|
2015-04-02 18:48:06 +02:00
|
|
|
# pickToolBar = self.addToolBar("PickTools")
|
|
|
|
# pickToolActions = (selectStation, )
|
|
|
|
# pickToolBar.setObjectName("PickTools")
|
|
|
|
# self.addActions(pickToolBar, pickToolActions)
|
2015-03-11 12:05:52 +01:00
|
|
|
|
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)
|
2015-03-11 12:05:52 +01:00
|
|
|
_widget.showFullScreen()
|
2014-10-27 11:57:34 +01:00
|
|
|
|
2015-03-11 12:05:52 +01:00
|
|
|
self.setCentralWidget(_widget)
|
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)
|
2015-07-07 10:31:39 +02:00
|
|
|
action = QAction(self.windowIcon(),
|
2014-12-01 12:37:52 +01:00
|
|
|
"&{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])
|
|
|
|
|
2015-07-18 16:11:20 +02:00
|
|
|
def getRoot(self):
|
|
|
|
settings = QSettings()
|
|
|
|
return settings.value("data/dataRoot")
|
|
|
|
|
2014-12-01 12:37:52 +01:00
|
|
|
def loadData(self, fname=None):
|
2015-09-03 13:21:46 +02:00
|
|
|
if not self.okToContinue():
|
2015-09-18 09:54:29 +02:00
|
|
|
return
|
2014-12-01 12:37:52 +01:00
|
|
|
if fname is None:
|
2015-09-17 17:45:10 +02:00
|
|
|
action = self.sender()
|
|
|
|
if isinstance(action, QAction):
|
|
|
|
if action.data() is None:
|
|
|
|
filt = "Supported event formats (*.mat *.qml *.xml *.kor *.evt)"
|
|
|
|
caption = "Open an event file"
|
|
|
|
fname = QFileDialog().getOpenFileName(self,
|
|
|
|
caption=caption,
|
|
|
|
filter=filt)
|
2015-09-03 13:21:46 +02:00
|
|
|
fname = fname[0]
|
2015-09-17 17:45:10 +02:00
|
|
|
else:
|
2015-09-03 13:21:46 +02:00
|
|
|
fname = unicode(action.data().toString())
|
|
|
|
self.setFileName(fname)
|
2015-09-17 17:45:10 +02:00
|
|
|
self.data += Data(self, evtdata=self.getFileName())
|
2015-09-18 09:54:29 +02:00
|
|
|
self.updatePicks()
|
2015-09-03 13:21:46 +02:00
|
|
|
self.drawPicks()
|
2014-11-26 08:46:16 +01:00
|
|
|
|
2015-02-13 11:23:01 +01:00
|
|
|
def getLastEvent(self):
|
|
|
|
return self.recentEvents[0]
|
|
|
|
|
2015-08-31 13:37:18 +02:00
|
|
|
def addRecentEvent(self, event):
|
|
|
|
self.recentEvents.insert(0, event)
|
|
|
|
|
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-06-11 10:07:21 +02:00
|
|
|
"Select waveform "
|
|
|
|
"files:",
|
|
|
|
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-09-25 15:06:59 +02:00
|
|
|
except DatastructureError as 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
|
|
|
|
2015-08-31 13:37:18 +02:00
|
|
|
def getFileName(self):
|
|
|
|
return self.fname
|
|
|
|
|
|
|
|
def setFileName(self, fname):
|
|
|
|
if self.getFileName() is not None:
|
|
|
|
self.addRecentEvent(self.getFileName())
|
|
|
|
self.fname = fname
|
|
|
|
|
2015-07-18 16:11:20 +02:00
|
|
|
def getEventFileName(self):
|
2015-08-31 13:37:18 +02:00
|
|
|
if self.getFileName() is None:
|
|
|
|
self.setFileName(self.getData().getEventFileName())
|
|
|
|
return self.getFileName()
|
2015-07-18 16:11:20 +02:00
|
|
|
|
2014-11-28 11:15:49 +01:00
|
|
|
def saveData(self):
|
2015-08-31 13:37:18 +02:00
|
|
|
|
|
|
|
def getSavePath(e):
|
2015-09-25 15:06:59 +02:00
|
|
|
print('warning: {0}'.format(e))
|
2015-08-31 13:37:18 +02:00
|
|
|
directory = os.path.join(self.getRoot(), self.getEventFileName())
|
|
|
|
file_filter = "QuakeML file (*.xml);;VELEST observation file format (*.cnv);;NonLinLoc observation file (*.obs)"
|
|
|
|
fname = QFileDialog.getSaveFileName(self, 'Save event data ...',
|
|
|
|
directory, file_filter)
|
|
|
|
|
|
|
|
fbasename, exform = os.path.splitext(fname[0])
|
|
|
|
|
|
|
|
if not exform:
|
|
|
|
exform = file_filter[0].split('*')[1][:-1]
|
|
|
|
return fbasename, exform
|
|
|
|
|
2014-12-17 12:16:32 +01:00
|
|
|
settings = QSettings()
|
2015-08-31 13:37:18 +02:00
|
|
|
fbasename = self.getEventFileName()
|
2015-07-08 15:12:35 +02:00
|
|
|
exform = settings.value('data/exportFormat', 'QUAKEML')
|
2015-08-27 12:55:34 +02:00
|
|
|
try:
|
|
|
|
self.getData().applyEVTData(self.getPicks())
|
|
|
|
except OverwriteError:
|
|
|
|
msgBox = QMessageBox()
|
|
|
|
msgBox.setText("Picks have been modified!")
|
2015-08-28 16:01:42 +02:00
|
|
|
msgBox.setInformativeText("Do you want to save the changes and overwrite the picks?")
|
|
|
|
msgBox.setDetailedText(self.getData().getPicksStr())
|
|
|
|
msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Cancel)
|
2015-08-27 12:55:34 +02:00
|
|
|
msgBox.setDefaultButton(QMessageBox.Save)
|
|
|
|
ret = msgBox.exec_()
|
|
|
|
if ret == QMessageBox.Save:
|
2015-08-28 16:01:42 +02:00
|
|
|
self.getData().resetPicks()
|
|
|
|
self.saveData()
|
|
|
|
elif ret == QMessageBox.Cancel:
|
|
|
|
return False
|
2014-12-17 12:16:32 +01:00
|
|
|
try:
|
2015-07-18 16:11:20 +02:00
|
|
|
self.getData().exportEvent(fbasename, exform)
|
2015-08-31 13:37:18 +02:00
|
|
|
except FormatError as e:
|
|
|
|
fbasename, exform = getSavePath(e)
|
|
|
|
except AttributeError as e:
|
|
|
|
fbasename, exform = getSavePath(e)
|
|
|
|
if not fbasename:
|
|
|
|
return False
|
|
|
|
self.getData().exportEvent(fbasename, exform)
|
|
|
|
self.setDirty(False)
|
|
|
|
self.updateStatus('Event saved as %s' % (fbasename + 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
|
|
|
|
2015-07-07 14:21:11 +02:00
|
|
|
def setComponent(self, component):
|
|
|
|
self.dispComponent = component
|
|
|
|
|
2014-11-13 11:27:52 +01:00
|
|
|
def getData(self):
|
|
|
|
return self.data
|
|
|
|
|
2015-07-07 10:32:56 +02:00
|
|
|
def getPicks(self):
|
|
|
|
return self.picks
|
|
|
|
|
|
|
|
def getPicksOnStation(self, station):
|
|
|
|
try:
|
|
|
|
return self.getPicks()[station]
|
|
|
|
except KeyError:
|
|
|
|
return None
|
|
|
|
|
2015-03-04 11:52:04 +01:00
|
|
|
def getPlotWidget(self):
|
2014-11-13 11:27:52 +01:00
|
|
|
return self.DataPlot
|
|
|
|
|
2015-06-11 10:07:21 +02:00
|
|
|
@staticmethod
|
|
|
|
def getWFID(gui_event):
|
2015-03-11 12:05:52 +01:00
|
|
|
|
2015-04-02 18:48:06 +02:00
|
|
|
ycoord = gui_event.ydata
|
2015-03-11 12:05:52 +01:00
|
|
|
|
2015-03-12 13:59:29 +01:00
|
|
|
statID = int(round(ycoord))
|
2015-03-11 12:05:52 +01:00
|
|
|
|
|
|
|
return statID
|
2015-03-09 11:21:33 +01:00
|
|
|
|
2015-07-07 10:39:01 +02:00
|
|
|
def getStationID(self, station):
|
|
|
|
for wfID in self.getPlotWidget().getPlotDict().keys():
|
|
|
|
actual_station = self.getPlotWidget().getPlotDict()[wfID][0]
|
|
|
|
if station == actual_station:
|
|
|
|
return wfID
|
|
|
|
return None
|
|
|
|
|
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():
|
2015-07-18 16:11:20 +02:00
|
|
|
self.setDirty(True)
|
2015-02-13 11:20:29 +01:00
|
|
|
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-29 08:07:46 +02:00
|
|
|
zne_text = {'Z': 'vertical', 'N': 'north-south', 'E': 'east-west'}
|
|
|
|
comp = self.getComponent()
|
2015-09-25 15:06:59 +02:00
|
|
|
title = 'section: {0} components'.format(zne_text[comp])
|
2015-03-29 08:07:46 +02:00
|
|
|
wfst = self.getData().getWFData().select(component=comp)
|
|
|
|
self.getPlotWidget().plotWFData(wfdata=wfst, title=title)
|
2015-07-07 14:21:11 +02:00
|
|
|
self.draw()
|
2015-07-13 06:36:33 +02:00
|
|
|
plotDict = self.getPlotWidget().getPlotDict()
|
|
|
|
pos = plotDict.keys()
|
|
|
|
labels = [plotDict[n][0] for n in pos]
|
2015-04-02 18:48:06 +02:00
|
|
|
self.getPlotWidget().setYTickLabels(pos, labels)
|
2014-03-19 12:24:41 +01:00
|
|
|
|
2015-07-07 14:21:11 +02:00
|
|
|
def plotZ(self):
|
|
|
|
self.setComponent('Z')
|
|
|
|
self.plotWaveformData()
|
|
|
|
self.drawPicks()
|
|
|
|
|
|
|
|
def plotN(self):
|
|
|
|
self.setComponent('N')
|
|
|
|
self.plotWaveformData()
|
|
|
|
self.drawPicks()
|
|
|
|
|
|
|
|
def plotE(self):
|
|
|
|
self.setComponent('E')
|
|
|
|
self.plotWaveformData()
|
|
|
|
self.drawPicks()
|
|
|
|
|
2015-02-17 13:17:01 +01:00
|
|
|
def filterWaveformData(self):
|
2014-12-09 05:25:43 +01:00
|
|
|
if self.getData():
|
2015-06-11 10:07:21 +02:00
|
|
|
def hasfreq(kwdict):
|
|
|
|
for key in kwdict.keys():
|
2015-02-18 15:27:50 +01:00
|
|
|
if not key.startswith('freq'):
|
|
|
|
return True
|
|
|
|
return False
|
2015-06-11 10:07:21 +02:00
|
|
|
|
2015-10-30 08:39:51 +01:00
|
|
|
def pushFilterWF(kwdict):
|
2015-02-20 08:38:26 +01:00
|
|
|
if hasfreq(kwargs):
|
2015-02-20 08:35:26 +01:00
|
|
|
self.getData().filterWFData(kwargs)
|
2015-10-30 08:39:51 +01:00
|
|
|
|
|
|
|
if self.getFilterOptions() and self.filterAction.isChecked():
|
|
|
|
kwargs = self.getFilterOptions().parseFilterOptions()
|
|
|
|
pushFilterWF(kwargs)
|
|
|
|
elif self.filterAction.isChecked():
|
|
|
|
self.adjustFilterOptions()
|
|
|
|
kwargs = self.getFilterOptions().parseFilterOptions()
|
|
|
|
pushFilterWF(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):
|
2015-07-07 10:47:55 +02:00
|
|
|
filteroptions = self.getFilterOptions()
|
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,
|
2015-07-07 10:47:55 +02:00
|
|
|
filterOptions=filteroptions)
|
2014-12-01 12:42:50 +01:00
|
|
|
if filterDlg.exec_():
|
2014-12-09 05:25:43 +01:00
|
|
|
filteroptions = filterDlg.getFilterOptions()
|
2015-03-05 14:52:34 +01:00
|
|
|
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()]
|
2015-09-25 15:06:59 +02:00
|
|
|
except AttributeError as e:
|
|
|
|
print(e)
|
2015-03-01 10:31:49 +01:00
|
|
|
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-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()
|
2015-06-11 10:07:21 +02:00
|
|
|
if settings.value("filterdefaults",
|
|
|
|
None) is None and not self.getFilters():
|
2015-09-25 15:06:59 +02:00
|
|
|
for key, value in FILTERDEFAULTS.items():
|
2015-03-01 10:31:49 +01:00
|
|
|
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)
|
2015-09-25 15:06:59 +02:00
|
|
|
except Exception as 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 ... '
|
2015-06-11 10:07:21 +02:00
|
|
|
'[{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
|
|
|
|
|
2015-03-09 11:21:33 +01:00
|
|
|
def getStationName(self, wfID):
|
2015-04-02 18:48:06 +02:00
|
|
|
return self.getPlotWidget().getPlotDict()[wfID][0]
|
2015-03-09 11:21:33 +01:00
|
|
|
|
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
|
|
|
|
2015-04-02 18:48:06 +02:00
|
|
|
def pickOnStation(self, gui_event):
|
2015-03-09 11:21:33 +01:00
|
|
|
|
2015-04-02 18:48:06 +02:00
|
|
|
wfID = self.getWFID(gui_event)
|
2015-03-09 11:21:33 +01:00
|
|
|
|
|
|
|
station = self.getStationName(wfID)
|
2015-07-07 10:44:06 +02:00
|
|
|
self.updateStatus('picking on station {0}'.format(station))
|
2015-03-29 08:07:46 +02:00
|
|
|
data = self.getData().getWFData()
|
|
|
|
pickDlg = PickDlg(self, data=data.select(station=station),
|
2015-07-07 11:02:46 +02:00
|
|
|
station=station,
|
|
|
|
picks=self.getPicksOnStation(station))
|
2015-03-29 08:07:46 +02:00
|
|
|
if pickDlg.exec_():
|
2015-07-18 16:11:20 +02:00
|
|
|
self.setDirty(True)
|
2015-07-07 10:44:06 +02:00
|
|
|
self.updateStatus('picks accepted ({0})'.format(station))
|
2015-09-25 15:06:59 +02:00
|
|
|
replot = self.addPicks(station, pickDlg.getPicks())
|
|
|
|
if replot:
|
|
|
|
self.plotWaveformData()
|
|
|
|
self.drawPicks()
|
|
|
|
else:
|
|
|
|
self.drawPicks(station)
|
2015-03-29 08:07:46 +02:00
|
|
|
else:
|
2015-07-07 10:44:06 +02:00
|
|
|
self.updateStatus('picks discarded ({0})'.format(station))
|
2015-03-12 13:59:29 +01:00
|
|
|
|
2015-07-09 11:37:03 +02:00
|
|
|
def autoPick(self):
|
|
|
|
list = QListWidget()
|
2015-07-18 16:11:20 +02:00
|
|
|
self.setDirty(True)
|
2015-07-10 09:22:58 +02:00
|
|
|
logDockWidget = QDockWidget("AutoPickLog", self)
|
|
|
|
logDockWidget.setObjectName("LogDockWidget")
|
|
|
|
logDockWidget.setAllowedAreas(Qt.LeftDockWidgetArea)
|
|
|
|
logDockWidget.setWidget(list)
|
|
|
|
logDockWidget.show()
|
|
|
|
logDockWidget.setFloating(False)
|
|
|
|
list.addItem('loading default values for local data ...')
|
2015-07-09 11:37:03 +02:00
|
|
|
autopick_parameter = AutoPickParameter('autoPyLoT_local.in')
|
|
|
|
list.addItem(str(autopick_parameter))
|
|
|
|
|
|
|
|
# Create the worker thread and run it
|
2015-07-14 08:10:49 +02:00
|
|
|
self.thread = AutoPickThread(parent=self,
|
2015-07-09 11:37:03 +02:00
|
|
|
func=autopickevent,
|
|
|
|
data=self.getData().getWFData(),
|
|
|
|
param=autopick_parameter)
|
|
|
|
self.thread.message.connect(list.addItem)
|
|
|
|
self.thread.start()
|
|
|
|
|
2015-07-10 09:22:58 +02:00
|
|
|
self.drawPicks()
|
|
|
|
|
2015-07-09 11:37:03 +02:00
|
|
|
|
2015-07-07 10:37:54 +02:00
|
|
|
def addPicks(self, station, picks):
|
|
|
|
stat_picks = self.getPicksOnStation(station)
|
2015-09-25 15:06:59 +02:00
|
|
|
rval = False
|
2015-07-07 10:37:54 +02:00
|
|
|
if not stat_picks:
|
|
|
|
stat_picks = picks
|
|
|
|
else:
|
|
|
|
msgBox = QMessageBox()
|
|
|
|
msgBox.setText("The picks for station {0} have been "
|
|
|
|
"changed.".format(station))
|
|
|
|
msgBox.setDetailedText("Old picks:\n"
|
|
|
|
"{old_picks}\n\n"
|
|
|
|
"New picks:\n"
|
|
|
|
"{new_picks}".format(old_picks=stat_picks,
|
|
|
|
new_picks=picks))
|
|
|
|
msgBox.setInformativeText("Do you want to save your changes?")
|
|
|
|
msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Cancel)
|
|
|
|
msgBox.setDefaultButton(QMessageBox.Save)
|
|
|
|
ret = msgBox.exec_()
|
|
|
|
if ret == QMessageBox.Save:
|
|
|
|
stat_picks = picks
|
2015-09-25 15:06:59 +02:00
|
|
|
rval = True
|
2015-07-07 10:37:54 +02:00
|
|
|
elif ret == QMessageBox.Cancel:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
raise Exception('FATAL: Should never occur!')
|
|
|
|
self.getPicks()[station] = stat_picks
|
2015-09-25 15:06:59 +02:00
|
|
|
return rval
|
2015-07-07 10:37:54 +02:00
|
|
|
|
2015-09-18 09:54:29 +02:00
|
|
|
def updatePicks(self):
|
2015-09-03 13:21:46 +02:00
|
|
|
evt = self.getData().getEvtData()
|
2015-09-04 15:01:59 +02:00
|
|
|
picks = {}
|
2015-09-03 13:21:46 +02:00
|
|
|
for pick in evt.picks:
|
2015-09-04 15:01:59 +02:00
|
|
|
phase = {}
|
|
|
|
station = pick.waveform_id.station_code
|
2015-09-21 08:48:29 +02:00
|
|
|
try:
|
|
|
|
onsets = picks[station]
|
|
|
|
except KeyError as e:
|
|
|
|
print(e)
|
|
|
|
onsets = {}
|
2015-09-04 15:01:59 +02:00
|
|
|
mpp = pick.time
|
2015-09-21 08:48:29 +02:00
|
|
|
lpp = mpp + pick.time_errors.upper_uncertainty
|
|
|
|
epp = mpp - pick.time_errors.lower_uncertainty
|
|
|
|
spe = pick.time_errors.uncertainty
|
2015-09-04 15:01:59 +02:00
|
|
|
phase['mpp'] = mpp
|
|
|
|
phase['epp'] = epp
|
|
|
|
phase['lpp'] = lpp
|
|
|
|
phase['spe'] = spe
|
|
|
|
|
2015-09-21 08:48:29 +02:00
|
|
|
onsets[pick.phase_hint] = phase.copy()
|
|
|
|
picks[station] = onsets.copy()
|
|
|
|
self.picks.update(picks)
|
2015-09-03 13:21:46 +02:00
|
|
|
|
2015-07-07 10:39:01 +02:00
|
|
|
def drawPicks(self, station=None):
|
|
|
|
# if picks to draw not specified, draw all picks available
|
|
|
|
if not station:
|
|
|
|
for station in self.getPicks():
|
|
|
|
self.drawPicks(station)
|
|
|
|
return
|
|
|
|
# plotting picks
|
|
|
|
plotID = self.getStationID(station)
|
|
|
|
ax = self.getPlotWidget().axes
|
|
|
|
ylims = np.array([-.5, +.5]) + plotID
|
|
|
|
phase_col = {'P': ('c', 'c--', 'b-'),
|
|
|
|
'S': ('m', 'm--', 'r-')}
|
|
|
|
|
|
|
|
stat_picks = self.getPicks()[station]
|
|
|
|
|
|
|
|
for phase in stat_picks:
|
|
|
|
|
|
|
|
picks = stat_picks[phase]
|
|
|
|
colors = phase_col[phase[0].upper()]
|
|
|
|
|
2015-07-13 06:39:25 +02:00
|
|
|
stime = getGlobalTimes(self.getData().getWFData())[0]
|
|
|
|
|
|
|
|
mpp = picks['mpp'] - stime
|
|
|
|
epp = picks['epp'] - stime
|
|
|
|
lpp = picks['lpp'] - stime
|
2015-07-07 10:39:01 +02:00
|
|
|
spe = picks['spe']
|
|
|
|
|
|
|
|
ax.fill_between([epp, lpp], ylims[0], ylims[1],
|
|
|
|
alpha=.5, color=colors[0])
|
|
|
|
ax.plot([mpp - spe, mpp - spe], ylims, colors[1],
|
|
|
|
[mpp, mpp], ylims, colors[2],
|
|
|
|
[mpp + spe, mpp + spe], ylims, colors[1])
|
|
|
|
self.draw()
|
|
|
|
|
2015-07-07 10:37:54 +02:00
|
|
|
def updateStatus(self, message, duration=5000):
|
|
|
|
self.statusBar().showMessage(message, duration)
|
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)
|
|
|
|
|
2015-07-07 10:45:42 +02:00
|
|
|
def tutorUser(self):
|
|
|
|
self.updateStatus('select trace to pick on station ...', 10000)
|
|
|
|
|
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-03-06 09:03:04 +01:00
|
|
|
cinfo = createCreationInfo(agency_id=self.agency)
|
2015-06-11 10:12:50 +02:00
|
|
|
event = createEvent(evtpar['origintime'], cinfo)
|
|
|
|
self.data = Data(self, evtdata=event)
|
2015-07-18 16:11:20 +02:00
|
|
|
self.setDirty(True)
|
2015-01-22 16:41:52 +01:00
|
|
|
|
2015-07-07 10:39:01 +02:00
|
|
|
def draw(self):
|
|
|
|
self.getPlotWidget().draw()
|
|
|
|
|
2015-07-18 16:11:20 +02:00
|
|
|
def setDirty(self, value):
|
|
|
|
self.dirty = value
|
|
|
|
|
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
|
2015-04-02 18:36:21 +02:00
|
|
|
pylot_app = QApplication(sys.argv)
|
2015-07-07 12:14:18 +02:00
|
|
|
pixmap = QPixmap(":/splash/splash.png")
|
|
|
|
splash = QSplashScreen(pixmap)
|
|
|
|
splash.show()
|
2015-04-02 18:36:21 +02:00
|
|
|
|
|
|
|
app_icon = QIcon()
|
2015-07-07 11:21:06 +02:00
|
|
|
app_icon.addPixmap(QPixmap(':/icons/pylot.png'))
|
2014-01-09 10:43:40 +01:00
|
|
|
|
2015-09-18 09:54:29 +02:00
|
|
|
# create the main window
|
|
|
|
pylot_form = MainWindow()
|
|
|
|
splash.showMessage('Loading. Please wait ...')
|
|
|
|
pylot_app.processEvents()
|
|
|
|
|
2014-03-28 22:26:15 +01:00
|
|
|
# set Application Information
|
|
|
|
pylot_app.setOrganizationName("Ruhr-University Bochum / MAGS2")
|
|
|
|
pylot_app.setOrganizationDomain("rub.de")
|
2015-09-18 09:54:29 +02:00
|
|
|
pylot_app.processEvents()
|
2014-03-28 22:26:15 +01:00
|
|
|
pylot_app.setApplicationName("PyLoT")
|
2015-09-18 09:54:29 +02:00
|
|
|
pylot_app.setApplicationVersion(pylot_form.__version__)
|
2015-04-02 18:36:21 +02:00
|
|
|
pylot_app.setWindowIcon(app_icon)
|
2015-07-07 12:14:18 +02:00
|
|
|
pylot_app.processEvents()
|
2014-01-09 10:43:40 +01:00
|
|
|
|
2014-03-13 13:27:34 +01:00
|
|
|
# Show main window and run the app
|
2015-06-25 10:25:08 +02:00
|
|
|
pylot_form.showMaximized()
|
2015-09-18 09:54:29 +02:00
|
|
|
pylot_app.processEvents()
|
|
|
|
|
2015-07-07 12:14:18 +02:00
|
|
|
splash.finish(pylot_form)
|
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())
|