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,37 +25,37 @@ 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):
|
try:
|
||||||
self.wfdata = wfdata
|
self.wfdata = read()
|
||||||
elif wfdata is not None:
|
except IOError, e:
|
||||||
try:
|
msg = 'An I/O error occured while loading data!'
|
||||||
self.wfdata = read(wfdata)
|
inform = 'Variable wfdata will be empty.'
|
||||||
except IOError, e:
|
details = '{0}'.format(e)
|
||||||
msg = 'An I/O error occured while loading data!'
|
if parent is not None:
|
||||||
inform = 'Variable wfdata will be empty.'
|
warnio = QMessageBox(parent=parent)
|
||||||
details = '{0}'.format(e)
|
warnio.setText(msg)
|
||||||
if parent is not None:
|
warnio.setDetailedText(details)
|
||||||
warnio = QMessageBox(parent=parent)
|
warnio.setInformativeText(inform)
|
||||||
warnio.setText(msg)
|
warnio.setStandarButtons(QMessageBox.Ok)
|
||||||
warnio.setDetailedText(details)
|
warnio.setIcon(QMessageBox.Warning)
|
||||||
warnio.setInformativeText(inform)
|
else:
|
||||||
warnio.setStandarButtons(QMessageBox.Ok)
|
print msg, '\n', details
|
||||||
warnio.setIcon(QMessageBox.Warning)
|
self.wfdata = Stream()
|
||||||
else:
|
|
||||||
print msg, '\n', details
|
|
||||||
self.wfdata = Stream()
|
|
||||||
else:
|
else:
|
||||||
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