mirror of https://gitlab.com/pamhyr/pamhyr2
Results: Add current timestamps on hydrograph.
parent
5c0f90b43e
commit
e4670e4a4d
|
|
@ -92,31 +92,24 @@ class PlotH(PamhyrPlot):
|
||||||
self.ts = list(self.results.get("timestamps"))
|
self.ts = list(self.results.get("timestamps"))
|
||||||
self.ts.sort()
|
self.ts.sort()
|
||||||
|
|
||||||
self.canvas.axes.set_xlim(
|
|
||||||
left=min(self.ts), right=max(self.ts)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Draw discharge for each timestamp
|
# Draw discharge for each timestamp
|
||||||
x = self.ts
|
x = self.ts
|
||||||
y = profile.get_key("Q")
|
y = profile.get_key("Q")
|
||||||
|
|
||||||
if len(self.ts) != len(x):
|
self._line, = self.canvas.axes.plot(
|
||||||
logger.warning(
|
x, y, lw=1.,
|
||||||
"Results as less Q data ({len(x)}) " +
|
color='r',
|
||||||
"than timestamps ({len(self.ts)}) " +
|
markersize=3, marker='+'
|
||||||
"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(
|
self._current, = self.canvas.axes.plot(
|
||||||
x, y, lw=1.,
|
self._current_timestamp,
|
||||||
color='r',
|
y[self.ts.index(self._current_timestamp)],
|
||||||
markersize=3, marker='+'
|
lw=1., color='b',
|
||||||
)
|
markersize=3, marker='+'
|
||||||
|
)
|
||||||
|
|
||||||
|
self.canvas.axes.relim()
|
||||||
|
|
||||||
# Custom time display
|
# Custom time display
|
||||||
nb = len(x)
|
nb = len(x)
|
||||||
|
|
@ -175,12 +168,21 @@ 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()
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
reach = self.results.river.reach(self._current_reach_id)
|
reach = self.results.river.reach(self._current_reach_id)
|
||||||
profile = reach.profile(self._current_profile_id)
|
profile = reach.profile(self._current_profile_id)
|
||||||
|
|
||||||
x = self.ts
|
x = self.ts
|
||||||
y = profile.get_key("Q")
|
y = profile.get_key("Q")
|
||||||
|
|
||||||
self._line.set_data(x, y)
|
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()
|
self.canvas.figure.canvas.draw_idle()
|
||||||
|
|
|
||||||
|
|
@ -396,7 +396,7 @@ class ResultsWindow(PamhyrWindow):
|
||||||
self.plot_xy.set_timestamp(timestamp)
|
self.plot_xy.set_timestamp(timestamp)
|
||||||
self.plot_ac.set_timestamp(timestamp)
|
self.plot_ac.set_timestamp(timestamp)
|
||||||
self.plot_kpc.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():
|
if self._study.river.has_sediment():
|
||||||
self.plot_sed_reach.set_timestamp(timestamp)
|
self.plot_sed_reach.set_timestamp(timestamp)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue