From a9d92e70ce5356324c5fe9386ee938af1624add0 Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 6 Mar 2019 11:25:58 +0100 Subject: [PATCH] [bugfix] stations not updated when changing event --- PyLoT.py | 16 +++++++++++++++- pylot/core/util/array_map.py | 11 ++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/PyLoT.py b/PyLoT.py index 4a21aa21..ac1836c4 100755 --- a/PyLoT.py +++ b/PyLoT.py @@ -1088,6 +1088,15 @@ class MainWindow(QMainWindow): if ed.exec_(): eventlist = ed.selectedFiles() 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): print('Recognized obspyDMT structure in selected files. Settings Datastructure to ObspyDMT') self.dataStructure = DATASTRUCTURE['obspyDMT']() @@ -1727,6 +1736,8 @@ class MainWindow(QMainWindow): if not plotted and self._eventChanged[0]: # newWF(plot=False) = load data without plotting self.newWF(plot=False) + self.update_obspy_dmt() + self.refresh_array_map() def newWF(self, event=None, plot=True): ''' @@ -1963,7 +1974,10 @@ class MainWindow(QMainWindow): if True in self.comparable.values(): self.compare_action.setEnabled(True) 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: invpath = os.path.join(self.get_current_event_path(), 'resp') if not invpath in self.metadata.inventories: diff --git a/pylot/core/util/array_map.py b/pylot/core/util/array_map.py index e6c81163..ba330cb7 100644 --- a/pylot/core/util/array_map.py +++ b/pylot/core/util/array_map.py @@ -49,13 +49,16 @@ class Array_map(QtGui.QWidget): return hybrids_dict def init_map(self): - self.init_lat_lon_dimensions() - self.init_lat_lon_grid() - self.init_x_y_dimensions() + self.init_colormap() self.connectSignals() self.draw_everything() 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): ind = event.ind button = event.mouseevent.button @@ -461,6 +464,8 @@ class Array_map(QtGui.QWidget): def _refresh_drawings(self): self.remove_drawings() + self.init_stations() + self.init_colormap() self.draw_everything() def draw_everything(self):