Compare commits

..
Author SHA1 Message Date
Theophile Terraz 6f7a891a6d optimization + debug 2025-01-20 16:24:17 +01:00
Theophile Terraz e4224e6358 force Mage sulver type in open from file 2025-01-17 13:54:27 +01:00
Theophile Terraz aa8a9dccbf translation 2025-01-17 12:00:42 +01:00
Theophile Terraz 1732e30e58 debug 2025-01-17 09:31:37 +01:00
Theophile Terraz 9eedd1fff9 debug results 2025-01-17 09:20:01 +01:00
Theophile Terraz ac6e8a3704 debug Adis-TS files generation 2025-01-16 15:54:50 +01:00
Theophile Terraz c5f918c885 pep8 2025-01-16 15:08:24 +01:00
Theophile Terraz 230712c3ea debug Adis-TS 2025-01-16 15:03:52 +01:00
Theophile Terraz 2e2f054a4f debug Adis-TS 2025-01-16 14:16:24 +01:00
Theophile Terraz f75a25d010 debug 2025-01-15 14:26:31 +01:00
Theophile Terraz 9db90debeb translation 2024-12-20 17:13:44 +01:00
Theophile Terraz 2333ab540e debug 2024-12-20 15:54:25 +01:00
Theophile Terraz c81d65f527 rm test case 2024-12-20 15:49:30 +01:00
Theophile Terraz bf44f5c027 rm test case 2024-12-20 15:47:48 +01:00
Theophile Terraz d1400f12a6 debug 2024-12-20 15:41:19 +01:00
38 changed files with 1051 additions and 357 deletions

No files matched your search

