mirror of https://gitlab.com/pamhyr/pamhyr2
envelop optional
parent
5f043468ee
commit
b21b6be9ca
|
|
@ -42,6 +42,7 @@ class CustomPlotValuesSelectionDialog(PamhyrDialog):
|
|||
self._available_values_y = self._trad.get_dict("values_y")
|
||||
|
||||
self.setup_radio_buttons()
|
||||
self.setup_envelop_box()
|
||||
self.setup_check_boxs()
|
||||
|
||||
self.value = None
|
||||
|
|
@ -61,6 +62,24 @@ class CustomPlotValuesSelectionDialog(PamhyrDialog):
|
|||
self._radio[0][1].setChecked(True)
|
||||
layout.addStretch()
|
||||
|
||||
def setup_envelop_box(self):
|
||||
self._envelop = []
|
||||
layout = self.find(QVBoxLayout, "verticalLayout_x")
|
||||
self._envelop = QCheckBox(
|
||||
"envelop",
|
||||
parent=self
|
||||
)
|
||||
layout.addWidget(self._envelop)
|
||||
self._envelop.setChecked(True)
|
||||
for r in self._radio:
|
||||
r[1].clicked.connect(self.envelop_box_status)
|
||||
|
||||
def envelop_box_status(self):
|
||||
if self._radio[0][1].isChecked():
|
||||
self._envelop.setEnabled(True)
|
||||
else:
|
||||
self._envelop.setEnabled(False)
|
||||
|
||||
def setup_check_boxs(self):
|
||||
self._check = []
|
||||
layout = self.find(QVBoxLayout, "verticalLayout_y")
|
||||
|
|
@ -94,6 +113,6 @@ class CustomPlotValuesSelectionDialog(PamhyrDialog):
|
|||
)
|
||||
)
|
||||
|
||||
self.value = x, y
|
||||
self.value = x, y, self._envelop.isChecked()
|
||||
|
||||
super().accept()
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ unit = {
|
|||
|
||||
|
||||
class CustomPlot(PamhyrPlot):
|
||||
def __init__(self, x, y, reach, profile, timestamp,
|
||||
def __init__(self, x, y, envelop, reach, profile, timestamp,
|
||||
data=None, canvas=None, trad=None,
|
||||
toolbar=None, parent=None):
|
||||
super(CustomPlot, self).__init__(
|
||||
|
|
@ -59,6 +59,7 @@ class CustomPlot(PamhyrPlot):
|
|||
|
||||
self._x = x
|
||||
self._y = y
|
||||
self._envelop = envelop
|
||||
self._reach = reach
|
||||
self._profile = profile
|
||||
self._timestamp = timestamp
|
||||
|
|
@ -134,37 +135,37 @@ class CustomPlot(PamhyrPlot):
|
|||
color='blue', alpha=0.5, interpolate=True
|
||||
)
|
||||
|
||||
#if "water_elevation_envelop" in self._y:
|
||||
if self._envelop:
|
||||
|
||||
ax = self._axes[unit["water_elevation_envelop"]]
|
||||
ax = self._axes[unit["water_elevation_envelop"]]
|
||||
|
||||
d = list(
|
||||
map(
|
||||
lambda p: max(p.get_key("Z")),
|
||||
reach.profiles
|
||||
d = list(
|
||||
map(
|
||||
lambda p: max(p.get_key("Z")),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
line1 = ax.plot(
|
||||
rk, d, lw=1.,
|
||||
color='blue',
|
||||
linestyle='dotted',
|
||||
)
|
||||
self.lines["water_elevation_envelop"] = line1
|
||||
|
||||
d = list(
|
||||
map(
|
||||
lambda p: min(p.get_key("Z")),
|
||||
reach.profiles
|
||||
line1 = ax.plot(
|
||||
rk, d, lw=1.,
|
||||
color='blue',
|
||||
linestyle='dotted',
|
||||
)
|
||||
)
|
||||
self.lines["water_elevation_envelop"] = line1
|
||||
|
||||
line2 = ax.plot(
|
||||
rk, d, lw=1.,
|
||||
color='blue',
|
||||
linestyle='dotted',
|
||||
)
|
||||
#self.lines["water_elevation_envelop2"] = line2
|
||||
d = list(
|
||||
map(
|
||||
lambda p: min(p.get_key("Z")),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
|
||||
line2 = ax.plot(
|
||||
rk, d, lw=1.,
|
||||
color='blue',
|
||||
linestyle='dotted',
|
||||
)
|
||||
#self.lines["water_elevation_envelop2"] = line2
|
||||
|
||||
if "discharge" in self._y:
|
||||
|
||||
|
|
@ -175,35 +176,35 @@ class CustomPlot(PamhyrPlot):
|
|||
)
|
||||
self.lines["discharge"] = line
|
||||
|
||||
#if "discharge_envelop" in self._y:
|
||||
if self._envelop:
|
||||
|
||||
ax = self._axes[unit["discharge_envelop"]]
|
||||
ax = self._axes[unit["discharge_envelop"]]
|
||||
|
||||
q1 = list(
|
||||
map(
|
||||
lambda p: max(p.get_key("Q")),
|
||||
reach.profiles
|
||||
q1 = list(
|
||||
map(
|
||||
lambda p: max(p.get_key("Q")),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
)
|
||||
line1 = ax.plot(
|
||||
rk, q1, lw=1.,
|
||||
color='r',
|
||||
linestyle='dotted',
|
||||
)
|
||||
self.lines["discharge_envelop"] = line1
|
||||
|
||||
q2 = list(
|
||||
map(
|
||||
lambda p: min(p.get_key("Q")),
|
||||
reach.profiles
|
||||
line1 = ax.plot(
|
||||
rk, q1, lw=1.,
|
||||
color='r',
|
||||
linestyle='dotted',
|
||||
)
|
||||
)
|
||||
line2 = ax.plot(
|
||||
rk, q2, lw=1.,
|
||||
color='r',
|
||||
linestyle='dotted',
|
||||
)
|
||||
#self.lines["discharge_envelop2"] = line2
|
||||
self.lines["discharge_envelop"] = line1
|
||||
|
||||
q2 = list(
|
||||
map(
|
||||
lambda p: min(p.get_key("Q")),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
line2 = ax.plot(
|
||||
rk, q2, lw=1.,
|
||||
color='r',
|
||||
linestyle='dotted',
|
||||
)
|
||||
#self.lines["discharge_envelop2"] = line2
|
||||
|
||||
if "velocity" in self._y:
|
||||
|
||||
|
|
@ -223,33 +224,33 @@ class CustomPlot(PamhyrPlot):
|
|||
)
|
||||
self.lines["velocity"] = line
|
||||
|
||||
#if "velocity_envelop" in self._y:
|
||||
if self._envelop:
|
||||
|
||||
velocities = list(map(lambda p:
|
||||
list(map(lambda q, z:
|
||||
p.geometry.speed(q, z),
|
||||
p.get_key("Q"), p.get_key("Z")
|
||||
)), reach.profiles
|
||||
velocities = list(map(lambda p:
|
||||
list(map(lambda q, z:
|
||||
p.geometry.speed(q, z),
|
||||
p.get_key("Q"), p.get_key("Z")
|
||||
)), reach.profiles
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
ax = self._axes[unit["velocity_envelop"]]
|
||||
vmax = [max(v) for v in velocities]
|
||||
ax = self._axes[unit["velocity_envelop"]]
|
||||
vmax = [max(v) for v in velocities]
|
||||
|
||||
line1 = ax.plot(
|
||||
rk, vmax, lw=1.,
|
||||
color='g',
|
||||
linestyle='dotted',
|
||||
)
|
||||
self.lines["velocity_envelop"] = line1
|
||||
vmin = [min(v) for v in velocities]
|
||||
line1 = ax.plot(
|
||||
rk, vmax, lw=1.,
|
||||
color='g',
|
||||
linestyle='dotted',
|
||||
)
|
||||
self.lines["velocity_envelop"] = line1
|
||||
vmin = [min(v) for v in velocities]
|
||||
|
||||
line2 = ax.plot(
|
||||
rk, vmin, lw=1.,
|
||||
color='g',
|
||||
linestyle='dotted',
|
||||
)
|
||||
#self.lines["velocity_envelop2"] = line2
|
||||
line2 = ax.plot(
|
||||
rk, vmin, lw=1.,
|
||||
color='g',
|
||||
linestyle='dotted',
|
||||
)
|
||||
#self.lines["velocity_envelop2"] = line2
|
||||
|
||||
if "depth" in self._y:
|
||||
|
||||
|
|
@ -267,35 +268,35 @@ class CustomPlot(PamhyrPlot):
|
|||
)
|
||||
self.lines["depth"] = line
|
||||
|
||||
#if "depth_envelop" in self._y:
|
||||
if self._envelop:
|
||||
|
||||
ax = self._axes[unit["depth_envelop"]]
|
||||
ax = self._axes[unit["depth_envelop"]]
|
||||
|
||||
d = list(map(lambda p1, p2: p1 - p2,
|
||||
map(
|
||||
lambda p: max(p.get_key("Z")),
|
||||
reach.profiles
|
||||
), z_min)
|
||||
)
|
||||
line1 = ax.plot(
|
||||
rk, d,
|
||||
color='brown', lw=1.,
|
||||
linestyle='dotted',
|
||||
)
|
||||
self.lines["depth_envelop"] = line1
|
||||
d = list(map(lambda p1, p2: p1 - p2,
|
||||
map(
|
||||
lambda p: max(p.get_key("Z")),
|
||||
reach.profiles
|
||||
), z_min)
|
||||
)
|
||||
line1 = ax.plot(
|
||||
rk, d,
|
||||
color='brown', lw=1.,
|
||||
linestyle='dotted',
|
||||
)
|
||||
self.lines["depth_envelop"] = line1
|
||||
|
||||
d = list(map(lambda p1, p2: p1 - p2,
|
||||
map(
|
||||
lambda p: min(p.get_key("Z")),
|
||||
reach.profiles
|
||||
), z_min)
|
||||
)
|
||||
line2 = ax.plot(
|
||||
rk, d,
|
||||
color='brown', lw=1.,
|
||||
linestyle='dotted',
|
||||
)
|
||||
#self.lines["depth_envelop2"] = line2
|
||||
d = list(map(lambda p1, p2: p1 - p2,
|
||||
map(
|
||||
lambda p: min(p.get_key("Z")),
|
||||
reach.profiles
|
||||
), z_min)
|
||||
)
|
||||
line2 = ax.plot(
|
||||
rk, d,
|
||||
color='brown', lw=1.,
|
||||
linestyle='dotted',
|
||||
)
|
||||
#self.lines["depth_envelop2"] = line2
|
||||
|
||||
if "mean_depth" in self._y:
|
||||
|
||||
|
|
|
|||
|
|
@ -490,11 +490,13 @@ class ResultsWindow(PamhyrWindow):
|
|||
def _add_custom_plot(self):
|
||||
dlg = CustomPlotValuesSelectionDialog(parent=self)
|
||||
if dlg.exec():
|
||||
x, y = dlg.value
|
||||
self.create_new_tab_custom_plot(x, y)
|
||||
x, y, envelop = dlg.value
|
||||
self.create_new_tab_custom_plot(x, y, envelop)
|
||||
|
||||
def create_new_tab_custom_plot(self, x: str, y: list):
|
||||
def create_new_tab_custom_plot(self, x: str, y: list, envelop: bool):
|
||||
name = f"{x}: {','.join(y)}"
|
||||
if envelop and x == "rk":
|
||||
name += "_envelop"
|
||||
wname = f"tab_custom_{x}_{y}"
|
||||
|
||||
tab_widget = self.find(QTabWidget, f"tabWidget")
|
||||
|
|
@ -518,7 +520,7 @@ class ResultsWindow(PamhyrWindow):
|
|||
)
|
||||
|
||||
plot = CustomPlot(
|
||||
x, y,
|
||||
x, y, envelop,
|
||||
self._get_current_reach(),
|
||||
self._get_current_profile(),
|
||||
self._get_current_timestamp(),
|
||||
|
|
@ -589,7 +591,7 @@ class ResultsWindow(PamhyrWindow):
|
|||
|
||||
dlg = CustomPlotValuesSelectionDialog(parent=self)
|
||||
if dlg.exec():
|
||||
x, y = dlg.value
|
||||
x, y, = dlg.value
|
||||
else:
|
||||
return
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue