[change] Event class now bases on ObsPy Event class which should be more efficient in future, origin time will be read from notes file if possible
This commit is contained in:
parent
410fe18390
commit
7bb2d54f6e
29
QtPyLoT.py
29
QtPyLoT.py
@ -41,6 +41,8 @@ from PySide.QtGui import QMainWindow, QInputDialog, QIcon, QFileDialog, \
|
|||||||
QTreeView, QComboBox, QTabWidget, QPushButton, QGridLayout
|
QTreeView, QComboBox, QTabWidget, QPushButton, QGridLayout
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from obspy import UTCDateTime
|
from obspy import UTCDateTime
|
||||||
|
from obspy.core.event import Event as ObsPyEvent
|
||||||
|
from obspy.core.event import Origin
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import pyqtgraph as pg
|
import pyqtgraph as pg
|
||||||
@ -752,8 +754,8 @@ class MainWindow(QMainWindow):
|
|||||||
'''
|
'''
|
||||||
if not eventbox:
|
if not eventbox:
|
||||||
eventbox = self.eventBox
|
eventbox = self.eventBox
|
||||||
index = eventbox.currentIndex()
|
path = eventbox.currentText()
|
||||||
return eventbox.itemData(index)
|
return self.project.getEventFromPath(path)
|
||||||
|
|
||||||
def get_current_event_path(self, eventbox=None):
|
def get_current_event_path(self, eventbox=None):
|
||||||
'''
|
'''
|
||||||
@ -953,7 +955,8 @@ class MainWindow(QMainWindow):
|
|||||||
'{} unequal {}.'
|
'{} unequal {}.'
|
||||||
.format(event.path, self.eventBox.itemText(id)))
|
.format(event.path, self.eventBox.itemText(id)))
|
||||||
raise ValueError(message)
|
raise ValueError(message)
|
||||||
eventBox.setItemData(id, event)
|
#not working with obspy events
|
||||||
|
#eventBox.setItemData(id, event)
|
||||||
eventBox.setCurrentIndex(index)
|
eventBox.setCurrentIndex(index)
|
||||||
self.refreshRefTestButtons()
|
self.refreshRefTestButtons()
|
||||||
|
|
||||||
@ -2468,11 +2471,13 @@ class Project(object):
|
|||||||
return project
|
return project
|
||||||
|
|
||||||
|
|
||||||
class Event(object):
|
class Event(ObsPyEvent):
|
||||||
'''
|
'''
|
||||||
Pickable class containing information on a single event.
|
Pickable class derived from ~obspy.core.event.Event containing information on a single event.
|
||||||
'''
|
'''
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
|
# initialize super class
|
||||||
|
super(Event, self).__init__()
|
||||||
self.path = path
|
self.path = path
|
||||||
self.database = path.split('/')[-2]
|
self.database = path.split('/')[-2]
|
||||||
self.datapath = path.split('/')[-3]
|
self.datapath = path.split('/')[-3]
|
||||||
@ -2482,10 +2487,7 @@ class Event(object):
|
|||||||
self.notes = ''
|
self.notes = ''
|
||||||
self._testEvent = False
|
self._testEvent = False
|
||||||
self._refEvent = False
|
self._refEvent = False
|
||||||
try:
|
self.get_notes()
|
||||||
self.get_notes()
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def get_notes_path(self):
|
def get_notes_path(self):
|
||||||
notesfile = os.path.join(self.path, 'notes.txt')
|
notesfile = os.path.join(self.path, 'notes.txt')
|
||||||
@ -2495,8 +2497,15 @@ class Event(object):
|
|||||||
notesfile = self.get_notes_path()
|
notesfile = self.get_notes_path()
|
||||||
if os.path.isfile(notesfile):
|
if os.path.isfile(notesfile):
|
||||||
with open(notesfile) as infile:
|
with open(notesfile) as infile:
|
||||||
text = '[eventInfo: '+str(infile.readlines()[0].split('\n')[0])+']'
|
path = str(infile.readlines()[0].split('\n')[0])
|
||||||
|
text = '[eventInfo: '+path+']'
|
||||||
self.addNotes(text)
|
self.addNotes(text)
|
||||||
|
try:
|
||||||
|
datetime = UTCDateTime(path.split('/')[-1])
|
||||||
|
origin = Origin(time=datetime, latitude=0, longitude=0)
|
||||||
|
self.origins.append(origin)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
def addNotes(self, notes):
|
def addNotes(self, notes):
|
||||||
self.notes = str(notes)
|
self.notes = str(notes)
|
||||||
|
@ -1 +1 @@
|
|||||||
8e8b-dirty
|
410fe-dirty
|
||||||
|
@ -1687,8 +1687,8 @@ class TuneAutopicker(QWidget):
|
|||||||
self.listWidget.scrollToBottom()
|
self.listWidget.scrollToBottom()
|
||||||
|
|
||||||
def get_current_event(self):
|
def get_current_event(self):
|
||||||
index = self.eventBox.currentIndex()
|
path = self.eventBox.currentText()
|
||||||
return self.eventBox.itemData(index)
|
return self.parent.project.getEventFromPath(path)
|
||||||
|
|
||||||
def get_current_event_name(self):
|
def get_current_event_name(self):
|
||||||
return self.eventBox.currentText().split('/')[-1]
|
return self.eventBox.currentText().split('/')[-1]
|
||||||
@ -1855,6 +1855,9 @@ class TuneAutopicker(QWidget):
|
|||||||
self.init_tab_names()
|
self.init_tab_names()
|
||||||
|
|
||||||
def fill_eventbox(self):
|
def fill_eventbox(self):
|
||||||
|
project = self.parent.project
|
||||||
|
if not project:
|
||||||
|
return
|
||||||
# update own list
|
# update own list
|
||||||
self.parent.fill_eventbox(eventBox=self.eventBox, select_events='ref')
|
self.parent.fill_eventbox(eventBox=self.eventBox, select_events='ref')
|
||||||
index_start = self.parent.eventBox.currentIndex()
|
index_start = self.parent.eventBox.currentIndex()
|
||||||
@ -1862,10 +1865,13 @@ class TuneAutopicker(QWidget):
|
|||||||
if index == -1:
|
if index == -1:
|
||||||
index += 1
|
index += 1
|
||||||
nevents = self.eventBox.model().rowCount()
|
nevents = self.eventBox.model().rowCount()
|
||||||
if self.eventBox.itemData(index).isTestEvent():
|
path = self.eventBox.itemText(index)
|
||||||
|
if project.getEventFromPath(path).isTestEvent():
|
||||||
for index in range(nevents):
|
for index in range(nevents):
|
||||||
if not self.eventBox.itemData(index).isTestEvent():
|
path = self.eventBox.itemText(index)
|
||||||
|
if not project.getEventFromPath(index).isTestEvent():
|
||||||
break
|
break
|
||||||
|
#in case all events are marked as test events
|
||||||
elif index == nevents - 1:
|
elif index == nevents - 1:
|
||||||
index = -1
|
index = -1
|
||||||
self.eventBox.setCurrentIndex(index)
|
self.eventBox.setCurrentIndex(index)
|
||||||
|
Loading…
Reference in New Issue
Block a user