Solver: Mage: Fix export where data is deleted.

scenarios
Pierre-Antoine 2025-09-01 14:00:01 +02:00
parent 6288f039d2
commit 645a76b0e8
1 changed files with 74 additions and 44 deletions

View File

@ -250,7 +250,12 @@ class Mage(CommandLineSolver):
# Generate sediment additional data if available
sediment = ""
if profile.sl is not None:
if profile.sl is None:
return
if profile.sl.is_deleted():
return
if not any(filter(lambda f: ".GRA" in f, files)):
files.append(self._gra_file)
@ -278,7 +283,12 @@ class Mage(CommandLineSolver):
# Generate sediment additional data if available
sediment = ""
prev = point.z
if point.sl is not None:
if point.sl is None:
return
if point.sl.is_deleted():
return
# Number of layers
nl = len(point.sl)
sediment = f"{nl:>3}"
@ -311,6 +321,9 @@ class Mage(CommandLineSolver):
if bound.node is None:
continue
if bound.is_deleted():
continue
name = self.get_node_name(bound.node)
f.write(f"* {bound.node.name} ({name}) {bound.bctype}\n")
f.write(f"${name}\n")
@ -383,6 +396,9 @@ class Mage(CommandLineSolver):
if lateral.edge is None:
return
if lateral.is_deleted():
return
edges = study.river.enable_edges()
if lateral.edge not in edges:
return
@ -405,6 +421,9 @@ class Mage(CommandLineSolver):
f.write(f"*{header[0]:>9}|{header[1]:>10}\n")
for d in lateral.data:
if d.is_deleted():
continue
if lateral.lctype in ["EV"]:
f.write(f"{d[0]:10.3f}{-d[1]:10.3f}\n")
else:
@ -430,6 +449,9 @@ class Mage(CommandLineSolver):
if friction.begin_strickler is None:
continue
if friction.is_deleted():
continue
num = f"{id:>3}"
brk = f"{friction.begin_rk:>10.3f}"
erk = f"{friction.end_rk:>10.3f}"
@ -583,7 +605,12 @@ class Mage(CommandLineSolver):
def _export_SIN_bhs(self, study, sin_dict, hs, f):
for bhs in hs.basic_structures:
if bhs.enabled:
if not bhs.enabled:
continue
if bhs.is_deleted():
continue
reach_id = study.river.get_edge_id(hs.input_reach) + 1
param_str = ' '.join(
[
@ -677,12 +704,15 @@ class Mage(CommandLineSolver):
if hs.input_reach is None:
continue
if not hs.input_reach.is_enable():
if not hs.input_reach.is_enable() or hs.input_reach.is_deleted():
continue
if not hs.enabled:
continue
if hs.is_deleted():
continue
for bhs in hs.basic_structures:
if bhs.enabled:
logger.info(bhs._type)