diff --git a/doc/users/Tuto1/step2.pamhyr b/doc/users/Tuto1/step2.pamhyr index e10e685b6ce4b9e25e4542a1b28f15fdaa745870..c7516dff606939dd005eafa8e54776cee528a4ee 100644 Binary files a/doc/users/Tuto1/step2.pamhyr and b/doc/users/Tuto1/step2.pamhyr differ diff --git a/doc/users/Tuto1/step3.pamhyr b/doc/users/Tuto1/step3.pamhyr index 00a39e3a44170e11157d417d529b9238a17d726a..018a4aea279cf4566b96ce30dc3229f0bf7133cf 100644 Binary files a/doc/users/Tuto1/step3.pamhyr and b/doc/users/Tuto1/step3.pamhyr differ diff --git a/src/View/Results/CustomPlot/Plot.py b/src/View/Results/CustomPlot/Plot.py index cb45863cae05640fe98ce2a83644f3983aeb3506..0f2ed5cbeb9b2e24de4d47f1ce87f5a6e6ed5de7 100644 --- a/src/View/Results/CustomPlot/Plot.py +++ b/src/View/Results/CustomPlot/Plot.py @@ -37,6 +37,7 @@ unit = { "depth": "3-meter", "mean_depth": "3-meter", "froude": "4-dimensionless", + "wet_area": "5-m2", } @@ -174,7 +175,7 @@ class CustomPlot(PamhyrPlot): if "mean_depth" in self._y: - ax = self._axes[unit["depth"]] + ax = self._axes[unit["mean_depth"]] d = list( map( lambda p: p.geometry.mean_water_depth( @@ -213,6 +214,23 @@ class CustomPlot(PamhyrPlot): ) lines["froude"] = line + if "wet_area" in self._y: + + ax = self._axes[unit["wet_area"]] + d = list( + map( + lambda p: p.geometry.wet_area( + p.get_ts_key(self._timestamp, "Z")), + reach.profiles + ) + ) + + line = ax.plot( + rk, d, + color='blue', linestyle='--', lw=1., + ) + lines["wet_area"] = line + # Legend lns = reduce( lambda acc, line: acc + line, @@ -358,7 +376,7 @@ class CustomPlot(PamhyrPlot): if "mean_depth" in self._y: - ax = self._axes[unit["depth"]] + ax = self._axes[unit["mean_depth"]] d = list( map(lambda z: profile.geometry.mean_water_depth(z), z) ) @@ -386,6 +404,18 @@ class CustomPlot(PamhyrPlot): ) lines["froude"] = line + if "wet_area" in self._y: + + ax = self._axes[unit["wet_area"]] + d = list( + map(lambda z: profile.geometry.wet_area(z), z) + ) + + line = ax.plot( + ts, d, color='blue', linestyle='--', lw=1., + ) + lines["wet_area"] = line + self._customize_x_axes_time(ts) # Legend @@ -432,6 +462,21 @@ class CustomPlot(PamhyrPlot): self._draw_rk() elif self._x == "time": self._draw_time() + if self._x == "rk": + reach = self.data.river.reach(self._reach) + profile = reach.profile(self._profile) + x = profile.rk + elif self._x == "time": + x = self._timestamp + + self._current, = self.canvas.axes.plot( + [x, x], + self.canvas.axes.get_ylim(), + # label=self.label_timestamp, + color='grey', + linestyle="dashed", + lw=1., + ) self.canvas.figure.canvas.draw_idle() if self.toolbar is not None: @@ -441,6 +486,7 @@ class CustomPlot(PamhyrPlot): def update(self): if not self._init: self.draw() + self.draw_current() return def set_reach(self, reach_id): @@ -454,9 +500,23 @@ class CustomPlot(PamhyrPlot): if self._x != "rk": self.update() + else: + self.draw_current() def set_timestamp(self, timestamp): self._timestamp = timestamp if self._x != "time": self.update() + else: + self.draw_current() + + def draw_current(self): + if self._x == "rk": + reach = self.data.river.reach(self._reach) + profile = reach.profile(self._profile) + x = profile.rk + elif self._x == "time": + x = self._timestamp + self._current.set_data([x, x], self.canvas.axes.get_ylim()) + self.canvas.figure.canvas.draw_idle() diff --git a/src/View/Results/CustomPlot/Translate.py b/src/View/Results/CustomPlot/Translate.py index 6d96bf276553f99e1399e6abea3b7a4bc730d002..b00bab0ad5b1f6a47b69e7b0a44747b8a2a8f8d3 100644 --- a/src/View/Results/CustomPlot/Translate.py +++ b/src/View/Results/CustomPlot/Translate.py @@ -58,6 +58,7 @@ class CustomPlotTranslate(ResultsTranslate): self._dict['2-ms'] = self._dict["unit_speed"] self._dict['3-meter'] = self._dict["unit_height"] self._dict['4-dimensionless'] = self._dict["unit_froude"] + self._dict['5-m2'] = self._dict["wet_area"] # SubDict @@ -73,4 +74,5 @@ class CustomPlotTranslate(ResultsTranslate): "depth": self._dict["max_depth"], "mean_depth": self._dict["mean_depth"], "froude": self._dict["froude"], + "wet_area": self._dict["wet_area"], } diff --git a/src/View/Results/PlotH.py b/src/View/Results/PlotH.py index 2ac499e4a00e5abb88467142ddb6859e68a0de76..90aa667434097d98079fd84c25a21845ca38e67e 100644 --- a/src/View/Results/PlotH.py +++ b/src/View/Results/PlotH.py @@ -88,13 +88,14 @@ class PlotH(PamhyrPlot): self.draw_max(reach) self.draw_data(reach, profile) - self.draw_current(reach, profile) + self.draw_current() self.set_ticks_time_formater() self.enable_legend() self.idle() + self.update_current() self._init = True def draw_data(self, reach, profile): @@ -111,21 +112,12 @@ class PlotH(PamhyrPlot): **self.plot_default_kargs ) - def draw_current(self, reach, profile): - min_y, max_y = reduce( - lambda acc, p: ( - acc[0] + [min(p.get_key("Q"))], - acc[1] + [max(p.get_key("Q"))] - ), - reach.profiles, - ([], []) - ) - + def draw_current(self): self._current, = self.canvas.axes.plot( [self._current_timestamp, self._current_timestamp], - [min(min_y), max(max_y)], + self.canvas.axes.get_ylim(), # label=self.label_timestamp, - color=self.color_plot_river_bottom, + color="grey", linestyle="dashed", lw=1., ) @@ -162,14 +154,14 @@ class PlotH(PamhyrPlot): def set_timestamp(self, timestamp): self._current_timestamp = timestamp - self.update() + self.update_current() + self.update_idle() def update(self): if not self._init: self.draw() self.update_data() - self.update_idle() def update_data(self): @@ -181,8 +173,13 @@ class PlotH(PamhyrPlot): self._line.set_data(x, y) - _, min_max = self._current.get_data() self._current.set_data( self._current_timestamp, - min_max + self.canvas.axes.get_ylim() + ) + + def update_current(self): + self._current.set_data( + self._current_timestamp, + self.canvas.axes.get_ylim() )