Merge branch 'develop' of ariadne.geophysik.ruhr-uni-bochum.de:/data/git/pylot into develop
This commit is contained in:
commit
661b4d11c0
69
QtPyLoT.py
69
QtPyLoT.py
@ -53,7 +53,7 @@ from pylot.core.util.utils import fnConstructor, getLogin, \
|
||||
getGlobalTimes
|
||||
from pylot.core.io.location import create_creation_info, create_event
|
||||
from pylot.core.util.widgets import FilterOptionsDialog, NewEventDlg, \
|
||||
MPLWidget, PropertiesDlg, HelpForm, createAction, PickDlg
|
||||
WaveformWidget, PropertiesDlg, HelpForm, createAction, PickDlg, getDataType
|
||||
from pylot.core.util.structure import DATASTRUCTURE
|
||||
from pylot.core.util.thread import AutoPickThread
|
||||
from pylot.core.util.version import get_git_version as _getVersionString
|
||||
@ -142,8 +142,8 @@ class MainWindow(QMainWindow):
|
||||
plottitle = "Overview: {0} components ".format(self.getComponent())
|
||||
|
||||
# create central matplotlib figure canvas widget
|
||||
self.DataPlot = MPLWidget(parent=self, xlabel=xlab, ylabel=None,
|
||||
title=plottitle)
|
||||
self.DataPlot = WaveformWidget(parent=self, xlabel=xlab, ylabel=None,
|
||||
title=plottitle)
|
||||
self.DataPlot.mpl_connect('button_press_event',
|
||||
self.pickOnStation)
|
||||
self.DataPlot.mpl_connect('axes_enter_event',
|
||||
@ -178,6 +178,8 @@ class MainWindow(QMainWindow):
|
||||
auto_icon.addPixmap(QPixmap(':/icons/sync.png'))
|
||||
locate_icon = QIcon()
|
||||
locate_icon.addPixmap(QPixmap(':/icons/locate.png'))
|
||||
compare_icon = QIcon()
|
||||
compare_icon.addPixmap(QPixmap(':/icons/compare.png'))
|
||||
|
||||
newEventAction = self.createAction(self, "&New event ...",
|
||||
self.createNewEvent,
|
||||
@ -244,6 +246,12 @@ class MainWindow(QMainWindow):
|
||||
"Alt+S",
|
||||
s_icon,
|
||||
"Toggle S phase", True)
|
||||
self.compare_action = self.createAction(self, "&Compare picks...",
|
||||
self.comparePicks, "Alt+C",
|
||||
compare_icon, "Comparison of "
|
||||
"manual and "
|
||||
"automatic pick "
|
||||
"data.", False)
|
||||
printAction = self.createAction(self, "&Print event ...",
|
||||
self.printEvent, QKeySequence.Print,
|
||||
print_icon,
|
||||
@ -318,7 +326,7 @@ class MainWindow(QMainWindow):
|
||||
' displayed!')
|
||||
|
||||
autoPickToolBar = self.addToolBar("autoPyLoT")
|
||||
autoPickActions = (auto_pick,)
|
||||
autoPickActions = (auto_pick, self.compare_action)
|
||||
self.addActions(autoPickToolBar, autoPickActions)
|
||||
|
||||
# pickToolBar = self.addToolBar("PickTools")
|
||||
@ -389,43 +397,32 @@ class MainWindow(QMainWindow):
|
||||
settings = QSettings()
|
||||
return settings.value("data/dataRoot")
|
||||
|
||||
def getType(self):
|
||||
type = QInputDialog().getItem(self, self.tr("Select phases type"),
|
||||
self.tr("Type:"), [self.tr("manual"),
|
||||
self.tr("automatic")])
|
||||
|
||||
if type[0].startswith('auto'):
|
||||
type = 'auto'
|
||||
else:
|
||||
type = type[0]
|
||||
|
||||
return type
|
||||
|
||||
def load_autopicks(self, fname=None):
|
||||
self.load_data(fname, type='auto')
|
||||
|
||||
def load_loc(self, fname=None):
|
||||
self.load_data(fname, type='loc')
|
||||
type = getDataType(self)
|
||||
self.load_data(fname, type=type, loc=True)
|
||||
|
||||
def load_pilotevent(self):
|
||||
filt = "PILOT location files (*.mat)"
|
||||
filt = "PILOT location files (*LOC*.mat)"
|
||||
caption = "Select PILOT location file"
|
||||
fn_loc = QFileDialog().getOpenFileName(self, caption=caption,
|
||||
filter=filt, dir=self.getRoot())
|
||||
fn_loc = fn_loc[0]
|
||||
loc_dir = os.path.split(fn_loc)[0]
|
||||
filt = "PILOT phases files (*.mat)"
|
||||
filt = "PILOT phases files (*PHASES*.mat)"
|
||||
caption = "Select PILOT phases file"
|
||||
fn_phases = QFileDialog().getOpenFileName(self, caption=caption,
|
||||
filter=filt, dir=loc_dir)
|
||||
fn_phases = fn_phases[0]
|
||||
|
||||
type = self.getType()
|
||||
type = getDataType(self)
|
||||
|
||||
fname_dict = dict(phasfn=fn_phases, locfn=fn_loc)
|
||||
self.load_data(fname_dict, type=type)
|
||||
|
||||
def load_data(self, fname=None, type='manual'):
|
||||
def load_data(self, fname=None, type='manual', loc=False):
|
||||
if not self.okToContinue():
|
||||
return
|
||||
if fname is None:
|
||||
@ -435,7 +432,7 @@ class MainWindow(QMainWindow):
|
||||
self.set_fname(fname, type)
|
||||
data = dict(auto=self.autodata, manual=self.data)
|
||||
data[type] += Data(self, evtdata=fname)
|
||||
if 'loc' not in type:
|
||||
if not loc:
|
||||
self.updatePicks(type=type)
|
||||
self.drawPicks(picktype=type)
|
||||
self.draw()
|
||||
@ -485,9 +482,9 @@ class MainWindow(QMainWindow):
|
||||
filt = "Supported file formats" \
|
||||
" (*.mat *.qml *.xml *.kor *.evt)"
|
||||
caption = "Open an event file"
|
||||
fname = QFileDialog().getOpenFileName(self,
|
||||
caption=caption,
|
||||
filter=filt)
|
||||
fname = QFileDialog().getOpenFileName(self, caption=caption,
|
||||
filter=filt,
|
||||
dir=self.getRoot())
|
||||
fname = fname[0]
|
||||
else:
|
||||
fname = str(action.data().toString())
|
||||
@ -579,6 +576,10 @@ class MainWindow(QMainWindow):
|
||||
except KeyError:
|
||||
return None
|
||||
|
||||
def comparePicks(self):
|
||||
if self.check4Comparison():
|
||||
compare_dlg = ComparisonDialog(self)
|
||||
|
||||
def getPlotWidget(self):
|
||||
return self.DataPlot
|
||||
|
||||
@ -839,6 +840,7 @@ class MainWindow(QMainWindow):
|
||||
self.picks.update(picks)
|
||||
elif type == 'auto':
|
||||
self.autopicks.update(picks)
|
||||
self.check4Comparison()
|
||||
|
||||
def drawPicks(self, station=None, picktype='manual'):
|
||||
# if picks to draw not specified, draw all picks available
|
||||
@ -893,9 +895,22 @@ class MainWindow(QMainWindow):
|
||||
def check4Loc(self):
|
||||
return self.picksNum() > 4
|
||||
|
||||
def picksNum(self):
|
||||
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'):
|
||||
num = 0
|
||||
for phases in self.getPicks().values():
|
||||
for phases in self.getPicks(type).values():
|
||||
num += len(phases)
|
||||
return num
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
<file>icons/locate.png</file>
|
||||
<file>icons/printer.png</file>
|
||||
<file>icons/delete.png</file>
|
||||
<file>icons/compare.png</file>
|
||||
<file>icons/key_E.png</file>
|
||||
<file>icons/key_N.png</file>
|
||||
<file>icons/key_P.png</file>
|
||||
|
BIN
icons/compare.png
Normal file
BIN
icons/compare.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.0 KiB |
File diff suppressed because one or more lines are too long
@ -8,6 +8,7 @@
|
||||
EVENT_DATA/LOCAL #datapath# %data path
|
||||
2013.02_Insheim #database# %name of data base
|
||||
e0019.048.13 #eventID# %certain evnt ID for processing
|
||||
True #apverbose#
|
||||
PILOT #datastructure# %choose data structure
|
||||
0 #iplot# %flag for plotting: 0 none, 1, partly, >1 everything
|
||||
AUTOPHASES_AIC_HOS4_ARH #phasefile# %name of autoPILOT output phase file
|
||||
|
@ -29,7 +29,10 @@ class Comparison(object):
|
||||
names = list()
|
||||
self._pdfs = dict()
|
||||
for name, fn in kwargs.items():
|
||||
self._pdfs[name] = PDFDictionary.from_quakeml(fn)
|
||||
if not isinstance(PDFDictionary, fn):
|
||||
self._pdfs[name] = PDFDictionary.from_quakeml(fn)
|
||||
else:
|
||||
self._pdfs[name] = fn
|
||||
names.append(name)
|
||||
if len(names) > 2:
|
||||
raise ValueError('Comparison is only defined for two '
|
||||
@ -101,14 +104,19 @@ class Comparison(object):
|
||||
|
||||
return compare_pdfs
|
||||
|
||||
def plot(self):
|
||||
nstations = self.nstations
|
||||
stations = self.stations
|
||||
def plot(self, stations=None):
|
||||
if stations is None:
|
||||
nstations = self.nstations
|
||||
stations = self.stations
|
||||
else:
|
||||
nstations = len(stations)
|
||||
istations = range(nstations)
|
||||
fig, axarr = plt.subplots(nstations, 2, sharex='col', sharey='row')
|
||||
|
||||
for n in istations:
|
||||
station = stations[n]
|
||||
if station not in self.comparison.keys():
|
||||
continue
|
||||
compare_pdf = self.comparison[station]
|
||||
for l, phase in enumerate(compare_pdf.keys()):
|
||||
axarr[n, l].plot(compare_pdf[phase].axis,
|
||||
|
@ -20,7 +20,8 @@ from matplotlib.widgets import MultiCursor
|
||||
from PySide.QtGui import QAction, QApplication, QComboBox, QDateTimeEdit, \
|
||||
QDialog, QDialogButtonBox, QDoubleSpinBox, QGroupBox, QGridLayout, \
|
||||
QIcon, QKeySequence, QLabel, QLineEdit, QMessageBox, QPixmap, QSpinBox, \
|
||||
QTabWidget, QToolBar, QVBoxLayout, QWidget, QPushButton, QFileDialog
|
||||
QTabWidget, QToolBar, QVBoxLayout, QWidget, QPushButton, QFileDialog, \
|
||||
QInputDialog
|
||||
from PySide.QtCore import QSettings, Qt, QUrl, Signal, Slot
|
||||
from PySide.QtWebKit import QWebView
|
||||
from obspy import Stream, UTCDateTime
|
||||
@ -33,6 +34,18 @@ from pylot.core.util.utils import prepTimeAxis, getGlobalTimes, scaleWFData, \
|
||||
demeanTrace, isSorted, findComboBoxIndex
|
||||
|
||||
|
||||
def getDataType(parent):
|
||||
type = QInputDialog().getItem(parent, "Select phases type", "Type:",
|
||||
["manual", "automatic"])
|
||||
|
||||
if type[0].startswith('auto'):
|
||||
type = 'auto'
|
||||
else:
|
||||
type = type[0]
|
||||
|
||||
return type
|
||||
|
||||
|
||||
def createAction(parent, text, slot=None, shortcut=None, icon=None,
|
||||
tip=None, checkable=False):
|
||||
"""
|
||||
@ -51,8 +64,86 @@ def createAction(parent, text, slot=None, shortcut=None, icon=None,
|
||||
action.setCheckable(True)
|
||||
return action
|
||||
|
||||
class ComparsionDialog(QDialog):
|
||||
def __init__(self, c, parent=None):
|
||||
self._data = c
|
||||
self._stats = c.keys()
|
||||
self._canvas = PlotWidget(parent)
|
||||
super(ComparsionDialog, self).__init__(parent)
|
||||
self
|
||||
|
||||
class MPLWidget(FigureCanvas):
|
||||
def setupUI(self):
|
||||
pass
|
||||
|
||||
@property
|
||||
def canvas(self):
|
||||
return self._canvas
|
||||
|
||||
@property
|
||||
def stations(self):
|
||||
return self._stats
|
||||
|
||||
@stations.setter
|
||||
def stations(self, stations):
|
||||
self._stats = stations
|
||||
|
||||
@property
|
||||
def data(self):
|
||||
return self._data
|
||||
|
||||
@data.setter
|
||||
def data(self, data):
|
||||
self.stations = data.keys()
|
||||
self._data = data
|
||||
|
||||
|
||||
class PlotWidget(FigureCanvas):
|
||||
def __init__(self, parent=None, xlabel='x', ylabel='y', title='Title'):
|
||||
self._parent = parent
|
||||
self._fig = Figure()
|
||||
self._xl = xlabel
|
||||
self._yl = ylabel
|
||||
self._title = title
|
||||
super(PlotWidget, self).__init__(self.figure)
|
||||
|
||||
@property
|
||||
def figure(self):
|
||||
return self._fig
|
||||
|
||||
@figure.setter
|
||||
def figure(self, fig):
|
||||
self._fig = fig
|
||||
|
||||
@property
|
||||
def xlabel(self):
|
||||
return self._xl
|
||||
|
||||
@xlabel.setter
|
||||
def xlabel(self, label):
|
||||
self._xl = label
|
||||
|
||||
@property
|
||||
def ylabel(self):
|
||||
return self._yl
|
||||
|
||||
@ylabel.setter
|
||||
def ylabel(self, label):
|
||||
self._yl = label
|
||||
|
||||
@property
|
||||
def title(self):
|
||||
return self._title
|
||||
|
||||
@title.setter
|
||||
def title(self, title):
|
||||
self._title = title
|
||||
|
||||
@property
|
||||
def parent(self):
|
||||
return self._parent
|
||||
|
||||
|
||||
class WaveformWidget(FigureCanvas):
|
||||
def __init__(self, parent=None, xlabel='x', ylabel='y', title='Title'):
|
||||
|
||||
self._parent = None
|
||||
@ -66,7 +157,7 @@ class MPLWidget(FigureCanvas):
|
||||
# clear axes each time plot is called
|
||||
self.axes.hold(True)
|
||||
# initialize super class
|
||||
super(MPLWidget, self).__init__(self.figure)
|
||||
super(WaveformWidget, self).__init__(self.figure)
|
||||
# add an cursor for station selection
|
||||
self.multiCursor = MultiCursor(self.figure.canvas, (self.axes,),
|
||||
horizOn=True,
|
||||
@ -210,7 +301,7 @@ class PickDlg(QDialog):
|
||||
self.stime, self.etime = getGlobalTimes(self.getWFData())
|
||||
|
||||
# initialize plotting widget
|
||||
self.multicompfig = MPLWidget(self)
|
||||
self.multicompfig = WaveformWidget(self)
|
||||
|
||||
# setup ui
|
||||
self.setupUi()
|
||||
|
Loading…
Reference in New Issue
Block a user