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, \
QActionGroup, QListWidget, QDockWidget
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.inputs import FilterOptions, AutoPickParameter
@ -339,26 +339,25 @@ class MainWindow(QMainWindow):
return settings.value("data/dataRoot")
def loadData(self, fname=None):
if not self.okToContinue():
return
if fname is None:
try:
self.data = Data(self, evtdata=self.fname)
except AttributeError:
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)
self.fname = fname[0]
else:
self.fname = unicode(action.data().toString())
if not self.okToContinue():
return
else:
self.fname = fname
self.data = Data(self, evtdata=self.fname)
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)
fname = fname[0]
else:
fname = unicode(action.data().toString())
event = readEvents(fname)[0]
self.setFileName(fname)
self.getData().applyEVTData(event, type='event')
self.convertPicks4PyLoT()
self.drawPicks()
def getLastEvent(self):
return self.recentEvents[0]
@ -694,6 +693,11 @@ class MainWindow(QMainWindow):
raise Exception('FATAL: Should never occur!')
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):
# if picks to draw not specified, draw all picks available
if not station:

View File

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

View File

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

View File

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