mirror of https://gitlab.com/pamhyr/pamhyr2
allow to define height or discharge only
parent
70dcb1a6ee
commit
fe30a20882
|
|
@ -140,7 +140,6 @@ class Data(SQLSubModel):
|
||||||
reach=self._reach,
|
reach=self._reach,
|
||||||
status=self._status,
|
status=self._status,
|
||||||
)
|
)
|
||||||
|
|
||||||
return new
|
return new
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
@ -368,53 +367,68 @@ class InitialConditions(SQLSubModel):
|
||||||
key=lambda p: p.kp
|
key=lambda p: p.kp
|
||||||
)
|
)
|
||||||
|
|
||||||
def generate_growing_constante_height(self, height: float):
|
def generate_growing_constante_height(self, height: float, compute_discharge: bool):
|
||||||
self._data = []
|
|
||||||
|
|
||||||
profiles = self._reach.reach.profiles.copy()
|
profiles = self._reach.reach.profiles.copy()
|
||||||
self._sort_by_z_and_kp(profiles)
|
self._sort_by_z_and_kp(profiles)
|
||||||
|
|
||||||
incline = self._reach.reach.get_incline_median_mean()
|
|
||||||
logger.debug(f"incline = {incline}")
|
logger.debug(f"incline = {incline}")
|
||||||
|
|
||||||
previous_elevation = -99999.99
|
previous_elevation = -99999.99
|
||||||
for profile in profiles:
|
|
||||||
width = profile.width_approximation()
|
|
||||||
strickler = 25
|
|
||||||
discharge = (
|
|
||||||
((width * 0.8)
|
|
||||||
* strickler
|
|
||||||
* (height ** (5/3))
|
|
||||||
* (abs(incline) ** (0.5)))
|
|
||||||
)
|
|
||||||
|
|
||||||
elevation = max(
|
if compute_discharge:
|
||||||
profile.z_min() + height,
|
incline = self._reach.reach.get_incline_median_mean()
|
||||||
previous_elevation
|
self._data = []
|
||||||
)
|
for profile in profiles:
|
||||||
|
width = profile.width_approximation()
|
||||||
|
strickler = 25
|
||||||
|
discharge = (
|
||||||
|
((width * 0.8)
|
||||||
|
* strickler
|
||||||
|
* (height ** (5/3))
|
||||||
|
* (abs(incline) ** (0.5)))
|
||||||
|
)
|
||||||
|
|
||||||
logger.debug(f"({profile.kp}):")
|
elevation = max(
|
||||||
logger.debug(f" width = {width}")
|
profile.z_min() + height,
|
||||||
logger.debug(f" strickler = {strickler}")
|
previous_elevation
|
||||||
logger.debug(f" discharge = {discharge}")
|
)
|
||||||
|
|
||||||
new = Data(reach=self._reach, status=self._status)
|
logger.debug(f"({profile.kp}):")
|
||||||
new["kp"] = profile.kp
|
logger.debug(f" width = {width}")
|
||||||
new["discharge"] = discharge
|
logger.debug(f" strickler = {strickler}")
|
||||||
|
logger.debug(f" discharge = {discharge}")
|
||||||
|
|
||||||
new["elevation"] = elevation
|
new = Data(reach=self._reach, status=self._status)
|
||||||
|
new["kp"] = profile.kp
|
||||||
|
new["discharge"] = discharge
|
||||||
|
|
||||||
self._data.append(new)
|
new["elevation"] = elevation
|
||||||
previous_elevation = elevation
|
|
||||||
|
self._data.append(new)
|
||||||
|
else:
|
||||||
|
for data, profile in zip(self._data, profiles):
|
||||||
|
|
||||||
|
elevation = max(
|
||||||
|
profile.z_min() + height,
|
||||||
|
previous_elevation
|
||||||
|
)
|
||||||
|
data["elevation"] = elevation
|
||||||
|
previous_elevation = elevation
|
||||||
|
|
||||||
self._generate_resort_data(profiles)
|
self._generate_resort_data(profiles)
|
||||||
|
|
||||||
def generate_discharge(self, discharge: float):
|
def generate_discharge(self, discharge: float, compute_height: bool):
|
||||||
self._data = []
|
|
||||||
|
|
||||||
self._generate_height_estimation_from_discharge(
|
if compute_height:
|
||||||
discharge
|
self._data = []
|
||||||
)
|
|
||||||
|
self._generate_height_estimation_from_discharge(
|
||||||
|
discharge
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
for data in self._data:
|
||||||
|
data["discharge"] = discharge
|
||||||
|
|
||||||
def _generate_height_estimation_from_discharge(self, discharge: float):
|
def _generate_height_estimation_from_discharge(self, discharge: float):
|
||||||
profiles = self._reach.reach.profiles.copy()
|
profiles = self._reach.reach.profiles.copy()
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ from PyQt5.QtCore import (
|
||||||
|
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QDialogButtonBox, QComboBox, QUndoStack, QShortcut,
|
QDialogButtonBox, QComboBox, QUndoStack, QShortcut,
|
||||||
QDoubleSpinBox,
|
QDoubleSpinBox, QCheckBox,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -45,9 +45,11 @@ class DischargeDialog(PamhyrDialog):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.value = None
|
self.value = None
|
||||||
|
self.option = None
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
self.value = self.find(QDoubleSpinBox, "doubleSpinBox").value()
|
self.value = self.find(QDoubleSpinBox, "doubleSpinBox").value()
|
||||||
|
self.option = self.find(QCheckBox, "checkBox").isChecked()
|
||||||
super().accept()
|
super().accept()
|
||||||
|
|
||||||
def reject(self):
|
def reject(self):
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ from PyQt5.QtCore import (
|
||||||
|
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QDialogButtonBox, QComboBox, QUndoStack, QShortcut,
|
QDialogButtonBox, QComboBox, QUndoStack, QShortcut,
|
||||||
QDoubleSpinBox,
|
QDoubleSpinBox, QCheckBox,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -45,9 +45,11 @@ class HeightDialog(PamhyrDialog):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.value = None
|
self.value = None
|
||||||
|
self.option = None
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
self.value = self.find(QDoubleSpinBox, "doubleSpinBox").value()
|
self.value = self.find(QDoubleSpinBox, "doubleSpinBox").value()
|
||||||
|
self.option = self.find(QCheckBox, "checkBox").isChecked()
|
||||||
super().accept()
|
super().accept()
|
||||||
|
|
||||||
def reject(self):
|
def reject(self):
|
||||||
|
|
|
||||||
|
|
@ -289,10 +289,10 @@ class InitialConditionTableModel(PamhyrTableModel):
|
||||||
self._undo.redo()
|
self._undo.redo()
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
def generate(self, generator, param):
|
def generate(self, generator, param, option):
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
GenerateCommand(
|
GenerateCommand(
|
||||||
self._lst, generator, param
|
self._lst, generator, param, option
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
|
||||||
|
|
@ -174,11 +174,12 @@ class DuplicateCommand(QUndoCommand):
|
||||||
|
|
||||||
|
|
||||||
class GenerateCommand(QUndoCommand):
|
class GenerateCommand(QUndoCommand):
|
||||||
def __init__(self, ics, generator, param):
|
def __init__(self, ics, generator, param, option):
|
||||||
QUndoCommand.__init__(self)
|
QUndoCommand.__init__(self)
|
||||||
|
|
||||||
self._ics = ics
|
self._ics = ics
|
||||||
self._param = param
|
self._param = param
|
||||||
|
self._option = option
|
||||||
self._copy = self._ics.data
|
self._copy = self._ics.data
|
||||||
self._generator = generator
|
self._generator = generator
|
||||||
|
|
||||||
|
|
@ -187,6 +188,8 @@ class GenerateCommand(QUndoCommand):
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
if self._generator == "growing":
|
if self._generator == "growing":
|
||||||
self._ics.generate_growing_constante_height(self._param)
|
self._ics.generate_growing_constante_height(self._param,
|
||||||
|
self._option)
|
||||||
elif self._generator == "discharge":
|
elif self._generator == "discharge":
|
||||||
self._ics.generate_discharge(self._param)
|
self._ics.generate_discharge(self._param,
|
||||||
|
self._option)
|
||||||
|
|
|
||||||
|
|
@ -349,12 +349,14 @@ class InitialConditionsWindow(PamhyrWindow):
|
||||||
dlg = HeightDialog(trad=self._trad, parent=self)
|
dlg = HeightDialog(trad=self._trad, parent=self)
|
||||||
if dlg.exec():
|
if dlg.exec():
|
||||||
value = dlg.value
|
value = dlg.value
|
||||||
self._table.generate("growing", value)
|
compute_discharge = dlg.option
|
||||||
|
self._table.generate("growing", value, compute_discharge)
|
||||||
self._update()
|
self._update()
|
||||||
|
|
||||||
def generate_discharge(self):
|
def generate_discharge(self):
|
||||||
dlg = DischargeDialog(trad=self._trad, parent=self)
|
dlg = DischargeDialog(trad=self._trad, parent=self)
|
||||||
if dlg.exec():
|
if dlg.exec():
|
||||||
value = dlg.value
|
value = dlg.value
|
||||||
self._table.generate("discharge", value)
|
compute_height = dlg.option
|
||||||
|
self._table.generate("discharge", value, compute_height)
|
||||||
self._update()
|
self._update()
|
||||||
|
|
|
||||||
|
|
@ -54,12 +54,12 @@ class NetworkTranslate(MainTranslate):
|
||||||
self._sub_dict["table_headers_node"] = {
|
self._sub_dict["table_headers_node"] = {
|
||||||
"name": self._dict['name'],
|
"name": self._dict['name'],
|
||||||
"type": self._dict['type'],
|
"type": self._dict['type'],
|
||||||
# "id": _translate("Network", "Index"),
|
"id": _translate("Network", "Index"),
|
||||||
}
|
}
|
||||||
|
|
||||||
self._sub_dict["table_headers_edge"] = {
|
self._sub_dict["table_headers_edge"] = {
|
||||||
"name": self._dict['name'],
|
"name": self._dict['name'],
|
||||||
"node1": _translate("Network", "Source node"),
|
"node1": _translate("Network", "Source node"),
|
||||||
"node2": _translate("Network", "Destination node"),
|
"node2": _translate("Network", "Destination node"),
|
||||||
# "id": _translate("Network", "Index"),
|
"id": _translate("Network", "Index"),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>284</width>
|
<width>284</width>
|
||||||
<height>80</height>
|
<height>107</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
|
@ -17,6 +17,16 @@
|
||||||
<locale language="English" country="Europe"/>
|
<locale language="English" country="Europe"/>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
|
|
@ -39,12 +49,12 @@
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QCheckBox" name="checkBox">
|
||||||
<property name="orientation">
|
<property name="text">
|
||||||
<enum>Qt::Horizontal</enum>
|
<string>Generate height</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="standardButtons">
|
<property name="checked">
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,16 @@
|
||||||
<locale language="English" country="Europe"/>
|
<locale language="English" country="Europe"/>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
|
|
@ -29,19 +39,19 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDoubleSpinBox" name="doubleSpinBox">
|
<widget class="QDoubleSpinBox" name="doubleSpinBox">
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<double>999999.998999999952503</double>
|
<double>1000000.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QCheckBox" name="checkBox">
|
||||||
<property name="orientation">
|
<property name="text">
|
||||||
<enum>Qt::Horizontal</enum>
|
<string>Generate discharge</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="standardButtons">
|
<property name="checked">
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue