mirror of https://gitlab.com/pamhyr/pamhyr2
work on custom plots
parent
f96f9cc62f
commit
e823b3ae95
|
|
@ -90,33 +90,21 @@ class CustomPlot(PamhyrPlot):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
# self.canvas.axes.set_xlim(
|
|
||||||
# left=min(rk), right=max(rk)
|
|
||||||
# )
|
|
||||||
|
|
||||||
meter_axes = self.canvas.axes
|
|
||||||
#m3s_axes = meter_axes.twinx()
|
|
||||||
#ms_axes = meter_axes.twinx()
|
|
||||||
shift = 0
|
shift = 0
|
||||||
if "0-meter" in self._y_axes and "1-m3s" in self._y_axes:
|
compt = 0
|
||||||
m3s_axes = self._axes["1-m3s"]
|
for ax in sorted(self._axes):
|
||||||
m3s_axes.spines['right'].set_position(('outward', shift))
|
if compt == 0:
|
||||||
shift += 60
|
self._axes[ax].spines['left'].set_position(('outward', shift))
|
||||||
|
compt += 1
|
||||||
if "0-meter" in self._y_axes and "2-ms" in self._y_axes:
|
else:
|
||||||
ms_axes = self._axes["2-ms"]
|
self._axes[ax].spines['right'].set_position(('outward', shift))
|
||||||
ms_axes.spines['right'].set_position(('outward', shift))
|
|
||||||
shift += 60
|
shift += 60
|
||||||
|
|
||||||
lines = {}
|
lines = {}
|
||||||
if "elevation" in self._y:
|
if "elevation" in self._y:
|
||||||
|
|
||||||
# meter_axes.set_ylim(
|
ax = self._axes[unit["elevation"]]
|
||||||
# bottom=min(0, min(z_min)),
|
line = ax.plot(
|
||||||
# top=max(z_min) + 1
|
|
||||||
# )
|
|
||||||
|
|
||||||
line = meter_axes.plot(
|
|
||||||
rk, z_min,
|
rk, z_min,
|
||||||
color='grey', lw=1.,
|
color='grey', lw=1.,
|
||||||
)
|
)
|
||||||
|
|
@ -124,37 +112,31 @@ class CustomPlot(PamhyrPlot):
|
||||||
|
|
||||||
if "water_elevation" in self._y:
|
if "water_elevation" in self._y:
|
||||||
|
|
||||||
# meter_axes.set_ylim(
|
ax = self._axes[unit["water_elevation"]]
|
||||||
# bottom=min(0, min(z_min)),
|
line = ax.plot(
|
||||||
# top=max(z) + 1
|
|
||||||
# )
|
|
||||||
|
|
||||||
line = meter_axes.plot(
|
|
||||||
rk, z, lw=1.,
|
rk, z, lw=1.,
|
||||||
color='blue',
|
color='blue',
|
||||||
)
|
)
|
||||||
lines["water_elevation"] = line
|
lines["water_elevation"] = line
|
||||||
|
|
||||||
if "elevation" in self._y:
|
if "elevation" in self._y:
|
||||||
meter_axes.fill_between(
|
ax.fill_between(
|
||||||
rk, z_min, z,
|
rk, z_min, z,
|
||||||
color='blue', alpha=0.5, interpolate=True
|
color='blue', alpha=0.5, interpolate=True
|
||||||
)
|
)
|
||||||
|
|
||||||
if "discharge" in self._y:
|
if "discharge" in self._y:
|
||||||
|
|
||||||
# m3s_axes.set_ylim(
|
ax = self._axes[unit["discharge"]]
|
||||||
# bottom=min(0, min(q)),
|
line = ax.plot(
|
||||||
# top=max(q) + 1
|
|
||||||
# )
|
|
||||||
|
|
||||||
line = m3s_axes.plot(
|
|
||||||
rk, q, lw=1.,
|
rk, q, lw=1.,
|
||||||
color='r',
|
color='r',
|
||||||
)
|
)
|
||||||
lines["discharge"] = line
|
lines["discharge"] = line
|
||||||
|
|
||||||
if "velocity" in self._y:
|
if "velocity" in self._y:
|
||||||
|
|
||||||
|
ax = self._axes[unit["velocity"]]
|
||||||
v = list(
|
v = list(
|
||||||
map(
|
map(
|
||||||
lambda p: p.geometry.speed(
|
lambda p: p.geometry.speed(
|
||||||
|
|
@ -164,12 +146,7 @@ class CustomPlot(PamhyrPlot):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
# m3s_axes.set_ylim(
|
line = ax.plot(
|
||||||
# bottom=min(0, min(q)),
|
|
||||||
# top=max(q) + 1
|
|
||||||
# )
|
|
||||||
|
|
||||||
line = ms_axes.plot(
|
|
||||||
rk, v, lw=1.,
|
rk, v, lw=1.,
|
||||||
color='g',
|
color='g',
|
||||||
)
|
)
|
||||||
|
|
@ -229,18 +206,14 @@ class CustomPlot(PamhyrPlot):
|
||||||
reach = results.river.reach(self._reach)
|
reach = results.river.reach(self._reach)
|
||||||
profile = reach.profile(self._profile)
|
profile = reach.profile(self._profile)
|
||||||
|
|
||||||
meter_axes = self.canvas.axes
|
|
||||||
#m3s_axes = meter_axes.twinx()
|
|
||||||
#ms_axes = meter_axes.twinx()
|
|
||||||
shift = 0
|
shift = 0
|
||||||
if "0-meter" in self._y_axes and "1-m3s" in self._y_axes:
|
compt = 0
|
||||||
m3s_axes = self._axes["1-m3s"]
|
for ax in sorted(self._axes):
|
||||||
m3s_axes.spines['right'].set_position(('outward', shift))
|
if compt == 0:
|
||||||
shift += 60
|
self._axes[ax].spines['left'].set_position(('outward', shift))
|
||||||
|
compt += 1
|
||||||
if "0-meter" in self._y_axes and "2-ms" in self._y_axes:
|
else:
|
||||||
ms_axes = self._axes["2-ms"]
|
self._axes[ax].spines['right'].set_position(('outward', shift))
|
||||||
ms_axes.spines['right'].set_position(('outward', shift))
|
|
||||||
shift += 60
|
shift += 60
|
||||||
|
|
||||||
ts = list(results.get("timestamps"))
|
ts = list(results.get("timestamps"))
|
||||||
|
|
@ -249,14 +222,11 @@ class CustomPlot(PamhyrPlot):
|
||||||
q = profile.get_key("Q")
|
q = profile.get_key("Q")
|
||||||
z = profile.get_key("Z")
|
z = profile.get_key("Z")
|
||||||
|
|
||||||
# self.canvas.axes.set_xlim(
|
|
||||||
# left=min(ts), right=max(ts)
|
|
||||||
# )
|
|
||||||
|
|
||||||
x = ts
|
|
||||||
lines = {}
|
lines = {}
|
||||||
if "elevation" in self._y:
|
if "elevation" in self._y:
|
||||||
# Z min is constant in time
|
# Z min is constant in time
|
||||||
|
|
||||||
|
ax = self._axes[unit["elevation"]]
|
||||||
z_min = profile.geometry.z_min()
|
z_min = profile.geometry.z_min()
|
||||||
ts_z_min = list(
|
ts_z_min = list(
|
||||||
map(
|
map(
|
||||||
|
|
@ -265,7 +235,7 @@ class CustomPlot(PamhyrPlot):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
line = meter_axes.plot(
|
line = ax.plot(
|
||||||
ts, ts_z_min,
|
ts, ts_z_min,
|
||||||
color='grey', lw=1.
|
color='grey', lw=1.
|
||||||
)
|
)
|
||||||
|
|
@ -273,12 +243,8 @@ class CustomPlot(PamhyrPlot):
|
||||||
|
|
||||||
if "water_elevation" in self._y:
|
if "water_elevation" in self._y:
|
||||||
|
|
||||||
# meter_axes.set_ylim(
|
ax = self._axes[unit["water_elevation"]]
|
||||||
# bottom=min(0, min(z)),
|
line = ax.plot(
|
||||||
# top=max(z) + 1
|
|
||||||
# )
|
|
||||||
|
|
||||||
line = meter_axes.plot(
|
|
||||||
ts, z, lw=1.,
|
ts, z, lw=1.,
|
||||||
color='b',
|
color='b',
|
||||||
)
|
)
|
||||||
|
|
@ -293,19 +259,15 @@ class CustomPlot(PamhyrPlot):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
meter_axes.fill_between(
|
ax.fill_between(
|
||||||
ts, ts_z_min, z,
|
ts, ts_z_min, z,
|
||||||
color='blue', alpha=0.5, interpolate=True
|
color='blue', alpha=0.5, interpolate=True
|
||||||
)
|
)
|
||||||
|
|
||||||
if "discharge" in self._y:
|
if "discharge" in self._y:
|
||||||
|
|
||||||
# m3s_axes.set_ylim(
|
ax = self._axes[unit["discharge"]]
|
||||||
# bottom=min(0, min(q)),
|
line = ax.plot(
|
||||||
# top=max(q) + 1
|
|
||||||
# )
|
|
||||||
|
|
||||||
line = m3s_axes.plot(
|
|
||||||
ts, q, lw=1.,
|
ts, q, lw=1.,
|
||||||
color='r',
|
color='r',
|
||||||
)
|
)
|
||||||
|
|
@ -313,6 +275,7 @@ class CustomPlot(PamhyrPlot):
|
||||||
|
|
||||||
if "velocity" in self._y:
|
if "velocity" in self._y:
|
||||||
|
|
||||||
|
ax = self._axes[unit["velocity"]]
|
||||||
v = list(
|
v = list(
|
||||||
map(
|
map(
|
||||||
lambda q, z: profile.geometry.speed(q, z),
|
lambda q, z: profile.geometry.speed(q, z),
|
||||||
|
|
@ -320,12 +283,7 @@ class CustomPlot(PamhyrPlot):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
# ms_axes.set_ylim(
|
line = ax.plot(
|
||||||
# bottom=min(0, min(q)),
|
|
||||||
# top=max(q) + 1
|
|
||||||
# )
|
|
||||||
|
|
||||||
line = ms_axes.plot(
|
|
||||||
ts, v, lw=1.,
|
ts, v, lw=1.,
|
||||||
color='g',
|
color='g',
|
||||||
)
|
)
|
||||||
|
|
@ -360,6 +318,7 @@ class CustomPlot(PamhyrPlot):
|
||||||
color='black', fontsize=10
|
color='black', fontsize=10
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self._axes[self._y_axes[0]] = self.canvas.axes
|
||||||
for axes in self._y_axes[1:]:
|
for axes in self._y_axes[1:]:
|
||||||
if axes in self._axes:
|
if axes in self._axes:
|
||||||
self._axes[axes].clear()
|
self._axes[axes].clear()
|
||||||
|
|
@ -377,7 +336,6 @@ class CustomPlot(PamhyrPlot):
|
||||||
elif self._x == "time":
|
elif self._x == "time":
|
||||||
self._draw_time()
|
self._draw_time()
|
||||||
|
|
||||||
#self.canvas.figure.tight_layout()
|
|
||||||
self.canvas.figure.canvas.draw_idle()
|
self.canvas.figure.canvas.draw_idle()
|
||||||
if self.toolbar is not None:
|
if self.toolbar is not None:
|
||||||
self.toolbar.update()
|
self.toolbar.update()
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,12 @@ class CustomPlotTranslate(ResultsTranslate):
|
||||||
"CustomPlot", "Bed elevation (m)"
|
"CustomPlot", "Bed elevation (m)"
|
||||||
)
|
)
|
||||||
self._dict['velocity'] = self._dict["unit_speed"]
|
self._dict['velocity'] = self._dict["unit_speed"]
|
||||||
|
self._dict['width'] = self._dict["unit_width"],
|
||||||
|
self._dict['max_depth'] = self._dict["unit_max_height"],
|
||||||
|
self._dict['mean_depth'] = self._dict["unit_mean_height"],
|
||||||
|
self._dict['wet_area'] = self._dict["unit_wet_area"],
|
||||||
|
self._dict['wet_perimeter'] = self._dict["unit_wet_perimeter"],
|
||||||
|
self._dict['hydraulic_radius'] = self._dict["unit_hydraulic_radius"],
|
||||||
|
|
||||||
# Unit corresponding long name (plot axes display)
|
# Unit corresponding long name (plot axes display)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -507,7 +507,7 @@ class ResultsWindow(PamhyrWindow):
|
||||||
tab_widget = self.find(QTabWidget, f"tabWidget")
|
tab_widget = self.find(QTabWidget, f"tabWidget")
|
||||||
|
|
||||||
# This plot already exists
|
# This plot already exists
|
||||||
if name in self._additional_plot:
|
if name in [tab_widget.tabText(i) for i in range(tab_widget.count())]:
|
||||||
tab_widget.setCurrentWidget(
|
tab_widget.setCurrentWidget(
|
||||||
tab_widget.findChild(QWidget, wname)
|
tab_widget.findChild(QWidget, wname)
|
||||||
)
|
)
|
||||||
|
|
@ -536,9 +536,6 @@ class ResultsWindow(PamhyrWindow):
|
||||||
)
|
)
|
||||||
plot.draw()
|
plot.draw()
|
||||||
|
|
||||||
# Add plot to additional plot
|
|
||||||
self._additional_plot[name] = plot
|
|
||||||
|
|
||||||
grid.addWidget(toolbar, 0, 0)
|
grid.addWidget(toolbar, 0, 0)
|
||||||
grid.addWidget(canvas, 1, 0)
|
grid.addWidget(canvas, 1, 0)
|
||||||
widget.setLayout(grid)
|
widget.setLayout(grid)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue