Commit ffbd2e24 authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

Mage: Minor code style refactoring.

Showing with 25 additions and 28 deletions
+25 -28
...@@ -442,14 +442,9 @@ class Mage(CommandLineSolver): ...@@ -442,14 +442,9 @@ class Mage(CommandLineSolver):
sin_dict = { sin_dict = {
"ND": "*", "ND": "*",
"S1": "D", "S1": "D", "S2": "T", "S3": "T",
"S2": "T", "OR": "O", "OC": "B", "OV": "F",
"S3": "T", "V1": "V", "V2": "W",
"OR": "O",
"OC": "B",
"OV": "F",
"V1": "V",
"V2": "W",
"BO": "A", "BO": "A",
"UD": "X", "UD": "X",
"PO": "P", "PO": "P",
...@@ -466,32 +461,34 @@ class Mage(CommandLineSolver): ...@@ -466,32 +461,34 @@ class Mage(CommandLineSolver):
files.append(f"{name}.SIN") files.append(f"{name}.SIN")
for hs in hydraulic_structures: for hs in hydraulic_structures:
if hs.input_reach.is_enable: if not hs.input_reach.is_enable():
f.write( continue
'* ouvrage au pk ' +
f"{hs.input_kp:>12.1f}" + ' ' +
hs.name + '\n'
)
for bhs in hs.basic_structures: f.write(
reach_id = study.river.get_edge_id(hs.input_reach) + 1 '* ouvrage au pk ' +
param_str = ' '.join( f"{hs.input_kp:>12.1f}" + ' ' +
[ hs.name + '\n'
f'{p:>10.3f}' )
for p in self._export_SIN_parameters(bhs)
]
)
f.write( for bhs in hs.basic_structures:
f"{sin_dict[bhs._type]} " + reach_id = study.river.get_edge_id(hs.input_reach) + 1
f"{reach_id} {hs.input_kp:>12.3f} {param_str} " + param_str = ' '.join(
f"{bhs.name}\n" [
) f'{p:>10.3f}'
for p in self._export_SIN_parameters(bhs)
]
)
f.write(
f"{sin_dict[bhs._type]} " +
f"{reach_id} {hs.input_kp:>12.3f} {param_str} " +
f"{bhs.name}\n"
)
return files return files
def _export_SIN_parameters(self, bhs): def _export_SIN_parameters(self, bhs):
res = [9999.999]*5 res = [9999.999] * 5
if len(bhs) == 5: if len(bhs) == 5:
res = self._export_SIN_parameters_5(bhs) res = self._export_SIN_parameters_5(bhs)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment