[bugfix] wrong if cause in for loop in read_eventfile_info
[add] function to remove events from project
This commit is contained in:
parent
37875d5c87
commit
60594c97cf
56
QtPyLoT.py
56
QtPyLoT.py
@ -917,6 +917,10 @@ class MainWindow(QMainWindow):
|
|||||||
self.init_events()
|
self.init_events()
|
||||||
self.setDirty(True)
|
self.setDirty(True)
|
||||||
|
|
||||||
|
def removeEvent(self, eventID):
|
||||||
|
self.project.remove_event_by_id(eventID)
|
||||||
|
self.init_events()
|
||||||
|
|
||||||
def createEventBox(self):
|
def createEventBox(self):
|
||||||
'''
|
'''
|
||||||
Eventbox generator.
|
Eventbox generator.
|
||||||
@ -1308,6 +1312,10 @@ class MainWindow(QMainWindow):
|
|||||||
# which will read in data input twice. Therefore current tab is changed to 0
|
# which will read in data input twice. Therefore current tab is changed to 0
|
||||||
# in loadProject before calling this function.
|
# in loadProject before calling this function.
|
||||||
plotted = False
|
plotted = False
|
||||||
|
if self.tabs.currentIndex() == 2:
|
||||||
|
self.init_event_table()
|
||||||
|
self.refreshRefTestButtons()
|
||||||
|
|
||||||
# only refresh first/second tab when an event was changed.
|
# only refresh first/second tab when an event was changed.
|
||||||
if self._eventChanged[0] or self._eventChanged[1]:
|
if self._eventChanged[0] or self._eventChanged[1]:
|
||||||
event = self.get_current_event()
|
event = self.get_current_event()
|
||||||
@ -1338,10 +1346,6 @@ class MainWindow(QMainWindow):
|
|||||||
# newWF(False) = load data without plotting
|
# newWF(False) = load data without plotting
|
||||||
self.newWF(plot=False)
|
self.newWF(plot=False)
|
||||||
|
|
||||||
if self.tabs.currentIndex() == 2:
|
|
||||||
self.init_event_table()
|
|
||||||
self.refreshRefTestButtons()
|
|
||||||
|
|
||||||
def newWF(self, plot=True):
|
def newWF(self, plot=True):
|
||||||
'''
|
'''
|
||||||
Load new data and plot if necessary.
|
Load new data and plot if necessary.
|
||||||
@ -2599,8 +2603,18 @@ class Project(object):
|
|||||||
self.setDirty()
|
self.setDirty()
|
||||||
else:
|
else:
|
||||||
print('Skipping event with path {}. Already part of project.'.format(event.path))
|
print('Skipping event with path {}. Already part of project.'.format(event.path))
|
||||||
|
self.eventlist.sort(key=lambda x: x.pylot_id)
|
||||||
self.search_eventfile_info()
|
self.search_eventfile_info()
|
||||||
|
|
||||||
|
def remove_event(self, event):
|
||||||
|
self.eventlist.remove(event)
|
||||||
|
|
||||||
|
def remove_event_by_id(self, eventID):
|
||||||
|
for event in self.eventlist:
|
||||||
|
if eventID in str(event.resource_id):
|
||||||
|
self.remove_event(event)
|
||||||
|
break
|
||||||
|
|
||||||
def read_eventfile_info(self, filename, separator=','):
|
def read_eventfile_info(self, filename, separator=','):
|
||||||
'''
|
'''
|
||||||
Try to read event information from file (:param:filename) comparing specific event datetimes.
|
Try to read event information from file (:param:filename) comparing specific event datetimes.
|
||||||
@ -2609,7 +2623,7 @@ class Project(object):
|
|||||||
'''
|
'''
|
||||||
infile = open(filename, 'r')
|
infile = open(filename, 'r')
|
||||||
for line in infile.readlines():
|
for line in infile.readlines():
|
||||||
event, date, time, mag, lat, lon, depth = line.split(separator)[:7]
|
eventID, date, time, mag, lat, lon, depth = line.split(separator)[:7]
|
||||||
# skip first line
|
# skip first line
|
||||||
try:
|
try:
|
||||||
month, day, year = date.split('/')
|
month, day, year = date.split('/')
|
||||||
@ -2626,20 +2640,24 @@ class Project(object):
|
|||||||
print(e, datetime, filename)
|
print(e, datetime, filename)
|
||||||
continue
|
continue
|
||||||
for event in self.eventlist:
|
for event in self.eventlist:
|
||||||
if event.origins:
|
if eventID in str(event.resource_id) or event.origins:
|
||||||
origin = event.origins[0] # should have only one origin
|
if event.origins:
|
||||||
if origin.time == datetime:
|
origin = event.origins[0] # should have only one origin
|
||||||
origin.latitude = float(lat)
|
if origin.time == datetime:
|
||||||
origin.longitude = float(lon)
|
origin.latitude = float(lat)
|
||||||
origin.depth = float(depth)
|
origin.longitude = float(lon)
|
||||||
elif not event.origins:
|
origin.depth = float(depth)
|
||||||
origin = Origin(resource_id=event.resource_id,
|
else:
|
||||||
time=datetime, latitude=float(lat),
|
continue
|
||||||
longitude=float(lon), depth=float(depth))
|
elif not event.origins:
|
||||||
event.origins.append(origin)
|
origin = Origin(resource_id=event.resource_id,
|
||||||
event.magnitudes.append(Magnitude(resource_id=event.resource_id,
|
time=datetime, latitude=float(lat),
|
||||||
mag=float(mag),
|
longitude=float(lon), depth=float(depth))
|
||||||
mag_type='M'))
|
event.origins.append(origin)
|
||||||
|
event.magnitudes.append(Magnitude(resource_id=event.resource_id,
|
||||||
|
mag=float(mag),
|
||||||
|
mag_type='M'))
|
||||||
|
break
|
||||||
|
|
||||||
def search_eventfile_info(self):
|
def search_eventfile_info(self):
|
||||||
'''
|
'''
|
||||||
|
@ -1 +1 @@
|
|||||||
dbb3-dirty
|
3787-dirty
|
||||||
|
@ -5,7 +5,7 @@ import os
|
|||||||
|
|
||||||
from obspy import UTCDateTime
|
from obspy import UTCDateTime
|
||||||
from obspy.core.event import Event as ObsPyEvent
|
from obspy.core.event import Event as ObsPyEvent
|
||||||
from obspy.core.event import Origin, Magnitude, ResourceIdentifier
|
from obspy.core.event import Origin, ResourceIdentifier
|
||||||
|
|
||||||
from pylot.core.io.phases import picks_from_picksdict
|
from pylot.core.io.phases import picks_from_picksdict
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user