From 6e2c1851ec761ce489d4dfb3c4aa69e1cf2a9e86 Mon Sep 17 00:00:00 2001 From: Sebastian Wehling Date: Wed, 16 Jul 2014 12:07:42 +0200 Subject: [PATCH] modified: added imports added: new class Data added (container class for waveform- and event data) --- pylot/core/read/data.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/pylot/core/read/data.py b/pylot/core/read/data.py index d4f92d0d..622a55c8 100644 --- a/pylot/core/read/data.py +++ b/pylot/core/read/data.py @@ -6,6 +6,42 @@ # import os +from obspy.core import (read, Stream) +from obspy.core.event import Event + + +class Data(object): + ''' + Data container class providing ObSpy-Stream and -Event instances as + variables. + ''' + + def __init__(self, parent=None, wfdata=None, evtdata=None): + if wfdata is not None and isinstance(wfdata, Stream): + self.wfdata = wfdata + elif wfdata is not None: + try: + self.wfdata = read(wfdata) + except IOError, e: + msg = 'An I/O error occured while loading data!' + inform = 'Variable wfdata will be empty.' + details = '{0}'.format(e) + if parent is not None: + from PySide.QtGui import QMessageBox + warnio = QMessageBox(parent=parent) + warnio.setText(msg) + warnio.setDetailedText(details) + warnio.setStandarButtons(QMessageBox.Ok) + warnio.setIcon(QMessageBox.Warning) + else: + print msg, '\n', details + self.wfdata = Stream() + else: + self.wfdata = Stream() + if evtdata is not None and isinstance(evtdata, Event): + self.evtdata = evtdata + else: + self.evtdata = Event() class GenericDataStructure(object):