Results: Add current timestamps on hydrograph.

setup.py
Pierre-Antoine Rouby 2023-12-18 15:28:22 +01:00
parent 5c0f90b43e
commit e4670e4a4d
2 changed files with 23 additions and 21 deletions

View File

@ -92,31 +92,24 @@ class PlotH(PamhyrPlot):
self.ts = list(self.results.get("timestamps"))
self.ts.sort()
self.canvas.axes.set_xlim(
left=min(self.ts), right=max(self.ts)
)
# Draw discharge for each timestamp
x = self.ts
y = profile.get_key("Q")
if len(self.ts) != len(x):
logger.warning(
"Results as less Q data ({len(x)}) " +
"than timestamps ({len(self.ts)}) " +
"for profile {self._current_profile_id}"
)
return
self.canvas.axes.set_ylim(
[min(min(y), 0), max(y) + 10]
self._line, = self.canvas.axes.plot(
x, y, lw=1.,
color='r',
markersize=3, marker='+'
)
self._line, = self.canvas.axes.plot(
x, y, lw=1.,
color='r',
markersize=3, marker='+'
)
self._current, = self.canvas.axes.plot(
self._current_timestamp,
y[self.ts.index(self._current_timestamp)],
lw=1., color='b',
markersize=3, marker='+'
)
self.canvas.axes.relim()
# Custom time display
nb = len(x)
@ -175,12 +168,21 @@ class PlotH(PamhyrPlot):
def set_timestamp(self, timestamp):
self._current_timestamp = timestamp
# self.update()
self.update()
def update(self):
reach = self.results.river.reach(self._current_reach_id)
profile = reach.profile(self._current_profile_id)
x = self.ts
y = profile.get_key("Q")
self._line.set_data(x, y)
self._current.set_data(
self._current_timestamp,
y[self.ts.index(self._current_timestamp)]
)
self.canvas.axes.relim()
self.canvas.figure.canvas.draw_idle()

View File

@ -396,7 +396,7 @@ class ResultsWindow(PamhyrWindow):
self.plot_xy.set_timestamp(timestamp)
self.plot_ac.set_timestamp(timestamp)
self.plot_kpc.set_timestamp(timestamp)
# self.plot_h.set_timestamp(timestamp)
self.plot_h.set_timestamp(timestamp)
if self._study.river.has_sediment():
self.plot_sed_reach.set_timestamp(timestamp)