mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Compare commits
19
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c33913bd58 | ||
|
|
295ceaa702 | ||
|
|
8c64652b33 | ||
|
|
66a9563345 | ||
|
|
fdf241c6dd | ||
|
|
113989dc46 | ||
|
|
430cff8747 | ||
|
|
aee69fa3c7 | ||
|
|
afb3483fe3 | ||
|
|
90272fa444 | ||
|
|
73fd407aff | ||
|
|
46dc527222 | ||
|
|
b83494888b | ||
|
|
a0f964e89e | ||
|
|
30b3b8800e | ||
|
|
366baa737a | ||
|
|
453a2084e7 | ||
|
|
fe30a20882 | ||
|
|
70dcb1a6ee |
No files matched your search
@@ -72,7 +72,8 @@ class Friction(SQLSubModel):
|
||||
major, minor, release = version.strip().split(".")
|
||||
if major == minor == "0":
|
||||
if int(release) < 11:
|
||||
execute("ALTER TABLE friction RENAME COLUMN begin_kp TO begin_rk")
|
||||
execute("ALTER TABLE friction " +
|
||||
"RENAME COLUMN begin_kp TO begin_rk")
|
||||
execute("ALTER TABLE friction RENAME COLUMN end_kp TO end_rk")
|
||||
|
||||
return True
|
||||
|
||||
@@ -147,7 +147,6 @@ class Data(SQLSubModel):
|
||||
reach=self._reach,
|
||||
status=self._status,
|
||||
)
|
||||
|
||||
return new
|
||||
|
||||
@property
|
||||
@@ -375,25 +374,39 @@ class InitialConditions(SQLSubModel):
|
||||
key=lambda p: p.rk
|
||||
)
|
||||
|
||||
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_rk(profiles)
|
||||
|
||||
previous_elevation = -99999.99
|
||||
|
||||
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"]
|
||||
|
||||
incline = self._reach.reach.get_incline_median_mean()
|
||||
logger.debug(f"incline = {incline}")
|
||||
|
||||
previous_elevation = -99999.99
|
||||
self._data = []
|
||||
for profile in profiles:
|
||||
width = profile.width_approximation()
|
||||
strickler = 25
|
||||
discharge = (
|
||||
((width * 0.8)
|
||||
* strickler
|
||||
* (height ** (5/3))
|
||||
* (abs(incline) ** (0.5)))
|
||||
)
|
||||
|
||||
if not compute_discharge:
|
||||
discharge = data_discharge[profile.rk]
|
||||
else:
|
||||
discharge = (
|
||||
((width * 0.8)
|
||||
* strickler
|
||||
* (height ** (5/3))
|
||||
* (abs(incline) ** (0.5)))
|
||||
)
|
||||
|
||||
elevation = max(
|
||||
profile.z_min() + height,
|
||||
@@ -408,38 +421,44 @@ class InitialConditions(SQLSubModel):
|
||||
new = Data(reach=self._reach, status=self._status)
|
||||
new["rk"] = profile.rk
|
||||
new["discharge"] = discharge
|
||||
|
||||
new["elevation"] = elevation
|
||||
|
||||
self._data.append(new)
|
||||
previous_elevation = elevation
|
||||
self._data.append(new)
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
def _generate_height_estimation_from_discharge(self, discharge: float):
|
||||
profiles = self._reach.reach.profiles.copy()
|
||||
self._sort_by_z_and_rk(profiles)
|
||||
|
||||
previous_elevation = -99999.99
|
||||
|
||||
data_height = {}
|
||||
if not compute_height:
|
||||
if len(self._data) == 0:
|
||||
for profile in profiles:
|
||||
data_height[profile.rk] = 0.0
|
||||
else:
|
||||
for data in self._data:
|
||||
data_height[data["rk"]] = data["height"]
|
||||
|
||||
incline = self._reach.reach.get_incline_median_mean()
|
||||
logger.debug(f"incline = {incline}")
|
||||
|
||||
self._data = []
|
||||
for profile in profiles:
|
||||
width = profile.width_approximation()
|
||||
strickler = 25
|
||||
height = (
|
||||
discharge
|
||||
/
|
||||
((width * 0.8) * strickler * (abs(incline) ** (0.5)))
|
||||
) ** (0.6)
|
||||
|
||||
if not compute_height:
|
||||
height = data_height[profile.rk]
|
||||
else:
|
||||
height = (
|
||||
discharge
|
||||
/
|
||||
((width * 0.8) * strickler * (abs(incline) ** (0.5)))
|
||||
) ** (0.6)
|
||||
|
||||
elevation = max(
|
||||
profile.z_min() + height,
|
||||
|
||||
+3
-3
@@ -230,16 +230,16 @@ class Study(SQLModel):
|
||||
)
|
||||
self.execute(
|
||||
"INSERT INTO info VALUES ('date', " +
|
||||
f"'{self._date.timestamp()}')"
|
||||
f"'{timestamp(self._date)}')"
|
||||
)
|
||||
|
||||
self.execute(
|
||||
"INSERT INTO info VALUES ('creation_date', " +
|
||||
f"'{self.creation_date.timestamp()}')"
|
||||
f"'{timestamp(self.creation_date)}')"
|
||||
)
|
||||
self.execute(
|
||||
"INSERT INTO info VALUES ('last_save_date', " +
|
||||
f"'{self.last_save_date.timestamp()}')"
|
||||
f"'{timestamp(self.last_save_date)}')"
|
||||
)
|
||||
|
||||
self._create_submodel()
|
||||
|
||||
@@ -61,7 +61,7 @@ class GeometryTranslate(MainTranslate):
|
||||
|
||||
self._sub_dict["table_headers"] = {
|
||||
"name": self._dict["name"],
|
||||
"rk": self._dict["unit_rk_short"],
|
||||
"rk": self._dict["unit_rk"],
|
||||
"poins": _translate("Geometry", "Points"),
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
@@ -141,10 +141,6 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
# Translate
|
||||
self._trad = MainTranslate()
|
||||
|
||||
# Results
|
||||
self._last_solver = None
|
||||
self._last_results = None
|
||||
|
||||
# UI
|
||||
self.ui = loadUi(
|
||||
os.path.join(os.path.dirname(__file__), "ui", "MainWindow.ui"),
|
||||
|
||||
@@ -73,7 +73,10 @@ class NodeItem(QGraphicsItem):
|
||||
|
||||
def shape(self):
|
||||
path = QPainterPath()
|
||||
path.addEllipse(-10, -10, 20, 20)
|
||||
if self.graph.graph._reservoir.get_assoc_to_node(self.node) is None:
|
||||
path.addEllipse(-10, -10, 20, 20)
|
||||
else:
|
||||
path.addRect(-10, -10, 20, 20)
|
||||
return path
|
||||
|
||||
@timer
|
||||
@@ -95,7 +98,10 @@ class NodeItem(QGraphicsItem):
|
||||
color = Qt.green
|
||||
|
||||
painter.setBrush(QBrush(color))
|
||||
painter.drawEllipse(-10, -10, 20, 20)
|
||||
if self.graph.graph._reservoir.get_assoc_to_node(self.node) is None:
|
||||
painter.drawEllipse(-10, -10, 20, 20)
|
||||
else:
|
||||
painter.drawRect(-10, -10, 20, 20)
|
||||
|
||||
def itemChange(self, change, value):
|
||||
if change == QGraphicsItem.ItemPositionHasChanged:
|
||||
@@ -610,11 +616,15 @@ class GraphWidget(QGraphicsView):
|
||||
|
||||
def add_node_reservoir(self, node):
|
||||
self.parent.add_node_reservoir(node)
|
||||
self.display_update()
|
||||
|
||||
def del_node_reservoir(self, node):
|
||||
self.parent.del_node_reservoir(node)
|
||||
self.changeNode.emit(self.sender())
|
||||
self.display_update()
|
||||
|
||||
def edit_node_reservoir(self, node):
|
||||
self.changeNode.emit(self.sender())
|
||||
self.parent.edit_node_reservoir(node)
|
||||
|
||||
def enable_edge(self, edge, prev):
|
||||
@@ -999,12 +1009,20 @@ class GraphWidget(QGraphicsView):
|
||||
items = self.items(event.pos())
|
||||
|
||||
# Select current menu
|
||||
while len(items) > 0:
|
||||
if type(items[0]) in [NodeItem, EdgeItem]:
|
||||
break
|
||||
else:
|
||||
items = items[1:]
|
||||
|
||||
if len(items) == 0:
|
||||
m_type = DefaultMenu
|
||||
elif type(items[0]) is NodeItem:
|
||||
m_type = NodeMenu
|
||||
elif type(items[0]) is EdgeItem:
|
||||
m_type = EdgeMenu
|
||||
else:
|
||||
m_type = DefaultMenu
|
||||
|
||||
# Create and exec menu
|
||||
m = m_type(
|
||||
@@ -1012,3 +1030,4 @@ class GraphWidget(QGraphicsView):
|
||||
graph=self.graph, trad=self._trad, parent=self
|
||||
)
|
||||
m.run()
|
||||
self.clicked = False
|
||||
@@ -54,10 +54,12 @@ class NetworkTranslate(MainTranslate):
|
||||
self._sub_dict["table_headers_node"] = {
|
||||
"name": self._dict['name'],
|
||||
"type": self._dict['type'],
|
||||
"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"),
|
||||
}
|
||||
@@ -65,7 +65,6 @@ class PlotXY(PamhyrPlot):
|
||||
self._table = parent.find(QTableView, f"tableView_profile")
|
||||
|
||||
def onpick(self, event):
|
||||
print(event.mouseevent.button.value)
|
||||
if event.mouseevent.inaxes != self.canvas.axes:
|
||||
return
|
||||
if event.mouseevent.button.value != 1:
|
||||
|
||||
@@ -88,7 +88,7 @@ class TableModel(PamhyrTableModel):
|
||||
return f"{v:.4f}"
|
||||
elif self._headers[column] == "speed":
|
||||
q = self._lst[row].get_ts_key(self._timestamp, "Q")
|
||||
z = self._lst[row].get_ts_key(self._timestamp, "Q")
|
||||
z = self._lst[row].get_ts_key(self._timestamp, "Z")
|
||||
|
||||
v = self._lst[row].geometry.speed(q, z)
|
||||
return f"{v:.4f}"
|
||||
|
||||
@@ -271,9 +271,9 @@ class ResultsWindow(PamhyrWindow):
|
||||
table = self.find(QTableView, f"tableView_reach")
|
||||
indexes = table.selectedIndexes()
|
||||
if len(indexes) == 0:
|
||||
reach = self._study.river.edges()[0]
|
||||
reach = self._study.river.enable_edges()[0]
|
||||
else:
|
||||
reach = self._study.river.edges()[indexes[0].row()]
|
||||
reach = self._study.river.enable_edges()[indexes[0].row()]
|
||||
|
||||
# Profile
|
||||
table = self.find(QTableView, f"tableView_profile")
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
import logging
|
||||
|
||||
from tools import timestamp
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
Qt, QRect, QTime, QDateTime, pyqtSlot,
|
||||
)
|
||||
@@ -55,8 +57,8 @@ class PamhyrExTimeDelegate(QItemDelegate):
|
||||
if self._mode == "time":
|
||||
model.setData(index, int(time.total_seconds()))
|
||||
else:
|
||||
logger.debug(str(time.timestamp()))
|
||||
model.setData(index, int(time.timestamp()))
|
||||
logger.debug(str(timestamp(time)))
|
||||
model.setData(index, int(timestamp(time)))
|
||||
editor.close()
|
||||
editor.deleteLater()
|
||||
|
||||
|
||||
@@ -53,7 +53,6 @@ class UnitTranslate(CommonWordTranslate):
|
||||
super(UnitTranslate, self).__init__()
|
||||
|
||||
self._dict["unit_rk"] = _translate("Unit", "River Kilometric (m)")
|
||||
self._dict["unit_rk_short"] = _translate("Unit", "RK (m)")
|
||||
self._dict["unit_width"] = _translate("Unit", "Width (m)")
|
||||
self._dict["unit_height"] = _translate("Unit", "Height (m)")
|
||||
self._dict["unit_diameter"] = _translate("Unit", "Diameter (m)")
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_liquid">
|
||||
<attribute name="title">
|
||||
|
||||
@@ -145,7 +145,7 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_4">
|
||||
<attribute name="title">
|
||||
|
||||
+1
-1
@@ -237,7 +237,7 @@ def timestamp(dt: datetime):
|
||||
|
||||
def date_iso_to_timestamp(date: str):
|
||||
if type(date) is str:
|
||||
return datetime.fromisoformat(date).timestamp()
|
||||
return timestamp(datetime.fromisoformat(date))
|
||||
else:
|
||||
return datetime.isoformat(date)
|
||||
|
||||
|
||||
Reference in new issue
Block a user