diff --git a/src/View/Results/PlotKPC.py b/src/View/Results/PlotKPC.py index 458e60485689e7ce7a6a275a44a01e1718e5e116..b54d833ed2af5777a180a996c5c1e1a396ae30bd 100644 --- a/src/View/Results/PlotKPC.py +++ b/src/View/Results/PlotKPC.py @@ -42,7 +42,8 @@ class PlotKPC(PamhyrPlot): parent=parent ) - self._current_timestamp = max(results.get("timestamps")) + self._timestamps = results.get("timestamps") + self._current_timestamp = max(self._timestamps) self._current_reach_id = reach_id self._current_profile_id = profile_id @@ -76,6 +77,7 @@ class PlotKPC(PamhyrPlot): self.draw_bottom(reach) self.draw_water_elevation(reach) self.draw_water_elevation_max(reach) + self.draw_water_elevation_overflow(reach) self.draw_current(reach) # self.enable_legend() @@ -156,6 +158,45 @@ class PlotKPC(PamhyrPlot): lw=1. ) + def draw_water_elevation_overflow(self, reach): + overflow = [] + + for profile in reach.profiles: + z_max = max(profile.get_key("Z")) + z_max_ts = 0 + for ts in self._timestamps: + z = profile.get_ts_key(ts, "Z") + if z == z_max: + z_max_ts = ts + break + + pt_left, pt_right = profile.get_ts_key(z_max_ts, "water_limits") + + if self.is_overflow_point(profile, pt_left): + overflow.append((profile, z_max)) + elif self.is_overflow_point(profile, pt_right): + overflow.append((profile, z_max)) + + for profile, z in overflow: + self.canvas.axes.plot( + profile.kp, z, + lw=1., + color=self.color_plot, + markersize=3, + marker='x' + ) + + def is_overflow_point(self, profile, point): + left_limit = profile.geometry.point(0) + right_limit = profile.geometry.point( + profile.geometry.number_points - 1 + ) + + return ( + point == left_limit + or point == right_limit + ) + def set_reach(self, reach_id): self._current_reach_id = reach_id self._current_profile_id = 0 diff --git a/src/View/Results/PlotXY.py b/src/View/Results/PlotXY.py index d74c1326403307230e01dc48fc3fe3577694ebcd..22a7149ff2b11a058d6976f4d43dc89fa0b6e583 100644 --- a/src/View/Results/PlotXY.py +++ b/src/View/Results/PlotXY.py @@ -124,7 +124,6 @@ class PlotXY(PamhyrPlot): **self.plot_default_kargs ) - def draw_water_elevation_max(self, reach): l_x, l_y, r_x, r_y = [], [], [], [] overflow = [] @@ -174,18 +173,16 @@ class PlotXY(PamhyrPlot): marker='x' ) - def is_overflow_point(self, profile, point): - left_limit = profile.geometry.point(0) - right_limit = profile.geometry.point( - profile.geometry.number_points - 1 - ) - - return ( - point == left_limit - or point == right_limit - ) + left_limit = profile.geometry.point(0) + right_limit = profile.geometry.point( + profile.geometry.number_points - 1 + ) + return ( + point == left_limit + or point == right_limit + ) def draw_water_elevation(self, reach): reach = self.results.river.reach(self._current_reach_id) @@ -285,15 +282,10 @@ class PlotXY(PamhyrPlot): "water_limits" ) - left_limit = profile.geometry.point(0) - right_limit = profile.geometry.point( - profile.geometry.number_points - 1 - ) - - if pt_left == left_limit: + if self.is_overflow_point(profile, pt_left): overflow.append(pt_left) - if pt_right == right_limit: + if self.is_overflow_point(profile, pt_right): overflow.append(pt_right) for plot in self.overflow: