diff --git a/src/Model/Geometry/ProfileXYZ.py b/src/Model/Geometry/ProfileXYZ.py index 39a15c50f0d3f1247fa367fafb2636ccd2f1453c..6a4f196b70f3d276d58c64baafa2bde7cd0d31d2 100644 --- a/src/Model/Geometry/ProfileXYZ.py +++ b/src/Model/Geometry/ProfileXYZ.py @@ -167,8 +167,7 @@ class ProfileXYZ(Profile, SQLSubModel): filter( lambda s: s.id == sl, data["sediment_layers_list"].sediment_layers - ) - , None) + ), None) data["profile"] = new new._points = PointXYZ._db_load(execute, data.copy()) diff --git a/src/Model/Results/River/River.py b/src/Model/Results/River/River.py index c37479e658fad824c1aad66dce8da0642447ce26..fbf979c0f07631385426f4bcbd33133f593f057a 100644 --- a/src/Model/Results/River/River.py +++ b/src/Model/Results/River/River.py @@ -57,7 +57,10 @@ class Profile(object): ) def get_ts_key(self, timestamp, key): - return self._data[timestamp][key] + if timestamp in self._data: + if key in self._data[timestamp]: + return self._data[timestamp][key] + return None def has_sediment(self): return any(map(lambda ts: "sl" in self._data[ts], self._data)) diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py index cc651de4fa3ced41c6107edb3fb76c0f05a927c0..1aa86263d143a321fbbeecfe0bff52240f5f7199 100644 --- a/src/View/MainWindow.py +++ b/src/View/MainWindow.py @@ -82,7 +82,7 @@ from View.RunSolver.Window import ( SolverLogWindow, CompareSolversWindow ) -from View.Results.Window import ResultsWindow # , CompareResultsWindow +from View.Results.Window import ResultsWindow from View.RunSolver.WindowAdisTS import ( SelectSolverWindowAdisTS, SolverLogWindowAdisTS @@ -1584,22 +1584,11 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): # Windows already opened if self.sub_window_exists( ResultsWindow, - data=[ - self._study, - None] + # No config - [r._solver for r in results] + - [r._repertory for r in results] + - [r._name for r in results] + data=[self._study, None] + + [r._solver for r in results] + + [r._repertory for r in results] + + [r._name for r in results] ): - #w = self.get_sub_window( - #ResultsWindow, - #data=[ - #self._study, - #None, # No config - #results, - #parent=self - #]) - #w.add_result(result[1], run.solver2) return res = ResultsWindow( @@ -1609,15 +1598,6 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): ) res.show() - #res = CompareResultsWindow( - #study=self._study, - #solver=results._solver, - #results=results, - #parent=self - #) - #res.show() - - def diff_results(self, solver1, solver2): if solver1 is None: # TODO message @@ -1667,7 +1647,8 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): result3.set("nb_profile", result1.get("nb_profile")) result4.set("nb_profile", result1.get("nb_profile")) result5.set("nb_profile", result1.get("nb_profile")) - ts = list(result1.get("timestamps").intersection(result2.get("timestamps"))) + ts = list(result1.get("timestamps").intersection( + result2.get("timestamps"))) result3.set("timestamps", ts) result4.set("timestamps", ts) result5.set("timestamps", ts) @@ -1685,7 +1666,8 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): reach3 = result3.river.reach(r) reach4 = result4.river.reach(r) reach5 = result5.river.reach(r) - for p, (profile1, profile2) in enumerate(zip(reach1.profiles, reach2.profiles)): + for p, (profile1, profile2) in enumerate(zip( + reach1.profiles, reach2.profiles)): for key in ["Z", "Q", "V"]: d1 = profile1.get_ts_key(timestamp, key) d2 = profile2.get_ts_key(timestamp, key) diff --git a/src/View/Results/CustomPlot/Plot.py b/src/View/Results/CustomPlot/Plot.py index 9f3a005ed967549a15598544f94a7f94d8d15e64..41d1652db5d8b075655c52723f7f750c3b132e37 100644 --- a/src/View/Results/CustomPlot/Plot.py +++ b/src/View/Results/CustomPlot/Plot.py @@ -241,8 +241,8 @@ class CustomPlot(PamhyrPlot): self.lines["bed_elevation"] = line if (self._envelop and - reach.has_sediment() and - self._current_res_id != 2): + reach.has_sediment() and + self._current_res_id != 2): ax = self._axes[unit["bed_elevation_envelop"]] @@ -547,7 +547,7 @@ class CustomPlot(PamhyrPlot): reach2.profiles ) ) - fr = list( + fr = list( map( lambda x, y: x - y, fr1, fr2 @@ -1336,8 +1336,8 @@ class CustomPlot(PamhyrPlot): for axes in self._y_axes[1:]: print("axes: ", axes) if axes in self._axes.keys(): - for l in self._axes[axes].lines: - l.remove() + for ll in self._axes[axes].lines: + ll.remove() else: ax_new = self.canvas.axes.twinx() self._axes[axes] = ax_new diff --git a/src/View/Results/PlotAC.py b/src/View/Results/PlotAC.py index a8204708bb3e19f04e7caf5ec56d857154f0d3c1..614d1b4e81d031b18f4bfcbf01fdbb838cffc085 100644 --- a/src/View/Results/PlotAC.py +++ b/src/View/Results/PlotAC.py @@ -150,7 +150,8 @@ class PlotAC(PamhyrPlot): def set_timestamp(self, timestamp): self._current_timestamp = timestamp - reach = self.results[self._current_res_id].river.reach(self._current_reach_id) + reach = self.results[self._current_res_id].river.reach( + self._current_reach_id) profile = reach.profile(self._current_profile_id) x = profile.geometry.get_station() z = profile.geometry.z() @@ -162,7 +163,8 @@ class PlotAC(PamhyrPlot): if not self._init: self.draw() - reach = self.results[self._current_res_id].river.reach(self._current_reach_id) + reach = self.results[self._current_res_id].river.reach( + self._current_reach_id) profile = reach.profile(self._current_profile_id) x = profile.geometry.get_station() z = profile.geometry.z() diff --git a/src/View/Results/PlotH.py b/src/View/Results/PlotH.py index d5fd0e738fd71774d4efde2c5e5cec5b08fb162a..09d6acb33a66fa62fa62bc204c7c99bfb98e1478 100644 --- a/src/View/Results/PlotH.py +++ b/src/View/Results/PlotH.py @@ -62,8 +62,8 @@ class PlotH(PamhyrPlot): self._isometric_axis = False - #self._auto_relim_update = False - #self._autoscale_update = False + # self._auto_relim_update = False + # self._autoscale_update = False @property def results(self): @@ -182,11 +182,6 @@ class PlotH(PamhyrPlot): self._line.set_data(x, y) - #self._current.set_data( - #[self._current_timestamp, self._current_timestamp], - #self.canvas.axes.get_ylim() - #) - def update_current(self): y = self._current.get_ydata() self._current.set_data( diff --git a/src/View/Results/PlotRKC.py b/src/View/Results/PlotRKC.py index ea21f43507ef117efd4aa6256d07e8936dae021e..e24469636e9232a9a0e8b56cd0ae26ad43126445 100644 --- a/src/View/Results/PlotRKC.py +++ b/src/View/Results/PlotRKC.py @@ -112,11 +112,12 @@ class PlotRKC(PamhyrPlot): self._river_bottom = z def draw_profiles_hs(self, reach): + results = self.results[self._current_res_id] lhs = filter( lambda hs: hs._input_reach.reach is reach.geometry, filter( lambda hs: hs._input_reach is not None, - self.results[self._current_res_id].study.river.hydraulic_structures.lst + results.study.river.hydraulic_structures.lst ) ) diff --git a/src/View/Results/Table.py b/src/View/Results/Table.py index 13d7c29dfe53a2b1d38e741363591f6f355a044b..436b9bf670dc1e25ab440df262f7fd81a4edcd44 100644 --- a/src/View/Results/Table.py +++ b/src/View/Results/Table.py @@ -89,21 +89,18 @@ class TableModel(PamhyrTableModel): return f"{p.rk:.4f}" return f"{p.name}" elif self._headers[column] == "water_elevation": - try: - v = self._lst[row].get_ts_key(self._timestamp, "Z") - except: + v = self._lst[row].get_ts_key(self._timestamp, "Z") + if v is None: v = 0.0 return f"{v:.4f}" elif self._headers[column] == "discharge": - try: - v = self._lst[row].get_ts_key(self._timestamp, "Q") - except: + v = self._lst[row].get_ts_key(self._timestamp, "Q") + if v is None: v = 0.0 return f"{v:.4f}" elif self._headers[column] == "velocity": - try: - v = self._lst[row].get_ts_key(self._timestamp, "V") - except: + v = self._lst[row].get_ts_key(self._timestamp, "V") + if v is None: v = 0.0 return f"{v:.4f}" elif self._headers[column] == "width": diff --git a/src/View/Results/Window.py b/src/View/Results/Window.py index 0fa5f8283eac586967a45315e2def9b386f9c909..ad1c2b7f4b7707e1d1c0324d1f97df9816eaf9b0 100644 --- a/src/View/Results/Window.py +++ b/src/View/Results/Window.py @@ -957,7 +957,7 @@ class ResultsWindow(PamhyrWindow): reach2.profiles ) ) - fr = list( + fr = list( map( lambda x, y: x - y, fr1, fr2 @@ -1027,14 +1027,14 @@ class ResultsWindow(PamhyrWindow): if self._current_results != 2: z_min = [profile.geometry.z_min()] * len(self._timestamps) else: - z_min1 = profile1.geometry.z_min() - z_min2 = profile2.geometry.z_min() - z_min = list( - map( - lambda ts: z_min1 - z_min2, - self._timestamps - ) + z_min1 = profile1.geometry.z_min() + z_min2 = profile2.geometry.z_min() + z_min = list( + map( + lambda ts: z_min1 - z_min2, + self._timestamps ) + ) my_dict[dict_y["bed_elevation"]] = z_min if "discharge" in y: my_dict[dict_y["discharge"]] = q diff --git a/src/View/Results/WindowAdisTS.py b/src/View/Results/WindowAdisTS.py index 1388745ba338788f5beb98313b724005936e12f3..811dcff218600bfcf187fbc8c4239a1ede7d5822 100644 --- a/src/View/Results/WindowAdisTS.py +++ b/src/View/Results/WindowAdisTS.py @@ -555,7 +555,7 @@ class ResultsWindowAdisTS(PamhyrWindow): self.update(pol_id=rows) def _set_current_profile_raw_data(self): - return + return def _set_current_timestamp(self): timestamp = self._timestamps[self._slider_time.value()] diff --git a/src/View/Results/translate.py b/src/View/Results/translate.py index 11dc8b400cb81a1b6735ee559236d50e1781dea8..a2903b9662d753d563ab3cebb3de7e7d417ff8ea 100644 --- a/src/View/Results/translate.py +++ b/src/View/Results/translate.py @@ -139,11 +139,14 @@ class ResultsTranslate(MainTranslate): "unit_thickness": self._dict["unit_thickness"], } + class CompareResultsTranslate(ResultsTranslate): def __init__(self): super(CompareResultsTranslate, self).__init__() - self._dict['label_water'] = u"Δ "+_translate("Results", "Water elevation") + self._dict['label_water'] = u"Δ "+_translate( + "Results", "Water elevation" + ) self._dict['unit_elevation'] = u"Δ "+self._dict["unit_elevation"] self._sub_dict["table_headers_raw_data"] = {