mirror of https://gitlab.com/pamhyr/pamhyr2
Results: Update AC plot with max water level.
parent
f9a099a284
commit
a08b2c77d6
|
|
@ -43,6 +43,18 @@ class PlotAC(PamhyrPlot):
|
|||
self._current_reach_id = reach_id
|
||||
self._current_profile_id = profile_id
|
||||
|
||||
self.label_x = _translate("Results", "X (m)")
|
||||
self.label_y = _translate("MainWindow_reach", "Elevation (m)")
|
||||
|
||||
self.label_bottom = _translate("Results", "River bottom")
|
||||
self.label_water = _translate("Results", "Water elevation")
|
||||
self.label_water_max = _translate("Results", "Max water elevation")
|
||||
|
||||
self._isometric_axis = False
|
||||
|
||||
self._auto_relim_update = True
|
||||
self._autoscale_update = True
|
||||
|
||||
@property
|
||||
def results(self):
|
||||
return self.data
|
||||
|
|
@ -54,58 +66,67 @@ class PlotAC(PamhyrPlot):
|
|||
|
||||
@timer
|
||||
def draw(self, highlight=None):
|
||||
self.canvas.axes.cla()
|
||||
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
||||
self.init_axes()
|
||||
|
||||
if self.results is None:
|
||||
return
|
||||
|
||||
self.canvas.axes.set_xlabel(
|
||||
_translate("MainWindow_reach", "X (m)"),
|
||||
color='black', fontsize=11
|
||||
)
|
||||
self.canvas.axes.set_ylabel(
|
||||
_translate("MainWindow_reach", "Elevation (m)"),
|
||||
color='black', fontsize=11
|
||||
)
|
||||
|
||||
reach = self.results.river.reach(self._current_reach_id)
|
||||
profile = reach.profile(self._current_profile_id)
|
||||
|
||||
self.draw_profile(reach, profile)
|
||||
self.draw_water_elevation(reach, profile)
|
||||
self.draw_water_elevation_max(reach, profile)
|
||||
|
||||
self.enable_legend()
|
||||
|
||||
self.idle()
|
||||
self._init = True
|
||||
|
||||
def draw_profile(self, reach, profile):
|
||||
x = profile.geometry.get_station()
|
||||
z = profile.geometry.z()
|
||||
|
||||
self.canvas.axes.set_xlim(
|
||||
left=min(x), right=max(x)
|
||||
)
|
||||
|
||||
self.line_kp, = self.canvas.axes.plot(
|
||||
x, z,
|
||||
linestyle="solid",
|
||||
lw=1.8,
|
||||
color='grey',
|
||||
lw=1.5,
|
||||
label=self.label_bottom,
|
||||
color=self.color_plot_river_bottom,
|
||||
)
|
||||
|
||||
def draw_water_elevation(self, reach, profile):
|
||||
x = profile.geometry.get_station()
|
||||
z = profile.geometry.z()
|
||||
kp = reach.geometry.get_kp()
|
||||
|
||||
# Water elevation
|
||||
water_z = profile.get_ts_key(self._current_timestamp, "Z")
|
||||
|
||||
self.water, = self.canvas.axes.plot(
|
||||
[min(x), max(x)], [water_z, water_z],
|
||||
lw=1., color='b',
|
||||
label=self.label_water,
|
||||
lw=1., color=self.color_plot_river_water,
|
||||
)
|
||||
|
||||
self.collection = self.canvas.axes.fill_between(
|
||||
x, z, water_z,
|
||||
where=z <= water_z,
|
||||
color='skyblue', alpha=0.7, interpolate=True
|
||||
color=self.color_plot_river_water_zone,
|
||||
alpha=0.7, interpolate=True
|
||||
)
|
||||
self.liste_chemins = self.collection.get_paths()
|
||||
|
||||
self.canvas.figure.tight_layout()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
if self.toolbar is not None:
|
||||
self.toolbar.update()
|
||||
def draw_water_elevation_max(self, reach, profile):
|
||||
x = profile.geometry.get_station()
|
||||
z = profile.geometry.z()
|
||||
kp = reach.geometry.get_kp()
|
||||
water_z = max(profile.get_key("Z"))
|
||||
|
||||
self.water_max, = self.canvas.axes.plot(
|
||||
[min(x), max(x)], [water_z, water_z],
|
||||
label=self.label_water_max,
|
||||
linestyle='dotted',
|
||||
lw=1., color=self.color_plot_river_water,
|
||||
)
|
||||
|
||||
def set_reach(self, reach_id):
|
||||
self._current_reach_id = reach_id
|
||||
|
|
@ -118,52 +139,51 @@ class PlotAC(PamhyrPlot):
|
|||
|
||||
def set_timestamp(self, timestamp):
|
||||
self._current_timestamp = timestamp
|
||||
self.update_poly()
|
||||
|
||||
reach = self.results.river.reach(self._current_reach_id)
|
||||
profile = reach.profile(self._current_profile_id)
|
||||
x = profile.geometry.get_station()
|
||||
z = profile.geometry.z()
|
||||
|
||||
self.update_water(reach, profile, x, z)
|
||||
self.update_idle()
|
||||
|
||||
def update(self):
|
||||
if not self._init:
|
||||
self.draw()
|
||||
|
||||
reach = self.results.river.reach(self._current_reach_id)
|
||||
profile = reach.profile(self._current_profile_id)
|
||||
x = profile.geometry.get_station()
|
||||
z = profile.geometry.z()
|
||||
|
||||
self.update_river_bottom(reach, profile, x, z)
|
||||
self.update_water(reach, profile, x, z)
|
||||
self.update_water_max(reach, profile, x, z)
|
||||
|
||||
self.update_idle()
|
||||
|
||||
def update_river_bottom(self, reach, profile, x, z):
|
||||
self.line_kp.set_data(x, z)
|
||||
|
||||
self.canvas.axes.set_xlim(
|
||||
left=min(x), right=max(x)
|
||||
)
|
||||
|
||||
kp = reach.geometry.get_kp()
|
||||
|
||||
# Water elevation
|
||||
def update_water(self, reach, profile, x, z):
|
||||
water_z = profile.get_ts_key(self._current_timestamp, "Z")
|
||||
|
||||
self.water.set_data([min(x), max(x)], [water_z, water_z])
|
||||
self.water.set_data(
|
||||
[min(x), max(x)],
|
||||
[water_z, water_z]
|
||||
)
|
||||
|
||||
self.collection.remove()
|
||||
self.collection = self.canvas.axes.fill_between(
|
||||
x, z, water_z,
|
||||
where=z <= water_z,
|
||||
color='skyblue', alpha=0.7, interpolate=True
|
||||
color=self.color_plot_river_water_zone,
|
||||
alpha=0.7, interpolate=True
|
||||
)
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
|
||||
def update_poly(self):
|
||||
|
||||
reach = self.results.river.reach(self._current_reach_id)
|
||||
profile = reach.profile(self._current_profile_id)
|
||||
x = profile.geometry.get_station()
|
||||
z = profile.geometry.z()
|
||||
|
||||
# Water elevation
|
||||
water_z = profile.get_ts_key(self._current_timestamp, "Z")
|
||||
|
||||
self.water.set_data([min(x), max(x)], [water_z, water_z])
|
||||
|
||||
self.collection.remove()
|
||||
self.collection = self.canvas.axes.fill_between(
|
||||
x, z, water_z,
|
||||
where=z <= water_z,
|
||||
color='skyblue', alpha=0.7, interpolate=True
|
||||
def update_water_max(self, reach, profile, x, z):
|
||||
water_z = max(profile.get_key("Z"))
|
||||
self.water_max.set_data(
|
||||
[min(x), max(x)],
|
||||
[water_z, water_z]
|
||||
)
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
|
|
|
|||
|
|
@ -60,8 +60,8 @@ class PlotH(PamhyrPlot):
|
|||
|
||||
self._isometric_axis = False
|
||||
|
||||
self._auto_relim_update = True
|
||||
self._autoscale_update = True
|
||||
self._auto_relim_update = False
|
||||
self._autoscale_update = False
|
||||
|
||||
@property
|
||||
def results(self):
|
||||
|
|
@ -145,7 +145,6 @@ class PlotH(PamhyrPlot):
|
|||
**self.plot_default_kargs
|
||||
)
|
||||
|
||||
|
||||
def set_reach(self, reach_id):
|
||||
self._current_reach_id = reach_id
|
||||
self._current_profile_id = 0
|
||||
|
|
@ -160,6 +159,14 @@ class PlotH(PamhyrPlot):
|
|||
self.update()
|
||||
|
||||
def update(self):
|
||||
if not self._init:
|
||||
self.draw()
|
||||
|
||||
self.update_data()
|
||||
|
||||
self.update_idle()
|
||||
|
||||
def update_data(self):
|
||||
reach = self.results.river.reach(self._current_reach_id)
|
||||
profile = reach.profile(self._current_profile_id)
|
||||
|
||||
|
|
@ -172,6 +179,3 @@ class PlotH(PamhyrPlot):
|
|||
self._current_timestamp,
|
||||
y[self.ts.index(self._current_timestamp)]
|
||||
)
|
||||
|
||||
self.canvas.axes.relim()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
|
|
|
|||
Loading…
Reference in New Issue