add wet arrea in custom plots + slider mark

adists_release
Theophile Terraz 2024-08-21 15:45:42 +02:00
parent ec5b9571d3
commit 898aad3da5
5 changed files with 78 additions and 19 deletions

Binary file not shown.

Binary file not shown.

View File

@ -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()

View File

@ -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"],
}

View File

@ -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()
)