envelop optional

compare_results
Theophile Terraz 2024-11-04 16:32:44 +01:00
parent 5f043468ee
commit b21b6be9ca
3 changed files with 127 additions and 105 deletions

View File

@ -42,6 +42,7 @@ class CustomPlotValuesSelectionDialog(PamhyrDialog):
self._available_values_y = self._trad.get_dict("values_y") self._available_values_y = self._trad.get_dict("values_y")
self.setup_radio_buttons() self.setup_radio_buttons()
self.setup_envelop_box()
self.setup_check_boxs() self.setup_check_boxs()
self.value = None self.value = None
@ -61,6 +62,24 @@ class CustomPlotValuesSelectionDialog(PamhyrDialog):
self._radio[0][1].setChecked(True) self._radio[0][1].setChecked(True)
layout.addStretch() 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): def setup_check_boxs(self):
self._check = [] self._check = []
layout = self.find(QVBoxLayout, "verticalLayout_y") 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() super().accept()

View File

@ -46,7 +46,7 @@ unit = {
class CustomPlot(PamhyrPlot): 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, data=None, canvas=None, trad=None,
toolbar=None, parent=None): toolbar=None, parent=None):
super(CustomPlot, self).__init__( super(CustomPlot, self).__init__(
@ -59,6 +59,7 @@ class CustomPlot(PamhyrPlot):
self._x = x self._x = x
self._y = y self._y = y
self._envelop = envelop
self._reach = reach self._reach = reach
self._profile = profile self._profile = profile
self._timestamp = timestamp self._timestamp = timestamp
@ -134,37 +135,37 @@ class CustomPlot(PamhyrPlot):
color='blue', alpha=0.5, interpolate=True 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( d = list(
map( map(
lambda p: max(p.get_key("Z")), lambda p: max(p.get_key("Z")),
reach.profiles reach.profiles
)
) )
)
line1 = ax.plot( line1 = ax.plot(
rk, d, lw=1., rk, d, lw=1.,
color='blue', color='blue',
linestyle='dotted', linestyle='dotted',
)
self.lines["water_elevation_envelop"] = line1
d = list(
map(
lambda p: min(p.get_key("Z")),
reach.profiles
) )
) self.lines["water_elevation_envelop"] = line1
line2 = ax.plot( d = list(
rk, d, lw=1., map(
color='blue', lambda p: min(p.get_key("Z")),
linestyle='dotted', reach.profiles
) )
#self.lines["water_elevation_envelop2"] = line2 )
line2 = ax.plot(
rk, d, lw=1.,
color='blue',
linestyle='dotted',
)
#self.lines["water_elevation_envelop2"] = line2
if "discharge" in self._y: if "discharge" in self._y:
@ -175,35 +176,35 @@ class CustomPlot(PamhyrPlot):
) )
self.lines["discharge"] = line 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( q1 = list(
map( map(
lambda p: max(p.get_key("Q")), lambda p: max(p.get_key("Q")),
reach.profiles reach.profiles
)
) )
) line1 = ax.plot(
line1 = ax.plot( rk, q1, lw=1.,
rk, q1, lw=1., color='r',
color='r', linestyle='dotted',
linestyle='dotted',
)
self.lines["discharge_envelop"] = line1
q2 = list(
map(
lambda p: min(p.get_key("Q")),
reach.profiles
) )
) self.lines["discharge_envelop"] = line1
line2 = ax.plot(
rk, q2, lw=1., q2 = list(
color='r', map(
linestyle='dotted', lambda p: min(p.get_key("Q")),
) reach.profiles
#self.lines["discharge_envelop2"] = line2 )
)
line2 = ax.plot(
rk, q2, lw=1.,
color='r',
linestyle='dotted',
)
#self.lines["discharge_envelop2"] = line2
if "velocity" in self._y: if "velocity" in self._y:
@ -223,33 +224,33 @@ class CustomPlot(PamhyrPlot):
) )
self.lines["velocity"] = line self.lines["velocity"] = line
#if "velocity_envelop" in self._y: if self._envelop:
velocities = list(map(lambda p: velocities = list(map(lambda p:
list(map(lambda q, z: list(map(lambda q, z:
p.geometry.speed(q, z), p.geometry.speed(q, z),
p.get_key("Q"), p.get_key("Z") p.get_key("Q"), p.get_key("Z")
)), reach.profiles )), reach.profiles
)
) )
)
ax = self._axes[unit["velocity_envelop"]] ax = self._axes[unit["velocity_envelop"]]
vmax = [max(v) for v in velocities] vmax = [max(v) for v in velocities]
line1 = ax.plot( line1 = ax.plot(
rk, vmax, lw=1., rk, vmax, lw=1.,
color='g', color='g',
linestyle='dotted', linestyle='dotted',
) )
self.lines["velocity_envelop"] = line1 self.lines["velocity_envelop"] = line1
vmin = [min(v) for v in velocities] vmin = [min(v) for v in velocities]
line2 = ax.plot( line2 = ax.plot(
rk, vmin, lw=1., rk, vmin, lw=1.,
color='g', color='g',
linestyle='dotted', linestyle='dotted',
) )
#self.lines["velocity_envelop2"] = line2 #self.lines["velocity_envelop2"] = line2
if "depth" in self._y: if "depth" in self._y:
@ -267,35 +268,35 @@ class CustomPlot(PamhyrPlot):
) )
self.lines["depth"] = line 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, d = list(map(lambda p1, p2: p1 - p2,
map( map(
lambda p: max(p.get_key("Z")), lambda p: max(p.get_key("Z")),
reach.profiles reach.profiles
), z_min) ), z_min)
) )
line1 = ax.plot( line1 = ax.plot(
rk, d, rk, d,
color='brown', lw=1., color='brown', lw=1.,
linestyle='dotted', linestyle='dotted',
) )
self.lines["depth_envelop"] = line1 self.lines["depth_envelop"] = line1
d = list(map(lambda p1, p2: p1 - p2, d = list(map(lambda p1, p2: p1 - p2,
map( map(
lambda p: min(p.get_key("Z")), lambda p: min(p.get_key("Z")),
reach.profiles reach.profiles
), z_min) ), z_min)
) )
line2 = ax.plot( line2 = ax.plot(
rk, d, rk, d,
color='brown', lw=1., color='brown', lw=1.,
linestyle='dotted', linestyle='dotted',
) )
#self.lines["depth_envelop2"] = line2 #self.lines["depth_envelop2"] = line2
if "mean_depth" in self._y: if "mean_depth" in self._y:

