mirror of https://gitlab.com/pamhyr/pamhyr2
Solver: RubarBE: Fix results reading.
parent
df3b3b604d
commit
e640fa1bc0
|
|
@ -558,9 +558,9 @@ class Rubar3(CommandLineSolver):
|
|||
return tuple(map(float, line))
|
||||
|
||||
def set_and_compute_limites(reach, ind, z, q, s):
|
||||
reach.set(0, timestamp, "Z", z)
|
||||
reach.set(0, timestamp, "Q", q)
|
||||
reach.set(0, timestamp, "V", s)
|
||||
reach.set(ind, timestamp, "Z", z)
|
||||
reach.set(ind, timestamp, "Q", q)
|
||||
reach.set(ind, timestamp, "V", s)
|
||||
|
||||
profile = reach.profile(ind)
|
||||
limits = profile.geometry.get_water_limits(z)
|
||||
|
|
@ -573,21 +573,24 @@ class Rubar3(CommandLineSolver):
|
|||
while True:
|
||||
line = f.readline()
|
||||
if line == "":
|
||||
results.set("timestamps", ts)
|
||||
return
|
||||
|
||||
timestamp = float(line)
|
||||
ts.add(timestamp)
|
||||
|
||||
logger.info(f"read: profil.{name}: timestamp = {timestamp}")
|
||||
|
||||
for reach, lm in reachs:
|
||||
# First profile
|
||||
z, s, q, e = read_data_line(f)
|
||||
e, s, q, z = read_data_line(f)
|
||||
set_and_compute_limites(reach, 0, z, q, s)
|
||||
|
||||
# For each profile
|
||||
ind = 1
|
||||
pz, ps, pq, pe = read_data_line(f)
|
||||
pe, ps, pq, pz = read_data_line(f)
|
||||
while ind < lm - 2:
|
||||
z, s, q, e = read_data_line(f)
|
||||
e, s, q, z = read_data_line(f)
|
||||
set_and_compute_limites(
|
||||
reach, ind,
|
||||
(pz + z) / 2,
|
||||
|
|
@ -595,15 +598,13 @@ class Rubar3(CommandLineSolver):
|
|||
(ps + s) / 2
|
||||
)
|
||||
|
||||
pz, ps, pq, pe = z, s, q, e
|
||||
pe, ps, pq, pz = z, s, q, e
|
||||
ind += 1
|
||||
|
||||
# Last profile
|
||||
z, s, q, e = read_data_line(f)
|
||||
e, s, q, z = read_data_line(f)
|
||||
set_and_compute_limites(reach, ind, z, q, s)
|
||||
|
||||
results.set("timestamps", ts)
|
||||
|
||||
@timer
|
||||
def results(self, study, repertory, qlog=None, name="0"):
|
||||
results = Results(
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ from platformdirs import user_cache_dir
|
|||
|
||||
from Solver.AdisTS import AdisTS
|
||||
from Solver.Mage import Mage8
|
||||
from Solver.RubarBE import Rubar3
|
||||
from tools import logger_exception, pamhyr_db_need_update
|
||||
|
||||
from PyQt5 import QtGui
|
||||
|
|
@ -1506,6 +1507,8 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
return False
|
||||
|
||||
def open_solver_results(self, solver, results=None):
|
||||
logger.info(f"{solver} {results}")
|
||||
|
||||
def reading_fn():
|
||||
self._tmp_results = results
|
||||
|
||||
|
|
@ -1525,7 +1528,10 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
if type(results) is str:
|
||||
logger.info(f"Open results from {os.path.dirname(results)}")
|
||||
|
||||
name = os.path.basename(results).replace(".BIN", "")
|
||||
if ".BIN" in results:
|
||||
name = os.path.basename(results).replace(".BIN", "")
|
||||
elif "profil." in results:
|
||||
name = os.path.basename(results).replace("profil.", "")
|
||||
|
||||
def reading_fn():
|
||||
self._tmp_results = solver.results(
|
||||
|
|
@ -1664,7 +1670,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
dialog.setFileMode(QFileDialog.FileMode.ExistingFile)
|
||||
dialog.setDefaultSuffix(".BIN")
|
||||
# dialog.setFilter(dialog.filter() | QtCore.QDir.Hidden)
|
||||
dialog.setNameFilters(['Mage (*.BIN)'])
|
||||
dialog.setNameFilters(['Mage (*.BIN)', 'Rubar3 (profil.*)'])
|
||||
|
||||
if self._study.filename is not None:
|
||||
if self._last_solver is None:
|
||||
|
|
@ -1679,8 +1685,15 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
if dialog.exec_():
|
||||
file_name = dialog.selectedFiles()
|
||||
logger.info(f"Select results: {file_name}")
|
||||
|
||||
solver = None
|
||||
if ".BIN" in file_name:
|
||||
solver = Mage8("Mage8")
|
||||
else:
|
||||
solver = Rubar3("Rubar3")
|
||||
|
||||
self.open_solver_results(
|
||||
Mage8("Mage"),
|
||||
solver,
|
||||
results=file_name[0]
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,8 @@ class TableModel(PamhyrTableModel):
|
|||
self._lst = self._parent._solvers
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self._timestamp = 0.0
|
||||
self._timestamp = max(kwargs["parent"]._timestamps)
|
||||
|
||||
super(TableModel, self).__init__(**kwargs)
|
||||
|
||||
def data(self, index, role=Qt.DisplayRole):
|
||||
|
|
|
|||
Loading…
Reference in New Issue