:py:mod:`wolfhece.scenario.config_manager` ========================================== .. py:module:: wolfhece.scenario.config_manager .. autoapi-nested-parse:: Author: HECE - University of Liege, Pierre Archambeau Date: 2024 Copyright (c) 2024 University of Liege. All rights reserved. This script and its content are protected by copyright law. Unauthorized copying or distribution of this file, via any medium, is strictly prohibited. Module Contents --------------- .. py:data:: ACCEPTED_PREFIX :value: ['bath_', 'mann_', 'infil_', 'roof_', 'deck_'] .. py:function:: delete_folder(pth: pathlib.Path) .. py:class:: GPU_2D_file_extensions Bases: :py:obj:`enum.Enum` .. autoapi-inheritance-diagram:: wolfhece.scenario.config_manager.GPU_2D_file_extensions :parts: 1 :private-bases: Generic enumeration. Derive from this class to define new enumerations. .. py:attribute:: TIF :value: '.tif' .. py:attribute:: TIFF :value: '.tiff' .. py:attribute:: PY :value: '.py' .. py:attribute:: NPY :value: '.npy' .. py:attribute:: BIN :value: '.bin' .. py:attribute:: JSON :value: '.json' .. py:attribute:: TXT :value: '.txt' .. py:class:: IC_scenario Bases: :py:obj:`enum.Enum` .. autoapi-inheritance-diagram:: wolfhece.scenario.config_manager.IC_scenario :parts: 1 :private-bases: Generic enumeration. Derive from this class to define new enumerations. .. py:attribute:: WATERDEPTH :value: 'h.npy' .. py:attribute:: DISCHARGE_X :value: 'qx.npy' .. py:attribute:: DISCHARGE_Y :value: 'qy.npy' .. py:attribute:: BATHYMETRY :value: 'bathymetry.npy' .. py:data:: ALL_EXTENSIONS .. py:data:: WOLF_UPDATE :value: 'Wolf update' .. py:data:: WOLF_BC :value: 'Wolf boundary conditions' .. py:data:: OTHER_SCRIPTS :value: 'Other scripts' .. py:data:: IS_SIMUL :value: 'is_simul' .. py:data:: IS_SCENARIO :value: 'is_scenario' .. py:data:: IS_RESULTS :value: 'is_results' .. py:data:: HAS_RESULTS :value: 'has_results' .. py:data:: MISSING :value: 'missing' .. py:data:: SUBDIRS :value: 'subdirs' .. py:data:: DISCHARGES :value: 'discharges' .. py:data:: INITIAL_CONDITIONS :value: 'initial_conditions' .. py:data:: _gpu_file .. py:class:: GPU_2D_file Bases: :py:obj:`enum.Enum` .. autoapi-inheritance-diagram:: wolfhece.scenario.config_manager.GPU_2D_file :parts: 1 :private-bases: Generic enumeration. Derive from this class to define new enumerations. .. py:attribute:: PARAMETERS .. py:attribute:: BATHYMETRY .. py:attribute:: WATER_DEPTH .. py:attribute:: DISCHARGE_X .. py:attribute:: DISCHARGE_Y .. py:attribute:: MANNING .. py:attribute:: COMPUTATION_MASK .. py:attribute:: INFILTRATION .. py:data:: RESULT_DIR :value: 'simul_gpu_results' .. py:class:: Hydrograph_scenario(fname: pathlib.Path, sep: str = '\t', decimal='.') Hydrograph for a scenario .. py:property:: name :type: str .. py:property:: data :type: pandas.DataFrame .. py:method:: plot(figax=None) .. py:class:: InitialConditions_scenario(dir: pathlib.Path) Initial conditions for a scenario .. py:property:: z_elevation :type: numpy.ndarray Return the elevation of the water surface .. py:method:: set_h_from_z(z: numpy.ndarray) Set the water depth from the elevation of the water surface .. py:method:: save(dir: pathlib.Path) Save the initial conditions .. py:class:: Config_Manager_2D_GPU(workingdir: str = '', mapviewer: wolfhece.PyDraw.WolfMapViewer = None, python_venv: pathlib.Path = None, create_ui_if_wx: bool = False) Gestionnaire de configurations 2D - code GPU .. py:property:: epsilon .. py:property:: filter_independent .. py:property:: txtctrl .. py:method:: find_wolfgpu() Find the wolfgpu Path from wolfgpu package .. py:method:: _test_ui() Test if the UI is available .. py:method:: load_data() Chargement/Rechargement des données .. py:method:: _scan_dir(wd: pathlib.Path, curdict: dict) Scan récursif d'un répertoire de base et création de sous-dictionnaires .. py:method:: scan_wdir() Récupération de tous les répertoires et sous-répertoires et placement dans le dictionnaire self.configs .. py:method:: get_header() -> wolfhece.wolf_array.header_wolf Get header from .tif file .. py:method:: _get_header(filearray: pathlib.Path) -> wolfhece.wolf_array.header_wolf Get header from .tif file .. py:method:: get_all_numpy() -> list[pathlib.Path] Get all numpy files .. py:method:: get_all_tif() -> list[pathlib.Path] Get all tif files .. py:method:: get_all_sims() -> list[pathlib.Path] Get all simulation files .. py:method:: _flatten_configs() -> list[dict] flatten configs .. py:method:: check_prefix(list_tif: list[pathlib.Path]) -> str Check if all files have the right prefix .. py:method:: check_consistency() -> str Check consistency of all files All numpy files must have the same shape as the tif file in the root directory All hydrographs must have the same number of columns .. py:method:: _find_files_subdirs(wd: pathlib.Path, curdict: dict, erase_cache: bool = True) Recherche des fichiers de simulation/scenario dans un répertoire .. py:method:: _recursive_find_files(wd: pathlib.Path, curdict: dict, erase_cache: bool = True) Recherche récursive des fichiers de simulation/scenario dans les répertoires dont la structure a été traduite en dictionnaire .. py:method:: _prefill_dict(curdict: dict) Création des listes pour toutes les extensions .. py:method:: _test_is_simul(curdict: dict) Teste si le répertoire contient des fichiers de simulation .. py:method:: _test_is_scenario(curdict: dict) Teste si le répertoire contient des fichiers de scénario .. py:method:: _test_is_results(curdict: dict) Teste si le répertoire contient des fichiers de résultats .. py:method:: find_files() Recehrche des fichiers de simulation/scenario dans les répertoires dont la structure a été traduite en dictionnaire .. py:method:: get_tree(from_path: pathlib.Path) -> list[pathlib.Path] Get tree from a path Fnd all directories from the current path to the working directory .. py:method:: get_dicts(from_tree: list[pathlib.Path]) -> list[dict] Get dicts from a tree .. py:method:: _select_tif_partname(curdict: dict, tifstr: Literal[bath_, mann_, infil_, roof_, deck_]) Select tif files with a 'str' as name's prefix .. py:method:: check_nodata(from_path: pathlib.Path) Check nodata in a path .. py:method:: create_vrt(from_path: pathlib.Path) Create a vrt file from a path .. py:method:: create_vec(from_path: pathlib.Path, which: Literal[bath_, mann_, infil_, roof_, deck_] = 'bath_') -> wolfhece.PyVertexvectors.Zones Create a vec file from a path .. py:method:: translate_vrt2tif(from_path: pathlib.Path) Translate vrt to tif .. py:method:: apply_scripts_bath_mann_inf_roof_deck(from_path: pathlib.Path) Apply all scripts .. py:method:: _import_scripts(from_path: pathlib.Path, which) -> list[types.ModuleType] List all modules in structure and import them. As multiple files with a same name can be found in the structure, a copy of the file is made in the same folder with a unique name and then imported. So, if a file is required in the script, the relative import can be used. If we cache the file in an other folder, the relative import will not work. After the import, the copied files are deleted. .. py:method:: _import_scripts_topo_manning_inf_roof_deck(from_path: pathlib.Path) -> list[types.ModuleType] import all topo and manning scripts from a path .. py:method:: _apply_scripts_update_topo_maning_inf_roof_deck(modules: list[types.ModuleType] | pathlib.Path | str, array_bat: wolfhece.wolf_array.WolfArray, array_mann: wolfhece.wolf_array.WolfArray, array_inf: wolfhece.wolf_array.WolfArray, array_roof: wolfhece.wolf_array.WolfArray, array_deck: wolfhece.wolf_array.WolfArray) Apply all scripts from a list of modules .. py:method:: _import_scripts_bc(from_path: pathlib.Path) -> list[types.ModuleType] Import all BC's scripts from a path .. py:method:: _apply_scripts_bc(modules: list[types.ModuleType] | pathlib.Path | str, sim: wolfgpu.simple_simulation.SimpleSimulation) Apply all scripts from a list of modules .. py:method:: load_hydrograph(path: pathlib.Path, toplot=True) -> tuple[Hydrograph_scenario, matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] Load hydrograph from a path .. py:method:: load_ic(path: pathlib.Path) -> InitialConditions_scenario Load initial conditions from a path .. py:method:: get_hydrographs() -> list[wolfhece.PyHydrographs.Hydrograph] Get all hydrographs .. py:method:: get_initial_conditions() -> list[InitialConditions_scenario] Get all initial conditions .. py:method:: get_names_hydrographs() -> list[str] .. py:method:: get_name_initial_conditions() -> list[str] .. py:method:: create_void_infil() create void infiltration_zones file .. py:method:: create_void_roof() create void roof file .. py:method:: create_void_deck() create void deck file .. py:method:: combine_bath_roof_deck(bathymetry: wolfhece.wolf_array.WolfArray, bridge_roof: wolfhece.wolf_array.WolfArray, bridge_deck: wolfhece.wolf_array.WolfArray, threshold: float = 0.05) -> str Verify bathymetry, roof and deck .. py:method:: create_simulation(dir: pathlib.Path, idx_hydros: list[int] = [-1], delete_existing: bool = False, preserve_ic: bool = False, callback=None) -> list[pathlib.Path] Create a simulation from different hydrographs .. py:method:: create_batch(path: pathlib.Path, allsims: list[pathlib.Path]) -> str Create a batch file .. py:method:: run_batch(batch: pathlib.Path) run a batch file in a subprocess .. py:method:: get_mapviewer() Get the mapviewer object .. py:method:: transfer_ic(dir1: pathlib.Path, dir2: pathlib.Path) Transfer IC from one sim to another .. py:method:: extract_tif(from_path: pathlib.Path, to_path: pathlib.Path) Extract tif files from IC .. py:class:: UI_Manager_2D_GPU(data: dict, parent: Config_Manager_2D_GPU) User Interface for scenario 2D GPU .. py:method:: refill_data(data: dict) Fill tree with data .. py:method:: create_UI() Création de l'interface graphique Partie latérale gauche - arbre des simulations Partie latérale droite - boutons d'actions Partie inférieure - affichage des informations .. py:method:: onchange_epsilon(e: wx.KeyEvent) Change epsilon value .. py:method:: onchange_filter(e: wx.MouseEvent) Change filter independent zones value .. py:method:: reload() Reload the structure .. py:method:: onupdate_structure(e: wx.MouseEvent) Mise à jour de la structure .. py:method:: oncreate_void_infil(e: wx.MouseEvent) Création d'un fichier d'infiltration vide .. py:method:: oncreate_void_roof(e: wx.MouseEvent) Création d'un fichier de toit de pont vide .. py:method:: oncreate_void_deck(e: wx.MouseEvent) Création d'un fichier de tablier de pont vide .. py:method:: oncreate_void_scripts(e: wx.MouseEvent) Création d'un script vide .. py:method:: oncreatevrt(e: wx.MouseEvent) Création d'un fichier vrt .. py:method:: oncreatevec(e: wx.MouseEvent) Création d'un fichier vec .. py:method:: ontranslatevrt2tif(e: wx.MouseEvent) Traduction d'un fichier vrt en tif .. py:method:: onapply_scripts(e: wx.MouseEvent) Application des scripts sur les fichiers tif .. py:method:: oncheck_prefix(e: wx.MouseEvent) Vérification des préfixes des fichiers tif .. py:method:: oncheck_consistency(e: wx.MouseEvent) Vérification de la cohérence des fichiers .. py:method:: choice_hydrograph() -> list[int] .. py:method:: onextract_tif(e: wx.MouseEvent) Extraction des fichiers tif .. py:method:: ontransfer_ic(e: wx.MouseEvent) Transfert des conditions initiales .. py:method:: oncreate_simulation(e: wx.MouseEvent) Creation d'une simulation .. py:method:: onrun_batch(e: wx.MouseEvent) run batch file .. py:method:: onlist_simulation(e: wx.MouseEvent) List all simulations and print infos in text control .. py:method:: get_sims_only(force=False) Get paths to all or selected simulations .. py:method:: OnCheckItem(e) All levels under the item are checked/unchecked .. py:method:: _callbackwp() Callback for wolfparam .. py:method:: _callbackwp_destroy() Callback for wolfparam .. py:method:: OnActivateTreeElem(e) If you double click on a tree element .. py:method:: filter_independent_zones(n_largest: int = 1, icpath: pathlib.Path = None) Filtre des zones indépendantes et conservation des n plus grandes .. py:method:: clear_text() Reset txt control .. py:method:: _open_script(mydata: pathlib.Path, wolf: bool = False) Open the script in the editor .. py:method:: _append_configs2tree(curdict: dict, root: wx.dataview.TreeListItem) Ajout des éléments du dictionnaire dans l'arbre sur base de la racine fournie