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