mirror of https://gitlab.com/pamhyr/pamhyr2
Mage, Initial Cond: Fix INI files export.
parent
e66b7f665a
commit
d9176c6d83
|
|
@ -217,3 +217,12 @@ class InitialConditions(object):
|
|||
|
||||
self._data.append(new)
|
||||
prev = new
|
||||
|
||||
is_reverse = False
|
||||
if profiles[0].kp > profiles[-1].kp:
|
||||
is_reverse = True
|
||||
|
||||
self._data.sort(
|
||||
reverse = not is_reverse,
|
||||
key = lambda d: d['kp']
|
||||
)
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ class Mage(AbstractSolver):
|
|||
|
||||
return files
|
||||
|
||||
@timer
|
||||
def _export_BC(self, bound, repertory, qlog):
|
||||
files = []
|
||||
|
||||
|
|
@ -166,7 +167,6 @@ class Mage(AbstractSolver):
|
|||
f.write(f"K{num} {bkp}{ekp}{coef_1}{coef_2}\n")
|
||||
id += 1
|
||||
|
||||
|
||||
return files
|
||||
|
||||
@timer
|
||||
|
|
@ -180,22 +180,32 @@ class Mage(AbstractSolver):
|
|||
with open(os.path.join(repertory, "0.INI"), "w+") as f:
|
||||
files.append("0.INI")
|
||||
f.write("* This file is generate by PAMHYR, please don't modify\n")
|
||||
# TODO put real date...
|
||||
f.write(f"$ date en minutes : 0.00\n")
|
||||
f.write(f"* IB IS discharge elevation kp\n")
|
||||
|
||||
id = 1
|
||||
reachs = study.river.edges()
|
||||
for reach in reachs:
|
||||
cond = study.river.initial_conditions.get(reach)
|
||||
data = cond.data
|
||||
|
||||
id = f"{reach.id+1:>3}"
|
||||
id_sec = 1
|
||||
for data in cond.data:
|
||||
discharge = f"{data['flow']:>10.5f}"
|
||||
cote = f"{data['elevation']:>11.6f}"
|
||||
for d in data:
|
||||
IR = f"{id:>3}"
|
||||
IS = f"{id_sec:>3}"
|
||||
discharge = f"{d['flow']:>10.5f}"
|
||||
elevation = f"{d['elevation']:>11.6f}"
|
||||
kp = f"{d['kp']:>9.2f}"
|
||||
|
||||
f.write(f" {id} {id_sec:>3} {discharge}{cote}\n")
|
||||
f.write(f" {IR} {IS} {discharge}{elevation} {kp}\n")
|
||||
id_sec += 1
|
||||
|
||||
id += 1
|
||||
|
||||
return files
|
||||
|
||||
@timer
|
||||
def _export_REP(self, study, repertory, files, qlog):
|
||||
if qlog is not None:
|
||||
qlog.put("Export REP file")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import tempfile
|
||||
import os
|
||||
|
||||
from queue import Queue
|
||||
from tools import trace, timer
|
||||
|
||||
|
|
@ -53,6 +56,7 @@ class SelectSolverWindow(ASubWindow, ListedSubWindow):
|
|||
def setup_connections(self):
|
||||
self.find(QPushButton, "pushButton_run").clicked.connect(self.accept)
|
||||
self.find(QPushButton, "pushButton_cancel").clicked.connect(self.reject)
|
||||
|
||||
@property
|
||||
def solver(self):
|
||||
return self._solver
|
||||
|
|
@ -89,7 +93,16 @@ class SolverLogWindow(ASubMainWindow, ListedSubWindow):
|
|||
self.setup_alarm()
|
||||
self.setup_connections()
|
||||
|
||||
self._workdir = "/tmp/pamhyr/0/"
|
||||
self._workdir = ""
|
||||
if self._study.filename == "":
|
||||
self._workdir = tempfile.TemporaryDirectory()
|
||||
else:
|
||||
self._workdir = os.path.join(
|
||||
os.path.dirname(self._study.filename),
|
||||
"0"
|
||||
)
|
||||
os.makedirs(self._workdir, exist_ok = True)
|
||||
|
||||
self._alarm.start(500)
|
||||
self._output = Queue()
|
||||
self._process = self.new_process(parent)
|
||||
|
|
|
|||
Loading…
Reference in New Issue