diff --git a/README.md b/README.md
index 6618bfc..21a75c3 100644
--- a/README.md
+++ b/README.md
@@ -6,17 +6,17 @@ Crue10 tools
## Crue10 API - Parseur de fichiers
- Lecture d'une étude et la géométrie
- - [Lire une étude](snippets/read_studies.py)
- - [Lire un modèle](snippets/read_model.py)
- - [Lire un sous-modèle et ses EMHs](snippets/read_submodel.py)
+ - [Lire une étude](snippets/lire_etudes.py)
+ - [Lire un modèle](snippets/lire_modele.py)
+ - [Lire un sous-modèle et ses EMHs](snippets/lire_sous_modele.py)
- Écriture d'une étude et la géométrie
- [Écrire un sous-modèle](snippets/write_submodel_from_scratch.py)
- [Écrire une étude](snippets/write_study_from_scratch.py)
- Calcul (= lancer un run)
- [Créer et lancer une série de runs](snippets/run_calculations.py)
- Post-traitement de résultats (d'un run)
- - [Lire un run avec ses résultats](snippets/read_run_and_results.py)
- - [Lire un modèle et les résultats d'un run associé](snippets/read_model_and_run.py)
+ - [Lire un run avec ses résultats](snippets/lire_run_et_resultats.py)
+ - [Lire un modèle et les résultats d'un run associé](snippets/lire_modele_et_run.py)
## Scripts en ligne de commande
diff --git a/cli/crue10_merge_models.py b/cli/crue10_merge_models.py
index afb0373..4fd82d9 100755
--- a/cli/crue10_merge_models.py
+++ b/cli/crue10_merge_models.py
@@ -21,7 +21,7 @@
"""
import sys
-from crue10.study import Study
+from crue10.etude import Etude
from crue10.utils import CrueError, logger
from crue10.utils.cli_parser import MyArgParse
@@ -50,33 +50,33 @@ def crue10_merge_models(args):
if not reference_found:
raise CrueError("Le noeud de référence n'a pas pu être trouvé pour : `%s`" % nodes_str)
- study_out = Study(args.etu_path_out, access='w')
- study_out.create_empty_scenario('Sc_%s' % args.out_name, 'Mo_%s' % args.out_name, submodel_name=None)
- model_out = study_out.get_model('Mo_%s' % args.out_name)
+ study_out = Etude(args.etu_path_out, access='w')
+ study_out.create_empty_scenario('Sc_%s' % args.out_name, 'Mo_%s' % args.out_name, nom_sous_modele=None)
+ model_out = study_out.get_modele('Mo_%s' % args.out_name)
for i, (etu_path, mo_name, suffix) in enumerate(zip(args.etu_path_list, args.mo_name_list, args.suffix_list)):
- study_in = Study(etu_path, access='r')
- model_in = study_in.get_model(mo_name)
+ study_in = Etude(etu_path, access='r')
+ model_in = study_in.get_modele(mo_name)
model_in.read_all()
# Rename all EMHs and set optional shared nodes
model_in.rename_emhs(suffix, emhs_to_preserve=noeud_id_list[i])
for j, noeud_id in enumerate(noeud_id_list[i]):
if noeud_id != '':
- if noeud_id not in [nd.id for nd in model_in.get_noeud_list()]:
+ if noeud_id not in [nd.id for nd in model_in.get_liste_noeuds()]:
raise CrueError("Le noeud %s n'est pas dans le modèle %s" % (noeud_id, model_in.id))
model_in.rename_noeud(noeud_id, noeud_id_references[j])
- model_out.append_from_model(model_in)
+ model_out.ajouter_depuis_modele(model_in)
logger.info("~> Étude en sortie:")
logger.info(study_out)
logger.info(model_out.summary())
model_out.log_duplicated_emh()
- for submodel in model_out.submodels:
- study_out.add_submodel(submodel)
- logger.info(submodel.summary())
+ for sous_modele in model_out.sous_modeles:
+ study_out.ajouter_sous_modele(sous_modele)
+ logger.info(sous_modele.summary())
study_out.write_all()
diff --git a/cli/crue10_merge_submodels.py b/cli/crue10_merge_submodels.py
index e11564e..a78bf84 100755
--- a/cli/crue10_merge_submodels.py
+++ b/cli/crue10_merge_submodels.py
@@ -6,32 +6,32 @@
"""
import sys
-from crue10.study import Study
-from crue10.submodel import SubModel
+from crue10.etude import Etude
+from crue10.sous_modele import SousModele
from crue10.utils import CrueError, logger
from crue10.utils.cli_parser import MyArgParse
-def crue10_merge_submodels(args):
+def crue10_merge_sous_modeles(args):
if len(args.etu_path_list) != len(args.sm_name_list) != len(args.suffix_list):
raise CrueError("Les arguments `etu_path_list`, `suffix_list` et `sm_name_list` n'ont pas la même longueur !")
first = True
- merged_submodel = None
+ merged_sous_modele = None
for etu_path, sm_name, suffix in zip(args.etu_path_list, args.sm_name_list, args.suffix_list):
- study = Study(etu_path)
- submodel = study.get_submodel(sm_name)
- submodel.read_all()
- print(submodel)
+ study = Etude(etu_path)
+ sous_modele = study.get_sous_modele(sm_name)
+ sous_modele.read_all()
+ print(sous_modele)
if first:
- merged_submodel = SubModel(submodel.id, submodel.files)
+ merged_sous_modele = SousModele(sous_modele.id, sous_modele.files)
first = False
- merged_submodel.add_emh_from_submodel(submodel, suffix)
+ merged_sous_modele.ajouter_emh_depuis_sous_modele(sous_modele, suffix)
- print("~> Merged submodel:")
- print(merged_submodel)
- merged_submodel.write_all(args.output_folder)
+ print("~> Merged sous_modele:")
+ print(merged_sous_modele)
+ merged_sous_modele.write_all(args.output_folder)
parser = MyArgParse(description=__doc__)
@@ -44,7 +44,7 @@ def crue10_merge_submodels(args):
if __name__ == '__main__':
args = parser.parse_args()
try:
- crue10_merge_submodels(args)
+ crue10_merge_sous_modeles(args)
except CrueError as e:
logger.critical(e)
sys.exit(1)
diff --git a/cli/crue10_model_extract_shp.py b/cli/crue10_model_extract_shp.py
index 8d35c7c..912f41a 100755
--- a/cli/crue10_model_extract_shp.py
+++ b/cli/crue10_model_extract_shp.py
@@ -5,24 +5,24 @@
"""
import sys
-from crue10.study import Study
+from crue10.etude import Etude
from crue10.utils import CrueError, logger
from crue10.utils.cli_parser import MyArgParse
def crue10_model_extract_shp(args):
- study = Study(args.etu_path)
- model = study.get_model(args.mo_name)
- model.read_all()
- print(model.summary())
+ study = Etude(args.etu_path)
+ model = study.get_modele(args.mo_name)
+ modele.read_all()
+ print(modele.summary())
if args.shp_sections:
- model.write_shp_sectionprofil_as_points(args.shp_sections)
+ modele.write_shp_sectionprofil_as_points(args.shp_sections)
if args.shp_limits:
- for submodel in model.submodels:
- submodel.convert_sectionidem_to_sectionprofil()
- model.write_shp_limites_lits_numerotes(args.shp_limits)
+ for sous_modele in modele.sous_modeles:
+ sous_modele.convert_sectionidem_to_sectionprofil()
+ modele.write_shp_limites_lits_numerotes(args.shp_limits)
parser = MyArgParse(description=__doc__)
diff --git a/cli/crue10_model_for_maps.py b/cli/crue10_model_for_maps.py
index 51dae9a..253f479 100755
--- a/cli/crue10_model_for_maps.py
+++ b/cli/crue10_model_for_maps.py
@@ -22,21 +22,21 @@
from crue10.emh.branche import Branche
from crue10.emh.section import SectionProfil
-from crue10.study import Study
+from crue10.etude import Etude
from crue10.utils.cli_parser import MyArgParse
from crue10.utils import CrueError, logger
def crue10_model_for_maps(args):
- study = Study(args.etu_path)
- model = study.get_model(args.mo_name)
- model.read_all()
- logger.info(model.summary())
+ study = Etude(args.etu_path)
+ model = study.get_modele(args.mo_name)
+ modele.read_all()
+ logger.info(modele.summary())
if args.model_name:
model_name = args.model_name
else:
- model_name = model.id
+ model_name = modele.id
if not os.path.exists(args.out_folder):
os.makedirs(args.out_folder)
@@ -47,14 +47,14 @@ def crue10_model_for_maps(args):
'properties': OrderedDict([('NOM', 'str'), ('modele', 'str'), ('sousmodele', 'str')]),
}
with fiona.open(os.path.join(args.out_folder, 'noeuds.shp'), 'w', 'ESRI Shapefile', schema) as out_shp:
- for submodel in model.submodels:
- for _, noeud in submodel.noeuds.items():
+ for sous_modele in modele.sous_modeles:
+ for _, noeud in sous_modele.noeuds.items():
layer = {
'geometry': mapping(noeud.geom),
'properties': {
'NOM': noeud.id,
'modele': model_name,
- 'sousmodele': submodel.id,
+ 'sousmodele': sous_modele.id,
}
}
out_shp.write(layer)
@@ -63,18 +63,18 @@ def crue10_model_for_maps(args):
schema = {
'geometry': 'Polygon',
'properties': OrderedDict([('NOM', 'str'), ('modele', 'str'), ('sousmodele', 'str'),
- ('noeud', 'str'), ('is_active', 'bool')]),
+ ('noeud_reference', 'str'), ('is_active', 'bool')]),
}
with fiona.open(os.path.join(args.out_folder, 'casiers.shp'), 'w', 'ESRI Shapefile', schema) as out_shp:
- for submodel in model.submodels:
- for _, casier in submodel.casiers.items():
+ for sous_modele in modele.sous_modeles:
+ for _, casier in sous_modele.casiers.items():
layer = {
'geometry': mapping(Polygon(casier.geom)),
'properties': {
'NOM': casier.id,
'modele': model_name,
- 'sousmodele': submodel.id,
- 'noeud': casier.noeud.id,
+ 'sousmodele': sous_modele.id,
+ 'noeud_reference': casier.noeud_reference.id,
'is_active': casier.is_active,
}
}
@@ -87,14 +87,14 @@ def crue10_model_for_maps(args):
('nd_aval', 'str'), ('type', 'int'), ('is_active', 'bool')]),
}
with fiona.open(os.path.join(args.out_folder, 'branches.shp'), 'w', 'ESRI Shapefile', schema) as out_shp:
- for submodel in model.submodels:
- for _, branche in submodel.branches.items():
+ for sous_modele in modele.sous_modeles:
+ for _, branche in sous_modele.branches.items():
layer = {
'geometry': mapping(branche.geom),
'properties': {
'NOM': branche.id,
'modele': model_name,
- 'sousmodele': submodel.id,
+ 'sousmodele': sous_modele.id,
'nd_amont': branche.noeud_amont.id,
'nd_aval': branche.noeud_aval.id,
'type': branche.type,
@@ -110,36 +110,36 @@ def crue10_model_for_maps(args):
('id_branche', 'str'), ('xp', 'float')]),
}
with fiona.open(os.path.join(args.out_folder, 'sections.shp'), 'w', 'ESRI Shapefile', schema) as out_shp:
- for submodel in model.submodels:
- for section in submodel.iter_on_sections(section_type=SectionProfil, ignore_inactive=True):
+ for sous_modele in modele.sous_modeles:
+ for section in sous_modele.iter_on_sections(section_type=SectionProfil, ignore_inactive=True):
layer = {
'geometry': mapping(section.geom_trace),
'properties': {
'NOM': section.id,
'modele': model_name,
- 'sousmodele': submodel.id,
+ 'sousmodele': sous_modele.id,
'id_branche': branche.id,
'xp': section.xp,
}
}
out_shp.write(layer)
- # Submodels
+ # sous_modeles
mo_geom_list = []
schema = {
'geometry': 'Polygon',
'properties': OrderedDict([('NOM', 'str'), ('modele', 'str')]),
}
with fiona.open(os.path.join(args.out_folder, 'sous-modeles.shp'), 'w', 'ESRI Shapefile', schema) as out_shp:
- for submodel in model.submodels:
- submodel.remove_sectioninterpolee()
- submodel.normalize_geometry() # replace SectionIdem by SectionProfil
+ for sous_modele in modele.sous_modeles:
+ sous_modele.remove_sectioninterpolee()
+ sous_modele.normalize_geometry() # replace SectionIdem by SectionProfil
sm_geom_list = []
- for _, casier in submodel.casiers.items():
+ for _, casier in sous_modele.casiers.items():
sm_geom_list.append(Polygon(casier.geom).buffer(args.sm_buffer))
- for branche in submodel.iter_on_branches():
+ for branche in sous_modele.iter_on_branches():
if branche.type in Branche.TYPES_WITH_GEOM:
# Build list of coordinates following upstream section, left ending points, downstream section and
# right ending point
@@ -159,7 +159,7 @@ def crue10_model_for_maps(args):
# Add geometry of the branch (necessary for branches without geometry)
sm_geom_list.append(branche.geom.buffer(args.sm_buffer))
- for _, noeud in submodel.noeuds.items():
+ for _, noeud in sous_modele.noeuds.items():
sm_geom_list.append(noeud.geom.buffer(args.sm_buffer))
mo_geom_list += sm_geom_list
@@ -168,13 +168,13 @@ def crue10_model_for_maps(args):
layer = {
'geometry': mapping(sm_zone),
'properties': {
- 'NOM': submodel.id,
+ 'NOM': sous_modele.id,
'modele': model_name,
}
}
out_shp.write(layer)
- # Model
+ # Modele
schema = {
'geometry': 'Polygon',
'properties': OrderedDict([('NOM', 'str'), ('id_modele', 'str'), ('bief', 'str'),
@@ -187,7 +187,7 @@ def crue10_model_for_maps(args):
'geometry': mapping(mo_zone),
'properties': {
'NOM': model_name,
- 'id_modele': model.id,
+ 'id_modele': modele.id,
'bief': args.bief,
'auteurs': args.auteurs,
'date': args.date,
@@ -202,7 +202,7 @@ def crue10_model_for_maps(args):
parser.add_argument('out_folder', help="chemin du dossier pour les fichiers shp de sortie")
parser_attributes = parser.add_argument_group("Arguments pour écrire les méta-données")
-parser_attributes.add_argument('--model_name', help="nom du modèle", default='')
+parser_attributes.add_argument('--nom_modele', help="nom du modèle", default='')
parser_attributes.add_argument('--bief', help="bigramme du bief", default='')
parser_attributes.add_argument('--auteurs', help="détails des auteurs", default='')
parser_attributes.add_argument('--date', help="date de valeur (format : JJ/MM/AAAA)", default='')
diff --git a/cli/crue10_model_geom_to_mascaret.py b/cli/crue10_model_geom_to_mascaret.py
index f4683b5..78cf378 100755
--- a/cli/crue10_model_geom_to_mascaret.py
+++ b/cli/crue10_model_geom_to_mascaret.py
@@ -9,19 +9,19 @@
"""
import sys
-from crue10.study import Study
+from crue10.etude import Etude
from crue10.utils.cli_parser import MyArgParse
from crue10.utils import CrueError, logger
def crue10_model_geom_to_mascaret(args):
- study = Study(args.etu_path)
- model = study.get_model(args.mo_name)
- model.read_all()
- for submodel in model.submodels:
- submodel.remove_sectioninterpolee()
- submodel.normalize_geometry()
- model.write_mascaret_geometry(args.georef_path)
+ study = Etude(args.etu_path)
+ model = study.get_modele(args.mo_name)
+ modele.read_all()
+ for sous_modele in modele.sous_modeles:
+ sous_modele.remove_sectioninterpolee()
+ sous_modele.normalize_geometry()
+ modele.write_mascaret_geometry(args.georef_path)
parser = MyArgParse(description=__doc__)
diff --git a/cli/crue10_model_topographical_graph.py b/cli/crue10_model_topographical_graph.py
index 613bb0e..5da1d9b 100755
--- a/cli/crue10_model_topographical_graph.py
+++ b/cli/crue10_model_topographical_graph.py
@@ -9,7 +9,7 @@
* il s'agit d'une vue schématique avec tous les noeuds/casiers et les branches
(aucune information géographique)
* l'orientation des branches correspond au sens de la ligne qui se termine par
- une flèche (branche fluviale) ou un symbole qui est "côté noeud aval"
+ une flèche (branche fluviale) ou un symbole qui est "côté noeud_reference aval"
(la seule exception concerne les branches orifices dont la position du symbole
tient compte du sens de l'orifice)
* les branches ou sous-modèles inactifs sont en pointillés
@@ -24,16 +24,16 @@
from crue10.utils.cli_parser import MyArgParse
from crue10.utils import CrueError, logger
-from crue10.study import Study
+from crue10.etude import Etude
def crue10_model_topographical_graph(args):
- study = Study(args.etu_path)
- model = study.get_model(args.mo_name)
- model.read_all()
+ study = Etude(args.etu_path)
+ model = study.get_modele(args.mo_name)
+ modele.read_all()
logger.info(model)
- model.write_topological_graph(args.out_files, nodesep=args.sep, prog=args.prog)
+ modele.write_topological_graph(args.out_files, nodesep=args.sep, prog=args.prog)
parser = MyArgParse(description=__doc__)
diff --git a/cli/crue10_xsd_validator.py b/cli/crue10_xsd_validator.py
index 9a2521a..0ee58f5 100755
--- a/cli/crue10_xsd_validator.py
+++ b/cli/crue10_xsd_validator.py
@@ -6,14 +6,14 @@
"""
import sys
-from crue10.study import Study
+from crue10.etude import Etude
from crue10.utils import CrueError, logger
from crue10.utils.cli_parser import MyArgParse
def crue10_xsd_validator(args):
has_error = False
- study = Study(args.etu_path)
+ study = Etude(args.etu_path)
errors = study.check_xml_files()
for file, errors in errors.items():
diff --git a/cli/crue9_dc_topographical_graph.py b/cli/crue9_dc_topographical_graph.py
index 5216586..058447d 100755
--- a/cli/crue9_dc_topographical_graph.py
+++ b/cli/crue9_dc_topographical_graph.py
@@ -9,7 +9,7 @@
* il s'agit d'une vue schématique avec tous les noeuds/casiers et les branches
(aucune information géographique)
* l'orientation des branches correspond au sens de la ligne qui se termine par
- une flèche (branche fluviale) ou un symbole qui est "côté noeud aval"
+ une flèche (branche fluviale) ou un symbole qui est "côté noeud_reference aval"
* la coloration des lignes dépend du type de branches
* la forme des noeuds et des casiers (avec leur nom associé) sont différentes
* les parties commentées ou shunter (par un GOTO) sont ignorées
diff --git a/crue10/base/__init__.py b/crue10/base/__init__.py
index 3de3bfb..46343eb 100644
--- a/crue10/base/__init__.py
+++ b/crue10/base/__init__.py
@@ -10,7 +10,7 @@
ABC = abc.ABCMeta('ABC', (object,), {'__slots__': ()})
-class CrueXMLFile(ABC):
+class FichierXML(ABC):
"""
Abstract class for Crue10 XML files
diff --git a/crue10/data/templates/dcsp.xml b/crue10/data/templates/dcsp.xml
index b039e0c..cf853de 100644
--- a/crue10/data/templates/dcsp.xml
+++ b/crue10/data/templates/dcsp.xml
@@ -16,8 +16,8 @@
{%- elif branche.type == 2 %}
- {{ branche.formule_pdc }}
- {%- for larg, z_seuil, coeff_d, coeff_pdc in branche.elts_seuil %}
+ {{ branche.formule_pertes_de_charge }}
+ {%- for larg, z_seuil, coeff_d, coeff_pdc in branche.liste_elements_seuil %}
{{ larg }}
{{ z_seuil }}
@@ -28,8 +28,8 @@
{%- elif branche.type == 4 %}
- {{ branche.formule_pdc }}
- {%- for larg, z_seuil, coeff_d, coeff_pdc in branche.elts_seuil %}
+ {{ branche.formule_pertes_de_charge }}
+ {%- for larg, z_seuil, coeff_d, coeff_pdc in branche.liste_elements_seuil %}
{{ larg }}
{{ z_seuil }}
@@ -88,7 +88,7 @@
{{ branche.QLimInf|float2str }}
{{ branche.QLimSup|float2str }}
- {%- for larg, z_seuil, coeff_d in branche.elts_seuil %}
+ {%- for larg, z_seuil, coeff_d in branche.liste_elements_seuil %}
{{ larg }}
{{ z_seuil }}
diff --git a/crue10/data/templates/dfrt.xml b/crue10/data/templates/dfrt.xml
index 2151ca8..5bd9e60 100644
--- a/crue10/data/templates/dfrt.xml
+++ b/crue10/data/templates/dfrt.xml
@@ -13,4 +13,4 @@
{%- endfor %}
-
+
\ No newline at end of file
diff --git a/crue10/data/templates/dptg.xml b/crue10/data/templates/dptg.xml
index 42b4c0a..494ecb3 100644
--- a/crue10/data/templates/dptg.xml
+++ b/crue10/data/templates/dptg.xml
@@ -22,10 +22,10 @@
{%- for section in section_profil_list %}
{{ section.comment_profilsection|html_escape }}
- {%- if section.has_fente %}
+ {%- if section.is_avec_fente %}
- {{ section.fente[0] }}
- {{ section.fente[1] }}
+ {{ section.largeur_fente }}
+ {{ section.profondeur_fente }}
{%- endif %}
@@ -40,8 +40,8 @@
{{ lit_numerote.xt_max }} {{ section.interp_z(lit_numerote.xt_max) }}
{{ lit_numerote.id }}
{% if lit_numerote.is_active %}true{% else %}false{% endif %}
- {% if lit_numerote.is_mineur %}true{% else %}false{% endif %}
-
+ {% if lit_numerote.get_est_mineur %}true{% else %}false{% endif %}
+
{%- endfor %}
@@ -59,7 +59,7 @@
{%- for section in section_idem_list %}
- {{ section.dz }}
+ {{ section.dz_section_reference }}
{%- endfor %}
diff --git a/crue10/data/templates/drso.xml b/crue10/data/templates/drso.xml
index bc3002e..6963b0d 100644
--- a/crue10/data/templates/drso.xml
+++ b/crue10/data/templates/drso.xml
@@ -13,7 +13,7 @@
{{ casier.comment|html_escape }}
{% if casier.is_active %}true{% else %}false{% endif %}
-
+
{%- for profil_casier in casier.profils_casier %}
{%- endfor %}
@@ -31,7 +31,7 @@
{%- if isinstance(section, SectionIdem) %}
{{ section.comment|html_escape }}
-
+
{%- endif %}
{%- if isinstance(section, SectionInterpolee) %}
@@ -73,7 +73,7 @@
{%- if branche.type in (14, 15) %}
-
+
{%- endif %}
diff --git a/crue10/data/templates/etu.xml b/crue10/data/templates/etu.xml
index 1a13965..edf9262 100644
--- a/crue10/data/templates/etu.xml
+++ b/crue10/data/templates/etu.xml
@@ -21,44 +21,44 @@
{%- endfor %}
- {%- for submodel in submodels %}
-
- {{ submodel.metadata.Type }}
- {{ submodel.metadata.IsActive }}
- {{ submodel.metadata.Commentaire|html_escape }}
- {{ submodel.metadata.AuteurCreation }}
- {{ submodel.metadata.DateCreation }}
- {{ submodel.metadata.AuteurDerniereModif }}
- {{ submodel.metadata.DateDerniereModif }}
+ {%- for sous_modele in sous_modeles %}
+
+ {{ sous_modele.metadata.Type }}
+ {{ sous_modele.metadata.IsActive }}
+ {{ sous_modele.metadata.Commentaire|html_escape }}
+ {{ sous_modele.metadata.AuteurCreation }}
+ {{ sous_modele.metadata.DateCreation }}
+ {{ sous_modele.metadata.AuteurDerniereModif }}
+ {{ sous_modele.metadata.DateDerniereModif }}
-
-
-
-
+
+
+
+
{%- endfor %}
- {%- for model in models %}
-
- {{ model.metadata.Type }}
- {{ model.metadata.IsActive }}
- {{ model.metadata.Commentaire|html_escape }}
- {{ model.metadata.AuteurCreation }}
- {{ model.metadata.DateCreation }}
- {{ model.metadata.AuteurDerniereModif }}
- {{ model.metadata.DateDerniereModif }}
+ {%- for modele in modeles %}
+
+ {{ modele.metadata.Type }}
+ {{ modele.metadata.IsActive }}
+ {{ modele.metadata.Commentaire|html_escape }}
+ {{ modele.metadata.AuteurCreation }}
+ {{ modele.metadata.DateCreation }}
+ {{ modele.metadata.AuteurDerniereModif }}
+ {{ modele.metadata.DateDerniereModif }}
-
-
-
-
-
+
+
+
+
+
- {%- for submodel in model.submodels %}
-
+ {%- for sous_modele in modele.liste_sous_modeles %}
+
{%- endfor %}
@@ -82,7 +82,7 @@
-
+
{%- if scenario.runs %}
diff --git a/crue10/emh/branche.py b/crue10/emh/branche.py
index 9073bc8..63ee8b5 100644
--- a/crue10/emh/branche.py
+++ b/crue10/emh/branche.py
@@ -48,7 +48,7 @@ class Branche(ABC):
- geom : polyline branch trace
- noeud_amont : upstream node
- noeud_aval : downstream node
- - sections <[crue10.emh.section.Section]>: list of sections
+ - liste_sections <[crue10.emh.section.Section]>: list of sections
- comment : optional text explanation
"""
@@ -113,7 +113,7 @@ def type_name(self):
def has_geom(self):
return self.type in Branche.TYPES_WITH_GEOM
- def add_section(self, section, xp):
+ def ajouter_section_dans_branche(self, section, xp):
check_isinstance(section, Section)
if isinstance(section, SectionInterpolee):
if self.type != 20:
@@ -195,27 +195,27 @@ def name_loi_LoiQPdc(self):
class BrancheSeuilTransversal(Branche):
"""
BrancheSeuilTransversal - #2
- - formule_pdc : 'Borda' or 'Divergent'
- - elts_seuil <2D-array>: ndarray(dtype=float, ndim=2 with 4 columns)
+ - formule_pertes_de_charge : 'Borda' or 'Divergent'
+ - liste_elements_seuil <2D-array>: ndarray(dtype=float, ndim=2 with 4 columns)
"""
def __init__(self, nom_branche, noeud_amont, noeud_aval, is_active=True):
super().__init__(nom_branche, noeud_amont, noeud_aval, 2, is_active)
- self.formule_pdc = DEFAULT_FORMULE_PDC
- self.elts_seuil = DEFAULT_ELTS_SEUILS_AVEC_PDC
+ self.formule_pertes_de_charge = DEFAULT_FORMULE_PDC
+ self.liste_elements_seuil = DEFAULT_ELTS_SEUILS_AVEC_PDC
class BrancheSeuilLateral(Branche):
"""
BrancheSeuilLateral - #4
- - formule_pdc : 'Borda' or 'Divergent'
- - elts_seuil <2D-array>: ndarray(dtype=float, ndim=2 with 4 columns)
+ - formule_pertes_de_charge : 'Borda' or 'Divergent'
+ - liste_elements_seuil <2D-array>: ndarray(dtype=float, ndim=2 with 4 columns)
"""
def __init__(self, nom_branche, noeud_amont, noeud_aval, is_active=True):
super().__init__(nom_branche, noeud_amont, noeud_aval, 4, is_active)
- self.formule_pdc = DEFAULT_FORMULE_PDC
- self.elts_seuil = DEFAULT_ELTS_SEUILS_AVEC_PDC
+ self.formule_pertes_de_charge = DEFAULT_FORMULE_PDC
+ self.liste_elements_seuil = DEFAULT_ELTS_SEUILS_AVEC_PDC
class BrancheOrifice(Branche):
@@ -273,7 +273,7 @@ def name_loi_ZavZam(self):
class BrancheBarrageGenerique(Branche):
"""
BrancheBarrageGenerique - #14
- - section_pilotage : section de pilotage
+ - section_pilote : section de pilotage
- QLimInf: "Débit minimum admis dans la branche"
- QLimSup: "Débit maximum admis dans la branche"
- loi_QDz <2D-array>: ndarray(dtype=float, ndim=2 with 2 columns)
@@ -284,7 +284,7 @@ class BrancheBarrageGenerique(Branche):
def __init__(self, nom_branche, noeud_amont, noeud_aval, is_active=True):
super().__init__(nom_branche, noeud_amont, noeud_aval, 14, is_active)
- self.section_pilotage = None
+ self.section_pilote = None
self.QLimInf = DEFAULT_QLIMINF
self.QLimSup = DEFAULT_QLIMSUP
self.loi_QDz = np.array([(-15000.0, -1.0E30)])
@@ -304,20 +304,20 @@ def name_loi_QpilZam(self):
class BrancheBarrageFilEau(Branche):
"""
BrancheBarrageFilEau - #15
- - section_pilotage : section de pilotage
+ - section_pilote : section de pilotage
- QLimInf: "Débit minimum admis dans la branche"
- QLimSup: "Débit maximum admis dans la branche"
- loi_QZam <2D-array>: ndarray(dtype=float, ndim=2 with 2 columns)
- - elts_seuil <2D-array>: ndarray(dtype=float, ndim=2 with 3 columns)
+ - liste_elements_seuil <2D-array>: ndarray(dtype=float, ndim=2 with 3 columns)
- comment_denoye : commentaire loi dénoyée
"""
def __init__(self, nom_branche, noeud_amont, noeud_aval, is_active=True):
super().__init__(nom_branche, noeud_amont, noeud_aval, 15, is_active)
- self.section_pilotage = None
+ self.section_pilote = None
self.QLimInf = DEFAULT_QLIMINF
self.QLimSup = DEFAULT_QLIMSUP
self.loi_QZam = np.array([(0.0, -15.0)])
- self.elts_seuil = DEFAULT_ELTS_SEUILS
+ self.liste_elements_seuil = DEFAULT_ELTS_SEUILS
self.comment_denoye = ''
@property
diff --git a/crue10/emh/casier.py b/crue10/emh/casier.py
index e09c56b..b68512b 100644
--- a/crue10/emh/casier.py
+++ b/crue10/emh/casier.py
@@ -96,7 +96,7 @@ class Casier:
- id : casier identifier
- is_active : True if its node is active
- geom : polygon
- - noeud : related node
+ - noeud_reference : related node
- profils_casier <[ProfilCaser]>: profils casier (usually only one)
- CoefRuis : "coefficient modulation du débit linéique de ruissellement"
- comment : optional text explanation
@@ -108,7 +108,7 @@ def __init__(self, nom_casier, noeud, is_active=True):
self.id = nom_casier
self.is_active = is_active
self.geom = None
- self.noeud = noeud
+ self.noeud_reference = noeud
self.profils_casier = []
self.CoefRuis = 0.0
self.comment = ''
@@ -119,7 +119,7 @@ def set_geom(self, geom):
raise CrueError("La trace du %s ne doit pas avoir de Z !" % self)
self.geom = geom
- def add_profil_casier(self, profil_casier):
+ def ajouter_profil_casier(self, profil_casier):
check_isinstance(profil_casier, ProfilCasier)
self.profils_casier.append(profil_casier)
@@ -138,7 +138,7 @@ def compute_volume(self, z):
def compute_surface(self, z):
return self.compute_volume(z) / self.sum_distances()
- def merge_profil_casiers(self):
+ def fusion_profil_casiers(self):
"""Replace multiple ProfilCasiers by a combined ProfilCasier giving a similar volume law"""
if len(self.profils_casier) > 2:
# Extract a sequence of bottom elevation
@@ -171,7 +171,7 @@ def merge_profil_casiers(self):
# Clear and add ProfilCasier
self.profils_casier = []
- self.add_profil_casier(new_profil_casier)
+ self.ajouter_profil_casier(new_profil_casier)
else:
logger.debug("Le %s n'est pas fusionné car il a moins de 2 ProfilCasiers" % self)
diff --git a/crue10/emh/section.py b/crue10/emh/section.py
index 46cd5f0..0e22ee8 100644
--- a/crue10/emh/section.py
+++ b/crue10/emh/section.py
@@ -1,7 +1,7 @@
# coding: utf-8
"""
Classes for cross-section with minor and major beds:
-- FrictionLaw
+- LoiFrottement
- LitNumerote
- LimiteGeom
- Section
@@ -27,7 +27,7 @@
DISTANCE_TOL = 0.01 # m
-class FrictionLaw:
+class LoiFrottement:
"""
Friction law (Strickler coefficient could vary with Z elevation)
- id : friction law identifier
@@ -41,7 +41,7 @@ class FrictionLaw:
def __init__(self, nom_loi_frottement, type, loi_Fk):
check_preffix(nom_loi_frottement, 'Fk')
check_isinstance(loi_Fk, np.ndarray)
- if type not in FrictionLaw.TYPES:
+ if type not in LoiFrottement.TYPES:
raise RuntimeError
self.id = nom_loi_frottement
self.type = type
@@ -49,9 +49,9 @@ def __init__(self, nom_loi_frottement, type, loi_Fk):
self.comment = ''
-DEFAULT_FK_STO = FrictionLaw('FkSto_K0_0001', 'FkSto', np.array([(0.0, 0.0)]))
-DEFAULT_FK_MAX = FrictionLaw('Fk_DefautMaj', 'Fk', np.array([(-15.0, 8.0)]))
-DEFAULT_FK_MIN = FrictionLaw('Fk_DefautMin', 'Fk', np.array([(-15.0, 8.0)]))
+DEFAULT_FK_STO = LoiFrottement('FkSto_K0_0001', 'FkSto', np.array([(0.0, 0.0)]))
+DEFAULT_FK_MAX = LoiFrottement('Fk_DefautMaj', 'Fk', np.array([(-15.0, 8.0)]))
+DEFAULT_FK_MIN = LoiFrottement('Fk_DefautMin', 'Fk', np.array([(-15.0, 8.0)]))
class LitNumerote:
@@ -60,33 +60,33 @@ class LitNumerote:
- id : bed identifier (a key of `BED_NAMES`)
- xt_min : first curvilinear abscissa
- xt_max : first curvilinear abscissa
- - friction_law : friction law (take the associated default law if it is not given)
+ - loi_frottement : friction law (take the associated default law if it is not given)
"""
BED_NAMES = ['Lt_StoD', 'Lt_MajD', 'Lt_Mineur', 'Lt_MajG', 'Lt_StoG']
LIMIT_NAMES = ['RD', 'StoD-MajD', 'MajD-Min', 'Min-MajG', 'MajG-StoG', 'RG']
- def __init__(self, nom_lit, xt_min, xt_max, friction_law=None):
+ def __init__(self, nom_lit, xt_min, xt_max, loi_frottement=None):
if nom_lit not in LitNumerote.BED_NAMES:
raise RuntimeError
self.id = nom_lit
self.xt_min = xt_min
self.xt_max = xt_max
- if friction_law is None:
+ if loi_frottement is None:
if 'Sto' in nom_lit:
- friction_law = DEFAULT_FK_STO
+ loi_frottement = DEFAULT_FK_STO
elif 'Maj' in nom_lit:
- friction_law = DEFAULT_FK_MAX
+ loi_frottement = DEFAULT_FK_MAX
else:
- friction_law = DEFAULT_FK_MIN
- self.friction_law = friction_law
+ loi_frottement = DEFAULT_FK_MIN
+ self.loi_frottement = loi_frottement
@property
def is_active(self):
return 'Maj' in self.id or 'Min' in self.id
@property
- def is_mineur(self):
+ def get_est_mineur(self):
return 'Min' in self.id
def __repr__(self):
@@ -144,6 +144,8 @@ class SectionProfil(Section):
- xz <2D-array>: ndarray(dtype=float, ndim=2)
Array containing series of transversal abscissa and elevation (first axis should be strictly increasing)
- geom_trace : polyline section trace (/!\ only between left and right bank)
+ - largeur_fente : largeur de la fente
+ - profondeur_fente : profondeur de la fente
- lits_numerotes <[LitNumerote]>: lits numérotés
- limites_geom <[LimiteGeom]>: limites géométriques (thalweg, axe hydraulique...)
"""
@@ -155,7 +157,8 @@ def __init__(self, nom_section, nom_profilsection=None):
self.set_profilsection_name(nom_profilsection)
self.xz = None
self.geom_trace = None
- self.fente = None
+ self.largeur_fente = None
+ self.profondeur_fente = None
self.lits_numerotes = []
self.limites_geom = []
@@ -175,8 +178,8 @@ def xt_axe(self):
raise CrueError("Limite 'Et_AxeHyd' could not be found for %s" % self)
@property
- def has_fente(self):
- return self.fente is not None
+ def is_avec_fente(self):
+ return self.largeur_fente is not None and self.profondeur_fente is not None
@property
def xz_filtered(self):
@@ -201,8 +204,12 @@ def set_trace(self, trace):
if abs(diff_xt) > 1e-2:
logger.warn("Écart de longueur pour la section %s: %s" % (self, diff_xt))
- def set_fente(self, largeur, profondeur):
- self.fente = (largeur, profondeur)
+ def ajouter_fente(self, largeur, profondeur):
+ """Adds (or replaces if already exists) fente width and depth"""
+ assert largeur > 0
+ assert profondeur > 0
+ self.largeur_fente = largeur
+ self.profondeur_fente = profondeur
def set_lits_numerotes(self, xt_list):
"""Add directly the 5 beds from a list of 6 ordered xt values"""
@@ -215,7 +222,7 @@ def set_lits_numerotes(self, xt_list):
lit_numerote = LitNumerote(bed_name, xt_min, xt_max)
self.lits_numerotes.append(lit_numerote)
- def add_lit_numerote(self, lit_numerote):
+ def ajouter_lit(self, lit_numerote):
check_isinstance(lit_numerote, LitNumerote)
if lit_numerote.id in self.lits_numerotes:
raise CrueError("Le lit numéroté `%s` est déjà présent" % lit_numerote.id)
@@ -276,7 +283,7 @@ def get_friction_coeff_array(self):
bed_pos = np.logical_and(lit.xt_min < xt, xt <= lit.xt_max)
else:
bed_pos = np.logical_and(lit.xt_min <= xt, xt <= lit.xt_max)
- coeff[bed_pos] = lit.friction_law.loi_Fk[:, 1].mean()
+ coeff[bed_pos] = lit.loi_frottement.loi_Fk[:, 1].mean()
return coeff
def has_xz(self):
@@ -325,26 +332,26 @@ def __repr__(self):
class SectionIdem(Section):
"""
SectionIdem
- - parent_section : parent (= initial/reference) section
- - dz : vertical shift (in meters)
+ - section_reference : parent (= initial/reference) section
+ - dz_section_reference : vertical shift (in meters)
"""
def __init__(self, nom_section, parent_section, dz=0.0):
super().__init__(nom_section)
check_isinstance(parent_section, SectionProfil)
- self.parent_section = parent_section
- self.dz = dz
+ self.section_reference = parent_section
+ self.dz_section_reference = dz
def get_as_sectionprofil(self):
"""
Return a SectionProfil instance from the original section
"""
- new_section = deepcopy(self.parent_section)
+ new_section = deepcopy(self.section_reference)
new_section.id = self.id
new_section.xp = self.xp
new_section.is_active = self.is_active
- new_section.xz[:, 1] += self.dz
- new_section.comment = 'Copie de la section parent %s' % self.parent_section.id
+ new_section.xz[:, 1] += self.dz_section_reference
+ new_section.comment = 'Copie de la section parent %s' % self.section_reference.id
return new_section
diff --git a/crue10/study.py b/crue10/etude.py
similarity index 72%
rename from crue10/study.py
rename to crue10/etude.py
index 84686b5..f594dd1 100644
--- a/crue10/study.py
+++ b/crue10/etude.py
@@ -5,10 +5,10 @@
import os.path
import xml.etree.ElementTree as ET
-from crue10.model import Model
+from crue10.modele import Modele
from crue10.run import Run
from crue10.scenario import Scenario
-from crue10.submodel import SubModel
+from crue10.sous_modele import SousModele
from crue10.utils import add_default_missing_metadata, check_isinstance, CrueError, JINJA_ENV, \
logger, PREFIX, XSD_FOLDER
from crue10.utils.settings import XML_ENCODING
@@ -22,50 +22,50 @@ def read_metadata(elt, keys):
return metadata
-class Study:
+class Etude:
"""
- Crue10 study
+ Crue10 etude
- etu_path : path to etu.xml file
- access : 'r' to read and 'w' to write
- folders <{str}>: dict with folders (keys correspond to `FOLDERS` list)
- filename_list <[str]>: list of xml file names
- metadata <{dict}>: containing metadata (keys correspond to `METADATA_FIELDS` list)
- - current_scenario_id : current scenario identifier
- - comment : information describing current study
+ - nom_scenario_courant : current scenario identifier
+ - comment : information describing current etude
- scenarios <{str: Scenario}>: dict with scneario name and Scenario object
- - models <{str: Model}>: dict with model name and Model object
- - submodels <{str: SubModel}>: dict with submodel name and SubModel object
+ - modeles <{str: Modele}>: dict with modele name and Modele object
+ - liste_sous_modeles <{str: SousModele}>: dict with sous_modele name and SousModele object
"""
FOLDERS = OrderedDict([('CONFIG', 'Config'), ('FICHETUDES', '.'),
('RAPPORTS', 'Rapports'), ('RUNS', 'Runs')])
- XML_FILES = Scenario.FILES_XML + Model.FILES_XML + SubModel.FILES_XML
+ XML_FILES = Scenario.FILES_XML + Modele.FILES_XML + SousModele.FILES_XML
METADATA_FIELDS = ['Commentaire', 'AuteurCreation', 'DateCreation', 'AuteurDerniereModif', 'DateDerniereModif']
def __init__(self, etu_path, folders=None, access='r', metadata=None, comment=''):
"""
- :param etu_path: Crue10 study file (etu.xml format)
+ :param etu_path: Crue10 etude file (etu.xml format)
"""
self.etu_path = etu_path
self.access = access
if folders is None:
- self.folders = Study.FOLDERS
+ self.folders = Etude.FOLDERS
else:
- if set(folders.keys()) != set(Study.FOLDERS.keys()):
+ if set(folders.keys()) != set(Etude.FOLDERS.keys()):
raise RuntimeError
if folders['FICHETUDES'] != '.':
raise NotImplementedError
self.folders = folders
self.filename_list = []
self.metadata = {} if metadata is None else metadata
- self.current_scenario_id = ''
+ self.nom_scenario_courant = ''
self.comment = comment
self.scenarios = OrderedDict()
- self.models = OrderedDict()
- self.submodels = OrderedDict()
+ self.modeles = OrderedDict()
+ self.sous_modeles = OrderedDict()
- self.metadata = add_default_missing_metadata(self.metadata, Study.METADATA_FIELDS)
+ self.metadata = add_default_missing_metadata(self.metadata, Etude.METADATA_FIELDS)
if access == 'r':
self._read_etu()
@@ -82,11 +82,11 @@ def _read_etu(self):
root = ET.parse(self.etu_path).getroot()
folder = os.path.dirname(self.etu_path)
- # Study metadata
- self.metadata = read_metadata(root, Study.METADATA_FIELDS)
+ # Etude metadata
+ self.metadata = read_metadata(root, Etude.METADATA_FIELDS)
if root.find(PREFIX + 'ScenarioCourant') is not None:
- self.current_scenario_id = root.find(PREFIX + 'ScenarioCourant').get('NomRef')
+ self.nom_scenario_courant = root.find(PREFIX + 'ScenarioCourant').get('NomRef')
# Repertoires
elt_repertoires = root.find(PREFIX + 'Repertoires')
@@ -96,7 +96,7 @@ def _read_etu(self):
# FichEtudes
elt_fichiers = root.find(PREFIX + 'FichEtudes')
for elt_fichier in elt_fichiers:
- if elt_fichier.get('Type').lower() in Study.XML_FILES: # Ignore Crue9 files
+ if elt_fichier.get('Type').lower() in Etude.XML_FILES: # Ignore Crue9 files
if elt_fichier.get('Chemin') != '.\\':
raise NotImplementedError
self.filename_list.append(os.path.join(folder, elt_fichier.get('Nom')))
@@ -105,12 +105,12 @@ def _read_etu(self):
elt_sous_modeles = root.find(PREFIX + 'SousModeles')
for elt_sm in elt_sous_modeles:
files = {}
- submodel_name = elt_sm.get('Nom')
+ nom_sous_modele = elt_sm.get('Nom')
- metadata = read_metadata(elt_sm, SubModel.METADATA_FIELDS)
+ metadata = read_metadata(elt_sm, SousModele.METADATA_FIELDS)
elt_fichiers = elt_sm.find(PREFIX + 'SousModele-FichEtudes')
- for ext in SubModel.FILES_XML:
+ for ext in SousModele.FILES_XML:
try:
filename = elt_fichiers.find(PREFIX + ext.upper()).attrib['NomRef']
except AttributeError:
@@ -122,26 +122,26 @@ def _read_etu(self):
raise CrueError("Le fichier %s n'est pas dans la liste des fichiers !" % filepath)
files[ext] = filepath
- for shp_name in SubModel.FILES_SHP:
+ for shp_name in SousModele.FILES_SHP:
files[shp_name] = os.path.join(folder, self.folders['CONFIG'],
- submodel_name.upper(), shp_name + '.shp')
+ nom_sous_modele.upper(), shp_name + '.shp')
- submodel = SubModel(submodel_name, files=files, metadata=metadata)
- self.add_submodel(submodel)
- if not self.submodels:
+ sous_modele = SousModele(nom_sous_modele, files=files, metadata=metadata)
+ self.ajouter_sous_modele(sous_modele)
+ if not self.sous_modeles:
raise CrueError("Il faut au moins un sous-modèle !")
# Modele
elt_models = root.find(PREFIX + 'Modeles')
for elt_modele in elt_models:
- if elt_modele.tag == PREFIX + 'Modele': # Ignore Crue9 models
+ if elt_modele.tag == PREFIX + 'Modele': # Ignore Crue9 modeles
files = {}
model_name = elt_modele.get('Nom')
- metadata = read_metadata(elt_modele, Model.METADATA_FIELDS)
+ metadata = read_metadata(elt_modele, Modele.METADATA_FIELDS)
elt_fichiers = elt_modele.find(PREFIX + 'Modele-FichEtudes')
- for ext in Model.FILES_XML:
+ for ext in Modele.FILES_XML:
try:
filename = elt_fichiers.find(PREFIX + ext.upper()).attrib['NomRef']
except AttributeError:
@@ -153,16 +153,16 @@ def _read_etu(self):
raise CrueError("Le fichier %s n'est pas dans la liste des fichiers !" % filepath)
files[ext] = filepath
- model = Model(model_name, files=files, metadata=metadata)
+ modele = Modele(model_name, files=files, metadata=metadata)
elt_sous_modeles = elt_modele.find(PREFIX + 'Modele-SousModeles')
for elt_sm in elt_sous_modeles:
- submodel_name = elt_sm.get('NomRef')
- submodel = self.submodels[submodel_name]
- model.add_submodel(submodel)
+ nom_sous_modele = elt_sm.get('NomRef')
+ sous_modele = self.sous_modeles[nom_sous_modele]
+ modele.ajouter_sous_modele(sous_modele)
- self.add_model(model)
- if not self.models:
+ self.ajouter_modele(modele)
+ if not self.modeles:
raise CrueError("Il faut au moins un modèle !")
# Scenarios
@@ -170,7 +170,7 @@ def _read_etu(self):
for elt_scenario in elt_scenarios:
if elt_scenario.tag == PREFIX + 'Scenario':
files = {}
- scenario_name = elt_scenario.get('Nom')
+ nom_scenario = elt_scenario.get('Nom')
elt_fichiers = elt_scenario.find(PREFIX + 'Scenario-FichEtudes')
for ext in Scenario.FILES_XML:
@@ -186,14 +186,14 @@ def _read_etu(self):
files[ext] = filepath
elt_models = elt_scenario.find(PREFIX + 'Scenario-Modeles')
- model = None
+ modele = None
for i, elt_modele in enumerate(elt_models):
- model = self.models[elt_modele.get('NomRef')]
+ modele = self.modeles[elt_modele.get('NomRef')]
if i != 0:
- raise NotImplementedError # A single Model for a Scenario!
+ raise NotImplementedError # A single Modele for a Scenario!
metadata = read_metadata(elt_scenario, Scenario.METADATA_FIELDS)
- scenario = Scenario(scenario_name, model, files=files, metadata=metadata)
+ scenario = Scenario(nom_scenario, modele, files=files, metadata=metadata)
runs = elt_scenario.find(PREFIX + 'Runs')
if runs is not None:
@@ -201,14 +201,14 @@ def _read_etu(self):
run_id = run_elt.get('Nom')
metadata = read_metadata(run_elt, Run.METADATA_FIELDS)
run_mo_folder = os.path.join(self.folder, self.folders['RUNS'], scenario.id,
- run_id, scenario.model.id)
+ run_id, scenario.modele.id)
scenario.add_run(Run(run_mo_folder, metadata=metadata))
elt_current_run = elt_scenario.find(PREFIX + 'RunCourant')
if elt_current_run is not None:
scenario.set_current_run_id(elt_current_run.get('NomRef'))
- self.add_scenario(scenario)
+ self.ajouter_scenario(scenario)
if not self.scenarios:
raise CrueError("Il faut au moins un scénario !")
@@ -228,10 +228,10 @@ def write_etu(self, folder=None):
template_render = JINJA_ENV.get_template(xml + '.xml').render(
folders=[(name, folder) for name, folder in self.folders.items()],
metadata=self.metadata,
- current_scenario_id=self.current_scenario_id,
+ current_scenario_id=self.nom_scenario_courant,
files=[(os.path.basename(file), file[-8:-4].upper()) for file in sorted(self.filename_list)],
- models=[mo for _, mo in self.models.items()],
- submodels=[sm for _, sm in self.submodels.items()],
+ modeles=[mo for _, mo in self.modeles.items()],
+ sous_modeles=[sm for _, sm in self.sous_modeles.items()],
scenarios=[sc for _, sc in self.scenarios.items()],
)
with open(etu_path, 'w', encoding=XML_ENCODING) as out:
@@ -254,33 +254,33 @@ def add_files(self, file_list):
if file not in self.filename_list:
self.filename_list.append(file)
- def add_model(self, model):
- check_isinstance(model, Model)
- self.add_files([file for _, file in model.files.items()])
- for submodel in model.submodels:
- self.add_submodel(submodel)
- self.models[model.id] = model
+ def ajouter_modele(self, modele):
+ check_isinstance(modele, Modele)
+ self.add_files([file for _, file in modele.files.items()])
+ for sous_modele in modele.liste_sous_modeles:
+ self.ajouter_sous_modele(sous_modele)
+ self.modeles[modele.id] = modele
- def add_submodel(self, submodel):
- check_isinstance(submodel, SubModel)
- self.add_files([file for _, file in submodel.files.items() if file[-8:-4] in SubModel.FILES_XML])
- self.submodels[submodel.id] = submodel
+ def ajouter_sous_modele(self, sous_modele):
+ check_isinstance(sous_modele, SousModele)
+ self.add_files([file for _, file in sous_modele.files.items() if file[-8:-4] in SousModele.FILES_XML])
+ self.sous_modeles[sous_modele.id] = sous_modele
- def add_scenario(self, scenario):
+ def ajouter_scenario(self, scenario):
check_isinstance(scenario, Scenario)
self.add_files([file for _, file in scenario.files.items()])
- self.add_model(scenario.model)
+ self.ajouter_modele(scenario.modele)
self.scenarios[scenario.id] = scenario
- def create_empty_scenario(self, scenario_name, model_name, submodel_name=None, comment=''):
- model = Model(model_name, access=self.access, metadata={'Commentaire': comment})
- if submodel_name is not None:
- submodel = SubModel(submodel_name, access=self.access, metadata={'Commentaire': comment})
- model.add_submodel(submodel)
- scenario = Scenario(scenario_name, model, access=self.access, metadata={'Commentaire': comment})
- self.add_scenario(scenario)
- if not self.current_scenario_id:
- self.current_scenario_id = scenario.id
+ def create_empty_scenario(self, nom_scenario, nom_modele, nom_sous_modele=None, comment=''):
+ modele = Modele(nom_modele, access=self.access, metadata={'Commentaire': comment})
+ if nom_sous_modele is not None:
+ sous_modele = SousModele(nom_sous_modele, access=self.access, metadata={'Commentaire': comment})
+ modele.ajouter_sous_modele(sous_modele)
+ scenario = Scenario(nom_scenario, modele, access=self.access, metadata={'Commentaire': comment})
+ self.ajouter_scenario(scenario)
+ if not self.nom_scenario_courant:
+ self.nom_scenario_courant = scenario.id
def get_scenario(self, scenario_name):
try:
@@ -289,19 +289,19 @@ def get_scenario(self, scenario_name):
raise CrueError("Le scénario %s n'existe pas !\nLes noms possibles sont: %s"
% (scenario_name, list(self.scenarios.keys())))
- def get_model(self, model_name):
+ def get_modele(self, nom_modele):
try:
- return self.models[model_name]
+ return self.modeles[nom_modele]
except KeyError:
raise CrueError("Le modèle %s n'existe pas !\nLes noms possibles sont: %s"
- % (model_name, list(self.models.keys())))
+ % (nom_modele, list(self.modeles.keys())))
- def get_submodel(self, submodel_name):
+ def get_sous_modele(self, nom_sous_modele):
try:
- return self.submodels[submodel_name]
+ return self.sous_modeles[nom_sous_modele]
except KeyError:
raise CrueError("Le sous-modèle %s n'existe pas !\nLes noms possibles sont: %s"
- % (submodel_name, list(self.submodels.keys())))
+ % (nom_sous_modele, list(self.sous_modeles.keys())))
def check_xml_files(self):
errors = {}
@@ -327,7 +327,7 @@ def check_xml_files(self):
def summary(self):
return "%s: %i scénario(s) %i modèle(s), %i sous-modèle(s)" % (self, len(self.scenarios),
- len(self.models), len(self.submodels))
+ len(self.modeles), len(self.sous_modeles))
def __repr__(self):
return "Étude %s" % os.path.basename(self.etu_path[:-8])
diff --git a/crue10/model.py b/crue10/modele.py
similarity index 74%
rename from crue10/model.py
rename to crue10/modele.py
index dd4f775..0f608af 100644
--- a/crue10/model.py
+++ b/crue10/modele.py
@@ -7,22 +7,22 @@
import os.path
from shapely.geometry import LineString, mapping, Point
-from crue10.base import CrueXMLFile
+from crue10.base import FichierXML
from crue10.emh.branche import BrancheOrifice
from crue10.emh.section import SectionProfil, LitNumerote
from crue10.utils import check_isinstance, check_preffix, CrueError, \
logger, PREFIX, write_default_xml_file, write_xml_from_tree
from crue10.utils.graph_1d_model import *
-from crue10.submodel import SubModel
+from crue10.sous_modele import SousModele
from mascaret.mascaret_file import Reach, Section
from mascaret.mascaretgeo_file import MascaretGeoFile
-class Model(CrueXMLFile):
+class Modele(FichierXML):
"""
- Crue10 model
- - id : model identifier
- - submodels <[SubModel]>: list of submodels
+ Crue10 modele
+ - id : modele identifier
+ - liste_sous_modeles <[SousModele]>: list of sous_modeles
- noeuds_ic : initial condition at noeuds
- casiers_ic : initial condition at casiers
- branches_ic : initial condition at branches
@@ -36,7 +36,7 @@ class Model(CrueXMLFile):
def __init__(self, model_name, access='r', files=None, metadata=None):
"""
- :param model_name: model name
+ :param model_name: modele name
:param files: dict with xml path files
:param metadata: dict containing metadata
"""
@@ -44,7 +44,7 @@ def __init__(self, model_name, access='r', files=None, metadata=None):
self.id = model_name
super().__init__(access, files, metadata)
- self.submodels = []
+ self.liste_sous_modeles = []
# Initial conditions
self.noeuds_ic = OrderedDict()
@@ -67,104 +67,110 @@ def rename_key_and_obj(dictionary, suffix, replace_obj=True, insert_before=False
new_id = new_left_id + suffix + '_' + new_right_id
else:
new_id = old_id + suffix
- Model.rename_emh(dictionary, old_id, new_id, replace_obj)
+ Modele.rename_emh(dictionary, old_id, new_id, replace_obj)
def rename_noeud(self, old_id, new_id):
logger.debug("Renommage Noeud: %s -> %s" % (old_id, new_id))
- for submodel in self.submodels:
- Model.rename_emh(submodel.noeuds, old_id, new_id)
- Model.rename_emh(self.noeuds_ic, old_id, new_id, replace_obj=False)
+ for sous_modele in self.liste_sous_modeles:
+ Modele.rename_emh(sous_modele.noeuds, old_id, new_id)
+ Modele.rename_emh(self.noeuds_ic, old_id, new_id, replace_obj=False)
def rename_emhs(self, suffix, emh_list=['Fk', 'Nd', 'Cd', 'St', 'Br'], emhs_to_preserve=[]):
- for submodel in self.submodels:
+ for sous_modele in self.liste_sous_modeles:
if 'Fk' in emh_list:
- Model.rename_key_and_obj(submodel.friction_laws, suffix)
+ Modele.rename_key_and_obj(sous_modele.liste_lois_frottement, suffix)
if 'Nd' in emh_list:
- Model.rename_key_and_obj(submodel.noeuds, suffix, emhs_to_preserve=emhs_to_preserve)
- Model.rename_key_and_obj(self.noeuds_ic, suffix, emhs_to_preserve=emhs_to_preserve, replace_obj=False)
+ Modele.rename_key_and_obj(sous_modele.noeuds, suffix, emhs_to_preserve=emhs_to_preserve)
+ Modele.rename_key_and_obj(self.noeuds_ic, suffix, emhs_to_preserve=emhs_to_preserve, replace_obj=False)
if 'Cd' in emh_list:
- Model.rename_key_and_obj(submodel.casiers, suffix)
- Model.rename_key_and_obj(self.casiers_ic, suffix, replace_obj=False)
- Model.rename_key_and_obj(submodel.profils_casier, suffix, insert_before=True)
+ Modele.rename_key_and_obj(sous_modele.casiers, suffix)
+ Modele.rename_key_and_obj(self.casiers_ic, suffix, replace_obj=False)
+ Modele.rename_key_and_obj(sous_modele.profils_casier, suffix, insert_before=True)
if 'St' in emh_list:
- Model.rename_key_and_obj(submodel.sections, suffix)
- for st in submodel.iter_on_sections_profil():
+ Modele.rename_key_and_obj(sous_modele.sections, suffix)
+ for st in sous_modele.iter_on_sections_profil():
st.set_profilsection_name()
if 'Br' in emh_list:
- Model.rename_key_and_obj(submodel.branches, suffix)
- Model.rename_key_and_obj(self.branches_ic, suffix, replace_obj=False)
+ Modele.rename_key_and_obj(sous_modele.branches, suffix)
+ Modele.rename_key_and_obj(self.branches_ic, suffix, replace_obj=False)
- def get_noeud_list(self):
+ def get_sous_modele(self, nom_sous_modele):
+ for sous_modele in self.liste_sous_modeles:
+ if sous_modele.id == nom_sous_modele:
+ return sous_modele
+ raise CrueError("Le sous-modèle %s n'existe pas dans le modèle %s" % (nom_sous_modele, self.id))
+
+ def get_liste_noeuds(self):
noeuds = []
- for submodel in self.submodels:
- noeuds += [noeud for _, noeud in submodel.noeuds.items()]
+ for sous_modele in self.liste_sous_modeles:
+ noeuds += [noeud for _, noeud in sous_modele.noeuds.items()]
return noeuds
- def get_casier_list(self):
+ def get_liste_casiers(self):
casiers = []
- for submodel in self.submodels:
- casiers += [casier for _, casier in submodel.casiers.items()]
+ for sous_modele in self.liste_sous_modeles:
+ casiers += [casier for _, casier in sous_modele.casiers.items()]
return casiers
- def get_section_list(self, ignore_inactive=False):
+ def get_liste_sections(self, ignore_inactive=False):
sections = []
- for submodel in self.submodels:
- sections += submodel.iter_on_sections(ignore_inactive=ignore_inactive)
+ for sous_modele in self.liste_sous_modeles:
+ sections += sous_modele.iter_on_sections(ignore_inactive=ignore_inactive)
return sections
- def get_branche_list(self):
+ def get_liste_branches(self):
branches = []
- for submodel in self.submodels:
- branches += submodel.iter_on_branches()
+ for sous_modele in self.liste_sous_modeles:
+ branches += sous_modele.iter_on_branches()
return branches
def get_missing_active_sections(self, section_id_list):
"""
- Returns the list of the requested sections which are not found (or not active) in the current model
+ Returns the list of the requested sections which are not found (or not active) in the current modele
(section type is not checked)
@param section_id_list: list of section identifiers
"""
- return set([st.id for st in self.get_section_list(ignore_inactive=True)]).difference(set(section_id_list))
+ return set([st.id for st in self.get_liste_sections(ignore_inactive=True)]).difference(set(section_id_list))
def get_duplicated_noeuds(self):
- return [nd for nd, count in Counter([noeud.id for noeud in self.get_noeud_list()]).items() if count > 1]
+ return [nd for nd, count in Counter([noeud.id for noeud in self.get_liste_noeuds()]).items() if count > 1]
def get_duplicated_casiers(self):
- return [ca for ca, count in Counter([casier.id for casier in self.get_casier_list()]).items() if count > 1]
+ return [ca for ca, count in Counter([casier.id for casier in self.get_liste_casiers()]).items() if count > 1]
def get_duplicated_sections(self):
- return [st for st, count in Counter([section.id for section in self.get_section_list()]).items() if count > 1]
+ return [st for st, count in Counter([section.id for section in self.get_liste_sections()]).items() if count > 1]
def get_duplicated_branches(self):
- return [br for br, count in Counter([branche.id for branche in self.get_branche_list()]).items() if count > 1]
+ return [br for br, count in Counter([branche.id for branche in self.get_liste_branches()]).items() if count > 1]
- def add_submodel(self, submodel):
- check_isinstance(submodel, SubModel)
- if submodel.id in self.submodels:
- raise CrueError("Le sous-modèle %s est déjà présent" % submodel.id)
- self.submodels.append(submodel)
+ def ajouter_sous_modele(self, sous_modele):
+ check_isinstance(sous_modele, SousModele)
+ if sous_modele.id in self.liste_sous_modeles:
+ raise CrueError("Le sous-modèle %s est déjà présent" % sous_modele.id)
+ self.liste_sous_modeles.append(sous_modele)
- def append_from_model(self, model):
- """Add submodel in current model with the related initial conditions"""
- for submodel in model.submodels:
- self.add_submodel(submodel)
+ def ajouter_depuis_modele(self, modele):
+ """Add sous_modele in current modele with the related initial conditions"""
+ for sous_modele in modele.susoubmodels:
+ self.ajouter_sous_modele(sous_modele)
# Copy initial conditions
- for noeud_id, value in model.noeuds_ic.items():
+ for noeud_id, value in modele.noeuds_ic.items():
self.noeuds_ic[noeud_id] = value
- for branche_id, values in model.branches_ic.items():
+ for branche_id, values in modele.branches_ic.items():
self.branches_ic[branche_id] = values
- for casier_id, value in model.casiers_ic.items():
+ for casier_id, value in modele.casiers_ic.items():
self.casiers_ic[casier_id] = value
def reset_initial_conditions(self):
"""Set initial conditions to default values"""
- self.noeuds_ic = OrderedDict([(noeud.id, 1.0E30) for noeud in self.get_noeud_list()])
+ self.noeuds_ic = OrderedDict([(noeud.id, 1.0E30) for noeud in self.get_liste_noeuds()])
- self.casiers_ic = OrderedDict([(casier.id, 0.0) for casier in self.get_casier_list()])
+ self.casiers_ic = OrderedDict([(casier.id, 0.0) for casier in self.get_liste_casiers()])
self.branches_ic = OrderedDict()
- for branche in self.get_branche_list():
+ for branche in self.get_liste_branches():
self.branches_ic[branche.id] = {
'type': branche.type,
'values': {'Qini': 0.0},
@@ -210,8 +216,8 @@ def read_all(self):
if not self.was_read:
self._set_xml_trees()
- for submodel in self.submodels:
- submodel.read_all()
+ for sous_modele in self.liste_sous_modeles:
+ sous_modele.read_all()
self._read_dpti()
self.was_read = True
@@ -231,7 +237,7 @@ def write_all(self, folder, folder_config):
if not os.path.exists(folder):
os.makedirs(folder)
- for xml_type in Model.FILES_XML_WITHOUT_TEMPLATE:
+ for xml_type in Modele.FILES_XML_WITHOUT_TEMPLATE:
xml_path = os.path.join(folder, os.path.basename(self.files[xml_type]))
if self.xml_trees:
write_xml_from_tree(self.xml_trees[xml_type], xml_path)
@@ -240,8 +246,8 @@ def write_all(self, folder, folder_config):
self._write_dpti(folder)
- for submodel in self.submodels:
- submodel.write_all(folder, folder_config)
+ for sous_modele in self.liste_sous_modeles:
+ sous_modele.write_all(folder, folder_config)
def write_topological_graph(self, out_files, nodesep=0.8, prog='dot'):
try:
@@ -253,14 +259,14 @@ def write_topological_graph(self, out_files, nodesep=0.8, prog='dot'):
# Create a directed graph
graph = pydot.Dot(graph_type='digraph', label=self.id, fontsize=MO_FONTSIZE,
nodesep=nodesep, prog=prog) # vertical : rankdir='LR'
- for submodel in self.submodels:
- subgraph = pydot.Cluster(submodel.id, label=submodel.id, fontsize=SM_FONTSIZE,
- style=key_from_constant(submodel.is_active, SM_STYLE))
+ for sous_modele in self.liste_sous_modeles:
+ subgraph = pydot.Cluster(sous_modele.id, label=sous_modele.id, fontsize=SM_FONTSIZE,
+ style=key_from_constant(sous_modele.is_active, SM_STYLE))
# Add nodes
- for _, noeud in submodel.noeuds.items():
+ for _, noeud in sous_modele.noeuds.items():
name = noeud.id
- connected_casier = submodel.get_connected_casier(noeud)
+ connected_casier = sous_modele.get_connected_casier(noeud)
has_casier = connected_casier is not None
is_active = True
if has_casier:
@@ -272,7 +278,7 @@ def write_topological_graph(self, out_files, nodesep=0.8, prog='dot'):
subgraph.add_node(node)
# Add branches
- for branche in submodel.iter_on_branches():
+ for branche in sous_modele.iter_on_branches():
direction = 'forward'
if isinstance(branche, BrancheOrifice):
if branche.SensOrifice == 'Bidirect':
@@ -308,7 +314,7 @@ def write_topological_graph(self, out_files, nodesep=0.8, prog='dot'):
def write_mascaret_geometry(self, geo_path):
"""
- @brief: Convert model to Mascaret geometry format (extension: geo or georef)
+ @brief: Convert modele to Mascaret geometry format (extension: geo or georef)
Only active branche of type 20 (SaintVenant) are written
TODO: Add min/maj delimiter
@param geo_path : output file path
@@ -317,8 +323,8 @@ def write_mascaret_geometry(self, geo_path):
"""
geofile = MascaretGeoFile(geo_path, access='w')
i_section = 0
- for submodel in self.submodels:
- for i_branche, branche in enumerate(submodel.iter_on_branches([20])):
+ for sous_modele in self.liste_sous_modeles:
+ for i_branche, branche in enumerate(sous_modele.iter_on_branches([20])):
if branche.has_geom() and branche.is_active:
reach = Reach(i_branche, name=branche.id)
for section in branche.sections:
@@ -337,8 +343,8 @@ def write_mascaret_geometry(self, geo_path):
def write_shp_sectionprofil_as_points(self, shp_path):
schema = {'geometry': '3D Point', 'properties': {'id_section': 'str', 'Z': 'float'}}
with fiona.open(shp_path, 'w', driver='ESRI Shapefile', schema=schema) as out_shp:
- for submodel in self.submodels:
- for section in submodel.iter_on_sections(SectionProfil, ignore_inactive=True):
+ for sous_modele in self.liste_sous_modeles:
+ for section in sous_modele.iter_on_sections(SectionProfil, ignore_inactive=True):
coords = section.get_coord(add_z=True)
for coord in coords:
out_shp.write({'geometry': mapping(Point(coord)),
@@ -347,8 +353,8 @@ def write_shp_sectionprofil_as_points(self, shp_path):
def write_shp_limites_lits_numerotes(self, shp_path):
schema = {'geometry': 'LineString', 'properties': {'id_limite': 'str', 'id_branche': 'str'}}
with fiona.open(shp_path, 'w', driver='ESRI Shapefile', schema=schema) as out_shp:
- for submodel in self.submodels:
- for branche in submodel.iter_on_branches():
+ for sous_modele in self.liste_sous_modeles:
+ for branche in sous_modele.iter_on_branches():
for i_lit, lit_name in enumerate(LitNumerote.LIMIT_NAMES):
coords = []
for section in branche.sections:
@@ -380,7 +386,7 @@ def log_duplicated_emh(self):
logger.warn("Branches dupliquées: %s" % duplicated_branches)
def summary(self):
- return "%s: %i sous-modèle(s)" % (self, len(self.submodels))
+ return "%s: %i sous-modèle(s)" % (self, len(self.liste_sous_modeles))
def __repr__(self):
return "Modèle %s" % self.id
diff --git a/crue10/results.py b/crue10/results.py
index 543ad68..b099ed5 100644
--- a/crue10/results.py
+++ b/crue10/results.py
@@ -61,7 +61,7 @@ def get_data(self, res_pattern, is_steady, emh_type_first_branche):
return res
-class CalcSteady:
+class CalcPseudoPerm:
"""Metadata for a steady calculation"""
def __init__(self, name, bin_path, byte_offset):
@@ -72,7 +72,7 @@ def __repr__(self):
return "Calcul permanent #%s" % self.name
-class CalcUnsteady:
+class CalcTrans:
"""Metadata for an unsteady calculation"""
def __init__(self, name):
@@ -130,7 +130,7 @@ def __init__(self, rcal_path):
@property
def model_name(self):
- """Model name with 'Mo_' preffix"""
+ """Modele name with 'Mo_' preffix"""
return os.path.basename(self.rcal_folder)
@property
@@ -208,12 +208,12 @@ def _read_structure(self):
def _read_rescalc(self):
for calc in self.rcal_root.find(PREFIX + 'ResCalcPerms'):
- calc_steady = CalcSteady(calc.get('NomRef'), os.path.join(self.rcal_folder, calc.get('Href')),
- int(calc.get('OffsetMot')))
+ calc_steady = CalcPseudoPerm(calc.get('NomRef'), os.path.join(self.rcal_folder, calc.get('Href')),
+ int(calc.get('OffsetMot')))
self.calc_steady_dict[calc_steady.name] = calc_steady
for calc in self.rcal_root.find(PREFIX + 'ResCalcTranss'):
- calc_unsteady = CalcUnsteady(calc.get('NomRef'))
+ calc_unsteady = CalcTrans(calc.get('NomRef'))
for pdt in calc:
calc_unsteady.add_frame(get_time_in_seconds(pdt.get('TempsSimu')),
os.path.join(self.rcal_folder, pdt.get('Href')), int(pdt.get('OffsetMot')))
@@ -329,7 +329,7 @@ def get_res_unsteady_var_at_emhs(self, calc_name, varname, emh_list):
def export_calc_steady_as_csv(self, csv_path):
"""
- Write CSV containing all `CalcSteady` results
+ Write CSV containing all `CalcPseudoPerm` results
Header is: "calc;emh_type;emh;variable;value"
"""
with open(csv_path, 'w', newline='') as csv_file:
@@ -350,7 +350,7 @@ def export_calc_steady_as_csv(self, csv_path):
def export_calc_unsteady_as_csv(self, csv_path):
"""
- Write CSV containing all `CalcUnsteady` results
+ Write CSV containing all `CalcTrans` results
Header is: "calc;time;emh_type;emh;variable;value"
"""
with open(csv_path, 'w', newline='') as csv_file:
diff --git a/crue10/run.py b/crue10/run.py
index c0ccbc0..a7aedc8 100644
--- a/crue10/run.py
+++ b/crue10/run.py
@@ -21,7 +21,7 @@ class Run:
"""
Run
- id: run identifier corresponding to folder name
- - mo_folder : path to run model folder
+ - mo_folder : path to run modele folder
- metadata <{dict}>: containing metadata (keys correspond to `METADATA_FIELDS` list)
"""
diff --git a/crue10/scenario.py b/crue10/scenario.py
index cf55891..22198ba 100644
--- a/crue10/scenario.py
+++ b/crue10/scenario.py
@@ -5,19 +5,19 @@
import shutil
import subprocess
-from crue10.base import CrueXMLFile
-from crue10.model import Model
+from crue10.base import FichierXML
+from crue10.modele import Modele
from crue10.run import get_run_identifier, Run
from crue10.utils import check_isinstance, check_preffix, CrueError, logger, \
write_default_xml_file, write_xml_from_tree
from crue10.utils.settings import CRUE10_EXE_PATH, CRUE10_EXE_OPTS
-class Scenario(CrueXMLFile):
+class Scenario(FichierXML):
"""
Crue10 scenario
- id : scenario identifier
- - model <[Model]>: model
+ - modele <[Modele]>: modele
- runs <[Runs]>: runs
- current_run_id : current run identifier
"""
@@ -30,7 +30,7 @@ class Scenario(CrueXMLFile):
def __init__(self, scenario_name, model, access='r', files=None, metadata=None):
"""
:param scenario_name: scenario name
- :param model: a Model instance
+ :param model: a Modele instance
:param files: dict with xml path files
:param metadata: dict containing metadata
"""
@@ -38,8 +38,8 @@ def __init__(self, scenario_name, model, access='r', files=None, metadata=None):
self.id = scenario_name
super().__init__(access, files, metadata)
- self.model = None
- self.set_model(model)
+ self.modele = None
+ self.set_modele(model)
self.current_run_id = None
self.runs = OrderedDict()
@@ -53,14 +53,14 @@ def get_run(self, run_id):
raise CrueError("Le run %s n'existe pas !\nLes noms possibles sont: %s"
% (run_id, list(self.runs.keys())))
- def set_model(self, model):
- check_isinstance(model, Model)
- self.model = model
+ def set_modele(self, model):
+ check_isinstance(model, Modele)
+ self.modele = model
def read_all(self):
if not self.was_read:
self._set_xml_trees()
- self.model.read_all()
+ self.modele.read_all()
self.was_read = True
def add_run(self, run):
@@ -83,7 +83,7 @@ def remove_run(self, run_id, run_folder):
def create_and_launch_new_run(self, study, run_id=None, comment='', force=False):
"""
Create and launch a new run
- /!\ The instance of `study` is modified but the original etu file not overwritten
+ /!\ The instance of `etude` is modified but the original etu file not overwritten
(If necessary, it should be done after calling this method)
1) Création d'un nouveau run (sans enregistrer la mise à jour du fichier etu.xml en entrée)
@@ -102,7 +102,7 @@ def create_and_launch_new_run(self, study, run_id=None, comment='', force=False)
if run_id is None:
run_id = get_run_identifier()
run_folder = os.path.join(study.folder, study.folders['RUNS'], self.id, run_id)
- run = Run(os.path.join(run_folder, self.model.id), metadata={'Commentaire': comment})
+ run = Run(os.path.join(run_folder, self.modele.id), metadata={'Commentaire': comment})
if not force:
if os.path.exists(run_folder):
raise CrueError("Le dossier du run existe déjà. "
@@ -112,14 +112,14 @@ def create_and_launch_new_run(self, study, run_id=None, comment='', force=False)
self.add_run(run)
self.set_current_run_id(run.id)
- # Update study attributes
+ # Update etude attributes
study.current_scenario_id = self.id
# Write files and create folder is necessary
logger.debug("Écriture de %s dans %s" % (run, run_folder))
- mo_folder = os.path.join(run_folder, self.model.id)
+ mo_folder = os.path.join(run_folder, self.modele.id)
self.write_all(run_folder, folder_config=None, write_model=False)
- self.model.write_all(mo_folder, folder_config=None)
+ self.modele.write_all(mo_folder, folder_config=None)
study.write_etu(run_folder)
# Run crue10.exe in command line and redirect stdout and stderr in csv files
@@ -147,7 +147,7 @@ def write_all(self, folder, folder_config=None, write_model=True):
write_default_xml_file(xml_type, xml_path)
if write_model:
- self.model.write_all(folder, folder_config)
+ self.modele.write_all(folder, folder_config)
def __repr__(self):
return "Scénario %s" % self.id
diff --git a/crue10/submodel.py b/crue10/sous_modele.py
similarity index 87%
rename from crue10/submodel.py
rename to crue10/sous_modele.py
index a2dffec..f1ff1b9 100644
--- a/crue10/submodel.py
+++ b/crue10/sous_modele.py
@@ -5,11 +5,11 @@
import os.path
from shapely.geometry import LinearRing, LineString, mapping, Point
-from crue10.base import CrueXMLFile
+from crue10.base import FichierXML
from crue10.emh.branche import *
from crue10.emh.casier import Casier, ProfilCasier
from crue10.emh.noeud import Noeud
-from crue10.emh.section import DEFAULT_FK_MAX, DEFAULT_FK_MIN, DEFAULT_FK_STO, FrictionLaw, LimiteGeom, LitNumerote, \
+from crue10.emh.section import DEFAULT_FK_MAX, DEFAULT_FK_MIN, DEFAULT_FK_STO, LoiFrottement, LimiteGeom, LitNumerote, \
SectionIdem, SectionInterpolee, SectionProfil, SectionSansGeometrie
from crue10.utils import check_preffix, CrueError, CrueErrorGeometryNotFound, PREFIX
@@ -49,17 +49,17 @@ def get_optional_commentaire(elt):
return ''
-class SubModel(CrueXMLFile):
+class SousModele(FichierXML):
"""
- Crue10 sub-model
- - id : submodel identifier
+ Crue10 sous_modele
+ - id : sous_modele identifier
- noeuds <{crue10.emh.noeud.Noeud}>: nodes
- sections <{crue10.emh.section.Section}>: sections
(SectionProfil, SectionIdem, SectionInterpolee or SectionSansGeometrie)
- branches <{crue10.emh.section.SectionInterpolee}>: branches (only those with geometry are considered)
- casiers <{crue10.emh.casier.Casier}>: casiers
- profils_casier <{crue10.emh.casier.ProfilCasier}>: profils casier
- - friction_laws <{crue10.emh.section.FrictionLaw}>: friction laws (Strickler coefficients)
+ - lois_frottement <{crue10.emh.section.LoiFrottement}>: friction laws (Strickler coefficients)
"""
FILES_SHP = ['noeuds', 'branches', 'casiers', 'tracesSections']
@@ -67,12 +67,12 @@ class SubModel(CrueXMLFile):
METADATA_FIELDS = ['Type', 'IsActive', 'Commentaire', 'AuteurCreation', 'DateCreation', 'AuteurDerniereModif',
'DateDerniereModif']
- def __init__(self, submodel_name, access='r', files=None, metadata=None):
+ def __init__(self, nom_sous_modele, access='r', files=None, metadata=None):
"""
- :param submodel_name: submodel name
+ :param nom_sous_modele: sous_modele name
"""
- check_preffix(submodel_name, 'Sm_')
- self.id = submodel_name
+ check_preffix(nom_sous_modele, 'Sm_')
+ self.id = nom_sous_modele
super().__init__(access, files, metadata)
self.noeuds = OrderedDict()
@@ -80,75 +80,75 @@ def __init__(self, submodel_name, access='r', files=None, metadata=None):
self.branches = OrderedDict()
self.casiers = OrderedDict()
self.profils_casier = OrderedDict()
- self.friction_laws = OrderedDict()
+ self.lois_frottement = OrderedDict()
- def add_noeud(self, noeud):
+ def ajouter_noeud(self, noeud):
check_isinstance(noeud, Noeud)
if noeud.id in self.noeuds:
raise CrueError("Le noeud %s est déjà présent" % noeud.id)
self.noeuds[noeud.id] = noeud
- def add_section(self, section):
+ def ajouter_section(self, section):
check_isinstance(section, [SectionProfil, SectionIdem, SectionSansGeometrie, SectionInterpolee])
if section.id in self.sections:
raise CrueError("La Section `%s` est déjà présente" % section.id)
if isinstance(section, SectionIdem):
- if section.parent_section.id not in self.sections:
+ if section.section_reference.id not in self.sections:
raise CrueError("La SectionIdem `%s` fait référence à une SectionProfil inexistante `%s`"
% (section.id, section.section_ori.id))
if isinstance(section, SectionProfil):
for lit in section.lits_numerotes:
- if lit.friction_law.id not in self.friction_laws:
+ if lit.loi_frottement.id not in self.lois_frottement:
raise CrueError("La loi de frottement %s de la section `%s` doit être ajoutée au sous-modèle avant"
- % (lit.friction_law.id, section.id))
+ % (lit.loi_frottement.id, section.id))
self.sections[section.id] = section
- def add_branche(self, branche):
+ def ajouter_branche(self, branche):
check_isinstance(branche, BRANCHE_CLASSES)
if branche.id in self.branches:
raise CrueError("La branche `%s` est déjà présente" % branche.id)
if branche.noeud_amont.id not in self.noeuds:
- raise CrueError("Le noeud amont %s de la branche `%s` doit être ajouté au sous-modèle avant"
+ raise CrueError("Le noeud_reference amont %s de la branche `%s` doit être ajouté au sous-modèle avant"
% (branche.noeud_amont.id, branche.id))
if branche.noeud_aval.id not in self.noeuds:
- raise CrueError("Le noeud aval %s de la branche `%s` doit être ajouté au sous-modèle avant"
+ raise CrueError("Le noeud_reference aval %s de la branche `%s` doit être ajouté au sous-modèle avant"
% (branche.noeud_aval.id, branche.id))
self.branches[branche.id] = branche
- def add_casier(self, casier):
+ def ajouter_casier(self, casier):
check_isinstance(casier, Casier)
if casier.id in self.casiers:
raise CrueError("Le casier %s est déjà présent" % casier.id)
- if casier.noeud.id not in self.noeuds:
- raise CrueError("Le noeud %s du casier `%s` doit être ajouté au sous-modèle avant"
- % (casier.noeud.id, casier.id))
+ if casier.noeud_reference.id not in self.noeuds:
+ raise CrueError("Le noeud_reference %s du casier `%s` doit être ajouté au sous-modèle avant"
+ % (casier.noeud_reference.id, casier.id))
for profilcasier in casier.profils_casier:
if profilcasier.id not in self.profils_casier:
- self.add_profil_casier(profilcasier)
+ self.ajouter_profil_casier(profilcasier)
self.casiers[casier.id] = casier
- def add_profil_casier(self, profil_casier):
+ def ajouter_profil_casier(self, profil_casier):
check_isinstance(profil_casier, ProfilCasier)
if profil_casier.id in self.profils_casier:
raise CrueError("Le profil casier %s est déjà présent" % profil_casier.id)
self.profils_casier[profil_casier.id] = profil_casier
- def add_friction_law(self, friction_law):
- check_isinstance(friction_law, FrictionLaw)
- if friction_law.id in self.friction_laws:
- raise CrueError("La loi de frottement %s est déjà présente" % friction_law.id)
- self.friction_laws[friction_law.id] = friction_law
+ def ajouter_loi_frottement(self, loi_frottement):
+ check_isinstance(loi_frottement, LoiFrottement)
+ if loi_frottement.id in self.lois_frottement:
+ raise CrueError("La loi de frottement %s est déjà présente" % loi_frottement.id)
+ self.lois_frottement[loi_frottement.id] = loi_frottement
- def add_default_friction_laws(self):
- self.add_friction_law(DEFAULT_FK_STO)
- self.add_friction_law(DEFAULT_FK_MAX)
- self.add_friction_law(DEFAULT_FK_MIN)
+ def ajouter_lois_frottement_par_defaut(self):
+ self.ajouter_loi_frottement(DEFAULT_FK_STO)
+ self.ajouter_loi_frottement(DEFAULT_FK_MAX)
+ self.ajouter_loi_frottement(DEFAULT_FK_MIN)
def get_noeud(self, nom_noeud):
try:
return self.noeuds[nom_noeud]
except KeyError:
- raise CrueError("Le noeud %s n'est pas dans le sous-modèle %s" % (nom_noeud, self))
+ raise CrueError("Le noeud_reference %s n'est pas dans le sous-modèle %s" % (nom_noeud, self))
def get_section(self, nom_section):
try:
@@ -204,9 +204,9 @@ def _read_dfrt(self):
"""
root = self._get_xml_root_and_set_comment('dfrt')
for loi in root.find(PREFIX + 'LoiFFs'):
- friction_law = FrictionLaw(loi.get('Nom'), loi.get('Type'), parse_loi(loi))
- friction_law.comment = get_optional_commentaire(loi)
- self.add_friction_law(friction_law)
+ loi_frottement = LoiFrottement(loi.get('Nom'), loi.get('Type'), parse_loi(loi))
+ loi_frottement.comment = get_optional_commentaire(loi)
+ self.ajouter_loi_frottement(loi_frottement)
def _read_drso(self, filter_branch_types=None):
"""
@@ -219,7 +219,7 @@ def _read_drso(self, filter_branch_types=None):
for emh_noeud in emh_group.findall(PREFIX + 'NoeudNiveauContinu'):
noeud = Noeud(emh_noeud.get('Nom'))
noeud.comment = get_optional_commentaire(emh_noeud)
- self.add_noeud(noeud)
+ self.ajouter_noeud(noeud)
elif emh_group.tag == (PREFIX + 'Sections'):
@@ -242,7 +242,7 @@ def _read_drso(self, filter_branch_types=None):
raise NotImplementedError
section.comment = get_optional_commentaire(emh_section)
- self.add_section(section)
+ self.ajouter_section(section)
# SectionIdem set after SectionProfil to define its parent section properly
for emh_section in emh_group:
@@ -305,7 +305,7 @@ def _read_drso(self, filter_branch_types=None):
# Add section pilotage
if isinstance(branche, BrancheBarrageGenerique) or isinstance(branche, BrancheBarrageFilEau):
- branche.section_pilotage = \
+ branche.section_pilote = \
self.sections[emh_branche.find(PREFIX + 'SectionPilote').get('NomRef')]
for emh_section in emh_sections:
@@ -315,8 +315,8 @@ def _read_drso(self, filter_branch_types=None):
section.CoefPond = float(emh_section.find(PREFIX + 'CoefPond').text)
section.CoefConv = float(emh_section.find(PREFIX + 'CoefConv').text)
section.CoefDiv = float(emh_section.find(PREFIX + 'CoefDiv').text)
- branche.add_section(section, xp)
- self.add_branche(branche)
+ branche.ajouter_section_dans_branche(section, xp)
+ self.ajouter_branche(branche)
elif emh_group.tag == (PREFIX + 'Casiers'):
for emh_profils_casier in emh_group:
@@ -326,9 +326,9 @@ def _read_drso(self, filter_branch_types=None):
casier.comment = get_optional_commentaire(emh_profils_casier)
for emh_pc in emh_profils_casier.findall(PREFIX + 'ProfilCasier'):
pc = ProfilCasier(emh_pc.get('NomRef'))
- self.add_profil_casier(pc)
- casier.add_profil_casier(pc)
- self.add_casier(casier)
+ self.ajouter_profil_casier(pc)
+ casier.ajouter_profil_casier(pc)
+ self.ajouter_casier(casier)
def _read_dptg(self):
"""
@@ -358,15 +358,15 @@ def _read_dptg(self):
fente = emh.find(PREFIX + 'Fente')
if fente is not None:
- section.set_fente(float(fente.find(PREFIX + 'LargeurFente').text),
- float(fente.find(PREFIX + 'ProfondeurFente').text))
+ section.ajouter_fente(float(fente.find(PREFIX + 'LargeurFente').text),
+ float(fente.find(PREFIX + 'ProfondeurFente').text))
for lit_num_elt in emh.find(PREFIX + 'LitNumerotes').findall(PREFIX + 'LitNumerote'):
lit_id = lit_num_elt.find(PREFIX + 'LitNomme').text
xt_min = float(lit_num_elt.find(PREFIX + 'LimDeb').text.split()[0])
xt_max = float(lit_num_elt.find(PREFIX + 'LimFin').text.split()[0])
- friction_law = self.friction_laws[lit_num_elt.find(PREFIX + 'Frot').get('NomRef')]
- section.add_lit_numerote(LitNumerote(lit_id, xt_min, xt_max, friction_law))
+ loi_frottement = self.lois_frottement[lit_num_elt.find(PREFIX + 'Frot').get('NomRef')]
+ section.ajouter_lit(LitNumerote(lit_id, xt_min, xt_max, loi_frottement))
etiquettes = emh.find(PREFIX + 'Etiquettes')
if etiquettes is None:
@@ -453,7 +453,7 @@ def _read_dcsp(self):
raise NotImplementedError
def _read_shp_noeuds(self):
- """Read geometry of all `Noeuds` from current submodel (they are compulsory)"""
+ """Read geometry of all `Noeuds` from current sous_modele (they are compulsory)"""
geoms = {}
with fiona.open(self.files['noeuds'], 'r') as src:
for obj in src:
@@ -467,7 +467,7 @@ def _read_shp_noeuds(self):
raise CrueErrorGeometryNotFound(noeud)
def _read_shp_branches(self):
- """Read geometry of all `Branches` from current submodel (they are compulsory)"""
+ """Read geometry of all `Branches` from current sous_modele (they are compulsory)"""
geoms = {}
with fiona.open(self.files['branches'], 'r') as src:
for obj in src:
@@ -482,7 +482,7 @@ def _read_shp_branches(self):
def _read_shp_traces_sections(self):
"""
- Read geometry of all `SectionProfils` from current submodel
+ Read geometry of all `SectionProfils` from current sous_modele
Missing sections are computed orthogonally to the branch
"""
geoms = {}
@@ -502,7 +502,7 @@ def _read_shp_traces_sections(self):
logger.warn("La géométrie manquante de la section %s est reconstruite" % section.id)
def _read_shp_casiers(self):
- """Read geometry of all `Casiers` from current submodel (they are compulsory)"""
+ """Read geometry of all `Casiers` from current sous_modele (they are compulsory)"""
geoms = {}
with fiona.open(self.files['casiers'], 'r') as src:
for obj in src:
@@ -543,7 +543,7 @@ def read_all(self):
def _write_dfrt(self, folder):
self._write_xml_file(
'dfrt', folder,
- friction_law_list=[fl for _, fl in self.friction_laws.items()],
+ friction_law_list=[fl for _, fl in self.lois_frottement.items()],
)
def _write_drso(self, folder):
@@ -644,7 +644,7 @@ def write_all(self, folder, folder_config=None):
# TO CHECK:
# - Casier has at least one ProfilCasier
- # - BrancheSaintVenant has a section_pilotage
+ # - BrancheSaintVenant has a section_pilote
# ...
# Create folder if not existing
@@ -704,7 +704,7 @@ def get_connected_casier(self, noeud):
Returns the connected casier if found, else returns None
"""
for _, casier in self.casiers.items():
- if casier.noeud == noeud:
+ if casier.noeud_reference == noeud:
return casier
return None
@@ -742,7 +742,7 @@ def convert_sectionidem_to_sectionprofil(self):
for br in branches:
section_pos = 0 if br.noeud_amont.id == nom_noeud else -1
section_at_node = br.sections[section_pos]
- if section_at_node is section.parent_section:
+ if section_at_node is section.section_reference:
located_at_parent_section = True
break
@@ -759,28 +759,28 @@ def normalize_geometry(self):
branche.shift_sectionprofil_to_extremity()
self.convert_sectionidem_to_sectionprofil()
- def add_emh_from_submodel(self, submodel, suffix=''):
- for _, friction_law in submodel.friction_laws.items():
- friction_law.id = friction_law.id + suffix
- self.add_friction_law(friction_law)
- for _, noeud in submodel.noeuds.items():
- self.add_noeud(noeud)
- for _, section in submodel.sections.items():
- self.add_section(section)
- for branche in submodel.iter_on_branches():
- self.add_branche(branche)
- for _, profils_casier in submodel.profils_casier.items():
- self.add_profil_casier(profils_casier)
- for _, casier in submodel.casiers.items():
- self.add_casier(casier)
+ def ajouter_emh_depuis_sous_modele(self, sous_modele, suffix=''):
+ for _, loi_frottement in sous_modele.lois_frottement.items():
+ loi_frottement.id = loi_frottement.id + suffix
+ self.ajouter_loi_frottement(loi_frottement)
+ for _, noeud in sous_modele.noeuds.items():
+ self.ajouter_noeud(noeud)
+ for _, section in sous_modele.sections.items():
+ self.ajouter_section(section)
+ for branche in sous_modele.iter_on_branches():
+ self.ajouter_branche(branche)
+ for _, profils_casier in sous_modele.profils_casier.items():
+ self.ajouter_profil_casier(profils_casier)
+ for _, casier in sous_modele.casiers.items():
+ self.ajouter_casier(casier)
def summary(self):
- return "%s: %i noeud(s), %i branche(s), %i section(s) (%i profil + %i idem + %i interpolee +" \
+ return "%s: %i noeud_reference(s), %i branche(s), %i section(s) (%i profil + %i idem + %i interpolee +" \
" %i sans géométrie), %i casier(s) (%i profil(s) casier)" % (
- self, len(self.noeuds), len(self.branches), len(self.sections),
- len(list(self.iter_on_sections_profil())), len(list(self.iter_on_sections_item())),
- len(list(self.iter_on_sections_interpolees())), len(list(self.iter_on_sections_sans_geometrie())),
- len(self.casiers), len(self.profils_casier)
+ self, len(self.noeuds), len(self.branches), len(self.sections),
+ len(list(self.iter_on_sections_profil())), len(list(self.iter_on_sections_item())),
+ len(list(self.iter_on_sections_interpolees())), len(list(self.iter_on_sections_sans_geometrie())),
+ len(self.casiers), len(self.profils_casier)
)
def __repr__(self):
diff --git a/mascaret/mascaret_file.py b/mascaret/mascaret_file.py
index 49ece38..3794eb3 100644
--- a/mascaret/mascaret_file.py
+++ b/mascaret/mascaret_file.py
@@ -21,7 +21,7 @@ class Reach:
id (int) reach identifier
name (str) reach name
- section ([Section]) list of sections
+ sections ([Section]) list of sections
"""
def __init__(self, id, name=None):
@@ -235,7 +235,7 @@ class MascaretFileParent:
def __init__(self, file_name, access='r', log_lvl='INFO'):
"""
Constructor for MascaretFile
- /!\ Only suited for results at cross-sections (not adapted to Casier or Traceur outputs)
+ /!\ Only suited for results at cross-liste_sections (not adapted to Casier or Traceur outputs)
@param file_name (str) Name of the file
@param access (str) Access to the file ('r' for read 'w' for write, add 'b' for binary file)
@@ -534,7 +534,7 @@ class Opthyca(MascaretFileParent):
def __init__(self, file_name, access='r', log_lvl='INFO'):
"""
Constructor for Opthyca file
- /!\ Only suited for results at cross-sections (not adapted to Casier or Traceur outputs)
+ /!\ Only suited for results at cross-liste_sections (not adapted to Casier or Traceur outputs)
@param file_name Name of the file
@param access Access to the file ('r' for read 'w' for write)
diff --git a/requirements.txt b/requirements.txt
index 03fbd03..b8b6d9a 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,5 +3,5 @@ future # python2 only packages
jinja2
lxml
numpy
-pydot # only required for Model.write_topological_graph
+pydot # only required for Modele.write_topological_graph
shapely
\ No newline at end of file
diff --git a/snippets/all.py b/snippets/all.py
index 082c362..87bc5c3 100644
--- a/snippets/all.py
+++ b/snippets/all.py
@@ -2,13 +2,13 @@
A script to check that all snippets execute properly
"""
-import snippets.merge_profilcasier
+import snippets.merge_profilcasiers
import snippets.post_crue_VS
-import snippets.read_model
-import snippets.read_model_and_run
-import snippets.read_run_and_results
-import snippets.read_studies
-import snippets.read_submodel
-# import snippets.run_calculations
+import snippets.lire_modele
+import snippets.lire_modele_et_run
+import snippets.lire_run_et_resultats
+import snippets.lire_etudes
+import snippets.lire_sous_modele
+import snippets.run_calculations
import snippets.write_study_from_scratch
import snippets.write_submodel_from_scratch
diff --git a/snippets/read_studies.py b/snippets/lire_etudes.py
similarity index 71%
rename from snippets/read_studies.py
rename to snippets/lire_etudes.py
index bf71b59..f5ace7a 100644
--- a/snippets/read_studies.py
+++ b/snippets/lire_etudes.py
@@ -13,16 +13,16 @@
# GE2009_Conc
- dclm: ' => '
-(With Python2 on Linux: drso: some Xp are truncated)
+(Sur Windows ou Python2 sur Linux: drso: some Xp are truncated)
# VA2018_Conc
OK (sauf copie manquante des fichiers orphelins)
-(With Python2 on Linux: drso: some Xp are truncated)
+(Sur Windows ou Python2 sur Linux: drso: some Xp are truncated)
"""
from glob import glob
import os.path
-from crue10.study import Study
+from crue10.etude import Etude
from crue10.utils import CrueError, logger
@@ -30,20 +30,20 @@
for etu_path in glob(os.path.join(folder, '*.etu.xml')):
logger.info(etu_path)
try:
- study = Study(etu_path)
+ study = Etude(etu_path)
try:
study.check_xml_files()
except IOError: # avoid some Crue9 missing files in `Etu_BV2016_Conc_Etatref - ISfonds2016_K2016`
pass
study.read_all()
- # Write study (to check in integrity, see difference in file docstring above)
+ # Write etude (to check in integrity, see difference in file docstring above)
out_folder = os.path.join('../tmp/Etudes-tests', os.path.basename(folder))
study.write_all(out_folder)
- # Write topographical graph for each model
- # for _, model in study.models.items():
- # model.write_topological_graph([os.path.join(out_folder, model.id + '.png')])
+ # Write topographical graph for each modele
+ # for _, modele in etude.modeles.items():
+ # modele.write_topological_graph([os.path.join(out_folder, modele.id + '.png')])
except CrueError as e:
logger.critical(e)
diff --git a/snippets/lire_modele.py b/snippets/lire_modele.py
new file mode 100644
index 0000000..0764b65
--- /dev/null
+++ b/snippets/lire_modele.py
@@ -0,0 +1,39 @@
+# coding: utf-8
+"""
+Lecture d'un modèle Crue10
+"""
+import os.path
+import sys
+
+from crue10.utils import CrueError, logger
+from crue10.etude import Etude
+
+
+try:
+ FileNotFoundError
+except NameError: # Python2 fix
+ FileNotFoundError = IOError
+
+try:
+ # Get modele
+ study = Etude(os.path.join('..', '..', 'Crue10_examples', 'Etudes-tests',
+ 'Etu_BE2016_conc', 'Etu_BE2016_conc.etu.xml'))
+ modele = study.get_modele('Mo_BE2016_etatref')
+ modele.read_all()
+
+ print(modele)
+ for sous_modele in modele.liste_sous_modeles:
+ print(sous_modele)
+ # sous_modele.convert_sectionidem_to_sectionprofil()
+
+ # Write some output files
+ # modele.write_mascaret_geometry('../tmp/Etu_VS2003_Conc.georef')
+ modele.write_shp_limites_lits_numerotes('../tmp/limites.shp')
+ modele.write_shp_sectionprofil_as_points('../tmp/liste_sections.shp')
+
+except FileNotFoundError as e:
+ logger.critical(e)
+ sys.exit(1)
+except CrueError as e:
+ logger.critical(e)
+ sys.exit(2)
diff --git a/snippets/read_model_and_run.py b/snippets/lire_modele_et_run.py
similarity index 83%
rename from snippets/read_model_and_run.py
rename to snippets/lire_modele_et_run.py
index 7b42432..8dc6099 100644
--- a/snippets/read_model_and_run.py
+++ b/snippets/lire_modele_et_run.py
@@ -14,7 +14,7 @@
import sys
from crue10.emh.section import SectionProfil
-from crue10.study import Study
+from crue10.etude import Etude
from crue10.utils import CrueError, logger
@@ -24,28 +24,28 @@
etu_folder = '../../TatooineMesher_examples/VS2015/in/Etu_VS2015_conc'
try:
- # Get model
- study = Study(os.path.join(etu_folder, 'Etu_VS2003_Conc.etu.xml'))
- model = study.get_model('Mo_VS2013_c10_octobre_2014')
- model.read_all()
- for submodel in model.submodels:
- submodel.convert_sectionidem_to_sectionprofil()
- print(submodel.summary())
+ # Get modele
+ etude = Etude(os.path.join(etu_folder, 'Etu_VS2003_Conc.etu.xml'))
+ modele = etude.get_modele('Mo_VS2013_c10_octobre_2014')
+ modele.read_all()
+ for sous_modele in modele.liste_sous_modeles:
+ sous_modele.convert_sectionidem_to_sectionprofil()
+ print(sous_modele.summary())
# Get a dict with active section bottom elevations
bottom = OrderedDict()
- for section in model.get_section_list():
+ for section in modele.get_liste_sections():
if section.is_active and isinstance(section, SectionProfil):
bottom[section.id] = section.get_coord(add_z=True)
# Read rcal result file
- scenario = study.get_scenario('Sc_EtatsRef2015')
+ scenario = etude.get_scenario('Sc_EtatsRef2015')
run = scenario.get_run('R2019-04-16-14h09m19s')
results = run.get_results()
print(results.summary())
# Check result consistency
- missing_sections = model.get_missing_active_sections(results.emh['Section'])
+ missing_sections = modele.get_missing_active_sections(results.emh['Section'])
if missing_sections:
print("Missing sections:\n%s" % missing_sections)
diff --git a/snippets/read_run_and_results.py b/snippets/lire_run_et_resultats.py
similarity index 93%
rename from snippets/read_run_and_results.py
rename to snippets/lire_run_et_resultats.py
index 959729b..c8dff9a 100644
--- a/snippets/read_run_and_results.py
+++ b/snippets/lire_run_et_resultats.py
@@ -2,16 +2,16 @@
import os.path
import sys
-from crue10.study import Study
+from crue10.etude import Etude
from crue10.utils import CrueError, logger
etu_folder = '../../TatooineMesher_examples/VS2015/in/Etu_VS2015_conc'
try:
- study = Study(os.path.join(etu_folder, 'Etu_VS2003_Conc.etu.xml'))
+ study = Etude(os.path.join(etu_folder, 'Etu_VS2003_Conc.etu.xml'))
run = study.get_scenario('Sc_EtatsRef2015').get_run('R2019-04-16-14h09m19s')
results = run.get_results()
- # It is also possible to avoid using the Study instance, in providing the path rcal to RunResults:
+ # It is also possible to avoid using the Etude instance, in providing the path rcal to RunResults:
# from crue10.results import RunResults
# results = RunResults(os.path.join(etu_folder, 'Runs', 'Sc_EtatsRef2015', 'R2019-04-16-14h09m19s',
# 'Mo_VS2013_c10_octobre_2014', 'VS2013_c10_EtatsRef.rcal.xml'))
diff --git a/snippets/read_submodel.py b/snippets/lire_sous_modele.py
similarity index 71%
rename from snippets/read_submodel.py
rename to snippets/lire_sous_modele.py
index e1fbdfe..91e1722 100644
--- a/snippets/read_submodel.py
+++ b/snippets/lire_sous_modele.py
@@ -7,23 +7,23 @@
from crue10.utils import CrueError, logger
from crue10.emh.section import LitNumerote
-from crue10.study import Study
+from crue10.etude import Etude
try:
- # Get submodel
- study = Study(os.path.join('..', '..', 'Crue10_examples', 'Etudes-tests',
+ # Get sous_modele
+ study = Etude(os.path.join('..', '..', 'Crue10_examples', 'Etudes-tests',
'Etu_BE2016_conc', 'Etu_BE2016_conc.etu.xml'))
- submodel = study.get_submodel('Sm_BE2016_etatref')
- submodel.read_all()
+ sous_modele = study.get_sous_modele('Sm_BE2016_etatref')
+ sous_modele.read_all()
- # Do something with `submodel`...
+ # Do something with `sous_modele`...
# Here is an example below:
- submodel.remove_sectioninterpolee()
- submodel.convert_sectionidem_to_sectionprofil()
+ sous_modele.remove_sectioninterpolee()
+ sous_modele.convert_sectionidem_to_sectionprofil()
# Select a single branch
- branch = submodel.get_branche('Br_VRH99.900')
+ branch = sous_modele.get_branche('Br_VRH99.900')
print(branch)
# Sections of a single branch
print(branch.sections)
@@ -32,7 +32,7 @@
print(section)
print(section.get_coord(add_z=True)) # 3D coordinates
# Select another section by its identifier
- section = submodel.get_section('St_KBE09_BE10_am')
+ section = sous_modele.get_section('St_KBE09_BE10_am')
# Display coordinates of its limits
print(section.lits_numerotes)
for i_lit, lit_name in enumerate(LitNumerote.LIMIT_NAMES):
diff --git a/snippets/merge_profilcasiers.py b/snippets/merge_profilcasiers.py
index 3682fb0..c26fe97 100644
--- a/snippets/merge_profilcasiers.py
+++ b/snippets/merge_profilcasiers.py
@@ -3,23 +3,23 @@
import matplotlib.pyplot as plt
import numpy as np
-from crue10.study import Study
+from crue10.etude import Etude
-study = Study('../../Crue10_examples/Etudes-tests/Etu_GE2009_Conc/Etu_GE2009_Conc.etu.xml')
-submodel = study.get_submodel('Sm_GE2009_conc')
-submodel.read_all()
+study = Etude('../../Crue10_examples/Etudes-tests/Etu_GE2009_Conc/Etu_GE2009_Conc.etu.xml')
+sous_modele = study.get_sous_modele('Sm_GE2009_conc')
+sous_modele.read_all()
fig1, ax_xz = plt.subplots(figsize=(16, 9))
fig2, ax_vol = plt.subplots(figsize=(16, 9))
-casier = submodel.get_casier('Ca_N8')
+casier = sous_modele.get_casier('Ca_N8')
old_casier = deepcopy(casier)
for pc in casier.profils_casier:
ax_xz.plot(pc.xz[:, 0], pc.xz[:, 1], marker='.', label=pc.id)
z_array = np.unique(np.sort(pc.xz[:, 1]))
ax_vol.plot(z_array, [pc.compute_volume(z) for z in z_array], marker='.', label=pc.id)
-casier.merge_profil_casiers()
+casier.fusion_profil_casiers()
z_array = casier.profils_casier[0].xz[:, 1]
ax_vol.plot(z_array, [old_casier.compute_volume(z) for z in z_array],
diff --git a/snippets/out/Etu_from_scratch/Config/SM_FROM_SCRATCH/branches.dbf b/snippets/out/Etu_from_scratch/Config/SM_FROM_SCRATCH/branches.dbf
index 826625c..6fa9369 100644
Binary files a/snippets/out/Etu_from_scratch/Config/SM_FROM_SCRATCH/branches.dbf and b/snippets/out/Etu_from_scratch/Config/SM_FROM_SCRATCH/branches.dbf differ
diff --git a/snippets/out/Etu_from_scratch/Config/SM_FROM_SCRATCH/casiers.dbf b/snippets/out/Etu_from_scratch/Config/SM_FROM_SCRATCH/casiers.dbf
index b0d78cf..0a3d2bd 100644
Binary files a/snippets/out/Etu_from_scratch/Config/SM_FROM_SCRATCH/casiers.dbf and b/snippets/out/Etu_from_scratch/Config/SM_FROM_SCRATCH/casiers.dbf differ
diff --git a/snippets/out/Etu_from_scratch/Config/SM_FROM_SCRATCH/noeuds.dbf b/snippets/out/Etu_from_scratch/Config/SM_FROM_SCRATCH/noeuds.dbf
index b96eb7f..9cabf4b 100644
Binary files a/snippets/out/Etu_from_scratch/Config/SM_FROM_SCRATCH/noeuds.dbf and b/snippets/out/Etu_from_scratch/Config/SM_FROM_SCRATCH/noeuds.dbf differ
diff --git a/snippets/out/Etu_from_scratch/Config/SM_FROM_SCRATCH/tracesSections.dbf b/snippets/out/Etu_from_scratch/Config/SM_FROM_SCRATCH/tracesSections.dbf
index 6f3197a..c34c6e7 100644
Binary files a/snippets/out/Etu_from_scratch/Config/SM_FROM_SCRATCH/tracesSections.dbf and b/snippets/out/Etu_from_scratch/Config/SM_FROM_SCRATCH/tracesSections.dbf differ
diff --git a/snippets/out/Etu_from_scratch/Etu_from_scratch.etu.xml b/snippets/out/Etu_from_scratch/Etu_from_scratch.etu.xml
index 72bcf16..6844bdc 100644
--- a/snippets/out/Etu_from_scratch/Etu_from_scratch.etu.xml
+++ b/snippets/out/Etu_from_scratch/Etu_from_scratch.etu.xml
@@ -1,10 +1,10 @@
- lucd
- 2019-09-18T10:26:54.000
- lucd
- 2019-09-18T10:26:54.000
+ DURON
+ 2020-01-09T13:58:24.000
+ DURON
+ 2020-01-09T13:58:24.000
@@ -41,10 +41,10 @@
Crue10
true
- lucd
- 2019-09-18T10:26:54.000
- lucd
- 2019-09-18T10:26:54.000
+ DURON
+ 2020-01-09T13:58:24.000
+ DURON
+ 2020-01-09T13:58:24.000
@@ -58,10 +58,10 @@
Crue10
true
- lucd
- 2019-09-18T10:26:54.000
- lucd
- 2019-09-18T10:26:54.000
+ DURON
+ 2020-01-09T13:58:24.000
+ DURON
+ 2020-01-09T13:58:24.000
@@ -79,10 +79,10 @@
Crue10
true
- lucd
- 2019-09-18T10:26:54.000
- lucd
- 2019-09-18T10:26:54.000
+ DURON
+ 2020-01-09T13:58:24.000
+ DURON
+ 2020-01-09T13:58:24.000
diff --git a/snippets/out/Etu_from_scratch/from_scratch.dcsp.xml b/snippets/out/Etu_from_scratch/from_scratch.dcsp.xml
index 4999095..251d69f 100644
--- a/snippets/out/Etu_from_scratch/from_scratch.dcsp.xml
+++ b/snippets/out/Etu_from_scratch/from_scratch.dcsp.xml
@@ -39,8 +39,8 @@
- -1E30
- 1E30
+ -1.0E30
+ 1.0E30
@@ -49,8 +49,8 @@
- -1E30
- 1E30
+ -1.0E30
+ 1.0E30
@@ -65,8 +65,8 @@
- -1E30
- 1E30
+ -1.0E30
+ 1.0E30
1.0
0.0
diff --git a/snippets/out/Etu_from_scratch/from_scratch.dpti.xml b/snippets/out/Etu_from_scratch/from_scratch.dpti.xml
index 5fbf2a1..b0b67fa 100644
--- a/snippets/out/Etu_from_scratch/from_scratch.dpti.xml
+++ b/snippets/out/Etu_from_scratch/from_scratch.dpti.xml
@@ -3,34 +3,34 @@
- 1E30
+ 1.0E30
- 1E30
+ 1.0E30
- 1E30
+ 1.0E30
- 1E30
+ 1.0E30
- 1E30
+ 1.0E30
- 1E30
+ 1.0E30
- 1E30
+ 1.0E30
- 1E30
+ 1.0E30
- 1E30
+ 1.0E30
- 1E30
+ 1.0E30
diff --git a/snippets/post_crue_VS.py b/snippets/post_crue_VS.py
index 9b3bc24..b75ef57 100644
--- a/snippets/post_crue_VS.py
+++ b/snippets/post_crue_VS.py
@@ -4,16 +4,16 @@
from shapely.geometry import mapping
import sys
-from crue10.study import Study
+from crue10.etude import Etude
from crue10.utils import CrueError, logger
try:
- # Read model
+ # Read modele
model_folder = '../../TatooineMesher_examples/VS2015/in/Etu_VS2015_conc'
- study = Study(os.path.join(model_folder, 'Etu_VS2003_Conc.etu.xml'))
- model = study.get_model('Mo_VS2013_c10_octobre_2014')
- model.read_all()
+ study = Etude(os.path.join(model_folder, 'Etu_VS2003_Conc.etu.xml'))
+ modele = study.get_modele('Mo_VS2013_c10_octobre_2014')
+ modele.read_all()
# Read rcal result file and its results
run = study.get_scenario('Sc_EtatsRef2015').get_run('R2019-04-16-14h09m19s')
@@ -34,11 +34,11 @@
'properties': {'id_branche': 'str', **{var: 'str' for var in variables}}
}
with fiona.open(os.path.join(model_folder, 'check_at_branches.shp'), 'w', 'ESRI Shapefile', schema) as out_shp:
- for submodel in model.submodels:
- submodel.convert_sectionidem_to_sectionprofil()
- print(submodel.summary())
+ for sous_modele in modele.sous_modeles:
+ sous_modele.convert_sectionidem_to_sectionprofil()
+ print(sous_modele.summary())
- for branche in submodel.iter_on_branches():
+ for branche in sous_modele.iter_on_branches():
if branche.is_active:
values = {var: 'NA' for var in variables}
diff --git a/snippets/read_model.py b/snippets/read_model.py
deleted file mode 100644
index 5e8270f..0000000
--- a/snippets/read_model.py
+++ /dev/null
@@ -1,39 +0,0 @@
-# coding: utf-8
-"""
-Lecture d'un modèle Crue10
-"""
-import os.path
-import sys
-
-from crue10.utils import CrueError, logger
-from crue10.study import Study
-
-
-try:
- FileNotFoundError
-except NameError: # Python2 fix
- FileNotFoundError = IOError
-
-try:
- # Get model
- study = Study(os.path.join('..', '..', 'Crue10_examples', 'Etudes-tests',
- 'Etu_BE2016_conc', 'Etu_BE2016_conc.etu.xml'))
- model = study.get_model('Mo_BE2016_etatref')
- model.read_all()
-
- print(model)
- for submodel in model.submodels:
- print(submodel)
- # submodel.convert_sectionidem_to_sectionprofil()
-
- # Write some output files
- # model.write_mascaret_geometry('../tmp/Etu_VS2003_Conc.georef')
- model.write_shp_limites_lits_numerotes('../tmp/limites.shp')
- model.write_shp_sectionprofil_as_points('../tmp/sections.shp')
-
-except FileNotFoundError as e:
- logger.critical(e)
- sys.exit(1)
-except CrueError as e:
- logger.critical(e)
- sys.exit(2)
diff --git a/snippets/run_calculations.py b/snippets/run_calculations.py
index 670f0d3..8e72393 100644
--- a/snippets/run_calculations.py
+++ b/snippets/run_calculations.py
@@ -14,10 +14,10 @@
import numpy as np
import os.path
-from crue10.study import Study
+from crue10.etude import Etude
-study = Study(os.path.join('..', '..', 'Crue10_examples', 'Etudes-tests',
+study = Etude(os.path.join('..', '..', 'Crue10_examples', 'Etudes-tests',
'Etu_BE2016_conc', 'Etu_BE2016_conc.etu.xml'))
study.read_all()
@@ -25,16 +25,16 @@
scenario_ori = deepcopy(scenario)
for delta_strickler in np.arange(-20.0, 20.0, step=5.0):
- for idx_sm, submodel in enumerate(scenario.model.submodels):
- for fk_id, friction_law in submodel.friction_laws.items():
- if friction_law.type != 'FkSto':
- friction_law_ori = scenario_ori.model.submodels[idx_sm].friction_laws[fk_id]
- new_strickler = friction_law_ori.loi_Fk[:, 1] + delta_strickler
- friction_law.loi_Fk[:, 1] = new_strickler.clip(min=10.0)
- # print("Nouvelles valeurs de Strickler pour %s: %s" % (fk_id, friction_law.loi_Fk[:, 1]))
+ for idx_sm, sous_modele in enumerate(scenario.modele.liste_sous_modeles):
+ for fk_id, loi_frottement in sous_modele.lois_frottement.items():
+ if loi_frottement.type != 'FkSto':
+ loi_frottement_ori = scenario_ori.modele.get_sous_modele(sous_modele.id).lois_frottement[fk_id]
+ new_strickler = loi_frottement_ori.loi_Fk[:, 1] + delta_strickler
+ loi_frottement.loi_Fk[:, 1] = new_strickler.clip(min=10.0)
+ # print("Nouvelles valeurs de Strickler pour %s: %s" % (fk_id, loi_frottement.loi_Fk[:, 1]))
# With regular run identifiers
- # run_id = scenario.create_and_launch_new_run(study, comment='Modif Strickler %f points' % delta_strickler,
+ # run_id = scenario.create_and_launch_new_run(etude, comment='Modif Strickler %f points' % delta_strickler,
# force=True)
# With custom run identifiers
diff --git a/snippets/write_study_from_scratch.py b/snippets/write_study_from_scratch.py
index d75cc93..06c470f 100644
--- a/snippets/write_study_from_scratch.py
+++ b/snippets/write_study_from_scratch.py
@@ -2,7 +2,7 @@
import logging
import os.path
-from crue10.study import Study
+from crue10.etude import Etude
from crue10.utils import logger
logger.setLevel(logging.DEBUG)
@@ -10,24 +10,24 @@
etu_path = os.path.join('out', 'Etu_from_scratch', 'Etu_from_scratch.etu.xml')
-# Write an empty study
-study_out = Study(etu_path, access='w')
+# Write an empty etude
+study_out = Etude(etu_path, access='w')
study_out.create_empty_scenario('Sc_from_scratch', 'Mo_from_scratch', 'Sm_from_scratch')
-submodel_out = study_out.get_submodel('Sm_from_scratch')
+sous_modele_out = study_out.get_sous_modele('Sm_from_scratch')
if True:
- # Add some EMHs in submodel
- from snippets.write_submodel_from_scratch import submodel
- submodel_out.add_emh_from_submodel(submodel)
+ # Add some EMHs in sous_modele
+ from snippets.write_submodel_from_scratch import sous_modele
+ sous_modele_out.ajouter_emh_depuis_sous_modele(sous_modele)
logger.info(study_out.summary())
-logger.info(study_out.get_submodel('Sm_from_scratch').summary())
-study_out.get_model('Mo_from_scratch').reset_initial_conditions()
+logger.info(study_out.get_sous_modele('Sm_from_scratch').summary())
+study_out.get_modele('Mo_from_scratch').reset_initial_conditions()
study_out.write_all()
-# Read this new study to check its integrity
-study_in = Study(etu_path, access='r')
+# Read this new etude to check its integrity
+study_in = Etude(etu_path, access='r')
study_in.read_all()
logger.info(study_in.summary())
-logger.info(study_in.get_submodel('Sm_from_scratch').summary())
+logger.info(study_in.get_sous_modele('Sm_from_scratch').summary())
diff --git a/snippets/write_submodel_from_scratch.py b/snippets/write_submodel_from_scratch.py
index 2fad468..9f0eb52 100644
--- a/snippets/write_submodel_from_scratch.py
+++ b/snippets/write_submodel_from_scratch.py
@@ -8,63 +8,63 @@
from crue10.emh.casier import Casier, ProfilCasier
from crue10.emh.noeud import Noeud
from crue10.emh.section import *
-from crue10.submodel import SubModel
+from crue10.sous_modele import SousModele
from crue10.utils import logger
logger.setLevel(logging.DEBUG)
-# Build a submodel
-submodel = SubModel('Sm_fromscratch', access='w')
-submodel.add_default_friction_laws()
+# Build a sous_modele
+sous_modele = SousModele('Sm_fromscratch', access='w')
+sous_modele.ajouter_lois_frottement_par_defaut()
# Add nodes
noeud1 = Noeud('Nd_1')
noeud1.set_geom(Point(0, 100))
-submodel.add_noeud(noeud1)
+sous_modele.ajouter_noeud(noeud1)
noeud2 = Noeud('Nd_2')
noeud2.set_geom(Point(0, 90))
-submodel.add_noeud(noeud2)
+sous_modele.ajouter_noeud(noeud2)
noeud4 = Noeud('Nd_4')
noeud4.set_geom(Point(0, 70))
-submodel.add_noeud(noeud4)
+sous_modele.ajouter_noeud(noeud4)
noeud5 = Noeud('Nd_5')
noeud5.set_geom(Point(0, 60))
-submodel.add_noeud(noeud5)
+sous_modele.ajouter_noeud(noeud5)
noeud6 = Noeud('Nd_6')
noeud6.set_geom(Point(0, 50))
-submodel.add_noeud(noeud6)
+sous_modele.ajouter_noeud(noeud6)
noeud12 = Noeud('Nd_12')
noeud12.set_geom(Point(0, -10))
-submodel.add_noeud(noeud12)
+sous_modele.ajouter_noeud(noeud12)
noeud14 = Noeud('Nd_14')
noeud14.set_geom(Point(0, -30))
-submodel.add_noeud(noeud14)
+sous_modele.ajouter_noeud(noeud14)
noeud15 = Noeud('Nd_15')
noeud15.set_geom(Point(0, -40))
-submodel.add_noeud(noeud15)
+sous_modele.ajouter_noeud(noeud15)
noeud20 = Noeud('Nd_20')
noeud20.set_geom(Point(0, -90))
-submodel.add_noeud(noeud20)
+sous_modele.ajouter_noeud(noeud20)
noeud_aval = Noeud('Nd_aval')
noeud_aval.set_geom(Point(0, -150))
-submodel.add_noeud(noeud_aval)
+sous_modele.ajouter_noeud(noeud_aval)
# Add a casier
casier = Casier('Ca_1', noeud1)
-casier.add_profil_casier(ProfilCasier('Pc_' + casier.id[3:] + '_001'))
+casier.ajouter_profil_casier(ProfilCasier('Pc_' + casier.id[3:] + '_001'))
casier.set_geom(LinearRing([(-4, 96), (4, 96), (4, 104), (-4, 104)]))
-submodel.add_casier(casier)
+sous_modele.ajouter_casier(casier)
# Define an hydraulic axis line, used only to compute orthogonal trace (for SectionProfil)
@@ -73,116 +73,116 @@
# Add sections
section1_am = SectionSansGeometrie('St_1_Am')
-submodel.add_section(section1_am)
+sous_modele.ajouter_section(section1_am)
section1_av = SectionSansGeometrie('St_1_Av')
-submodel.add_section(section1_av)
+sous_modele.ajouter_section(section1_av)
section2_am = SectionProfil('St_2_Am')
section2_am.set_xz(np.array([(0, 3), (1, 0.5), (5, 0), (9, 0.5), (10, 3)]))
section2_am.add_limite_geom(LimiteGeom('Et_AxeHyd', 5.0))
section2_am.set_lits_numerotes((0.0, 0.0, 1.0, 9.0, 10.0, 10.0))
section2_am.build_orthogonal_trace(axe_geom)
-submodel.add_section(section2_am)
+sous_modele.ajouter_section(section2_am)
section2_av = SectionIdem('St_2_Av', section2_am, dz=0.0)
-submodel.add_section(section2_av)
+sous_modele.ajouter_section(section2_av)
section4_am = SectionSansGeometrie('St_4_Am')
-submodel.add_section(section4_am)
+sous_modele.ajouter_section(section4_am)
section4_av = SectionSansGeometrie('St_4_Av')
-submodel.add_section(section4_av)
+sous_modele.ajouter_section(section4_av)
section5_am = SectionSansGeometrie('St_5_Am')
-submodel.add_section(section5_am)
+sous_modele.ajouter_section(section5_am)
section5_av = SectionSansGeometrie('St_5_Av')
-submodel.add_section(section5_av)
+sous_modele.ajouter_section(section5_av)
section6_am = SectionIdem('St_6_Am', section2_am, dz=0.0)
-submodel.add_section(section6_am)
+sous_modele.ajouter_section(section6_am)
section6_av = SectionIdem('St_6_Av', section2_am, dz=0.0)
-submodel.add_section(section6_av)
+sous_modele.ajouter_section(section6_av)
section12_am = SectionSansGeometrie('St_12_Am')
-submodel.add_section(section12_am)
+sous_modele.ajouter_section(section12_am)
section12_av = SectionSansGeometrie('St_12_Av')
-submodel.add_section(section12_av)
+sous_modele.ajouter_section(section12_av)
section14_am = SectionSansGeometrie('St_14_Am')
-submodel.add_section(section14_am)
+sous_modele.ajouter_section(section14_am)
section14_av = SectionSansGeometrie('St_14_Av')
-submodel.add_section(section14_av)
+sous_modele.ajouter_section(section14_av)
section15_am = SectionIdem('St_15_Am', section2_am, dz=0.0)
-submodel.add_section(section15_am)
+sous_modele.ajouter_section(section15_am)
section15_av = SectionIdem('St_15_Av', section2_am, dz=0.0)
-submodel.add_section(section15_av)
+sous_modele.ajouter_section(section15_av)
section20_am = SectionIdem('St_20_Am', section2_am, dz=0.0)
-submodel.add_section(section20_am)
+sous_modele.ajouter_section(section20_am)
section20_middle = SectionProfil('St_20_middle')
section20_middle.set_xz(np.array([(0, 3), (1, 0.5), (5, 0), (9, 0.5), (10, 3)]))
-section20_middle.set_fente(0.15, 15)
+section20_middle.ajouter_fente(0.15, 15)
section20_middle.add_limite_geom(LimiteGeom('Et_AxeHyd', 5.0))
section20_middle.set_lits_numerotes((0.0, 0.0, 1.0, 9.0, 10.0, 10.0))
section20_middle.build_orthogonal_trace(axe_geom)
-submodel.add_section(section20_middle)
+sous_modele.ajouter_section(section20_middle)
section20_av = SectionIdem('St_20_Av', section20_middle, dz=-1.0)
-submodel.add_section(section20_av)
+sous_modele.ajouter_section(section20_av)
# Add branches
branche1 = BranchePdC('Br_1-PdC', noeud1, noeud2)
# branche1.set_geom(LineString([(0, 100), (0, 90)])) # this is already the default behaviour
-branche1.add_section(section1_am, 0.0)
-branche1.add_section(section1_av, 11.0) # => branche1.length = 11 m
-submodel.add_branche(branche1)
+branche1.ajouter_section_dans_branche(section1_am, 0.0)
+branche1.ajouter_section_dans_branche(section1_av, 11.0) # => branche1.length = 11 m
+sous_modele.ajouter_branche(branche1)
branche2 = BrancheSeuilTransversal('Br_2-SeuilTransversal', noeud2, noeud4)
-branche2.add_section(section2_am, 0.0)
-branche2.add_section(section2_av, 10.1)
-submodel.add_branche(branche2)
+branche2.ajouter_section_dans_branche(section2_am, 0.0)
+branche2.ajouter_section_dans_branche(section2_av, 10.1)
+sous_modele.ajouter_branche(branche2)
branche4 = BrancheSeuilLateral('Br_4-SeuilLateral', noeud4, noeud5)
-branche4.add_section(section4_am, 0.0)
-branche4.add_section(section4_av, 9.9)
-submodel.add_branche(branche4)
+branche4.ajouter_section_dans_branche(section4_am, 0.0)
+branche4.ajouter_section_dans_branche(section4_av, 9.9)
+sous_modele.ajouter_branche(branche4)
branche5 = BrancheOrifice('Br_5-Orifice', noeud5, noeud6)
-branche5.add_section(section5_am, 0.0)
-branche5.add_section(section5_av, 9.9)
-submodel.add_branche(branche5)
+branche5.ajouter_section_dans_branche(section5_am, 0.0)
+branche5.ajouter_section_dans_branche(section5_av, 9.9)
+sous_modele.ajouter_branche(branche5)
branche6 = BrancheStrickler('Br_6-Strickler', noeud6, noeud12)
-branche6.add_section(section6_am, 0.0)
-branche6.add_section(section6_av, 10.0)
-submodel.add_branche(branche6)
+branche6.ajouter_section_dans_branche(section6_am, 0.0)
+branche6.ajouter_section_dans_branche(section6_av, 10.0)
+sous_modele.ajouter_branche(branche6)
branche12 = BrancheNiveauxAssocies('Br_12-NiveauxAssocies', noeud12, noeud14)
-branche12.add_section(section12_am, 0.0)
-branche12.add_section(section12_av, 10.0)
-submodel.add_branche(branche12)
+branche12.ajouter_section_dans_branche(section12_am, 0.0)
+branche12.ajouter_section_dans_branche(section12_av, 10.0)
+sous_modele.ajouter_branche(branche12)
branche14 = BrancheBarrageGenerique('Br_14-BarrageGenerique', noeud14, noeud15)
-branche14.section_pilotage = section1_am
-branche14.add_section(section14_am, 0.0)
-branche14.add_section(section14_av, 10.0)
-submodel.add_branche(branche14)
+branche14.section_pilote = section1_am
+branche14.ajouter_section_dans_branche(section14_am, 0.0)
+branche14.ajouter_section_dans_branche(section14_av, 10.0)
+sous_modele.ajouter_branche(branche14)
branche15 = BrancheBarrageFilEau('Br_15-BarrageFilEau', noeud15, noeud20)
-branche15.section_pilotage = section1_am
-branche15.add_section(section15_am, 0.0)
-branche15.add_section(section15_av, 10.0)
-submodel.add_branche(branche15)
+branche15.section_pilote = section1_am
+branche15.ajouter_section_dans_branche(section15_am, 0.0)
+branche15.ajouter_section_dans_branche(section15_av, 10.0)
+sous_modele.ajouter_branche(branche15)
branche20 = BrancheSaintVenant('Br_20-SaintVenant', noeud20, noeud_aval)
-branche20.add_section(section20_am, 0.0)
-branche20.add_section(section20_middle, 25.0)
-branche20.add_section(section20_av, 50.0)
-submodel.add_branche(branche20)
+branche20.ajouter_section_dans_branche(section20_am, 0.0)
+branche20.ajouter_section_dans_branche(section20_middle, 25.0)
+branche20.ajouter_section_dans_branche(section20_av, 50.0)
+sous_modele.ajouter_branche(branche20)
if __name__ == "__main__":
# Write all submodel files
- submodel.write_all(os.path.join('out', 'Sm_from_scratch'), 'Config')
+ sous_modele.write_all(os.path.join('out', 'Sm_from_scratch'), 'Config')