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

Results, Sediment: Change sediment display algorithme.

Showing with 72 additions and 23 deletions
+72 -23
...@@ -56,7 +56,7 @@ class PlotSedProfile(APlot): ...@@ -56,7 +56,7 @@ class PlotSedProfile(APlot):
x = profile.geometry.get_station() x = profile.geometry.get_station()
z = profile.geometry.z() z = profile.geometry.z()
psl = list( profiles_sl = list(
map( map(
lambda sl: sl[0], lambda sl: sl[0],
profile.get_ts_key(self._current_timestamp, "sl") profile.get_ts_key(self._current_timestamp, "sl")
...@@ -64,10 +64,10 @@ class PlotSedProfile(APlot): ...@@ -64,10 +64,10 @@ class PlotSedProfile(APlot):
) )
sl = [] sl = []
for i in range(len(psl)): for i in range(len(profiles_sl)):
cur = [] cur = []
for p in range(profile.geometry.number_points): for p in range(profile.geometry.number_points):
cur.append(psl[i]) cur.append(profiles_sl[i])
sl.append(cur) sl.append(cur)
# logger.info(sl) # logger.info(sl)
...@@ -76,19 +76,44 @@ class PlotSedProfile(APlot): ...@@ -76,19 +76,44 @@ class PlotSedProfile(APlot):
left = min(x), right = max(x) left = min(x), right = max(x)
) )
# Compute sediment layer in function to point z # Dummy layer with height = 0
f = list(map(lambda p: 0, range(profile.geometry.number_points)))
# We compute Z sediment layer in reverse order, from last layer to
# fake river bottom
r_sl = list(reversed(sl))
z_sl = reduce( z_sl = reduce(
lambda acc, v: acc + [ lambda acc, v: acc + [
list( list(
map(lambda x, y: y - x, v, acc[-1]) map(lambda x, y: y + x, v, acc[-1])
) )
], ],
sl, r_sl,
[z] [f]
)
# We normalize Z coordinate to 0 (the maximum must be 0)
f_z_max = max(z_sl[-1])
z_sl = list(
map(
lambda p: list(map(lambda z: z - f_z_max, p)),
z_sl
)
)
# We apply the river geometry bottom height at each layers to
# fond the new river geometry
z_sl = list(
map(
lambda sl: list(
map(lambda pz, m: pz + m, sl, z)
),
z_sl
)
) )
self.line_kp_sl = [] self.line_kp_sl = []
for i, zsl in enumerate(reversed(z_sl)): for i, zsl in enumerate(z_sl):
self.line_kp_sl.append(None) self.line_kp_sl.append(None)
self.line_kp_sl[i], = self.canvas.axes.plot( self.line_kp_sl[i], = self.canvas.axes.plot(
x, zsl, x, zsl,
......
...@@ -56,7 +56,7 @@ class PlotSedReach(APlot): ...@@ -56,7 +56,7 @@ class PlotSedReach(APlot):
z_min = reach.geometry.get_z_min() z_min = reach.geometry.get_z_min()
z_max = reach.geometry.get_z_max() z_max = reach.geometry.get_z_max()
psl = list( profiles_sl = list(
map( map(
# Get SL list for profile p # Get SL list for profile p
lambda p: p.get_ts_key(self._current_timestamp, "sl"), lambda p: p.get_ts_key(self._current_timestamp, "sl"),
...@@ -64,41 +64,65 @@ class PlotSedReach(APlot): ...@@ -64,41 +64,65 @@ class PlotSedReach(APlot):
) )
) )
max_sl = reduce( max_sl_num = reduce(
lambda acc, sl: max(acc, len(sl)), lambda acc, sl: max(acc, len(sl)),
psl, profiles_sl,
0 0
) )
sl = [] sl = []
for i in range(max_sl): for i in range(max_sl_num):
cur = [] cur = []
for csl in psl: for profile_sl in profiles_sl:
if i < len(csl): if i < len(profile_sl):
cur.append(csl[i][0]) cur.append(profile_sl[i][0])
else: else:
cur.append(0) cur.append(0)
sl.append(cur) sl.append(cur)
# logger.info(f"sl = {sl}")
self.canvas.axes.set_xlim( self.canvas.axes.set_xlim(
left = min(kp), right = max(kp) left = min(kp) - 10, right = max(kp) + 10
) )
# Compute sediment layer in function to profile z_min # Dummy layer with height = 0
f = list(map(lambda p: 0, reach.profiles))
# We compute Z sediment layer in reverse order, from last layer to
# fake river bottom
r_sl = list(reversed(sl))
z_sl = reduce( z_sl = reduce(
lambda acc, v: acc + [ lambda acc, v: acc + [
list( list(
map(lambda x, y: y - x, v, acc[-1]) map(lambda x, y: y + x, v, acc[-1])
) )
], ],
sl, r_sl,
[z_min] [f]
)
# We normalize Z coordinate to 0 (the maximum must be 0)
f_z_max = max(z_sl[-1])
z_sl = list(
map(
lambda p: list(map(lambda z: z - f_z_max, p)),
z_sl
)
)
# We apply the river geometry bottom height at each layers to
# fond the new river geometry
z_sl = list(
map(
lambda sl: list(
map(lambda z, m: z + m, sl, z_min)
),
z_sl
)
) )
# Draw
self.line_kp_sl = [] self.line_kp_sl = []
for i, z in enumerate(reversed(z_sl)): for i, z in enumerate(z_sl):
self.line_kp_sl.append(None) self.line_kp_sl.append(None)
self.line_kp_sl[i], = self.canvas.axes.plot( self.line_kp_sl[i], = self.canvas.axes.plot(
kp, z, kp, z,
......
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