Commit 1c736df6 authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

Results: Add overflow to KPC plot.

Showing with 52 additions and 19 deletions
+52 -19
......@@ -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
......
......@@ -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:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment