debugged some code fragments while trying to solve the load event data problem
This commit is contained in:
parent
ac7d239b40
commit
7a47594614
38
QtPyLoT.py
38
QtPyLoT.py
@ -340,25 +340,24 @@ class MainWindow(QMainWindow):
|
||||
|
||||
def loadData(self, fname=None):
|
||||
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
|
||||
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.setFileName(fname[0])
|
||||
else:
|
||||
self.setFileName(unicode(action.data().toString()))
|
||||
if not self.okToContinue():
|
||||
return
|
||||
else:
|
||||
self.fname = fname
|
||||
self.data = Data(self, evtdata=self.fname)
|
||||
self.setFileName(fname)
|
||||
self.data += Data(self, evtdata=self.getFileName())
|
||||
self.updatePicks()
|
||||
self.updateStatus('Event data loaded ...')
|
||||
|
||||
def getLastEvent(self):
|
||||
return self.recentEvents[0]
|
||||
@ -469,6 +468,9 @@ class MainWindow(QMainWindow):
|
||||
def getPicks(self):
|
||||
return self.picks
|
||||
|
||||
def updatePicks(self):
|
||||
pass
|
||||
|
||||
def getPicksOnStation(self, station):
|
||||
try:
|
||||
return self.getPicks()[station]
|
||||
|
@ -1 +1 @@
|
||||
c940-dirty
|
||||
ac7d-dirty
|
||||
|
@ -33,16 +33,16 @@ class Data(object):
|
||||
else:
|
||||
self.comp = 'Z'
|
||||
self.wfdata = Stream()
|
||||
self.newevent = False
|
||||
if evtdata is not None and isinstance(evtdata, Event):
|
||||
self._new = False
|
||||
if isinstance(evtdata, Event):
|
||||
self.evtdata = evtdata
|
||||
elif evtdata is not None and not isinstance(evtdata, dict):
|
||||
elif isinstance(evtdata, dict):
|
||||
cat = readPILOTEvent(**evtdata)
|
||||
elif evtdata:
|
||||
cat = readEvents(evtdata)
|
||||
self.evtdata = cat[0]
|
||||
elif evtdata is not None:
|
||||
cat = readPILOTEvent(**evtdata)
|
||||
else: # create an empty Event object
|
||||
self.newevent = True
|
||||
self.setNew()
|
||||
self.evtdata = Event()
|
||||
self.getEvtData().picks = []
|
||||
self.wforiginal = None
|
||||
@ -52,6 +52,27 @@ class Data(object):
|
||||
def __str__(self):
|
||||
return str(self.wfdata)
|
||||
|
||||
def __add__(self, other):
|
||||
assert isinstance(other, Data), "operands must be of same type 'Data'"
|
||||
if other.isNew() and not self.isNew():
|
||||
picks_to_add = other.getEvtData().picks
|
||||
old_picks = self.getEvtData().picks
|
||||
for pick in picks_to_add:
|
||||
if pick not in old_picks:
|
||||
old_picks.append(pick)
|
||||
elif not other.isNew() and self.isNew():
|
||||
new = other + self
|
||||
self.evtdata = new.getEvtData()
|
||||
elif self.isNew() and other.isNew():
|
||||
pass
|
||||
elif self.getEvtData().get('id') == other.getEvtData().get('id'):
|
||||
other.setNew()
|
||||
return self + other
|
||||
else:
|
||||
raise ValueError("both Data objects have differing "
|
||||
"unique Event identifiers")
|
||||
return self
|
||||
|
||||
def getPicksStr(self):
|
||||
picks_str = ''
|
||||
for pick in self.getEvtData().picks:
|
||||
@ -73,7 +94,10 @@ class Data(object):
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.newevent
|
||||
return self._new
|
||||
|
||||
def setNew(self):
|
||||
self._new = True
|
||||
|
||||
def getCutTimes(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user