Commit b04e325a authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

Results: PlotXY: Add water level.

Showing with 44 additions and 2 deletions
+44 -2
......@@ -47,7 +47,7 @@ class Profile(object):
def get_ts(self, timestamp):
return self._data[timestamp]
def get_key(self, timestamp):
def get_key(self, key):
return list(
map(lambda ts: self._data[ts][key], self._data)
)
......
......@@ -595,4 +595,5 @@ class Mage8(Mage):
end = newline().size <= 0
logger.debug(reachs[0].profiles[0]._data)
results.set("timestamps", ts)
logger.info(f"read_bin: ... end with {len(ts)} timestamp read")
......@@ -16,6 +16,8 @@
# -*- coding: utf-8 -*-
from functools import reduce
from tools import timer, trace
from View.Plot.APlot import APlot
......@@ -40,6 +42,7 @@ class PlotXY(APlot):
self.line_xy = []
self.line_gl = []
self._current_timestamp = max(results.get("timestamps"))
self._current_reach_id = reach_id
self._current_profile_id = profile_id
......@@ -106,9 +109,32 @@ class PlotXY(APlot):
for x, y in zip(x_complete, y_complete)
]
# Display point under water
for profile in reach.profiles:
water_z = profile.get_ts_key(
self._current_timestamp, "Z"
)
pgeo = profile.geometry
x, y = reduce(
lambda acc, pts: (acc[0] + [pts.x], acc[1] + [pts.y]),
filter(
lambda pts: pts.z < water_z,
pgeo.points
),
([], [])
)
self.canvas.axes.plot(
x, y, lw=1.,
color='b',
markersize=4,
marker='o'
)
if self.display_current:
# Current profile
profile = reach.geometry.profile(self._current_profile_id)
profile = reach.profile(self._current_profile_id).geometry
self.plot_selected, = self.canvas.axes.plot(
profile.x(),
......@@ -134,5 +160,9 @@ class PlotXY(APlot):
self._current_profile_id = profile_id
self.draw()
def set_timestamp(self, timestamp):
self._current_timestamp = timestamp
self.draw()
def update(self):
self.draw()
......@@ -158,6 +158,17 @@ class ResultsWindow(ASubMainWindow, ListedSubWindow):
self._table[t].dataChanged.connect(fun[t])
def plotXY(self, reach_id = None, profile_id = None, timestamp = None):
if reach_id is not None:
self.plot_xy.set_reach(reach_id)
if profile_id is not None:
self.plot_xy.set_profile(profile_id)
if timestamp is not None:
self.plot_xy.set_timestamp(timestamp)
self.plot_xy.draw()
def _set_current_reach(self):
return
......
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