Compare commits

..

5 Commits

5 changed files with 107 additions and 55 deletions

View File

@ -503,10 +503,16 @@ class BoundaryCondition(SQLSubModel):
new_0 = self._types[0](data[0].replace(",", "."))
new_1 = self._types[1](data[1].replace(",", "."))
return Data(new_0, new_1)
return Data(
new_0, new_1,
status=self._status
)
def add(self, index: int):
value = Data(self._default_0, self._default_1)
value = Data(
self._default_0, self._default_1,
status=self._status
)
self._data.insert(index, value)
self.modified()
return value

View File

@ -462,7 +462,10 @@ class ProfileXYZ(Profile, SQLSubModel):
"name": point[3],
}
pt = PointXYZ(id=-1, **named_args, profile=self, status=self._status)
pt = PointXYZ(
id=-1, **named_args, profile=self,
status=self._status
)
self._points.append(pt)
self.modified()
@ -524,7 +527,10 @@ class ProfileXYZ(Profile, SQLSubModel):
Returns:
Nothing.
"""
point_xyz = PointXYZ(x=0., y=0., z=0., profile=self, status=self._status)
point_xyz = PointXYZ(
x=0., y=0., z=0., profile=self,
status=self._status
)
self.points.append(point_xyz)
self.modified()

View File

@ -54,7 +54,7 @@ class Graph(SQLSubModel):
def _enable_edges(self):
"""Return a generator"""
return filter(
lambda e: e.is_enable(),
lambda e: e.is_enable() and not e.is_deleted(),
self.edges()
)

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}"
@ -466,6 +488,9 @@ class Mage(CommandLineSolver):
id = 1
for reach in reachs:
cond = study.river.initial_conditions.get(reach)
if cond.is_deleted():
continue
data = cond.data
if len(data) == 0:
continue
@ -474,6 +499,9 @@ class Mage(CommandLineSolver):
id_sec = 1
for d in data:
if d.is_deleted():
continue
IR = f"{id}"
IS = f"{id_sec}"
discharge = f"{d['discharge']:>10.5f}"
@ -490,6 +518,7 @@ class Mage(CommandLineSolver):
if has_ini:
files.append(f"{name}.INI")
return files
def _export_CAS(self, study, repertory, qlog, name="0"):
@ -506,7 +535,7 @@ class Mage(CommandLineSolver):
files.append(f"{name}.CAS")
for reservoir in reservoirs:
if reservoir.node is None:
if reservoir.node is None or reservoir.is_deleted():
continue
reservoir.sort()
@ -561,6 +590,9 @@ class Mage(CommandLineSolver):
if hs.input_section is None:
continue
if hs.is_deleted():
continue
f.write(
'* ouvrage au pk ' +
f"{float(hs.input_section.rk):>12.1f}" + ' ' +
@ -573,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(
[
@ -667,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)