mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Sediment: Add solid BC, QSO export and profile + point sediment layers export.
This commit is contained in:
1 parent
23fb3e6fb3
commit
768a0b9f14
8 files changed
+107
-14
No files matched your search
+12
-2
@@ -213,12 +213,22 @@ class AbstractSolver(object):
|
||||
# Command line executable path is between " char
|
||||
cmd = cmd.split("\"")
|
||||
exe = cmd[1].replace("\ ", " ")
|
||||
args = "\"".join(cmd[2:]).split(" ")[1:]
|
||||
args = list(
|
||||
filter(
|
||||
lambda s: s != "",
|
||||
"\"".join(cmd[2:]).split(" ")[1:]
|
||||
)
|
||||
)
|
||||
else:
|
||||
# We suppose the command line executable path as no space char
|
||||
cmd = cmd.replace("\ ", "&_&").split(" ")
|
||||
exe = cmd[0].replace("&_&", " ")
|
||||
args = list(map(lambda s: s.replace("&_&", "\ "), cmd[1:]))
|
||||
args = list(
|
||||
filter(
|
||||
lambda s: s != "",
|
||||
map(lambda s: s.replace("&_&", "\ "), cmd[1:])
|
||||
)
|
||||
)
|
||||
|
||||
logger.info(f"! {exe} {args}")
|
||||
return exe, args
|
||||
|
||||
+69
-7
@@ -127,23 +127,47 @@ class Mage(AbstractSolver):
|
||||
with mage_file_open(os.path.join(repertory, f"{name}.ST"), "w+") as f:
|
||||
files.append(f"{name}.ST")
|
||||
|
||||
cnt_num = 1
|
||||
for profile in edge.reach.profiles:
|
||||
num = f"{profile.num:>6}"
|
||||
num = f"{cnt_num:>6}"
|
||||
c1 = f"{profile.code1:>6}"
|
||||
c2 = f"{profile.code2:>6}"
|
||||
t = f"{len(profile.points):>6}"
|
||||
kp = f"{profile.kp:>13.4f}"
|
||||
name = profile.name
|
||||
pname = profile.name
|
||||
if profile.name == "":
|
||||
pname = f"p{profile.id:>3}".replace(" ", "p")
|
||||
name = f"{pname}"
|
||||
|
||||
f.write(f"{num}{c1}{c2}{t}{kp} {name}\n")
|
||||
sediment = ""
|
||||
if profile.sl is not None:
|
||||
if not any(filter(lambda f: ".GRA" in f, files)):
|
||||
files.append("0.GRA")
|
||||
|
||||
nl = len(profile.sl)
|
||||
sediment = f" {nl:>3}"
|
||||
for l in profile.sl.layers:
|
||||
sediment += f" {l.height:>10} {l.d50:>10} {l.sigma:>10} {l.critical_constraint:>10}"
|
||||
|
||||
f.write(f"{num}{c1}{c2}{t}{kp} {name} {sediment}\n")
|
||||
cnt_num += 1
|
||||
|
||||
for point in profile.points:
|
||||
x = f"{point.x:>13.4f}"
|
||||
y = f"{point.y:>13.4f}"
|
||||
z = f"{point.z:>13.4f}"
|
||||
n = point.name
|
||||
n = f"{point.name:<3}"
|
||||
|
||||
f.write(f"{x}{y}{z} {n}\n")
|
||||
sediment = ""
|
||||
prev = point.z
|
||||
if point.sl is not None:
|
||||
nl = len(point.sl)
|
||||
sediment = f"{nl:>3}"
|
||||
for l in point.sl.layers:
|
||||
prev = round(prev - l.height, 5)
|
||||
sediment += f" {prev:>10} {l.d50:>10} {l.sigma:>10} {l.critical_constraint:>10}"
|
||||
|
||||
f.write(f"{x}{y}{z} {n} {sediment}\n")
|
||||
|
||||
f.write(f" 999.9990 999.9990 999.9990\n")
|
||||
|
||||
@@ -182,6 +206,7 @@ class Mage(AbstractSolver):
|
||||
AVA = []
|
||||
HYD = []
|
||||
LIM = []
|
||||
QSO = []
|
||||
|
||||
for tab in ["liquid", "solid", "suspenssion"]:
|
||||
for bound in lst.get_tab(tab):
|
||||
@@ -191,10 +216,13 @@ class Mage(AbstractSolver):
|
||||
HYD.append(bound)
|
||||
elif bound.bctype == "TZ":
|
||||
LIM.append(bound)
|
||||
elif bound.bctype == "SL":
|
||||
QSO.append(bound)
|
||||
|
||||
files = files + self._export_BC("AVA", AVA, repertory, qlog)
|
||||
files = files + self._export_BC("HYD", HYD, repertory, qlog)
|
||||
files = files + self._export_BC("LIM", LIM, repertory, qlog)
|
||||
files = files + self._export_QSO(QSO, repertory, qlog)
|
||||
|
||||
return files
|
||||
|
||||
@@ -332,12 +360,20 @@ class Mage(AbstractSolver):
|
||||
for file in files:
|
||||
EXT = file.split('.')[1]
|
||||
|
||||
f.write(f"{EXT} {file}\n")
|
||||
if EXT not in ["ST", "GRA"]:
|
||||
f.write(f"{EXT} {file}\n")
|
||||
|
||||
f.write("* OUTPUT\n")
|
||||
f.write(f"TRA 0.TRA\n")
|
||||
f.write(f"BIN 0.BIN\n")
|
||||
|
||||
for file in files:
|
||||
EXT = file.split('.')[1]
|
||||
|
||||
if EXT in ["GRA"]:
|
||||
f.write(f"{EXT} {file}\n")
|
||||
|
||||
|
||||
@timer
|
||||
def export(self, study, repertory, qlog = None):
|
||||
self._export_ST(study, repertory, qlog)
|
||||
@@ -459,11 +495,37 @@ class Mage8(Mage):
|
||||
|
||||
return files
|
||||
|
||||
@timer
|
||||
def _export_QSO(self, bounds, repertory, qlog):
|
||||
files = []
|
||||
|
||||
if len(bounds) == 0:
|
||||
return files
|
||||
|
||||
if qlog is not None:
|
||||
qlog.put(f"Export QSO file")
|
||||
|
||||
with mage_file_open(os.path.join(repertory, f"0.QSO"), "w+") as f:
|
||||
files.append(f"0.QSO")
|
||||
|
||||
for bound in bounds:
|
||||
name = f"{bound.node.id:3}".replace(" ", "x")
|
||||
f.write(f"* {bound.node.name} ({name}) {bound.bctype}\n")
|
||||
f.write(f"${name}\n")
|
||||
header = bound.header
|
||||
f.write(f"*{header[0]:>9}|{header[1]:>10}\n")
|
||||
|
||||
for d in bound.data:
|
||||
f.write(f"{d[0]:10.3f}{d[1]:10.3f}\n")
|
||||
|
||||
return files
|
||||
|
||||
|
||||
@timer
|
||||
def export(self, study, repertory, qlog = None):
|
||||
files = []
|
||||
|
||||
self._export_ST(study, repertory, qlog)
|
||||
files = self._export_ST(study, repertory, qlog)
|
||||
files = files + self._export_PAR(study, repertory, qlog)
|
||||
files = files + self._export_NET(study, repertory, qlog)
|
||||
files = files + self._export_bound_cond(study, repertory, qlog)
|
||||
|
||||
Reference in new issue
Block a user