HS, Mage: Rewrite some code for coding style.

setup.py
Pierre-Antoine Rouby 2023-12-13 16:30:18 +01:00
parent 73ae571de1
commit cd2fda8224
2 changed files with 75 additions and 88 deletions

View File

@ -125,22 +125,22 @@ class OrificeCirculaire(BasicHS):
] ]
#class OrificeVoute(BasicHS): # class OrificeVoute(BasicHS):
#def __init__(self, id: int = -1, name: str = "", # def __init__(self, id: int = -1, name: str = "",
#status=None): # status=None):
#super(OrificeVoute, self).__init__( # super(OrificeVoute, self).__init__(
#id=id, name=name, # id=id, name=name,
#status=status # status=status
#) # )
#self._type = "OV" # self._type = "OV"
#self._data = [ # self._data = [
#BHSValue("Cote", float, 1.0, status=status), # BHSValue("Cote", float, 1.0, status=status),
#BHSValue("Largeur", float, 1.0, status=status), # BHSValue("Largeur", float, 1.0, status=status),
#BHSValue("Haut de la voute", float, 0.0, status=status), # BHSValue("Haut de la voute", float, 0.0, status=status),
#BHSValue("Bas de la voute", float, 0.0, status=status), # BHSValue("Bas de la voute", float, 0.0, status=status),
#BHSValue("Coefficient de debit", float, 0.4, status=status), # BHSValue("Coefficient de debit", float, 0.4, status=status),
#] # ]
class VanneRectangulaire(BasicHS): class VanneRectangulaire(BasicHS):
@ -220,7 +220,7 @@ BHS_types = {
"S3": SeuilTriangulaire, "S3": SeuilTriangulaire,
"OR": OrificeRectangulaire, "OR": OrificeRectangulaire,
"OC": OrificeCirculaire, "OC": OrificeCirculaire,
#"OV": OrificeVoute, # "OV": OrificeVoute,
"V1": VanneRectangulaire, "V1": VanneRectangulaire,
"V2": VanneRectangulaireSimplifiee, "V2": VanneRectangulaireSimplifiee,
"BO": Borda, "BO": Borda,

View File

@ -31,77 +31,6 @@ from Model.Results.River.River import River, Reach, Profile
logger = logging.getLogger() logger = logging.getLogger()
def mage_param(bhs):
params = []
if bhs._type == "S1": # D
params = [bhs._data[0].value,
bhs._data[1].value,
0.0,
bhs._data[2].value,
9999.999,
]
elif bhs._type == "S2": # T
params = [bhs._data[0].value,
bhs._data[1].value,
bhs._data[2].value,
bhs._data[3].value,
bhs._data[4].value,
]
elif bhs._type == "S3": # T
params = [0.0,bhs._data[0].value,
bhs._data[1].value,
bhs._data[2].value,
bhs._data[3].value,
]
elif bhs._type == "OR": # O
params = [bhs._data[0].value,
bhs._data[1].value,
bhs._data[2].value,
bhs._data[3].value,
bhs._data[4].value,
]
elif bhs._type == "OC": # B
params = [bhs._data[0].value,
bhs._data[1].value,
bhs._data[2].value,
bhs._data[3].value,
0.0,
]
elif bhs._type == "V1": # V
params = [bhs._data[0].value,
bhs._data[1].value,
bhs._data[2].value,
bhs._data[3].value,
bhs._data[4].value,
]
elif bhs._type == "V2": # W
params = [bhs._data[0].value,
bhs._data[1].value,
bhs._data[2].value,
bhs._data[3].value,
bhs._data[4].value,
]
elif bhs._type == "BO": # B
params = [bhs._data[0].value,
bhs._data[1].value,
bhs._data[2].value,
0.0,
0.0,
]
elif bhs._type == "UD": # X
params = [bhs._data[0].value,
bhs._data[1].value,
bhs._data[2].value,
bhs._data[3].value,
bhs._data[4].value,
]
else:
params = [9999.999]*5
return params
def mage_file_open(filepath, mode): def mage_file_open(filepath, mode):
f = open(filepath, mode) f = open(filepath, mode)
@ -549,7 +478,7 @@ class Mage(CommandLineSolver):
param_str = ' '.join( param_str = ' '.join(
[ [
f'{p:>10.3f}' f'{p:>10.3f}'
for p in mage_param(bhs) for p in self._export_SIN_parameters(bhs)
] ]
) )
@ -561,6 +490,64 @@ class Mage(CommandLineSolver):
return files return files
def _export_SIN_parameters(self, bhs):
res = [9999.999]*5
if len(bhs) == 5:
res = self._export_SIN_parameters_5(bhs)
elif len(bhs) == 4:
res = self._export_SIN_parameters_4(bhs)
elif len(bhs) == 3:
res = self._export_SIN_parameters_3(bhs)
return res
def _export_SIN_parameters_5(self, bhs):
# S2, OR, V1, V2, UD
return [
bhs._data[0].value,
bhs._data[1].value,
bhs._data[2].value,
bhs._data[3].value,
bhs._data[4].value,
]
def _export_SIN_parameters_4(self, bhs):
# S3, OC
res = [
bhs._data[0].value,
bhs._data[1].value,
bhs._data[2].value,
bhs._data[3].value,
0.0,
]
if bhs._type == "T": # S3
res = [0.0] + res[:-1]
return res
def _export_SIN_parameters_3(self, bhs):
# S1, BO
if bhs._type == "S1":
res = [
bhs._data[0].value,
bhs._data[1].value,
0.0,
bhs._data[2].value,
9999.99,
]
else:
res = [
bhs._data[0].value,
bhs._data[1].value,
bhs._data[2].value,
0.0,
0.0,
]
return res
@timer @timer
def _export_DEV(self, study, repertory, qlog, name="0"): def _export_DEV(self, study, repertory, qlog, name="0"):
files = [] files = []