loading data by initialization of a Data object (not working yet)

This commit is contained in:
Sebastian Wehling-Benatelli 2014-12-01 12:45:20 +01:00
parent 41684cd282
commit 553bb9990b

View File

@ -4,6 +4,7 @@
import os
from PySide.QtGui import QMessageBox
from obspy.core import (read, Stream)
from obspy import readEvents
from obspy.core.event import (Event, Catalog)
from pylot.core.util import fnConstructor
@ -24,12 +25,9 @@ class Data(object):
loaded event. Container object holding, e.g. phase arrivals, etc.
'''
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:
def __init__(self, parent=None, evtdata=None):
try:
self.wfdata = read(wfdata)
self.wfdata = read()
except IOError, e:
msg = 'An I/O error occured while loading data!'
inform = 'Variable wfdata will be empty.'
@ -48,13 +46,16 @@ class Data(object):
self.wfdata = Stream()
if evtdata is not None and isinstance(evtdata, Event):
self.evtdata = evtdata
else:
elif evtdata is not None:
cat = readEvents(evtdata)
self.evtdata = cat[0]
else: # create an empty Event object
self.evtdata = Event()
def exportEvent(self, fnout=None, evtformat='QUAKEML'):
if fnout is None:
fnout = self.event.resource_id.__str__().split('/')[-1]
fnout = self.evtdata.getEventID()
# handle forbidden filenames especially on windows systems
fnout = fnConstructor(fnout)