mirror of https://gitlab.com/pamhyr/pamhyr2
work on initial conditions
parent
8250efcd62
commit
fe4ae46784
|
|
@ -21,6 +21,7 @@ import logging
|
|||
from copy import copy, deepcopy
|
||||
from tools import trace, timer
|
||||
from functools import reduce
|
||||
from numpy import interp
|
||||
|
||||
from Model.Tools.PamhyrDB import SQLSubModel
|
||||
|
||||
|
|
@ -492,25 +493,39 @@ class InitialConditions(SQLSubModel):
|
|||
|
||||
self._generate_resort_data(profiles)
|
||||
|
||||
def generate_height(self, elevation: float):
|
||||
def generate_height(self,
|
||||
elevation1: float,
|
||||
elevation2: float,
|
||||
compute_discharge: bool,
|
||||
discharge: float):
|
||||
profiles = self._reach.reach.profiles.copy()
|
||||
upstream_rk = profiles[0].rk
|
||||
downstream_rk = profiles[-1].rk
|
||||
data_discharge = {}
|
||||
if len(self._data) == 0:
|
||||
for profile in profiles:
|
||||
data_discharge[profile.rk] = 0.0
|
||||
else:
|
||||
for data in self._data:
|
||||
data_discharge[data["rk"]] = data["discharge"]
|
||||
if not compute_discharge:
|
||||
if len(self._data) == 0:
|
||||
for profile in profiles:
|
||||
data_discharge[profile.rk] = 0.0
|
||||
else:
|
||||
for data in self._data:
|
||||
data_discharge[data["rk"]] = data["discharge"]
|
||||
|
||||
self._data = []
|
||||
for profile in profiles:
|
||||
|
||||
if not compute_discharge:
|
||||
d = data_discharge[profile.rk]
|
||||
else:
|
||||
d = discharge
|
||||
elevation = interp(profile.rk,
|
||||
[upstream_rk, downstream_rk],
|
||||
[elevation1, elevation2])
|
||||
new = Data(reach=self._reach, status=self._status)
|
||||
new["rk"] = profile.rk
|
||||
new["discharge"] = data_discharge[profile.rk]
|
||||
new["discharge"] = d
|
||||
new["elevation"] = elevation
|
||||
self._data.append(new)
|
||||
|
||||
self._generate_resort_data(profiles)
|
||||
|
||||
def _generate_resort_data(self, profiles):
|
||||
is_reverse = False
|
||||
if profiles[0].rk > profiles[-1].rk:
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ from PyQt5.QtCore import (
|
|||
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialogButtonBox, QComboBox, QUndoStack, QShortcut,
|
||||
QDoubleSpinBox
|
||||
QDoubleSpinBox, QCheckBox, QLabel
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -44,10 +44,27 @@ class HeightDialog(PamhyrDialog):
|
|||
parent=parent
|
||||
)
|
||||
|
||||
self.value = None
|
||||
self.value = [None, None, None]
|
||||
self.option = None
|
||||
self.find(QCheckBox, "checkBox").clicked.connect(
|
||||
self.enable_discharge
|
||||
)
|
||||
|
||||
def enable_discharge(self):
|
||||
cb = self.find(QCheckBox, "checkBox")
|
||||
dsb = self.find(QDoubleSpinBox, "doubleSpinBox_3")
|
||||
l = self.find(QLabel, "label_3")
|
||||
dsb.setEnabled(cb.isChecked())
|
||||
l.setEnabled(cb.isChecked())
|
||||
|
||||
def accept(self):
|
||||
self.value = self.find(QDoubleSpinBox, "doubleSpinBox").value()
|
||||
self.value[0] = self.find(QDoubleSpinBox, "doubleSpinBox_1").value()
|
||||
self.value[1] = self.find(QDoubleSpinBox, "doubleSpinBox_2").value()
|
||||
self.option = self.find(QCheckBox, "checkBox").isChecked()
|
||||
if self.option:
|
||||
self.value[2] = self.find(QDoubleSpinBox, "doubleSpinBox_3").value()
|
||||
else:
|
||||
self.value[2] = None
|
||||
super().accept()
|
||||
|
||||
def reject(self):
|
||||
|
|
|
|||
|
|
@ -194,4 +194,7 @@ class GenerateCommand(QUndoCommand):
|
|||
self._ics.generate_discharge(self._param,
|
||||
self._option)
|
||||
elif self._generator == "height":
|
||||
self._ics.generate_height(self._param)
|
||||
self._ics.generate_height(self._param[0],
|
||||
self._param[1],
|
||||
self._option,
|
||||
self._param[2])
|
||||
|
|
|
|||
|
|
@ -370,5 +370,6 @@ class InitialConditionsWindow(PamhyrWindow):
|
|||
dlg = HeightDialog(trad=self._trad, parent=self)
|
||||
if dlg.exec():
|
||||
value = dlg.value
|
||||
self._table.generate("height", value, None)
|
||||
compute_discharge = dlg.option
|
||||
self._table.generate("height", value, compute_discharge)
|
||||
self._update()
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>284</width>
|
||||
<height>80</height>
|
||||
<width>396</width>
|
||||
<height>182</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
|
@ -17,7 +17,70 @@
|
|||
<locale language="English" country="Europe"/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Upstream Height (m)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_1">
|
||||
<property name="minimum">
|
||||
<double>-1000000.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1000000.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Discharge</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_3">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Downstream Height (m)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_2">
|
||||
<property name="minimum">
|
||||
<double>-1000000.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
|
|
@ -27,19 +90,12 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="text">
|
||||
<string>Height (m)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox">
|
||||
<property name="maximum">
|
||||
<double>1000000.000000000000000</double>
|
||||
<string>Generate Constant Discharge</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@
|
|||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="tabsClosable">
|
||||
<bool>true</bool>
|
||||
|
|
|
|||
Loading…
Reference in New Issue