View File

@ -490,11 +490,13 @@ class ResultsWindow(PamhyrWindow):
def _add_custom_plot(self): def _add_custom_plot(self):
dlg = CustomPlotValuesSelectionDialog(parent=self) dlg = CustomPlotValuesSelectionDialog(parent=self)
if dlg.exec(): if dlg.exec():
x, y = dlg.value x, y, envelop = dlg.value
self.create_new_tab_custom_plot(x, y) 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)}" name = f"{x}: {','.join(y)}"
if envelop and x == "rk":
name += "_envelop"
wname = f"tab_custom_{x}_{y}" wname = f"tab_custom_{x}_{y}"
tab_widget = self.find(QTabWidget, f"tabWidget") tab_widget = self.find(QTabWidget, f"tabWidget")
@ -518,7 +520,7 @@ class ResultsWindow(PamhyrWindow):
) )
plot = CustomPlot( plot = CustomPlot(
x, y, x, y, envelop,
self._get_current_reach(), self._get_current_reach(),
self._get_current_profile(), self._get_current_profile(),
self._get_current_timestamp(), self._get_current_timestamp(),
@ -589,7 +591,7 @@ class ResultsWindow(PamhyrWindow):
dlg = CustomPlotValuesSelectionDialog(parent=self) dlg = CustomPlotValuesSelectionDialog(parent=self)
if dlg.exec(): if dlg.exec():
x, y = dlg.value x, y, = dlg.value
else: else:
return return