+2 -2
View File
@@ -75,8 +75,8 @@ class Friction(SQLSubModel):
if major == minor == "0":
if int(release) < 11:
execute("ALTER TABLE friction " +
"RENAME COLUMN begin_rk TO begin_rk")
execute("ALTER TABLE friction RENAME COLUMN end_rk TO end_rk")
"RENAME COLUMN begin_kp TO begin_rk")
execute("ALTER TABLE friction RENAME COLUMN end_kp TO end_rk")
return True
+94 -14
View File
@@ -20,6 +20,7 @@ import logging
import numpy as np
from typing import List
from functools import reduce
from dataclasses import dataclass
from tools import timer
from shapely import geometry
@@ -33,6 +34,13 @@ from Model.Geometry.Vector_1d import Vector1d
logger = logging.getLogger()
@dataclass
class Tabulation:
z: np.array([])
A: np.array([])
L: np.array([])
class ProfileXYZ(Profile, SQLSubModel):
_sub_classes = [
PointXYZ,
@@ -70,6 +78,14 @@ class ProfileXYZ(Profile, SQLSubModel):
status=status,
)
self.tab = Tabulation([], [], [])
self.tab_up_to_date = False
self.time_z = 0.0
self.time_A = 0.0
self.time_l = 0.0
self._station = []
self.station_up_to_date = False
@classmethod
def _db_create(cls, execute):
execute("""
@@ -108,7 +124,7 @@ class ProfileXYZ(Profile, SQLSubModel):
execute(
"""
ALTER TABLE geometry_profileXYZ
RENAME COLUMN rk TO rk
RENAME COLUMN kp TO rk
"""
)
@@ -305,6 +321,8 @@ class ProfileXYZ(Profile, SQLSubModel):
pt = PointXYZ(*point, profile=self, status=self._status)
self.points.append(pt)
self._status.modified()
self.tab_up_to_date = False
self.station_up_to_date = False
def get_point_i(self, index: int) -> PointXYZ:
"""Get point at index.
@@ -366,6 +384,8 @@ class ProfileXYZ(Profile, SQLSubModel):
point_xyz = PointXYZ(0., 0., 0., profile=self, status=self._status)
self.points.append(point_xyz)
self._status.modified()
self.tab_up_to_date = False
self.station_up_to_date = False
def insert(self, index: int):
"""Insert a new point at index.
@@ -379,6 +399,8 @@ class ProfileXYZ(Profile, SQLSubModel):
point = PointXYZ(0., 0., 0., profile=self, status=self._status)
self.points.insert(index, point)
self._status.modified()
self.tab_up_to_date = False
self.station_up_to_date = False
return point
def filter_isnan(self, lst):
@@ -410,7 +432,7 @@ class ProfileXYZ(Profile, SQLSubModel):
return abs(rg.dist(rd))
def wet_width(self, z):
def compute_wet_width(self, z):
start, end = self.get_all_water_limits_ac(z)
if len(start) == 0:
@@ -421,6 +443,17 @@ class ProfileXYZ(Profile, SQLSubModel):
length += abs(s - e)
return length
def wet_width(self, z):
if self.tab_up_to_date:
if z > self.tab.z[-1]:
return self.tab.L[-1]
elif z < self.tab.z[0]:
return 0.0
else:
return np.interp(z, self.tab.z, self.tab.L)
else:
return self.compute_wet_width(z)
def wet_perimeter(self, z):
lines = self.wet_lines(z)
@@ -432,17 +465,46 @@ class ProfileXYZ(Profile, SQLSubModel):
length += line.length
return length
def wet_area(self, z):
lines = self.wet_lines(z)
if lines is None:
return 0
def compute_wet_area(self, z):
area = 0.0
for line in lines:
if len(line.coords) > 2:
poly = geometry.Polygon(line)
area += poly.area
if len(self.tab.L) > 0:
if z < self.tab.z[0]:
return 0.0
i = np.searchsorted([z], self.tab.z, side='right')[0]
for j in range(i-1):
area += (self.tab.L[j] + self.tab.L[j+1]) * (
self.tab.z[j+1] - self.tab.z[j]) / 2.0
area += (self.tab.L[i-1] + self.wet_width(z))
else:
lines = self.wet_lines(z)
if lines is None:
return 0.0
for line in lines:
if len(line.coords) > 2:
poly = geometry.Polygon(line)
area += poly.area
return area
def wet_area(self, z):
if self.tab_up_to_date:
if z > self.tab.z[-1]:
return self.tab.A[-1] + self.tab.L[-1] * (z - self.tab.z[-1])
elif z < self.tab.z[0]:
return 0.0
else:
return np.interp(z, self.tab.z, self.tab.A)
else:
lines = self.wet_lines(z)
if lines is None:
return 0.0
area = 0.0
for line in lines:
if len(line.coords) > 2:
poly = geometry.Polygon(line)
area += poly.area
return area
def wet_radius(self, z):
@@ -563,7 +625,7 @@ class ProfileXYZ(Profile, SQLSubModel):
return None
zz = list(map(lambda p: p.z, points))
station = self._get_station(points)
station = self.get_station()
start = []
if points[0].z <= z:
@@ -651,6 +713,19 @@ class ProfileXYZ(Profile, SQLSubModel):
return pt_left, pt_right
def compute_tabulation(self):
sorted_points = sorted(self._points, key=lambda p: p.z)
self.tab.z = np.array([p.z for p in sorted_points], np.float64)
self.tab.L = np.zeros(len(self.tab.z), np.float64)
self.tab.A = np.zeros(len(self.tab.z), np.float64)
for i in range(1, len(self.tab.z)):
self.tab.L[i] = self.compute_wet_width(self.tab.z[i])
dx = (self.tab.L[i] + self.tab.L[i-1])/2
dz = self.tab.z[i] - self.tab.z[i-1]
self.tab.A[i] = self.tab.A[i-1] + dz * dx
self.tab_up_to_date = True
def get_station(self):
"""Projection of the points of the profile on a plane.
@@ -663,7 +738,12 @@ class ProfileXYZ(Profile, SQLSubModel):
if self.nb_points < 2:
return [0.0]
else:
return self._get_station(self.points)
if self.station_up_to_date:
return self._station
else:
self._station = self._get_station(self.points)
self.station_up_to_date = True
return self._station
@timer
def _get_station(self, points):
@@ -94,13 +94,13 @@ class HydraulicStructure(SQLSubModel):
execute(
"""
ALTER TABLE hydraulic_structures
RENAME COLUMN input_rk TO input_rk
RENAME COLUMN input_kp TO input_rk
"""
)
execute(
"""
ALTER TABLE hydraulic_structures
RENAME COLUMN output_rk TO output_rk
RENAME COLUMN output_kp TO output_rk
"""
)
@@ -80,7 +80,7 @@ class Data(SQLSubModel):
if major == minor == "0":
if int(release) < 11:
execute(
"ALTER TABLE initial_conditions RENAME COLUMN rk TO rk"
"ALTER TABLE initial_conditions RENAME COLUMN kp TO rk"
)
return cls._update_submodel(execute, version)
@@ -93,13 +93,13 @@ class LateralContribution(SQLSubModel):
execute(
"""
ALTER TABLE lateral_contribution
RENAME COLUMN begin_rk TO begin_rk
RENAME COLUMN begin_kp TO begin_rk
"""
)
execute(
"""
ALTER TABLE lateral_contribution
RENAME COLUMN end_rk TO end_rk
RENAME COLUMN end_kp TO end_rk
"""
)
+15 -1
View File
@@ -128,7 +128,7 @@ class Pollutants(SQLSubModel):
if table is not None:
for t in table:
new_data = t[1:]
new_data = t[1:-1]
new_pollutant._data.append(new_data)
@@ -177,5 +177,19 @@ class Pollutants(SQLSubModel):
def is_define(self):
return len(self._data) != 0
def new_from_data(self, data):
print("from_data before : ", data)
try:
new = [int(data[0])]
new += [float(d) for d in data[1:]]
except Exception as e:
logger.error(e)
new = None
print("from_data after : ", new)
return new
def __len__(self):
return len(self._data)
+3
View File
@@ -46,6 +46,9 @@ class Results(object):
el.split("/")[-1][0:-4]
for el in glob.glob(repertory_results + "/*.bin")
]
self._pollutants_list.insert(0, self._pollutants_list.pop(
self._pollutants_list.index("total_sediment"))
)
self._phys_var_list = ["C", "G", "M", "D", "L", "N", "R"]
+1
View File
@@ -50,6 +50,7 @@ class SQLModel(SQL):
self._create() # Create db
# self._save() # Save
else:
logger.info("Update database")
self._update() # Update db scheme if necessary
# self._load() # Load data
+21 -11
View File
@@ -410,10 +410,16 @@ class AdisTSwc(AdisTS):
def _export_ICs_AdisTS_Spec(self, study, pol_ics_spec_data,
f, qlog, name="0"):
edges = study.river.enable_edges()
for ic_spec in pol_ics_spec_data:
id_reach = ic_spec.reach
reach = next((x for x in edges if x.id == id_reach), None)
if reach is None:
continue
f.write(" ".join((f"{ic_spec.name}",
"=",
f"{ic_spec.reach}",
f"{study.river.get_edge_id(reach)+1}",
f"{ic_spec.start_rk}",
f"{ic_spec.end_rk}",
f"{ic_spec.concentration}",
@@ -429,7 +435,7 @@ class AdisTSwc(AdisTS):
list_characteristics = ["type", "diametre", "rho", "porosity",
"cdc_riv", "cdc_cas", "apd", "ac", "bc"]
if len(list_characteristics) == (len(pol_data[0])-1):
if len(list_characteristics) <= (len(pol_data[0])):
for i in range(len(list_characteristics)):
f.write(f"{list_characteristics[i]} = {pol_data[0][i]}\n")
@@ -470,13 +476,14 @@ class AdisTSwc(AdisTS):
id_edges = list(map(lambda x: x.id, edges))
id_reach = d90_spec.reach
reach = next((x for x in edges if x.id == id_reach), None)
if id_reach not in id_edges:
if reach is None:
return
f.write(" ".join((f"{d90_spec.name}",
"=",
f"{id_reach}",
f"{study.river.get_edge_id(reach)+1}",
f"{d90_spec.start_rk}",
f"{d90_spec.end_rk}",
f"{d90_spec.d90}\n")))
@@ -526,23 +533,22 @@ class AdisTSwc(AdisTS):
edges = study.river.enable_edges()
id_edges = list(map(lambda x: x.id, edges))
id_reach = dif_spec.reach
reach = next((x for x in edges if x.id == id_reach), None)
if id_reach not in id_edges:
if reach is None:
return
if dif_spec.method != "generique":
f.write(" ".join((f"{dif_spec.method}",
"=",
f"{id_reach}",
f"{study.river.get_edge_id(reach)+1}",
f"{dif_spec.start_rk}",
f"{dif_spec.end_rk}",
f"{dif_spec.dif}\n")))
else:
f.write(" ".join((f"{dif_spec.method}",
f"=" f"{id_reach}",
f"=" f"{study.river.get_edge_id(reach)+1}",
f"{dif_spec.start_rk}",
f"{dif_spec.end_rk}",
f"{dif_spec.dif}",
@@ -602,13 +608,14 @@ class AdisTSwc(AdisTS):
id_edges = list(map(lambda x: x.id, edges))
id_reach = outputrk.reach
reach = next((x for x in edges if x.id == id_reach), None)
rk = outputrk.rk
title = outputrk.title
if id_reach not in id_edges:
if reach is None:
return
f.write(f"output = {id_reach} {rk} {title}\n")
f.write(f"output = {study.river.get_edge_id(reach)+1} {rk} {title}\n")
@timer
def read_bin(self, study, repertory, results, qlog=None, name="0"):
@@ -616,6 +623,9 @@ class AdisTSwc(AdisTS):
files_bin_names = [el.split("/")[-1]
for el in glob.glob(repertory_results+"/*.bin")]
files_bin_names.insert(0, files_bin_names.pop(
files_bin_names.index("total_sediment.bin"))
)
print("files names resultats: ", files_bin_names)
ifilename = os.path.join(repertory_results, files_bin_names[0])
+17 -4
View File
@@ -1001,7 +1001,6 @@ class Mage8(Mage):
# Add profile id correspondance to reach
key = (i1, i2)
print("mage keys reachs: ", key)
iprofiles[key] = r
# Profile ID offset
@@ -1034,8 +1033,6 @@ class Mage8(Mage):
]
def ip_to_ri(r, i): return i - reach_offset[r]
print("mage iprofiles: ", iprofiles)
ts = set()
end = False
while not end:
@@ -1071,7 +1068,23 @@ class Mage8(Mage):
logger.debug(reachs[0].profiles[0]._data)
results.set("timestamps", ts)
print("set timestamps mage: ", ts)
ts_list = sorted(ts)
logger.info(f"compute tab...")
for r in reachs:
for p in r.profiles:
if not p.geometry.tab_up_to_date:
p.geometry.compute_tabulation()
logger.info(f"compute velocily...")
for r in reachs:
for t in ts_list:
for i, p in enumerate(r.profiles):
v = p.geometry.speed(
p.get_ts_key(t, "Q"),
p.get_ts_key(t, "Z")
)
r.set(i, t, "V", v)
logger.info(f"read_bin: ... end with {len(ts)} timestamp read")
@timer
+1 -1
View File
@@ -55,7 +55,7 @@ class AboutWindow(PamhyrDialog):
label = self.get_label_text("label_version")
label = label.replace("@version", version)
label = label.replace("@codename", "(Tahiti)")
label = label.replace("@codename", "(Adis-TS)")
self.set_label_text("label_version", label)
# Authors
@@ -88,13 +88,13 @@ class EditBoundaryConditionWindow(PamhyrWindow):
self.setup_connections()
def setup_table(self):
table_headers = self._trad.get_dict("table_headers")
if self._data.type == "Concentration":
self._data.header = ["time", "concentration"]
else:
self._data.header = ["time", "rate"]
self._data.header = ["time", "mass"]
headers = {}
table_headers = self._trad.get_dict("table_headers")
for h in self._data.header:
headers[h] = table_headers[h]
@@ -30,13 +30,13 @@ class BCETranslate(BCTranslate):
super(BCETranslate, self).__init__()
self._dict["Edit Boundary Conditions AdisTS"] = _translate(
"BoundaryConditionAdisTS", "Edit boundary conditions AdisTS"
"BoundaryConditionsAdisTS", "Edit boundary conditions AdisTS"
)
self._sub_dict["table_headers"] = {
"time": self._dict["time"],
"date": self._dict["date"],
"rate": _translate("BoundaryConditionAdisTS", "Rate"),
"concentration": _translate("BoundaryConditionAdisTS",
"mass": _translate("BoundaryConditionsAdisTS", "Mass"),
"concentration": _translate("BoundaryConditionsAdisTS",
"Concentration"),
}
+15 -7
View File
@@ -70,7 +70,7 @@ class ComboBoxDelegate(QItemDelegate):
self.editor = QComboBox(parent)
if self._mode == "type":
lst = [self._trad["not_associated"], "Concentration", "Rate"]
lst = [self._trad["not_associated"], "Concentration", "Mass"]
self.editor.addItems(
lst
)
@@ -181,13 +181,21 @@ class TableModel(PamhyrTableModel):
)
)
elif self._headers[column] == "pol":
pol = next(filter(lambda x: x.name == value,
self._data._Pollutants.Pollutants_List))
self._undo.push(
SetPolCommand(
self._lst, row, pol.id
if value == self._trad["not_associated"]:
self._undo.push(
SetPolCommand(
self._lst, row, None
)
)
else:
pol = next(filter(lambda x: x.name == value,
self._data._Pollutants.Pollutants_List)
)
self._undo.push(
SetPolCommand(
self._lst, row, pol.id
)
)
)
except Exception as e:
logger.info(e)
logger.debug(traceback.format_exc())
@@ -68,9 +68,8 @@ class SetPolCommand(QUndoCommand):
self._bcs = bcs
self._index = index
self._pollutant = pollutant
self._old = self._bcs[self._index].pollutant
self._new = self._pollutant
self._new = pollutant
def undo(self):
self._bcs[self._index].pollutant = self._old
+1 -6
View File
@@ -74,7 +74,6 @@ class BoundaryConditionAdisTSWindow(PamhyrWindow):
)
self._pollutants_lst = self._study._river._Pollutants
self._bcs = self._study.river.boundary_conditions_adists
self.setup_graph()
@@ -157,11 +156,7 @@ class BoundaryConditionAdisTSWindow(PamhyrWindow):
)
def add(self):
rows = self.index_selected_rows()
if len(self._bcs) == 0 or len(rows) == 0:
self._table.add(0)
else:
self._table.add(rows[0])
self._table.add(len(self._bcs))
def delete(self):
rows = self.index_selected_rows()
-1
View File
@@ -187,7 +187,6 @@ class DIFTableModel(PamhyrTableModel):
)
)
elif self._headers[column] == "reach":
print(self._river.edge(value).id)
self._undo.push(
SetCommandSpec(
self._lst,
-2
View File
@@ -287,9 +287,7 @@ class DIFAdisTSWindow(PamhyrWindow):
self._table_spec.add(rows[0])
def delete(self):
print("del")
rows = self.index_selected_rows()
if len(rows) == 0:
print("len 0")
return
self._table_spec.delete(rows)
@@ -28,7 +28,7 @@ class LCTranslate(MainTranslate):
super(LCTranslate, self).__init__()
self._dict["Lateral contribution AdisTS"] = _translate(
"LateralContribution1adisTS", "Lateral contribution AdisTS"
"LateralContributionAdisTS", "Lateral contribution AdisTS"
)
self._sub_dict["long_types"] = {
+13 -6
View File
@@ -29,6 +29,7 @@ from numpy.core.multiarray import where
from platformdirs import user_cache_dir
from Solver.AdisTS import AdisTS
from Solver.Mage import Mage8
from tools import logger_exception
from PyQt5 import QtGui
@@ -185,10 +186,10 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
title = "(dbg) " if self.conf.debug else ""
if self._study is not None:
title += f"Pamhyr2 (Tahiti 🌴) - {self._study.name}"
title += f"Pamhyr2 - {self._study.name}"
self.setWindowTitle(title)
else:
title += "Pamhyr2 (Tahiti 🌴)"
title += "Pamhyr2"
self.setWindowTitle(title)
def setup_tab(self):
@@ -785,14 +786,16 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
dlg.setWindowTitle(self._trad["mb_last_open_title"])
dlg.setText(self._trad["mb_last_open_msg"])
opt = QMessageBox.Cancel | QMessageBox.Ok # | QMessageBox.Open
opt = QMessageBox.No | QMessageBox.Yes # | QMessageBox.Open
dlg.setStandardButtons(opt)
dlg.setIcon(QMessageBox.Question)
dlg.button(QMessageBox.Yes).setText(self._trad["Yes"])
dlg.button(QMessageBox.No).setText(self._trad["No"])
res = dlg.exec()
if res == QMessageBox.Ok:
if res == QMessageBox.Yes:
old = self.conf.last_study
file = self.dialog_reopen_study_select_backup(
self.conf.last_study
@@ -805,7 +808,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
elif res == QMessageBox.Open:
self.open_model()
return True
elif res == QMessageBox.Cancel:
elif res == QMessageBox.No:
return False
def dialog_reopen_study_select_backup(self, filename):
@@ -832,6 +835,10 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
dlg.setStandardButtons(opt)
dlg.setIcon(QMessageBox.Warning)
dlg.button(QMessageBox.Save).setText(self._trad["Save"])
dlg.button(QMessageBox.Close).setText(self._trad["Close"])
if cancel:
dlg.button(QMessageBox.Cancel).setText(self._trad["Cancel"])
res = dlg.exec()
@@ -1544,7 +1551,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
file_name = dialog.selectedFiles()
logger.info(f"Select results: {file_name}")
self.open_solver_results(
self._last_solver,
Mage8("Mage"),
results=file_name[0]
)
+7 -10
View File
@@ -90,17 +90,14 @@ class TableModel(PamhyrTableModel):
self.layoutAboutToBeChanged.emit()
self._undo.push(
PasteCommand(
self._data, row,
list(
map(
lambda d: self._data.new_from_data(d),
data
)
)
self._undo.push(PasteCommand(self._data, row,
list(
map(
lambda d: self._data.new_from_data(d),
data
)
)
)
)
self.layoutAboutToBeChanged.emit()
self.layoutChanged.emit()
+1 -1
View File
@@ -35,7 +35,7 @@ class EditPollutantTranslate(PollutantsTranslate):
self._sub_dict["table_headers"] = {
"type": self._dict["type"],
"diametre": self._dict["unit_area"],
"diameter": self._dict["unit_diameter"],
"rho": self._dict["unit_rho"],
"porosity": self._dict["unit_porosity"],
"cdc_riv": self._dict["unit_cdc_riv"],
+24 -25
View File
@@ -31,36 +31,35 @@ logger = logging.getLogger()
class SetDataCommand(QUndoCommand):
def __init__(self, data, index, column, new_value):
QUndoCommand.__init__(self)
self._data = data
self._index = index
self._column = column
self._old = self._data.data[self._index][self._column]
self._new = new_value
def undo(self):
self._data.data[self._index][self._column] = self._old
def redo(self):
self._data.data[self._index][self._column] = self._new
class PasteCommand(QUndoCommand):
def __init__(self, data, row, hs):
def __init__(self, data, row, column, new_value):
QUndoCommand.__init__(self)
self._data = data
self._row = row
self._h = hs
self._h.reverse()
self._column = column
self._old = self._data.data[self._row][self._column]
self._new = new_value
def undo(self):
self._data.delete_i(
range(self._row, self._row + len(self._h))
)
self._data.data[self._row][self._column] = self._old
def redo(self):
for h in self._h:
self._data.insert(self._row, h)
self._data.data[self._row][self._column] = self._new
class PasteCommand(QUndoCommand):
def __init__(self, data, row, new_data):
QUndoCommand.__init__(self)
self._data = data
self._row = row
self._new = [n for n in new_data[row]]
self._old = [o for o in self._data.data[row]]
def undo(self):
for i in range(9):
self._data.data[self._row][i] = self._old[i]
def redo(self):
for i in range(9):
self._data.data[self._row][i] = self._new[i]
+1 -1
View File
@@ -129,7 +129,7 @@ class EditPolluantWindow(PamhyrWindow):
def _paste(self):
header, data = self.parseClipboardTable()
logger.debug(f"paste: h:{header}, d:{data}")
logger.debug(f"paste: header:{header}, data:{data}")
if len(data) == 0:
return
+1 -1
View File
@@ -103,7 +103,7 @@ class TableModel(PamhyrTableModel):
self._undo.push(
DelCommand(
self._lst, rows, self._data.initial_conditions_adists
self._lst, rows, self._data.ic_adists
)
)
+11 -12
View File
@@ -105,6 +105,7 @@ class PollutantsWindow(PamhyrWindow):
def setup_connections(self):
self.find(QAction, "action_add").triggered.connect(self.add)
self.find(QAction, "action_delete").setEnabled(False)
self.find(QAction, "action_delete").triggered.connect(self.delete)
self.find(QAction, "action_edit").triggered.connect(self.edit)
self.find(QAction, "action_initial_conditions"
@@ -154,11 +155,7 @@ class PollutantsWindow(PamhyrWindow):
)
def add(self):
rows = self.index_selected_rows()
if len(self._pollutants_lst) == 0 or len(rows) == 0:
self._table.add(0)
else:
self._table.add(rows[-1])
self._table.add(len(self._pollutants_lst))
def delete(self):
rows = self.index_selected_rows()
@@ -181,6 +178,9 @@ class PollutantsWindow(PamhyrWindow):
def edit(self):
rows = self.index_selected_rows()
if len(rows) == 0:
return
for row in rows:
data = self._pollutants_lst.get(row)
@@ -199,6 +199,8 @@ class PollutantsWindow(PamhyrWindow):
def initial_conditions(self):
rows = self.index_selected_rows()
if len(rows) == 0:
return
for row in rows:
pollutant_id = self._pollutants_lst.get(row).id
@@ -219,11 +221,7 @@ class PollutantsWindow(PamhyrWindow):
)
initial.show()
def boundary_conditions(self, tab=0):
rows = self.index_selected_rows()
for row in rows:
pollutant_id = self._pollutants_lst.get(row).id
def boundary_conditions(self):
if self.sub_window_exists(
BoundaryConditionAdisTSWindow,
@@ -242,9 +240,10 @@ class PollutantsWindow(PamhyrWindow):
def lateral_contrib(self):
rows = self.index_selected_rows()
if len(rows) == 0:
return
for row in rows:
pollutant_id = self._pollutants_lst.get(row).id
pollutant_id = self._pollutants_lst.get(rows[0]).id
if self.sub_window_exists(
LateralContributionAdisTSWindow,
+27 -47
View File
@@ -187,6 +187,12 @@ class CustomPlot(PamhyrPlot):
reach.profiles
)
)
v = list(
map(
lambda p: p.get_ts_key(self._timestamp, "V"),
reach.profiles
)
)
shift = 0
compt = 0
@@ -327,14 +333,6 @@ class CustomPlot(PamhyrPlot):
if "velocity" in self._y:
ax = self._axes[unit["velocity"]]
v = list(
map(
lambda p: p.geometry.speed(
p.get_ts_key(self._timestamp, "Q"),
p.get_ts_key(self._timestamp, "Z")),
reach.profiles
)
)
line = ax.plot(
rk, v, lw=1.,
@@ -344,12 +342,10 @@ class CustomPlot(PamhyrPlot):
if self._envelop:
velocities = list(map(
lambda p: list(map(
lambda q, z:
p.geometry.speed(q, z),
p.get_key("Q"), p.get_key("Z")
)), reach.profiles
velocities = list(
map(
lambda p: p.get_key("V"),
reach.profiles
)
)
@@ -440,9 +436,7 @@ class CustomPlot(PamhyrPlot):
fr = list(
map(
lambda p:
p.geometry.speed(
p.get_ts_key(self._timestamp, "Q"),
p.get_ts_key(self._timestamp, "Z")) /
p.get_ts_key(self._timestamp, "V") /
sqrt(9.81 * (
p.geometry.wet_area(
p.get_ts_key(self._timestamp, "Z")) /
@@ -506,6 +500,12 @@ class CustomPlot(PamhyrPlot):
reach.profiles
)
)
v = list(
map(
lambda p: p.get_ts_key(self._timestamp, "V"),
reach.profiles
)
)
if "bed_elevation" in self._y:
self.lines["bed_elevation"][0].set_ydata(z_min)
@@ -524,15 +524,7 @@ class CustomPlot(PamhyrPlot):
self.lines["discharge"][0].set_ydata(q)
if "velocity" in self._y:
v = list(
map(
lambda p: p.geometry.speed(
p.get_ts_key(self._timestamp, "Q"),
p.get_ts_key(self._timestamp, "Z")),
reach.profiles
)
)
self.lines["discharge"][0].set_ydata(v)
self.lines["velocity"][0].set_ydata(v)
if "depth" in self._y:
d = list(
@@ -558,9 +550,7 @@ class CustomPlot(PamhyrPlot):
fr = list(
map(
lambda p:
p.geometry.speed(
p.get_ts_key(self._timestamp, "Q"),
p.get_ts_key(self._timestamp, "Z")) /
p.get_ts_key(self._timestamp, "V") /
sqrt(9.81 * (
p.geometry.wet_area(
p.get_ts_key(self._timestamp, "Z")) /
@@ -642,6 +632,7 @@ class CustomPlot(PamhyrPlot):
q = profile.get_key("Q")
z = profile.get_key("Z")
v = profile.get_key("V")
z_min = profile.geometry.z_min()
if reach.has_sediment():
ts_z_min = self.get_ts_zmin(self._profile)
@@ -693,12 +684,6 @@ class CustomPlot(PamhyrPlot):
if "velocity" in self._y:
ax = self._axes[unit["velocity"]]
v = list(
map(
lambda q, z: profile.geometry.speed(q, z),
q, z
)
)
line = ax.plot(
ts, v, lw=1.,
@@ -736,12 +721,12 @@ class CustomPlot(PamhyrPlot):
ax = self._axes[unit["froude"]]
d = list(
map(lambda z, q:
profile.geometry.speed(q, z) /
map(lambda z, v:
v /
sqrt(9.81 * (
profile.geometry.wet_area(z) /
profile.geometry.wet_width(z))
), z, q)
), z, v)
)
line = ax.plot(
@@ -782,6 +767,7 @@ class CustomPlot(PamhyrPlot):
q = profile.get_key("Q")
z = profile.get_key("Z")
v = profile.get_key("V")
if reach.has_sediment():
ts_z_min = self.get_ts_zmin(self._profile)
else:
@@ -810,12 +796,6 @@ class CustomPlot(PamhyrPlot):
self.lines["discharge"][0].set_ydata(q)
if "velocity" in self._y:
v = list(
map(
lambda q, z: profile.geometry.speed(q, z),
q, z
)
)
self.lines["velocity"][0].set_ydata(v)
if "depth" in self._y:
@@ -832,12 +812,12 @@ class CustomPlot(PamhyrPlot):
if "froude" in self._y:
d = list(
map(lambda z, q:
profile.geometry.speed(q, z) /
map(lambda z, v:
v /
sqrt(9.81 * (
profile.geometry.wet_area(z) /
profile.geometry.wet_width(z))
), z, q)
), z, v)
)
self.lines["froude"][0].set_ydata(d)
+1
View File
@@ -309,6 +309,7 @@ class PlotAdis_dt(PlotAdis):
type_pol=type_pol,
parent=parent
)
self.label_x = self._trad["unit_time_s"]
def draw_data(self):
reach = self.results.river.reach(self._current_reach_id)
+2 -6
View File
@@ -47,12 +47,8 @@ _translate = QCoreApplication.translate
class TableModel(PamhyrTableModel):
def _setup_lst(self):
_river = self._data.river
print("data: ", self._data)
print("river: ", _river)
print("reaches: ", _river.reachs)
if self._opt_data == "reach":
self._lst = _river.reachs
print("optreach: ", self._lst)
elif self._opt_data == "profile":
self._lst = _river.reach(0).profiles
elif self._opt_data == "raw_data":
@@ -95,7 +91,7 @@ class TableModel(PamhyrTableModel):
elif self._headers[column] == "velocity":
q = 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)
v = self._lst[row].get_ts_key(self._timestamp, "V")
return f"{v:.4f}"
elif self._headers[column] == "width":
z = self._lst[row].get_ts_key(self._timestamp, "Z")
@@ -124,7 +120,7 @@ class TableModel(PamhyrTableModel):
elif self._headers[column] == "froude":
q = 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)
v = self._lst[row].get_ts_key(self._timestamp, "V")
a = self._lst[row].geometry.wet_area(z)
b = self._lst[row].geometry.wet_width(z)
froude = v / sqrt(9.81 * (a / b))
+10 -22
View File
@@ -730,21 +730,16 @@ class ResultsWindow(PamhyrWindow):
if "velocity" in y:
my_dict[dict_y["velocity"]] = list(
map(
lambda p: p.geometry.speed(
p.get_ts_key(timestamp, "Q"),
p.get_ts_key(timestamp, "Z")),
lambda p: p.get_ts_key(timestamp, "V"),
reach.profiles
)
)
if envelop:
velocities = list(map(
lambda p: list(map(
lambda q, z:
p.geometry.speed(q, z),
p.get_key("Q"), p.get_key("Z")
)), reach.profiles
lambda p: p.get_key("V"),
reach.profiles
)
)
)
my_dict[dict_y["min_velocity"]] = [min(v) for v in velocities]
my_dict[dict_y["max_velocity"]] = [max(v) for v in velocities]
@@ -784,9 +779,7 @@ class ResultsWindow(PamhyrWindow):
my_dict[dict_y["froude"]] = list(
map(
lambda p:
p.geometry.speed(
p.get_ts_key(timestamp, "Q"),
p.get_ts_key(timestamp, "Z")) /
p.get_ts_key(timestamp, "V") /
sqrt(9.81 * (
p.geometry.wet_area(
p.get_ts_key(timestamp, "Z")) /
@@ -818,6 +811,7 @@ class ResultsWindow(PamhyrWindow):
my_dict[dict_x["time"]] = ts
z = profile.get_key("Z")
q = profile.get_key("Q")
v = profile.get_key("V")
if "bed_elevation" in y:
my_dict[dict_y["bed_elevation"]] = [
profile.geometry.z_min()] * len(ts)
@@ -826,12 +820,7 @@ class ResultsWindow(PamhyrWindow):
if "water_elevation" in y:
my_dict[dict_y["water_elevation"]] = z
if "velocity" in y:
my_dict[dict_y["velocity"]] = list(
map(
lambda q, z: profile.geometry.speed(q, z),
q, z
)
)
my_dict[dict_y["velocity"]] = v
if "depth" in y:
my_dict[dict_y["depth"]] = list(
map(lambda z: profile.geometry.max_water_depth(z), z)
@@ -842,12 +831,11 @@ class ResultsWindow(PamhyrWindow):
)
if "froude" in y:
my_dict[dict_y["froude"]] = list(
map(lambda z, q:
profile.geometry.speed(q, z) /
sqrt(9.81 * (
map(lambda z, v:
v / sqrt(9.81 * (
profile.geometry.wet_area(z) /
profile.geometry.wet_width(z))
), z, q)
), z, v)
)
if "wet_area" in y:
my_dict[dict_y["wet_area"]] = list(
+7 -5
View File
@@ -78,6 +78,7 @@ class ResultsWindowAdisTS(PamhyrWindow):
parent=None):
self._solver = solver
self._results = results
self.pollutant_label = ["None"]
pollutants_headers = self._results.pollutants_list.copy()
@@ -374,14 +375,15 @@ class ResultsWindowAdisTS(PamhyrWindow):
# Pollutant
table = self.find(QTableView, f"tableView_pollutants")
indexes = table.selectedIndexes()
if len(indexes) == 0:
pollutant = self._results.pollutants_list[0]
else:
pollutant = self._results.pollutants_list[indexes[0].row()]
if len(indexes) != 0:
self.pollutant_label = [
self._results.pollutants_list[i.row()+1] for i in indexes
]
return (f"Reach: {reach.name} | " +
f"Profile: {pname} | " +
f"Pollutant: {pollutant}")
f"Pollutant: {', '.join(self.pollutant_label)} | " +
f"{self._trad['unit_time_s']} : {fts} ({ts} sec)")
def setup_statusbar(self):
txt = self._compute_status_label()
+5
View File
@@ -201,3 +201,8 @@ class MainTranslate(UnitTranslate):
)
self._dict["x"] = _translate("MainWindow", "X (m)")
self._dict["y"] = _translate("MainWindow", "Y (m)")
self._dict["Yes"] = _translate("MainWindow", "Yes")
self._dict["No"] = _translate("MainWindow", "No")
self._dict["Cancel"] = _translate("MainWindow", "Cancel")
self._dict["Save"] = _translate("MainWindow", "Save")
self._dict["Close"] = _translate("MainWindow", "Close")
-11
View File
@@ -142,17 +142,6 @@ class Config(SQL):
"WHERE name='default-mage'"
)
self.execute(f"""
INSERT INTO solver VALUES (
'mage_fake7',
'default-mage-fake-7',
'Default Pamhyr2 mage fake version 7',
'', '', '',
'',
'@install_dir/mage8/mage_as7{ext} @args @input',
''
)
""")
if int(release) < 6:
posix = os.name == 'posix'
ext = "" if posix else ".exe"
+759 -148
View File
File diff suppressed because it is too large. Load diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.