mirror of https://gitlab.com/pamhyr/pamhyr2
Results: CustomPlot: Fix kp / elevation, water_elevation and discharge drawing.
parent
4605950b94
commit
f73000056c
|
|
@ -23,12 +23,14 @@ from functools import reduce
|
|||
from tools import timer
|
||||
from View.Tools.PamhyrPlot import PamhyrPlot
|
||||
|
||||
from View.Results.CustomPlot.Translate import CustomPlotTranslate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
unit = {
|
||||
"elevation": "meter",
|
||||
"water_elevation": "meter",
|
||||
"discharge": "m3s",
|
||||
"elevation": "0-meter",
|
||||
"water_elevation": "0-meter",
|
||||
"discharge": "1-m3s",
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -38,7 +40,7 @@ class CustomPlot(PamhyrPlot):
|
|||
toolbar=None, parent=None):
|
||||
super(CustomPlot, self).__init__(
|
||||
canvas=canvas,
|
||||
trad=trad,
|
||||
trad=CustomPlotTranslate(),
|
||||
data=data,
|
||||
toolbar=toolbar,
|
||||
parent=parent
|
||||
|
|
@ -57,10 +59,10 @@ class CustomPlot(PamhyrPlot):
|
|||
f"timestamp={timestamp}"
|
||||
)
|
||||
|
||||
self._y_axis = list(
|
||||
self._y_axes = sorted(
|
||||
set(
|
||||
map(
|
||||
lambda y: self._trad[y],
|
||||
lambda y: unit[y],
|
||||
self._y
|
||||
)
|
||||
)
|
||||
|
|
@ -78,26 +80,91 @@ class CustomPlot(PamhyrPlot):
|
|||
self._trad[self._x],
|
||||
color='green', fontsize=12
|
||||
)
|
||||
|
||||
self.canvas.axes.set_ylabel(
|
||||
self._trad[self._y_axis[0]],
|
||||
self._trad[self._y_axes[0]],
|
||||
color='green', fontsize=12
|
||||
)
|
||||
|
||||
for axes in self._y_axis[1:]:
|
||||
logger.info(axes)
|
||||
ax_new = ax.twinx()
|
||||
self._axes = {}
|
||||
for axes in self._y_axes[1:]:
|
||||
ax_new = self.canvas.axes.twinx()
|
||||
ax_new.set_ylabel(
|
||||
self._trad[axes],
|
||||
color='green', fontsize=12
|
||||
)
|
||||
self._axes[axes] = ax_new
|
||||
|
||||
if self._x is "kp":
|
||||
results = self.data
|
||||
reach = results.river.reach(self._reach)
|
||||
kp = reach.geometry.get_kp()
|
||||
z_min = reach.geometry.get_z_min()
|
||||
|
||||
self.canvas.axes.set_xlim(
|
||||
left=min(kp), right=max(kp)
|
||||
)
|
||||
|
||||
meter_axes = self.canvas.axes
|
||||
m3S_axes = self.canvas.axes
|
||||
if "0-meter" in self._y_axes and "1-m3s" in self._y_axes:
|
||||
m3s_axes = self._axes["1-m3s"]
|
||||
|
||||
if "elevation" in self._y:
|
||||
logging.info("TODO: kp/elevation")
|
||||
meter_axes.set_ylim(
|
||||
bottom=min(0, min(z_min)),
|
||||
top=max(z_min) + 1
|
||||
)
|
||||
|
||||
meter_axes.plot(
|
||||
kp, z_min,
|
||||
color='grey', lw=1.
|
||||
)
|
||||
|
||||
if "water_elevation" in self._y:
|
||||
logging.info("TODO: kp/water_elevation")
|
||||
# Water elevation
|
||||
water_z = list(
|
||||
map(
|
||||
lambda p: p.get_ts_key(self._timestamp, "Z"),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
meter_axes.set_ylim(
|
||||
bottom=min(0, min(z_min)),
|
||||
top=max(water_z) + 1
|
||||
)
|
||||
|
||||
meter_axes.plot(
|
||||
kp, water_z, lw=1.,
|
||||
color='b',
|
||||
)
|
||||
|
||||
if "elevation" in self._y:
|
||||
meter_axes.fill_between(
|
||||
kp, z_min, water_z,
|
||||
color='blue', alpha=0.5, interpolate=True
|
||||
)
|
||||
|
||||
if "discharge" in self._y:
|
||||
logging.info("TODO: kp/discharge")
|
||||
q = list(
|
||||
map(
|
||||
lambda p: p.get_ts_key(self._timestamp, "Q"),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
|
||||
m3s_axes.set_ylim(
|
||||
bottom=min(0, min(q)),
|
||||
top=max(q) + 1
|
||||
)
|
||||
|
||||
m3s_axes.plot(
|
||||
kp, q, lw=1.,
|
||||
color='r',
|
||||
)
|
||||
|
||||
elif self._x is "time":
|
||||
if "elevation" in self._y:
|
||||
logging.info("TODO: time/elevation")
|
||||
|
|
|
|||
|
|
@ -47,10 +47,10 @@ class CustomPlotTranslate(ResultsTranslate):
|
|||
|
||||
# Unit corresponding long name (plot axes display)
|
||||
|
||||
self._dict['meter'] = _translate(
|
||||
self._dict['0-meter'] = _translate(
|
||||
"CustomPlot", "Elevation (m)"
|
||||
)
|
||||
self._dict['m3s'] = _translate(
|
||||
self._dict['1-m3s'] = _translate(
|
||||
"CustomPlot", "Discharge (m³/s)"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -467,7 +467,6 @@ class ResultsWindow(PamhyrWindow):
|
|||
data=self._results,
|
||||
canvas=canvas,
|
||||
toolbar=toolbar,
|
||||
trad=self._trad,
|
||||
parent=self,
|
||||
)
|
||||
plot.draw()
|
||||
|
|
|
|||
Loading…
Reference in New Issue