diff --git a/src/Model/Results/River/River.py b/src/Model/Results/River/River.py index ae8b33c04be00746b1a437886652e86bddbd2d68..5ae1e90f50f755868c3e24434b289abed3d5ad8c 100644 --- a/src/Model/Results/River/River.py +++ b/src/Model/Results/River/River.py @@ -47,7 +47,7 @@ class Profile(object): def get_ts(self, timestamp): return self._data[timestamp] - def get_key(self, timestamp): + def get_key(self, key): return list( map(lambda ts: self._data[ts][key], self._data) ) diff --git a/src/Solver/Mage.py b/src/Solver/Mage.py index cc69555658934711ae932286360391c026dc8763..6c129f887d717a19d0b88b06fca112451143b7ad 100644 --- a/src/Solver/Mage.py +++ b/src/Solver/Mage.py @@ -595,4 +595,5 @@ class Mage8(Mage): end = newline().size <= 0 logger.debug(reachs[0].profiles[0]._data) + results.set("timestamps", ts) logger.info(f"read_bin: ... end with {len(ts)} timestamp read") diff --git a/src/View/Results/PlotXY.py b/src/View/Results/PlotXY.py index 43934073b56ede4833b36aa52f3c75b38174393f..a0af6a2d81a91c0e6cbcf4632e15d2d3b2e5e18f 100644 --- a/src/View/Results/PlotXY.py +++ b/src/View/Results/PlotXY.py @@ -16,6 +16,8 @@ # -*- coding: utf-8 -*- +from functools import reduce + from tools import timer, trace from View.Plot.APlot import APlot @@ -40,6 +42,7 @@ class PlotXY(APlot): self.line_xy = [] self.line_gl = [] + self._current_timestamp = max(results.get("timestamps")) self._current_reach_id = reach_id self._current_profile_id = profile_id @@ -106,9 +109,32 @@ class PlotXY(APlot): for x, y in zip(x_complete, y_complete) ] + # Display point under water + for profile in reach.profiles: + water_z = profile.get_ts_key( + self._current_timestamp, "Z" + ) + pgeo = profile.geometry + + x, y = reduce( + lambda acc, pts: (acc[0] + [pts.x], acc[1] + [pts.y]), + filter( + lambda pts: pts.z < water_z, + pgeo.points + ), + ([], []) + ) + + self.canvas.axes.plot( + x, y, lw=1., + color='b', + markersize=4, + marker='o' + ) + if self.display_current: # Current profile - profile = reach.geometry.profile(self._current_profile_id) + profile = reach.profile(self._current_profile_id).geometry self.plot_selected, = self.canvas.axes.plot( profile.x(), @@ -134,5 +160,9 @@ class PlotXY(APlot): self._current_profile_id = profile_id self.draw() + def set_timestamp(self, timestamp): + self._current_timestamp = timestamp + self.draw() + def update(self): self.draw() diff --git a/src/View/Results/Window.py b/src/View/Results/Window.py index e2d3f8b38349c2a6a4a81667d54f9a354b873beb..66845431e36a2263d4e197fbc15f7968cc6778e1 100644 --- a/src/View/Results/Window.py +++ b/src/View/Results/Window.py @@ -158,6 +158,17 @@ class ResultsWindow(ASubMainWindow, ListedSubWindow): self._table[t].dataChanged.connect(fun[t]) + def plotXY(self, reach_id = None, profile_id = None, timestamp = None): + if reach_id is not None: + self.plot_xy.set_reach(reach_id) + if profile_id is not None: + self.plot_xy.set_profile(profile_id) + if timestamp is not None: + self.plot_xy.set_timestamp(timestamp) + + self.plot_xy.draw() + + def _set_current_reach(self): return