Commit 898aad3d authored by Theophile Terraz's avatar Theophile Terraz
Browse files

add wet arrea in custom plots + slider mark

No related merge requests found
Pipeline #57482 passed with stages
in 55 seconds
Showing with 78 additions and 19 deletions
+78 -19
No preview for this file type
No preview for this file type
...@@ -37,6 +37,7 @@ unit = { ...@@ -37,6 +37,7 @@ unit = {
"depth": "3-meter", "depth": "3-meter",
"mean_depth": "3-meter", "mean_depth": "3-meter",
"froude": "4-dimensionless", "froude": "4-dimensionless",
"wet_area": "5-m2",
} }
...@@ -174,7 +175,7 @@ class CustomPlot(PamhyrPlot): ...@@ -174,7 +175,7 @@ class CustomPlot(PamhyrPlot):
if "mean_depth" in self._y: if "mean_depth" in self._y:
ax = self._axes[unit["depth"]] ax = self._axes[unit["mean_depth"]]
d = list( d = list(
map( map(
lambda p: p.geometry.mean_water_depth( lambda p: p.geometry.mean_water_depth(
...@@ -213,6 +214,23 @@ class CustomPlot(PamhyrPlot): ...@@ -213,6 +214,23 @@ class CustomPlot(PamhyrPlot):
) )
lines["froude"] = line 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 # Legend
lns = reduce( lns = reduce(
lambda acc, line: acc + line, lambda acc, line: acc + line,
...@@ -358,7 +376,7 @@ class CustomPlot(PamhyrPlot): ...@@ -358,7 +376,7 @@ class CustomPlot(PamhyrPlot):
if "mean_depth" in self._y: if "mean_depth" in self._y:
ax = self._axes[unit["depth"]] ax = self._axes[unit["mean_depth"]]
d = list( d = list(
map(lambda z: profile.geometry.mean_water_depth(z), z) map(lambda z: profile.geometry.mean_water_depth(z), z)
) )
...@@ -386,6 +404,18 @@ class CustomPlot(PamhyrPlot): ...@@ -386,6 +404,18 @@ class CustomPlot(PamhyrPlot):
) )
lines["froude"] = line 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) self._customize_x_axes_time(ts)
# Legend # Legend
...@@ -432,6 +462,21 @@ class CustomPlot(PamhyrPlot): ...@@ -432,6 +462,21 @@ class CustomPlot(PamhyrPlot):
self._draw_rk() self._draw_rk()
elif self._x == "time": elif self._x == "time":
self._draw_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() self.canvas.figure.canvas.draw_idle()
if self.toolbar is not None: if self.toolbar is not None:
...@@ -441,6 +486,7 @@ class CustomPlot(PamhyrPlot): ...@@ -441,6 +486,7 @@ class CustomPlot(PamhyrPlot):
def update(self): def update(self):
if not self._init: if not self._init:
self.draw() self.draw()
self.draw_current()
return return
def set_reach(self, reach_id): def set_reach(self, reach_id):
...@@ -454,9 +500,23 @@ class CustomPlot(PamhyrPlot): ...@@ -454,9 +500,23 @@ class CustomPlot(PamhyrPlot):
if self._x != "rk": if self._x != "rk":
self.update() self.update()
else:
self.draw_current()
def set_timestamp(self, timestamp): def set_timestamp(self, timestamp):
self._timestamp = timestamp self._timestamp = timestamp
if self._x != "time": if self._x != "time":
self.update() 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()
...@@ -58,6 +58,7 @@ class CustomPlotTranslate(ResultsTranslate): ...@@ -58,6 +58,7 @@ class CustomPlotTranslate(ResultsTranslate):
self._dict['2-ms'] = self._dict["unit_speed"] self._dict['2-ms'] = self._dict["unit_speed"]
self._dict['3-meter'] = self._dict["unit_height"] self._dict['3-meter'] = self._dict["unit_height"]
self._dict['4-dimensionless'] = self._dict["unit_froude"] self._dict['4-dimensionless'] = self._dict["unit_froude"]
self._dict['5-m2'] = self._dict["wet_area"]
# SubDict # SubDict
...@@ -73,4 +74,5 @@ class CustomPlotTranslate(ResultsTranslate): ...@@ -73,4 +74,5 @@ class CustomPlotTranslate(ResultsTranslate):
"depth": self._dict["max_depth"], "depth": self._dict["max_depth"],
"mean_depth": self._dict["mean_depth"], "mean_depth": self._dict["mean_depth"],
"froude": self._dict["froude"], "froude": self._dict["froude"],
"wet_area": self._dict["wet_area"],
} }
...@@ -88,13 +88,14 @@ class PlotH(PamhyrPlot): ...@@ -88,13 +88,14 @@ class PlotH(PamhyrPlot):
self.draw_max(reach) self.draw_max(reach)
self.draw_data(reach, profile) self.draw_data(reach, profile)
self.draw_current(reach, profile) self.draw_current()
self.set_ticks_time_formater() self.set_ticks_time_formater()
self.enable_legend() self.enable_legend()
self.idle() self.idle()
self.update_current()
self._init = True self._init = True
def draw_data(self, reach, profile): def draw_data(self, reach, profile):
...@@ -111,21 +112,12 @@ class PlotH(PamhyrPlot): ...@@ -111,21 +112,12 @@ class PlotH(PamhyrPlot):
**self.plot_default_kargs **self.plot_default_kargs
) )
def draw_current(self, reach, profile): def draw_current(self):
min_y, max_y = reduce(
lambda acc, p: (
acc[0] + [min(p.get_key("Q"))],
acc[1] + [max(p.get_key("Q"))]
),
reach.profiles,
([], [])
)
self._current, = self.canvas.axes.plot( self._current, = self.canvas.axes.plot(
[self._current_timestamp, self._current_timestamp], [self._current_timestamp, self._current_timestamp],
[min(min_y), max(max_y)], self.canvas.axes.get_ylim(),
# label=self.label_timestamp, # label=self.label_timestamp,
color=self.color_plot_river_bottom, color="grey",
linestyle="dashed", linestyle="dashed",
lw=1., lw=1.,
) )
...@@ -162,14 +154,14 @@ class PlotH(PamhyrPlot): ...@@ -162,14 +154,14 @@ class PlotH(PamhyrPlot):
def set_timestamp(self, timestamp): def set_timestamp(self, timestamp):
self._current_timestamp = timestamp self._current_timestamp = timestamp
self.update() self.update_current()
self.update_idle()
def update(self): def update(self):
if not self._init: if not self._init:
self.draw() self.draw()
self.update_data() self.update_data()
self.update_idle() self.update_idle()
def update_data(self): def update_data(self):
...@@ -181,8 +173,13 @@ class PlotH(PamhyrPlot): ...@@ -181,8 +173,13 @@ class PlotH(PamhyrPlot):
self._line.set_data(x, y) self._line.set_data(x, y)
_, min_max = self._current.get_data()
self._current.set_data( self._current.set_data(
self._current_timestamp, 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()
) )
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