diff --git a/src/View/Results/PlotSedProfile.py b/src/View/Results/PlotSedProfile.py index 5b34bb1e2e87fa5eddf0e59b5e12eec9ddd238af..8f77ee3b420fcffa18ac4fd009a300570c95e593 100644 --- a/src/View/Results/PlotSedProfile.py +++ b/src/View/Results/PlotSedProfile.py @@ -56,7 +56,7 @@ class PlotSedProfile(APlot): x = profile.geometry.get_station() z = profile.geometry.z() - psl = list( + profiles_sl = list( map( lambda sl: sl[0], profile.get_ts_key(self._current_timestamp, "sl") @@ -64,10 +64,10 @@ class PlotSedProfile(APlot): ) sl = [] - for i in range(len(psl)): + for i in range(len(profiles_sl)): cur = [] for p in range(profile.geometry.number_points): - cur.append(psl[i]) + cur.append(profiles_sl[i]) sl.append(cur) # logger.info(sl) @@ -76,19 +76,44 @@ class PlotSedProfile(APlot): 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( lambda acc, v: acc + [ list( - map(lambda x, y: y - x, v, acc[-1]) + map(lambda x, y: y + x, v, acc[-1]) ) ], - sl, - [z] + r_sl, + [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 = [] - 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[i], = self.canvas.axes.plot( x, zsl, diff --git a/src/View/Results/PlotSedReach.py b/src/View/Results/PlotSedReach.py index 892120c60c96a742be65ec0f1edd52179ac881bd..d88e26df6b18fcc8c6b255ef04e894a763af71b7 100644 --- a/src/View/Results/PlotSedReach.py +++ b/src/View/Results/PlotSedReach.py @@ -56,7 +56,7 @@ class PlotSedReach(APlot): z_min = reach.geometry.get_z_min() z_max = reach.geometry.get_z_max() - psl = list( + profiles_sl = list( map( # Get SL list for profile p lambda p: p.get_ts_key(self._current_timestamp, "sl"), @@ -64,41 +64,65 @@ class PlotSedReach(APlot): ) ) - max_sl = reduce( + max_sl_num = reduce( lambda acc, sl: max(acc, len(sl)), - psl, + profiles_sl, 0 ) sl = [] - for i in range(max_sl): + for i in range(max_sl_num): cur = [] - for csl in psl: - if i < len(csl): - cur.append(csl[i][0]) + for profile_sl in profiles_sl: + if i < len(profile_sl): + cur.append(profile_sl[i][0]) else: cur.append(0) sl.append(cur) - # logger.info(f"sl = {sl}") - 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( lambda acc, v: acc + [ list( - map(lambda x, y: y - x, v, acc[-1]) + map(lambda x, y: y + x, v, acc[-1]) ) ], - sl, - [z_min] + r_sl, + [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 = [] - 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[i], = self.canvas.axes.plot( kp, z,