[bugfix] stations not updated when changing event

This commit is contained in:
Marcel Paffrath 2019-03-06 11:25:58 +01:00
parent 49bcdd2680
commit a9d92e70ce
2 changed files with 23 additions and 4 deletions

View File

@ -1088,6 +1088,15 @@ class MainWindow(QMainWindow):
if ed.exec_(): if ed.exec_():
eventlist = ed.selectedFiles() eventlist = ed.selectedFiles()
basepath = eventlist[0].split(os.path.basename(eventlist[0]))[0] basepath = eventlist[0].split(os.path.basename(eventlist[0]))[0]
# small hack: if a file "eventlist.txt" is found in the basepath use only those events specified inside
eventlist_file = os.path.join(basepath, 'eventlist.txt')
if os.path.isfile(eventlist_file):
with open(eventlist_file, 'r') as infile:
eventlist_subset = [os.path.join(basepath, filename.split('\n')[0]) for filename in infile.readlines()]
msg = 'Found file "eventlist.txt" in database path. WILL ONLY USE SELECTED EVENTS out of {} events ' \
'contained in this subset'
print(msg.format(len(eventlist_subset)))
eventlist = [eventname for eventname in eventlist if eventname in eventlist_subset]
if check_obspydmt_structure(basepath): if check_obspydmt_structure(basepath):
print('Recognized obspyDMT structure in selected files. Settings Datastructure to ObspyDMT') print('Recognized obspyDMT structure in selected files. Settings Datastructure to ObspyDMT')
self.dataStructure = DATASTRUCTURE['obspyDMT']() self.dataStructure = DATASTRUCTURE['obspyDMT']()
@ -1727,6 +1736,8 @@ class MainWindow(QMainWindow):
if not plotted and self._eventChanged[0]: if not plotted and self._eventChanged[0]:
# newWF(plot=False) = load data without plotting # newWF(plot=False) = load data without plotting
self.newWF(plot=False) self.newWF(plot=False)
self.update_obspy_dmt()
self.refresh_array_map()
def newWF(self, event=None, plot=True): def newWF(self, event=None, plot=True):
''' '''
@ -1963,7 +1974,10 @@ class MainWindow(QMainWindow):
if True in self.comparable.values(): if True in self.comparable.values():
self.compare_action.setEnabled(True) self.compare_action.setEnabled(True)
self.draw() self.draw()
# TODO: Quick and dirty, improve this on later iteration # TODO: Quick and dirty, improve this later
self.update_obspy_dmt()
def update_obspy_dmt(self):
if self.obspy_dmt: if self.obspy_dmt:
invpath = os.path.join(self.get_current_event_path(), 'resp') invpath = os.path.join(self.get_current_event_path(), 'resp')
if not invpath in self.metadata.inventories: if not invpath in self.metadata.inventories:

View File

@ -49,13 +49,16 @@ class Array_map(QtGui.QWidget):
return hybrids_dict return hybrids_dict
def init_map(self): def init_map(self):
self.init_lat_lon_dimensions() self.init_colormap()
self.init_lat_lon_grid()
self.init_x_y_dimensions()
self.connectSignals() self.connectSignals()
self.draw_everything() self.draw_everything()
self.canvas.setZoomBorders2content() self.canvas.setZoomBorders2content()
def init_colormap(self):
self.init_lat_lon_dimensions()
self.init_lat_lon_grid()
self.init_x_y_dimensions()
def onpick(self, event): def onpick(self, event):
ind = event.ind ind = event.ind
button = event.mouseevent.button button = event.mouseevent.button
@ -461,6 +464,8 @@ class Array_map(QtGui.QWidget):
def _refresh_drawings(self): def _refresh_drawings(self):
self.remove_drawings() self.remove_drawings()
self.init_stations()
self.init_colormap()
self.draw_everything() self.draw_everything()
def draw_everything(self): def draw_everything(self):