optim visu

setup.py
Theophile Terraz 2023-12-01 14:05:00 +01:00
parent 2d3e214514
commit eb26eba131
5 changed files with 96 additions and 34 deletions

View File

@ -18,6 +18,7 @@
from tools import timer
from View.Tools.PamhyrPlot import PamhyrPlot
from matplotlib import pyplot as plt
from PyQt5.QtCore import (
QCoreApplication
@ -89,17 +90,17 @@ class PlotAC(PamhyrPlot):
# Water elevation
water_z = profile.get_ts_key(self._current_timestamp, "Z")
self.canvas.axes.plot(
self.water, = self.canvas.axes.plot(
[min(x), max(x)], [water_z, water_z],
lw=1., color='b',
)
x_z = list(map(lambda _: water_z, x))
self.canvas.axes.fill_between(
self.collection = self.canvas.axes.fill_between(
x, z, water_z,
where=z <= water_z,
color='blue', alpha=0.5, interpolate=True
color='skyblue', alpha=0.7, interpolate=True
)
self.liste_chemins = self.collection.get_paths()
self.canvas.figure.tight_layout()
self.canvas.figure.canvas.draw_idle()
@ -109,15 +110,60 @@ class PlotAC(PamhyrPlot):
def set_reach(self, reach_id):
self._current_reach_id = reach_id
self._current_profile_id = 0
self.draw()
self.update()
def set_profile(self, profile_id):
self._current_profile_id = profile_id
self.draw()
self.update()
def set_timestamp(self, timestamp):
self._current_timestamp = timestamp
self.draw()
self.update_poly()
def update(self):
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.line_kp.set_data(x, z)
self.canvas.axes.set_xlim(
left=min(x), right=max(x)
)
kp = reach.geometry.get_kp()
# 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
)
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
)
self.canvas.figure.canvas.draw_idle()

View File

@ -89,21 +89,21 @@ class PlotH(PamhyrPlot):
color='black', fontsize=10
)
ts = list(self.results.get("timestamps"))
ts.sort()
self.ts = list(self.results.get("timestamps"))
self.ts.sort()
self.canvas.axes.set_xlim(
left=min(ts), right=max(ts)
left=min(self.ts), right=max(self.ts)
)
# Draw discharge for each timestamp
x = ts
x = self.ts
y = profile.get_key("Q")
if len(ts) != len(x):
if len(self.ts) != len(x):
logger.warning(
"Results as less Q data ({len(x)}) " +
"than timestamps ({len(ts)}) " +
"than timestamps ({len(self.ts)}) " +
"for profile {self._current_profile_id}"
)
return
@ -112,13 +112,11 @@ class PlotH(PamhyrPlot):
[min(min(y), 0), max(y) + 10]
)
self._line = [
self.canvas.axes.plot(
self._line, = self.canvas.axes.plot(
x, y, lw=1.,
color='r',
markersize=3, marker='+'
)
]
# Custom time display
nb = len(x)
@ -169,15 +167,20 @@ class PlotH(PamhyrPlot):
def set_reach(self, reach_id):
self._current_reach_id = reach_id
self._current_profile_id = 0
self.draw()
self.update()
def set_profile(self, profile_id):
self._current_profile_id = profile_id
self.draw()
self.update()
def set_timestamp(self, timestamp):
self._current_timestamp = timestamp
self.draw()
#self.update()
def update(self):
self.draw()
reach = self.results.river.reach(self._current_reach_id)
profile = reach.profile(self._current_profile_id)
x = self.ts
y = profile.get_key("Q")
self._line.set_data(x,y)
self.canvas.figure.canvas.draw_idle()

View File

@ -72,6 +72,7 @@ class PlotKPC(PamhyrPlot):
kp = reach.geometry.get_kp()
z_min = reach.geometry.get_z_min()
z_max = reach.geometry.get_z_max()
self.canvas.axes.set_xlim(
left=min(kp), right=max(kp)
@ -103,6 +104,12 @@ class PlotKPC(PamhyrPlot):
color='blue', alpha=0.5, interpolate=True
)
self.profile, = self.canvas.axes.plot(
[kp[self._current_profile_id], kp[self._current_profile_id]],
[z_max[self._current_profile_id],z_min[self._current_profile_id]],
color='red', lw=1.
)
self.canvas.figure.tight_layout()
self.canvas.figure.canvas.draw_idle()
if self.toolbar is not None:
@ -111,15 +118,26 @@ class PlotKPC(PamhyrPlot):
def set_reach(self, reach_id):
self._current_reach_id = reach_id
self._current_profile_id = 0
self.draw()
self.update()
def set_profile(self, profile_id):
self._current_profile_id = profile_id
self.draw()
self.update_profil()
def set_timestamp(self, timestamp):
self._current_timestamp = timestamp
self.draw()
self.update()
def update(self):
self.draw()
def update_profil(self):
reach = self.results.river.reach(self._current_reach_id)
kp = reach.geometry.get_kp()
z_min = reach.geometry.get_z_min()
z_max = reach.geometry.get_z_max()
self.profile.set_data(
[kp[self._current_profile_id], kp[self._current_profile_id]],
[z_max[self._current_profile_id],z_min[self._current_profile_id]]
)
self.canvas.figure.canvas.draw_idle()

View File

@ -129,9 +129,9 @@ class PlotXY(PamhyrPlot):
profile.x(),
profile.y(),
lw=1., markersize=3,
marker='+', color="b"
color="r", marker='+'
)
self.plot_selected.set_visible(False)
self.plot_selected.set_visible(True)
poly_x = [0]
poly_y = [0]
@ -166,13 +166,8 @@ class PlotXY(PamhyrPlot):
# Current profile
profile = reach.profile(self._current_profile_id).geometry
self.plot_selected, = self.canvas.axes.plot(
profile.x(),
profile.y(),
lw=1., markersize=3,
marker='+', color="b"
)
self.plot_selected.set_visible(False)
self.plot_selected.set_data(profile.x(),profile.y())
self.plot_selected.set_visible(True)
self.canvas.draw_idle()
def update_poly(self):

View File

@ -140,7 +140,7 @@ class ResultsWindow(PamhyrWindow):
reach_id=0,
profile_id=0,
toolbar=self.toolbar,
display_current=False
display_current=True
)
self.plot_xy.draw()