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
|
|
|
|
2016-01-29 07:21:17 +01:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
2016-09-23 15:12:04 +02:00
|
|
|
import matplotlib
|
|
|
|
|
2015-07-06 09:51:59 +02:00
|
|
|
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, \
|
2016-08-29 15:52:58 +02:00
|
|
|
QActionGroup, QListWidget, QDockWidget, QLineEdit
|
2015-07-07 10:39:51 +02:00
|
|
|
import numpy as np
|
2015-11-18 09:30:32 +01:00
|
|
|
from obspy import UTCDateTime
|
2015-02-16 10:24:17 +01:00
|
|
|
|
2016-09-23 15:12:04 +02:00
|
|
|
from pylot.core.analysis.magnitude import calc_richter_magnitude, calc_moment_magnitude
|
2016-05-01 21:10:30 +02:00
|
|
|
from pylot.core.io.data import Data
|
|
|
|
from pylot.core.io.inputs import FilterOptions, AutoPickParameter
|
2015-07-10 09:22:58 +02:00
|
|
|
from pylot.core.pick.autopick import autopickevent
|
2016-06-07 13:51:03 +02:00
|
|
|
from pylot.core.pick.compare import Comparison
|
2016-09-23 15:12:04 +02:00
|
|
|
from pylot.core.pick.utils import symmetrize_error
|
2016-05-03 13:54:59 +02:00
|
|
|
from pylot.core.io.phases import picksdict_from_picks
|
2016-08-25 13:31:51 +02:00
|
|
|
import pylot.core.loc.nll as nll
|
2016-05-27 11:25:47 +02:00
|
|
|
from pylot.core.util.defaults import FILTERDEFAULTS, COMPNAME_MAP, \
|
2016-04-11 05:47:38 +02:00
|
|
|
AUTOMATIC_DEFAULTS
|
2016-01-29 07:21:17 +01:00
|
|
|
from pylot.core.util.errors import FormatError, DatastructureError, \
|
2015-08-27 12:55:34 +02:00
|
|
|
OverwriteError
|
2015-07-10 09:22:58 +02:00
|
|
|
from pylot.core.util.connection import checkurl
|
2016-09-20 13:45:49 +02:00
|
|
|
from pylot.core.util.dataprocessing import read_metadata
|
2016-05-27 11:25:47 +02:00
|
|
|
from pylot.core.util.utils import fnConstructor, getLogin, \
|
2016-09-19 11:29:33 +02:00
|
|
|
full_range
|
2016-05-20 14:46:10 +02:00
|
|
|
from pylot.core.io.location import create_creation_info, create_event
|
2016-01-29 07:21:17 +01:00
|
|
|
from pylot.core.util.widgets import FilterOptionsDialog, NewEventDlg, \
|
2016-06-07 13:51:03 +02:00
|
|
|
WaveformWidget, PropertiesDlg, HelpForm, createAction, PickDlg, \
|
|
|
|
getDataType, ComparisonDialog
|
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-02-16 10:24:17 +01:00
|
|
|
|
2016-08-25 13:31:51 +02:00
|
|
|
locateTool = dict(nll=nll)
|
2015-06-11 10:07:21 +02:00
|
|
|
|
2016-01-29 07:21:17 +01: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
|
2016-09-08 14:02:21 +02:00
|
|
|
# read settings
|
2014-11-28 11:15:49 +01:00
|
|
|
settings = QSettings()
|
2016-09-08 15:31:23 +02:00
|
|
|
infile = os.path.join(os.path.expanduser('~'), '.pylot', 'pylot.in')
|
2016-09-08 14:02:21 +02:00
|
|
|
self._inputs = AutoPickParameter(infile)
|
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)
|
2016-05-27 11:25:47 +02:00
|
|
|
self.recentfiles = settings.value("data/recentEvents", [])
|
|
|
|
self.fname = dict(manual=None, auto=None, loc=None)
|
2015-02-13 11:17:18 +01:00
|
|
|
self.fnames = None
|
2016-05-31 17:27:59 +02:00
|
|
|
self._stime = 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(
|
2016-03-30 07:00:31 +02:00
|
|
|
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 = {}
|
2015-11-30 09:50:47 +01:00
|
|
|
self.autopicks = {}
|
2015-11-14 11:46:46 +01:00
|
|
|
self.loc = False
|
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
|
2016-05-27 11:25:47 +02:00
|
|
|
if self.recentfiles:
|
2015-02-13 11:14:17 +01:00
|
|
|
lastEvent = self.getLastEvent()
|
|
|
|
self.data = Data(self, lastEvent)
|
|
|
|
else:
|
|
|
|
self.data = Data(self)
|
2016-06-01 08:55:43 +02:00
|
|
|
self.autodata = 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
|
2016-05-27 11:25:47 +02:00
|
|
|
self.load_data()
|
2016-09-22 14:12:24 +02:00
|
|
|
finv = settings.value("inventoryFile", None)
|
|
|
|
if finv is not None:
|
|
|
|
self._metadata = read_metadata(finv)
|
|
|
|
else:
|
|
|
|
self._metadata = None
|
2016-03-22 10:49:06 +01:00
|
|
|
if self.loadWaveformData():
|
|
|
|
self.updateFilterOptions()
|
|
|
|
else:
|
|
|
|
sys.exit(0)
|
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(
|
2016-03-30 07:00:31 +02:00
|
|
|
[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
|
2016-06-06 14:10:46 +02:00
|
|
|
self.DataPlot = WaveformWidget(parent=self, xlabel=xlab, ylabel=None,
|
|
|
|
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',
|
2016-09-02 14:21:59 +02:00
|
|
|
lambda event: self.tutor_user())
|
2015-01-29 08:41:38 +01:00
|
|
|
_layout.addWidget(self.DataPlot)
|
|
|
|
|
2016-05-27 11:25:47 +02:00
|
|
|
manupicksicon = self.style().standardIcon(QStyle.SP_DialogYesButton)
|
|
|
|
autopicksicon = self.style().standardIcon(QStyle.SP_DialogNoButton)
|
|
|
|
locactionicon = self.style().standardIcon(QStyle.SP_DirOpenIcon)
|
|
|
|
loadpiloticon = self.style().standardIcon(QStyle.SP_ComputerIcon)
|
2015-01-29 08:41:38 +01:00
|
|
|
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-11-09 08:53:26 +01:00
|
|
|
locate_icon = QIcon()
|
|
|
|
locate_icon.addPixmap(QPixmap(':/icons/locate.png'))
|
2016-06-06 14:10:46 +02:00
|
|
|
compare_icon = QIcon()
|
|
|
|
compare_icon.addPixmap(QPixmap(':/icons/compare.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.")
|
2016-05-27 11:25:47 +02:00
|
|
|
openmanualpicksaction = self.createAction(self, "Load &picks ...",
|
|
|
|
self.load_data,
|
|
|
|
QKeySequence.Open,
|
|
|
|
manupicksicon,
|
|
|
|
"Load pick data for "
|
|
|
|
"the actual event.")
|
|
|
|
openmanualpicksaction.setData(None)
|
|
|
|
openautopicksaction = self.createAction(self, "Load &automatic picks "
|
|
|
|
"...",
|
|
|
|
self.load_autopicks,
|
|
|
|
"Ctrl+A",
|
|
|
|
autopicksicon,
|
|
|
|
"Load automatic pick data "
|
|
|
|
"for the actual event.")
|
|
|
|
openautopicksaction.setData(None)
|
|
|
|
|
|
|
|
loadlocationaction = self.createAction(self, "Load &location ...",
|
|
|
|
self.load_loc, "Ctrl+L",
|
|
|
|
locactionicon,
|
|
|
|
"Load location information on "
|
|
|
|
"the actual event.")
|
|
|
|
loadpilotevent = self.createAction(self, "Load PILOT &event ...",
|
2016-05-27 12:53:34 +02:00
|
|
|
self.load_pilotevent, "Ctrl+E",
|
2016-05-27 11:25:47 +02:00
|
|
|
loadpiloticon,
|
|
|
|
"Load PILOT event from information "
|
|
|
|
"Matlab binary collections.")
|
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"),
|
2016-05-27 11:25:47 +02:00
|
|
|
"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)
|
2016-06-06 14:10:46 +02:00
|
|
|
self.compare_action = self.createAction(self, "&Compare picks...",
|
|
|
|
self.comparePicks, "Alt+C",
|
|
|
|
compare_icon, "Comparison of "
|
|
|
|
"manual and "
|
|
|
|
"automatic pick "
|
|
|
|
"data.", False)
|
2015-03-04 15:40:25 +01:00
|
|
|
printAction = self.createAction(self, "&Print event ...",
|
2016-09-02 14:21:59 +02:00
|
|
|
self.show_event_information, 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')
|
2016-05-27 11:25:47 +02:00
|
|
|
self.fileMenuActions = (newEventAction, openmanualpicksaction,
|
2015-01-29 08:41:38 +01:00
|
|
|
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")
|
2016-05-27 11:25:47 +02:00
|
|
|
fileToolActions = (newEventAction, openmanualpicksaction,
|
|
|
|
openautopicksaction, loadlocationaction,
|
|
|
|
loadpilotevent, saveEventAction)
|
2015-02-23 14:47:38 +01:00
|
|
|
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")
|
2016-06-06 14:10:46 +02:00
|
|
|
autoPickActions = (auto_pick, self.compare_action)
|
2015-07-09 11:37:03 +02:00
|
|
|
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
|
|
|
|
2016-08-31 12:16:48 +02:00
|
|
|
locateEvent = self.createAction(parent=self, text='locate_event',
|
|
|
|
slot=self.locate_event,
|
2016-05-27 11:25:47 +02:00
|
|
|
shortcut='Alt+Ctrl+L',
|
|
|
|
icon=locate_icon,
|
|
|
|
tip='Locate the event using '
|
|
|
|
'the picked arrivals.')
|
2015-11-09 08:53:26 +01:00
|
|
|
|
|
|
|
locationToolBar = self.addToolBar("LocationTools")
|
|
|
|
locationToolActions = (locateEvent,)
|
|
|
|
locationToolBar.setObjectName("LocationTools")
|
|
|
|
self.addActions(locationToolBar, locationToolActions)
|
|
|
|
|
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
|
|
|
|
2016-09-22 14:12:24 +02:00
|
|
|
|
|
|
|
@property
|
|
|
|
def metadata(self):
|
|
|
|
return self._metadata
|
|
|
|
|
|
|
|
|
|
|
|
@metadata.setter
|
|
|
|
def metadata(self, value):
|
|
|
|
self._metadata = value
|
|
|
|
|
|
|
|
|
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 = []
|
2016-05-27 11:25:47 +02:00
|
|
|
for eventID in self.recentfiles:
|
2014-12-01 12:37:52 +01:00
|
|
|
fname = fnConstructor(eventID)
|
|
|
|
if eventID != current and QFile.exists(fname):
|
|
|
|
recentEvents.append(eventID)
|
2015-02-13 11:16:20 +01:00
|
|
|
recentEvents.reverse()
|
2016-05-27 11:25:47 +02:00
|
|
|
self.recentfiles = recentEvents[0:5]
|
2015-02-13 11:16:20 +01:00
|
|
|
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()"),
|
2016-05-27 11:25:47 +02:00
|
|
|
self.load_data)
|
2014-12-01 12:37:52 +01:00
|
|
|
self.fileMenu.addAction(action)
|
|
|
|
self.fileMenu.addSeparator()
|
|
|
|
self.fileMenu.addAction(self.fileMenuActions[-1])
|
|
|
|
|
2016-09-08 15:31:23 +02:00
|
|
|
@property
|
|
|
|
def inputs(self):
|
|
|
|
return self._inputs
|
|
|
|
|
2015-07-18 16:11:20 +02:00
|
|
|
def getRoot(self):
|
|
|
|
settings = QSettings()
|
|
|
|
return settings.value("data/dataRoot")
|
|
|
|
|
2016-05-27 11:25:47 +02:00
|
|
|
def load_autopicks(self, fname=None):
|
|
|
|
self.load_data(fname, type='auto')
|
|
|
|
|
|
|
|
def load_loc(self, fname=None):
|
2016-06-02 09:39:01 +02:00
|
|
|
type = getDataType(self)
|
|
|
|
self.load_data(fname, type=type, loc=True)
|
2016-05-27 11:25:47 +02:00
|
|
|
|
|
|
|
def load_pilotevent(self):
|
2016-06-02 09:39:01 +02:00
|
|
|
filt = "PILOT location files (*LOC*.mat)"
|
2016-05-31 17:36:00 +02:00
|
|
|
caption = "Select PILOT location file"
|
2016-05-27 11:25:47 +02:00
|
|
|
fn_loc = QFileDialog().getOpenFileName(self, caption=caption,
|
2016-05-27 12:53:34 +02:00
|
|
|
filter=filt, dir=self.getRoot())
|
|
|
|
fn_loc = fn_loc[0]
|
|
|
|
loc_dir = os.path.split(fn_loc)[0]
|
2016-06-02 09:39:01 +02:00
|
|
|
filt = "PILOT phases files (*PHASES*.mat)"
|
2016-05-27 11:25:47 +02:00
|
|
|
caption = "Select PILOT phases file"
|
|
|
|
fn_phases = QFileDialog().getOpenFileName(self, caption=caption,
|
2016-05-27 12:53:34 +02:00
|
|
|
filter=filt, dir=loc_dir)
|
|
|
|
fn_phases = fn_phases[0]
|
2016-03-29 11:26:08 +02:00
|
|
|
|
2016-06-02 09:39:01 +02:00
|
|
|
type = getDataType(self)
|
2016-05-27 11:25:47 +02:00
|
|
|
|
|
|
|
fname_dict = dict(phasfn=fn_phases, locfn=fn_loc)
|
|
|
|
self.load_data(fname_dict, type=type)
|
|
|
|
|
2016-06-02 09:39:01 +02:00
|
|
|
def load_data(self, fname=None, type='manual', loc=False):
|
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):
|
2016-05-27 11:25:47 +02:00
|
|
|
fname = self.filename_from_action(action)
|
|
|
|
self.set_fname(fname, type)
|
2016-06-01 08:55:43 +02:00
|
|
|
data = dict(auto=self.autodata, manual=self.data)
|
|
|
|
data[type] += Data(self, evtdata=fname)
|
2016-06-02 09:39:01 +02:00
|
|
|
if not loc:
|
2016-05-27 11:25:47 +02:00
|
|
|
self.updatePicks(type=type)
|
2016-06-01 08:55:43 +02:00
|
|
|
self.drawPicks(picktype=type)
|
2016-05-31 17:27:59 +02:00
|
|
|
self.draw()
|
2014-11-26 08:46:16 +01:00
|
|
|
|
2015-02-13 11:23:01 +01:00
|
|
|
def getLastEvent(self):
|
2016-05-27 11:25:47 +02:00
|
|
|
return self.recentfiles[0]
|
2015-02-13 11:23:01 +01:00
|
|
|
|
2016-05-27 11:25:47 +02:00
|
|
|
def add_recentfile(self, event):
|
|
|
|
self.recentfiles.insert(0, event)
|
2015-08-31 13:37:18 +02:00
|
|
|
|
2015-01-22 16:41:52 +01:00
|
|
|
def getWFFnames(self):
|
2015-01-26 21:11:53 +01:00
|
|
|
try:
|
2016-09-02 14:21:59 +02:00
|
|
|
evt = self.get_data().get_evt_data()
|
2015-01-26 21:11:53 +01:00
|
|
|
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')
|
2016-03-22 10:49:06 +01:00
|
|
|
if not self.fnames:
|
|
|
|
return None
|
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
|
|
|
|
2016-05-27 11:25:47 +02:00
|
|
|
def filename_from_action(self, action):
|
|
|
|
if action.data() is None:
|
|
|
|
filt = "Supported file formats" \
|
|
|
|
" (*.mat *.qml *.xml *.kor *.evt)"
|
|
|
|
caption = "Open an event file"
|
2016-06-02 09:39:01 +02:00
|
|
|
fname = QFileDialog().getOpenFileName(self, caption=caption,
|
|
|
|
filter=filt,
|
|
|
|
dir=self.getRoot())
|
2016-05-27 11:25:47 +02:00
|
|
|
fname = fname[0]
|
|
|
|
else:
|
|
|
|
fname = str(action.data().toString())
|
|
|
|
return fname
|
|
|
|
|
|
|
|
def get_fnames(self):
|
2015-08-31 13:37:18 +02:00
|
|
|
return self.fname
|
|
|
|
|
2016-05-27 11:25:47 +02:00
|
|
|
def set_fname(self, fname, type):
|
|
|
|
if self.get_fnames()[type] is not None:
|
|
|
|
self.add_recentfile(self.get_fnames())
|
|
|
|
self.fname[type] = fname
|
2015-08-31 13:37:18 +02:00
|
|
|
|
2015-07-18 16:11:20 +02:00
|
|
|
def getEventFileName(self):
|
2016-05-27 11:25:47 +02:00
|
|
|
if self.get_fnames() is None:
|
2016-09-02 14:21:59 +02:00
|
|
|
self.set_fname(self.get_data().getEventFileName())
|
2016-05-27 11:25:47 +02:00
|
|
|
return self.get_fnames()
|
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))
|
2016-09-19 11:33:08 +02:00
|
|
|
directory = os.path.realpath(self.getRoot())
|
2016-05-27 11:25:47 +02:00
|
|
|
file_filter = "QuakeML file (*.xml);;VELEST observation file " \
|
|
|
|
"format (*.cnv);;NonLinLoc observation file (*.obs)"
|
|
|
|
title = 'Save event data ...'
|
|
|
|
fname, selected_filter = QFileDialog.getSaveFileName(self,
|
|
|
|
title,
|
|
|
|
directory,
|
|
|
|
file_filter)
|
2015-08-31 13:37:18 +02:00
|
|
|
|
2016-03-02 11:04:11 +01:00
|
|
|
fbasename, exform = os.path.splitext(fname)
|
|
|
|
|
|
|
|
if not exform and selected_filter:
|
|
|
|
exform = selected_filter.split('*')[1][:-1]
|
2015-08-31 13:37:18 +02:00
|
|
|
|
|
|
|
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:
|
2016-09-02 14:21:59 +02:00
|
|
|
self.get_data().applyEVTData(self.getPicks())
|
2015-08-27 12:55:34 +02:00
|
|
|
except OverwriteError:
|
|
|
|
msgBox = QMessageBox()
|
|
|
|
msgBox.setText("Picks have been modified!")
|
2016-05-27 11:25:47 +02:00
|
|
|
msgBox.setInformativeText(
|
|
|
|
"Do you want to save the changes and overwrite the picks?")
|
2016-09-02 14:21:59 +02:00
|
|
|
msgBox.setDetailedText(self.get_data().getPicksStr())
|
2015-08-28 16:01:42 +02:00
|
|
|
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:
|
2016-09-02 14:21:59 +02:00
|
|
|
self.get_data().resetPicks()
|
2016-03-03 13:17:10 +01:00
|
|
|
return self.saveData()
|
2015-08-28 16:01:42 +02:00
|
|
|
elif ret == QMessageBox.Cancel:
|
|
|
|
return False
|
2014-12-17 12:16:32 +01:00
|
|
|
try:
|
2016-09-02 14:21:59 +02:00
|
|
|
self.get_data().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
|
2016-09-02 14:21:59 +02:00
|
|
|
self.get_data().exportEvent(fbasename, exform)
|
2015-08-31 13:37:18 +02:00
|
|
|
self.setDirty(False)
|
2016-09-02 14:21:59 +02:00
|
|
|
self.update_status('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
|
|
|
|
|
2016-09-02 14:21:59 +02:00
|
|
|
def get_data(self, type='manual'):
|
2016-05-27 07:43:54 +02:00
|
|
|
if type == 'auto':
|
|
|
|
return self.autodata
|
2014-11-13 11:27:52 +01:00
|
|
|
return self.data
|
|
|
|
|
2015-11-30 09:50:47 +01:00
|
|
|
def getPicks(self, type='manual'):
|
|
|
|
rdict = dict(auto=self.autopicks, manual=self.picks)
|
|
|
|
return rdict[type]
|
2015-07-07 10:32:56 +02:00
|
|
|
|
2015-11-30 09:50:47 +01:00
|
|
|
def getPicksOnStation(self, station, type='manual'):
|
2015-07-07 10:32:56 +02:00
|
|
|
try:
|
2015-11-30 09:50:47 +01:00
|
|
|
return self.getPicks(type)[station]
|
2015-07-07 10:32:56 +02:00
|
|
|
except KeyError:
|
|
|
|
return None
|
|
|
|
|
2016-06-06 14:10:46 +02:00
|
|
|
def comparePicks(self):
|
|
|
|
if self.check4Comparison():
|
2016-06-07 13:51:03 +02:00
|
|
|
co = Comparison(auto=self.getPicks('auto'), manu=self.getPicks())
|
|
|
|
compare_dlg = ComparisonDialog(co, self)
|
|
|
|
compare_dlg.exec_()
|
2016-06-06 14:10:46 +02:00
|
|
|
|
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
|
|
|
|
2016-05-31 15:53:23 +02:00
|
|
|
try:
|
|
|
|
statID = int(round(ycoord))
|
|
|
|
except TypeError as e:
|
|
|
|
if 'a float is required' in e.message:
|
|
|
|
return None
|
|
|
|
else:
|
|
|
|
raise e
|
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
|
|
|
|
|
2016-05-31 17:27:59 +02:00
|
|
|
def getStime(self):
|
|
|
|
return self._stime
|
|
|
|
|
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)
|
2016-03-22 10:49:06 +01:00
|
|
|
ans = self.data.setWFData(self.fnames)
|
2015-02-13 11:20:29 +01:00
|
|
|
elif self.fnames is None and self.okToContinue():
|
2016-03-22 10:49:06 +01:00
|
|
|
ans = self.data.setWFData(self.getWFFnames())
|
2016-08-25 21:32:41 +02:00
|
|
|
else:
|
|
|
|
ans = False
|
2016-09-19 11:29:33 +02:00
|
|
|
self._stime = full_range(self.get_data().getWFData())[0]
|
2016-03-22 10:49:06 +01:00
|
|
|
if ans:
|
|
|
|
self.plotWaveformData()
|
2016-03-23 12:01:46 +01:00
|
|
|
return ans
|
2016-03-22 10:49:06 +01:00
|
|
|
else:
|
|
|
|
return ans
|
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])
|
2016-03-29 14:06:57 +02:00
|
|
|
alter_comp = COMPNAME_MAP[comp]
|
2016-09-02 14:21:59 +02:00
|
|
|
wfst = self.get_data().getWFData().select(component=comp)
|
|
|
|
wfst += self.get_data().getWFData().select(component=alter_comp)
|
2016-03-18 15:35:12 +01:00
|
|
|
self.getPlotWidget().plotWFData(wfdata=wfst, title=title, mapping=False)
|
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()
|
2016-05-31 17:27:59 +02:00
|
|
|
self.draw()
|
2015-07-07 14:21:11 +02:00
|
|
|
|
|
|
|
def plotN(self):
|
|
|
|
self.setComponent('N')
|
|
|
|
self.plotWaveformData()
|
|
|
|
self.drawPicks()
|
2016-05-31 17:27:59 +02:00
|
|
|
self.draw()
|
2015-07-07 14:21:11 +02:00
|
|
|
|
|
|
|
def plotE(self):
|
|
|
|
self.setComponent('E')
|
|
|
|
self.plotWaveformData()
|
|
|
|
self.drawPicks()
|
2016-05-31 17:27:59 +02:00
|
|
|
self.draw()
|
2015-07-07 14:21:11 +02:00
|
|
|
|
2015-10-31 00:07:24 +01:00
|
|
|
def pushFilterWF(self, param_args):
|
2016-09-02 14:21:59 +02:00
|
|
|
self.get_data().filterWFData(param_args)
|
2015-10-31 00:07:24 +01:00
|
|
|
|
2015-02-17 13:17:01 +01:00
|
|
|
def filterWaveformData(self):
|
2016-09-02 14:21:59 +02:00
|
|
|
if self.get_data():
|
2015-10-30 08:39:51 +01:00
|
|
|
if self.getFilterOptions() and self.filterAction.isChecked():
|
|
|
|
kwargs = self.getFilterOptions().parseFilterOptions()
|
2015-10-31 00:07:24 +01:00
|
|
|
self.pushFilterWF(kwargs)
|
2015-10-30 08:39:51 +01:00
|
|
|
elif self.filterAction.isChecked():
|
|
|
|
self.adjustFilterOptions()
|
2015-02-20 08:38:26 +01:00
|
|
|
else:
|
2016-09-02 14:21:59 +02:00
|
|
|
self.get_data().resetWFData()
|
2015-02-20 08:38:26 +01:00
|
|
|
self.plotWaveformData()
|
2016-03-29 12:09:26 +02:00
|
|
|
self.drawPicks()
|
2016-05-31 17:27:59 +02:00
|
|
|
self.draw()
|
2014-11-28 11:15:49 +01:00
|
|
|
|
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,
|
2015-10-31 00:07:24 +01:00
|
|
|
parent=self)
|
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)
|
2015-10-31 00:07:24 +01:00
|
|
|
if self.filterAction.isChecked():
|
|
|
|
kwargs = self.getFilterOptions().parseFilterOptions()
|
|
|
|
self.pushFilterWF(kwargs)
|
|
|
|
self.plotWaveformData()
|
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:
|
2016-09-02 14:21:59 +02:00
|
|
|
self.update_status('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:
|
2016-09-02 14:21:59 +02:00
|
|
|
self.update_status('Filter loaded ... '
|
2015-06-11 10:07:21 +02:00
|
|
|
'[{0}: {1} Hz]'.format(
|
2016-03-30 07:00:31 +02:00
|
|
|
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()
|
2016-09-02 14:21:59 +02:00
|
|
|
self.update_status('Seismic phase changed to '
|
2015-02-23 14:46:18 +01:00
|
|
|
'{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
|
|
|
|
2016-06-10 09:01:37 +02:00
|
|
|
if wfID is None: return
|
2016-05-31 15:53:23 +02:00
|
|
|
|
2015-03-09 11:21:33 +01:00
|
|
|
station = self.getStationName(wfID)
|
2016-09-02 14:21:59 +02:00
|
|
|
self.update_status('picking on station {0}'.format(station))
|
|
|
|
data = self.get_data().getWFData()
|
2015-03-29 08:07:46 +02:00
|
|
|
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)
|
2016-09-02 14:21:59 +02:00
|
|
|
self.update_status('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()
|
2016-05-31 17:27:59 +02:00
|
|
|
self.draw()
|
2015-09-25 15:06:59 +02:00
|
|
|
else:
|
|
|
|
self.drawPicks(station)
|
2016-05-31 17:27:59 +02:00
|
|
|
self.draw()
|
2015-03-29 08:07:46 +02:00
|
|
|
else:
|
2016-09-02 14:21:59 +02:00
|
|
|
self.update_status('picks discarded ({0})'.format(station))
|
|
|
|
if not self.get_loc_flag() and self.check4Loc():
|
|
|
|
self.set_loc_flag(True)
|
|
|
|
elif self.get_loc_flag() and not self.check4Loc():
|
|
|
|
self.set_loc_flag(False)
|
2015-03-12 13:59:29 +01:00
|
|
|
|
2015-11-26 05:17:26 +01:00
|
|
|
def addListItem(self, text):
|
|
|
|
self.listWidget.addItem(text)
|
|
|
|
self.listWidget.scrollToBottom()
|
|
|
|
|
2015-07-09 11:37:03 +02:00
|
|
|
def autoPick(self):
|
2015-11-26 05:17:26 +01:00
|
|
|
self.listWidget = QListWidget()
|
2015-07-18 16:11:20 +02:00
|
|
|
self.setDirty(True)
|
2015-11-30 09:55:33 +01:00
|
|
|
self.logDockWidget = QDockWidget("AutoPickLog", self)
|
|
|
|
self.logDockWidget.setObjectName("LogDockWidget")
|
2016-05-27 11:25:47 +02:00
|
|
|
self.logDockWidget.setAllowedAreas(
|
|
|
|
Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
|
2015-11-30 09:55:33 +01:00
|
|
|
self.logDockWidget.setWidget(self.listWidget)
|
|
|
|
self.addDockWidget(Qt.LeftDockWidgetArea, self.logDockWidget)
|
2015-11-26 05:17:26 +01:00
|
|
|
self.addListItem('loading default values for local data ...')
|
2016-09-08 14:02:21 +02:00
|
|
|
# may become obsolete if generalized input parameter a read from disc
|
|
|
|
# during initialization
|
|
|
|
# TODO double check for obsolete read in of parameters
|
2016-04-11 05:47:38 +02:00
|
|
|
autopick_parameter = AutoPickParameter(AUTOMATIC_DEFAULTS)
|
2015-11-26 05:17:26 +01:00
|
|
|
self.addListItem(str(autopick_parameter))
|
2015-07-09 11:37:03 +02:00
|
|
|
|
|
|
|
# Create the worker thread and run it
|
2015-07-14 08:10:49 +02:00
|
|
|
self.thread = AutoPickThread(parent=self,
|
2016-01-29 07:21:17 +01:00
|
|
|
func=autopickevent,
|
2016-09-02 14:21:59 +02:00
|
|
|
data=self.get_data().getWFData(),
|
2016-01-29 07:21:17 +01:00
|
|
|
param=autopick_parameter)
|
2015-11-26 05:17:26 +01:00
|
|
|
self.thread.message.connect(self.addListItem)
|
2015-07-09 11:37:03 +02:00
|
|
|
self.thread.start()
|
2015-12-01 05:03:55 +01:00
|
|
|
self.thread.finished.connect(self.finalizeAutoPick)
|
|
|
|
|
|
|
|
def finalizeAutoPick(self):
|
|
|
|
self.drawPicks(picktype='auto')
|
2016-05-31 17:27:59 +02:00
|
|
|
self.draw()
|
2015-12-01 05:03:55 +01:00
|
|
|
self.thread.quit()
|
2015-07-09 11:37:03 +02:00
|
|
|
|
2015-11-30 09:50:47 +01:00
|
|
|
def addPicks(self, station, picks, type='manual'):
|
|
|
|
stat_picks = self.getPicksOnStation(station, type)
|
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"
|
2016-01-29 07:21:17 +01:00
|
|
|
"{old_picks}\n\n"
|
|
|
|
"New picks:\n"
|
|
|
|
"{new_picks}".format(old_picks=stat_picks,
|
|
|
|
new_picks=picks))
|
2015-07-07 10:37:54 +02:00
|
|
|
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!')
|
2015-11-30 09:50:47 +01:00
|
|
|
self.getPicks(type=type)[station] = stat_picks
|
2015-09-25 15:06:59 +02:00
|
|
|
return rval
|
2015-07-07 10:37:54 +02:00
|
|
|
|
2016-03-29 10:30:45 +02:00
|
|
|
def updatePicks(self, type='manual'):
|
2016-09-02 14:21:59 +02:00
|
|
|
picks = picksdict_from_picks(evt=self.get_data(type).get_evt_data())
|
2016-03-29 10:30:45 +02:00
|
|
|
if type == 'manual':
|
|
|
|
self.picks.update(picks)
|
|
|
|
elif type == 'auto':
|
|
|
|
self.autopicks.update(picks)
|
2016-06-06 14:10:46 +02:00
|
|
|
self.check4Comparison()
|
2015-09-03 13:21:46 +02:00
|
|
|
|
2015-11-30 09:50:47 +01:00
|
|
|
def drawPicks(self, station=None, picktype='manual'):
|
2015-07-07 10:39:01 +02:00
|
|
|
# if picks to draw not specified, draw all picks available
|
|
|
|
if not station:
|
2015-11-30 09:50:47 +01:00
|
|
|
for station in self.getPicks(type=picktype):
|
|
|
|
self.drawPicks(station, picktype=picktype)
|
2015-07-07 10:39:01 +02:00
|
|
|
return
|
|
|
|
# plotting picks
|
|
|
|
plotID = self.getStationID(station)
|
2016-09-08 15:29:37 +02:00
|
|
|
if not plotID:
|
|
|
|
return
|
2015-07-07 10:39:01 +02:00
|
|
|
ax = self.getPlotWidget().axes
|
|
|
|
ylims = np.array([-.5, +.5]) + plotID
|
2016-05-27 11:25:47 +02:00
|
|
|
phase_col = {
|
|
|
|
'P': ('c', 'c--', 'b-', 'bv', 'b^'),
|
|
|
|
'S': ('m', 'm--', 'r-', 'rv', 'r^')
|
|
|
|
}
|
2015-07-07 10:39:01 +02:00
|
|
|
|
2015-11-30 09:50:47 +01:00
|
|
|
stat_picks = self.getPicks(type=picktype)[station]
|
2015-07-07 10:39:01 +02:00
|
|
|
|
2016-05-31 17:27:59 +02:00
|
|
|
stime = self.getStime()
|
|
|
|
|
2015-07-07 10:39:01 +02:00
|
|
|
for phase in stat_picks:
|
|
|
|
picks = stat_picks[phase]
|
2015-11-30 09:50:47 +01:00
|
|
|
if type(stat_picks[phase]) is not dict:
|
|
|
|
return
|
2015-07-07 10:39:01 +02:00
|
|
|
colors = phase_col[phase[0].upper()]
|
|
|
|
|
2015-07-13 06:39:25 +02:00
|
|
|
mpp = picks['mpp'] - stime
|
|
|
|
epp = picks['epp'] - stime
|
|
|
|
lpp = picks['lpp'] - stime
|
2015-07-07 10:39:01 +02:00
|
|
|
spe = picks['spe']
|
2016-09-21 14:12:58 +02:00
|
|
|
if not spe:
|
|
|
|
spe = symmetrize_error(mpp - epp, lpp - mpp)
|
2015-07-07 10:39:01 +02:00
|
|
|
|
2015-11-30 09:50:47 +01:00
|
|
|
if picktype == 'manual':
|
|
|
|
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])
|
|
|
|
elif picktype == 'auto':
|
|
|
|
ax.plot(mpp, ylims[1], colors[3],
|
|
|
|
mpp, ylims[0], colors[4])
|
|
|
|
else:
|
|
|
|
raise TypeError('Unknow picktype {0}'.format(picktype))
|
2015-07-07 10:39:01 +02:00
|
|
|
|
2016-08-31 12:16:48 +02:00
|
|
|
def locate_event(self):
|
2016-08-25 21:32:41 +02:00
|
|
|
"""
|
|
|
|
locate event using the manually picked phases
|
|
|
|
:return:
|
|
|
|
"""
|
|
|
|
if not self.okToContinue():
|
|
|
|
return
|
2015-11-13 14:05:29 +01:00
|
|
|
settings = QSettings()
|
2016-08-25 13:31:51 +02:00
|
|
|
# get location tool hook
|
2015-11-13 14:05:29 +01:00
|
|
|
loctool = settings.value("loc/tool", "nll")
|
2016-08-25 13:31:51 +02:00
|
|
|
lt = locateTool[loctool]
|
|
|
|
# get working directory
|
|
|
|
locroot = settings.value("{0}/rootPath".format(loctool), None)
|
2016-08-26 10:48:16 +02:00
|
|
|
if locroot is None:
|
|
|
|
self.PyLoTprefs()
|
2016-08-31 12:16:48 +02:00
|
|
|
self.locate_event()
|
2016-08-26 14:36:33 +02:00
|
|
|
|
2016-08-25 13:31:51 +02:00
|
|
|
infile = settings.value("{0}/inputFile".format(loctool), None)
|
2016-08-26 14:36:33 +02:00
|
|
|
|
|
|
|
if not infile:
|
|
|
|
caption = 'Select {0} input file'.format(loctool)
|
|
|
|
filt = "Supported file formats" \
|
|
|
|
" (*.in *.ini *.conf *.cfg)"
|
|
|
|
ans = QFileDialog().getOpenFileName(self, caption=caption,
|
|
|
|
filter=filt, dir=locroot)
|
2016-09-08 15:28:40 +02:00
|
|
|
if ans[0]:
|
|
|
|
infile = ans[0]
|
|
|
|
else:
|
|
|
|
QMessageBox.information(self,
|
|
|
|
self.tr('No infile selected'),
|
|
|
|
self.tr('Inputfile necessary for localization.'))
|
|
|
|
return
|
2016-08-26 14:36:33 +02:00
|
|
|
settings.setValue("{0}/inputFile".format(loctool), infile)
|
|
|
|
settings.sync()
|
2016-08-29 15:52:58 +02:00
|
|
|
if loctool == 'nll':
|
|
|
|
ttt = settings.value("{0}/travelTimeTables", None)
|
|
|
|
ok = False
|
|
|
|
if ttt is None:
|
|
|
|
while not ok:
|
|
|
|
text, ok = QInputDialog.getText(self, 'Pattern for travel time tables',
|
|
|
|
'Base name of travel time tables',
|
|
|
|
echo=QLineEdit.Normal,
|
|
|
|
text="ttime")
|
|
|
|
ttt = text
|
|
|
|
|
|
|
|
outfile = settings.value("{0}/outputFile".format(loctool),
|
|
|
|
os.path.split(os.tempnam())[-1])
|
2016-08-26 14:36:33 +02:00
|
|
|
phasefile = os.path.split(os.tempnam())[-1]
|
|
|
|
phasepath = os.path.join(locroot, 'obs', phasefile)
|
2016-08-25 21:32:41 +02:00
|
|
|
locpath = os.path.join(locroot, 'loc', outfile)
|
|
|
|
lt.export(self.getPicks(), phasepath)
|
2016-08-29 15:52:58 +02:00
|
|
|
lt.modify_inputs(infile, locroot, outfile, phasefile, ttt)
|
2016-08-25 21:32:41 +02:00
|
|
|
try:
|
|
|
|
lt.locate(infile)
|
|
|
|
except RuntimeError as e:
|
|
|
|
print(e.message)
|
|
|
|
finally:
|
|
|
|
os.remove(phasepath)
|
|
|
|
|
2016-09-02 14:21:59 +02:00
|
|
|
self.get_data().applyEVTData(lt.read_location(locpath), type='event')
|
|
|
|
self.get_data().get_evt_data().magnitudes.append(self.calc_magnitude())
|
2014-12-08 10:26:14 +01:00
|
|
|
|
2016-09-22 11:39:07 +02:00
|
|
|
|
|
|
|
def calc_magnitude(self, type='ML'):
|
2016-09-23 15:12:04 +02:00
|
|
|
settings = QSettings()
|
|
|
|
fninv = settings.value("inventoryFile", None)
|
|
|
|
if fninv is None and not self.metadata:
|
|
|
|
fninv, _ = QFileDialog.getOpenFileName(self, self.tr(
|
|
|
|
"Select inventory..."), self.tr("Select file"))
|
|
|
|
ans = QMessageBox.question(self, self.tr("Make default..."),
|
|
|
|
self.tr(
|
|
|
|
"New inventory filename set.\n" + \
|
|
|
|
"Do you want to make it the default value?"),
|
|
|
|
QMessageBox.Yes | QMessageBox.No,
|
|
|
|
QMessageBox.No)
|
|
|
|
if ans == QMessageBox.Yes:
|
|
|
|
settings.setValue("inventoryFile", fninv)
|
|
|
|
settings.sync()
|
|
|
|
self.metadata = read_metadata(fninv)
|
2016-09-22 11:39:07 +02:00
|
|
|
if type == 'ML':
|
2016-09-23 15:12:04 +02:00
|
|
|
return calc_richter_magnitude(self.get_data().get_evt_data(), self.get_data().getWFData(), self.metadata, self.inputs.get('sstop'))
|
2016-09-22 11:39:07 +02:00
|
|
|
elif type == 'Mw':
|
2016-09-23 15:12:04 +02:00
|
|
|
return calc_moment_magnitude(self.get_data().get_evt_data(), self.get_data().getWFData(), self.metadata, self.inputs.get('vp'), self.inputs.get('Qp'), self.inputs.get('rho'))
|
2016-08-31 12:16:48 +02:00
|
|
|
else:
|
2016-09-02 09:03:51 +02:00
|
|
|
return None
|
2016-08-31 12:16:48 +02:00
|
|
|
|
2015-11-06 08:20:08 +01:00
|
|
|
def check4Loc(self):
|
|
|
|
return self.picksNum() > 4
|
|
|
|
|
2016-06-06 14:10:46 +02:00
|
|
|
def check4Comparison(self):
|
|
|
|
mpicks = self.getPicks()
|
|
|
|
apicks = self.getPicks('auto')
|
|
|
|
for station, phases in mpicks.items():
|
|
|
|
try:
|
|
|
|
aphases = apicks[station]
|
|
|
|
for phase in phases.keys():
|
|
|
|
if phase in aphases.keys():
|
|
|
|
return True
|
|
|
|
except KeyError:
|
|
|
|
continue
|
|
|
|
return False
|
|
|
|
|
|
|
|
def picksNum(self, type='manual'):
|
2015-11-06 08:20:08 +01:00
|
|
|
num = 0
|
2016-06-06 14:10:46 +02:00
|
|
|
for phases in self.getPicks(type).values():
|
2015-11-06 08:20:08 +01:00
|
|
|
num += len(phases)
|
|
|
|
return num
|
|
|
|
|
2016-09-02 14:21:59 +02:00
|
|
|
def get_loc_flag(self):
|
2015-11-06 15:40:21 +01:00
|
|
|
return self.loc
|
|
|
|
|
2016-09-02 14:21:59 +02:00
|
|
|
def set_loc_flag(self, value):
|
2015-11-06 15:40:21 +01:00
|
|
|
self.loc = value
|
2015-11-06 08:20:08 +01:00
|
|
|
|
2016-09-02 14:21:59 +02:00
|
|
|
def check_loc_plt(self):
|
|
|
|
evt = self.get_data().get_evt_data()
|
|
|
|
if evt.origins and evt.magnitudes:
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
def update_status(self, message, duration=5000):
|
2015-11-09 08:53:26 +01:00
|
|
|
self.statusBar().showMessage(message, duration)
|
2016-09-02 14:21:59 +02:00
|
|
|
if self.get_data() is not None:
|
|
|
|
if not self.get_data().isNew():
|
2015-11-09 08:53:26 +01:00
|
|
|
self.setWindowTitle(
|
2016-09-02 14:21:59 +02:00
|
|
|
"PyLoT - processing event %s[*]" % self.get_data().getID())
|
|
|
|
elif self.get_data().isNew():
|
2015-11-09 08:53:26 +01:00
|
|
|
self.setWindowTitle("PyLoT - New event [*]")
|
|
|
|
else:
|
|
|
|
self.setWindowTitle(
|
2016-03-30 07:00:31 +02:00
|
|
|
"PyLoT - seismic processing the python way[*]")
|
2015-11-09 08:53:26 +01:00
|
|
|
self.setWindowModified(self.dirty)
|
|
|
|
|
2016-09-02 14:21:59 +02:00
|
|
|
def tutor_user(self):
|
|
|
|
self.update_status('select trace to pick on station ...', 10000)
|
2015-07-07 10:45:42 +02:00
|
|
|
|
2016-09-02 14:21:59 +02:00
|
|
|
def show_event_information(self):
|
2014-11-28 11:15:49 +01:00
|
|
|
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()
|
2016-05-20 14:46:10 +02:00
|
|
|
cinfo = create_creation_info(agency_id=self.agency)
|
|
|
|
event = create_event(evtpar['origintime'], cinfo)
|
2015-06-11 10:12:50 +02:00
|
|
|
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(
|
2016-03-30 07:00:31 +02:00
|
|
|
'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())
|