176 open event failure

This commit is contained in:
Sebastian Wehling-Benatelli 2015-09-03 13:21:46 +02:00
parent 81b95e6a22
commit cc0b1e0a5b
4 changed files with 32 additions and 25 deletions

View File

@ -36,7 +36,7 @@ from PySide.QtGui import QMainWindow, QInputDialog, QIcon, QFileDialog, \
QDialog, QErrorMessage, QApplication, QPixmap, QMessageBox, QSplashScreen, \ QDialog, QErrorMessage, QApplication, QPixmap, QMessageBox, QSplashScreen, \
QActionGroup, QListWidget, QDockWidget QActionGroup, QListWidget, QDockWidget
import numpy as np import numpy as np
from obspy.core import UTCDateTime from obspy import UTCDateTime, readEvents
from pylot.core.read.data import Data from pylot.core.read.data import Data
from pylot.core.read.inputs import FilterOptions, AutoPickParameter from pylot.core.read.inputs import FilterOptions, AutoPickParameter
@ -339,26 +339,25 @@ class MainWindow(QMainWindow):
return settings.value("data/dataRoot") return settings.value("data/dataRoot")
def loadData(self, fname=None): def loadData(self, fname=None):
if not self.okToContinue():
return
if fname is None: if fname is None:
try: action = self.sender()
self.data = Data(self, evtdata=self.fname) if isinstance(action, QAction):
except AttributeError: if action.data() is None:
action = self.sender() filt = "Supported event formats (*.mat *.qml *.xml *.kor *.evt)"
if isinstance(action, QAction): caption = "Open an event file"
if action.data() is None: fname = QFileDialog().getOpenFileName(self,
filt = "Supported event formats (*.mat *.qml *.xml *.kor *.evt)" caption=caption,
caption = "Open an event file" filter=filt)
fname = QFileDialog().getOpenFileName(self, fname = fname[0]
caption=caption, else:
filter=filt) fname = unicode(action.data().toString())
self.fname = fname[0] event = readEvents(fname)[0]
else: self.setFileName(fname)
self.fname = unicode(action.data().toString()) self.getData().applyEVTData(event, type='event')
if not self.okToContinue(): self.convertPicks4PyLoT()
return self.drawPicks()
else:
self.fname = fname
self.data = Data(self, evtdata=self.fname)
def getLastEvent(self): def getLastEvent(self):
return self.recentEvents[0] return self.recentEvents[0]
@ -694,6 +693,11 @@ class MainWindow(QMainWindow):
raise Exception('FATAL: Should never occur!') raise Exception('FATAL: Should never occur!')
self.getPicks()[station] = stat_picks self.getPicks()[station] = stat_picks
def convertPicks4PyLoT(self):
evt = self.getData().getEvtData()
for pick in evt.picks:
station = pick.waveform_id.getSEEDstring()
def drawPicks(self, station=None): def drawPicks(self, station=None):
# if picks to draw not specified, draw all picks available # if picks to draw not specified, draw all picks available
if not station: if not station:

View File

@ -1 +1 @@
0.0.0-gbf11 81b9-dirty

View File

@ -417,7 +417,10 @@ class Data(object):
:param event: :param event:
""" """
pass if not self.evtdata:
self.evtdata = event
else:
raise OverwriteError('Acutal event would be overwritten!')
applydata = {'pick': applyPicks, applydata = {'pick': applyPicks,
'arrival': applyArrivals, 'arrival': applyArrivals,

View File

@ -105,10 +105,10 @@ class MPLWidget(FigureCanvas):
for level in noiselevel: for level in noiselevel:
self.getAxes().plot([time_ax[0], time_ax[-1]], self.getAxes().plot([time_ax[0], time_ax[-1]],
[level, level], '--k') [level, level], '--k')
xlabel = 'seconds since {0}'.format(wfstart)
ylabel = ''
self.updateWidget(xlabel, ylabel, title)
self.setPlotDict(n, (station, channel)) self.setPlotDict(n, (station, channel))
xlabel = 'seconds since {0}'.format(wfstart)
ylabel = ''
self.updateWidget(xlabel, ylabel, title)
self.setXLims([0, wfend - wfstart]) self.setXLims([0, wfend - wfstart])
self.setYLims([-0.5, n + 0.5]) self.setYLims([-0.5, n + 0.5])
if zoomx is not None: if zoomx is not None: