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