debug HS and friction plots

This commit is contained in:
Theophile Terraz committed 2024-10-01 14:38:07 +02:00
1 parent bed66fbde7
commit 2b886fb452
4 files changed
+79 -11

No files matched your search

+1
View File
@@ -118,3 +118,4 @@ class PlotAC(PamhyrPlot):
def update_clear(self):
if self.line_rk is not None:
self.line_rk.set_data([], [])
self.update_idle()
+71 -4
View File
@@ -69,21 +69,23 @@ class PlotRKC(PamhyrPlot):
self.profile = None
self.line_rk_zmin_zmax = None
self.line_rk_zmin = None
self.hs_vlines = None
return
if self._current_reach is None:
self.profile = None
self.line_rk_zmin_zmax = None
self.line_rk_zmin = None
self.hs_vlines = None
return
self.draw_data()
self.draw_data(highlight)
self.draw_current()
self.idle()
self._init = True
def draw_data(self):
def draw_data(self, highlight):
reach = self._current_reach
rk = reach.reach.get_rk()
@@ -107,11 +109,68 @@ class PlotRKC(PamhyrPlot):
self.line_rk_zmin_zmax = self.canvas.axes.vlines(
x=rk,
ymin=z_min, ymax=z_max,
color=self.color_plot,
color=self.color_highlight(highlight),
lw=1.,
picker=10
)
# Draw HS
lhs = filter(
lambda hs: hs._input_reach is reach,
filter(
lambda hs: hs._input_reach is not None,
self.data.hydraulic_structures.lst
)
)
vx = []
vymin = []
vymax = []
self.anotate_lst = []
hs_color = []
for hs in lhs:
if hs.enabled:
hs_color.append("black")
else:
hs_color.append("darkgrey")
x = hs.input_rk
if x is not None:
a = self.canvas.axes.annotate(
" > " + hs.name,
(x, max(z_max)),
horizontalalignment='left',
verticalalignment='top',
annotation_clip=True,
fontsize=9,
color=hs_color[-1],
)
self.anotate_lst.append(a)
vx.append(x)
vymin.append(min(z_min))
vymax.append(max(z_max))
self.hs_vlines = self.canvas.axes.vlines(
x=vx, ymin=vymin, ymax=vymax,
linestyle="--",
lw=1.,
color=hs_color,
)
def color_highlight(self, highlight):
reach = self._current_reach
colors = [self.color_plot] * reach.reach.number_profiles
if highlight is not None:
rk = reach.reach.get_rk()
rows = [i for i in range(len(rk))
if (rk[i] >= highlight[0] and rk[i] <= highlight[1])]
if len(rows) > 0:
for row in rows:
colors[row] = self.color_plot_current
return colors
def draw_current(self):
if self._current_profile is None:
self.profile = None
@@ -166,11 +225,19 @@ class PlotRKC(PamhyrPlot):
if self.line_rk_zmin is not None:
self.line_rk_zmin.set_data([], [])
if self.hs_vlines is not None:
self.hs_vlines.remove()
self.hs_vlines = None
for a in self.anotate_lst:
a.remove()
self.anotate_lst = []
self.canvas.figure.canvas.draw_idle()
def clear_profile(self):
if self.profile is not None:
self.profile.set_data([], [])
self.profile[0].set_data([], [])
self.canvas.figure.canvas.draw_idle()