:py:mod:`wolfhece.coupling.hydrology_2d` ======================================== .. py:module:: wolfhece.coupling.hydrology_2d .. 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:class:: InjectionType Bases: :py:obj:`enum.Enum` .. autoapi-inheritance-diagram:: wolfhece.coupling.hydrology_2d.InjectionType :parts: 1 :private-bases: Generic enumeration. Derive from this class to define new enumerations. .. py:attribute:: GLOBAL :value: 'Global' .. py:attribute:: PARTIAL :value: 'Partial' .. py:attribute:: ANTHROPOGENIC :value: 'Anthropogenic' .. py:attribute:: CONSTANT :value: 'Constant' .. py:attribute:: VIRTUAL :value: 'Virtual' .. py:attribute:: FORCED_UNSTEADY :value: 'Forced unsteady' .. py:data:: BUILDING_TOLERANCE :value: 0.05 .. py:class:: Searching_Context(river_axis: wolfhece.PyVertexvectors.vector, kdtree: scipy.spatial.KDTree, nodes: wolfhece.hydrology.PyWatershed.Node_Watershed, downstream_reaches: list[int], up_node: wolfhece.hydrology.PyWatershed.Node_Watershed) Part of the hydrological model adapted for seraching tasks .. py:class:: Scaled_Infiltration(idx: int, type: InjectionType, colref: str, factor: float, lagtime: float) .. py:class:: Coupling_Hydrology_2D .. py:property:: dateBegin :type: datetime.datetime .. py:property:: dateEnd :type: datetime.datetime .. py:property:: number_of_injections :type: int .. py:property:: number_of_nodes_per_zone :type: dict[int, int] Return the number of nodes per zone .. py:property:: along :type: list[str, str] .. py:property:: locales :type: list[str] .. py:property:: watershed :type: wolfhece.hydrology.PyWatershed.Watershed .. py:property:: river_system :type: wolfhece.hydrology.PyWatershed.RiverSystem .. py:property:: subs_array :type: wolfhece.wolf_array.WolfArray .. py:method:: plot_number_of_nodes_per_zone() -> tuple[matplotlib.figure.Figure, matplotlib.axes.Axes] Plot the number of nodes per zone .. py:method:: set_array_to_coupling(array: wolfhece.wolf_array.WolfArray | pathlib.Path, dtm: wolfhece.wolf_array.WolfArray | pathlib.Path = None) -> None Set the array to coupling :param array: The array to coupling :param dtm: The DTM of the array .. py:method:: _create_infiltration_array() Create the infiltration array .. py:method:: add_hydrology_model(name: str, filename: str | pathlib.Path) -> None Add a hydrology model to the coupling :param filename: The filename of the hydrology model .. py:method:: get_anthropogenic_names() -> list[str] Print the names of the anthropogenic hydrographs .. py:method:: get_names_areas() -> list[str] Print the names of the areas .. py:method:: create_hydrographs_local_global(unit_discharge: float, total_duration: float, anth_discharge: dict = None) -> None Create the hydrographs from the hydrology model . Global and local hydrographs are created based on a unit discharge and a total duration. You can also add anthropogenic hydrographs from a dictionary. The key is the name of the anthropogenic hydrograph and the value is the discharge. The keys can be obtained with the method get_anthropogenic_names. :param unit_discharge: The discharge per square kilometer [m³/s/km²] :param total_duration: The total duration of the hydrographs [s] .. py:method:: save_hydrographs(directory: str | pathlib.Path = None, total: str = None, partial: str = None) -> None Write the hydrographs from the hydrology model .. py:method:: load_hydrographs(directory: str | pathlib.Path = None, total: str = None, partial: str = None) -> None Load the hydrographs from the hydrology model :param directory: The directory of the hydrology model -- If None, the working directory of the loaded hydrology model is used :param total: The filename of the total hydrographs - If None, the default filename is used :param partial: The filename of the partial hydrographs - If None, the default filename is used .. py:method:: print_hydrographs(total: bool = True, partial: bool = True) -> None Print the hydrographs from the hydrology model .. py:method:: plot_hydrographs(total: bool = True, partial: bool = True) -> tuple[tuple[matplotlib.figure.Figure, matplotlib.axes.Axes], tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]] Plot the hydrographs from the hydrology model .. py:method:: add_virtual_hydrograph(name: str, src_hydrograph_name: str, factor: float, lag: float = 0.0) Add a virtual hydrograph to the hydrology model .. py:method:: add_river(filename: str | pathlib.Path) -> None Add a river to the hydrology model :param filename: The filename of the river .. py:method:: reset() -> None Reset the hydrology model .. py:method:: add_locale_injections(filename: str | pathlib.Path) -> None Add a local injection to the hydrology model :param filename: The filename of the local injection .. py:method:: find_river_axis() Find the river axis from Zones .. py:method:: _add_injection(name: str, vect: wolfhece.PyVertexvectors.vector) Add an injection to the hydrology model :param name: The name of the injection :param vect: The vector of the injection .. py:method:: find_injections() Find the injection points from Zones .. py:method:: find_rivers_upstream() Find the upstreams of the rivers .. py:method:: _find_upstream(curvect: wolfhece.PyVertexvectors.vector) -> wolfhece.PyVertexvectors.wolfvertex Find the upstream of a vector :param curvect: The river's axis .. py:method:: prepare_search(rivers: list[str] = None) Prepare the search for the hydrology model. The order is important because the reaches will be progressively excluded from the search for the next ones. So, you have to start with the **main river** and then the **tributaries**. :param rivers: The list of rivers to prepare .. py:method:: _is_global(col_name: str) Vérifie si la colonne est un hydrogramme global .. py:method:: _is_partial(col_name: str) Vérifie si la colonne est un hydrogramme partiel .. py:method:: _is_anthropic(col_name: str) Vérifie si la colonne est un hydrogramme anthropique (c'est-à-dire une colonne de l'hydrogramme total qui n'est pas un hydrogramme partiel) .. py:method:: _is_virtual(col_name: str) Vérifie si la colonne est un hydrogramme virtuel .. py:method:: _add_infil(type_name: InjectionType, col_name_q: str | float, factor: float, lag: float, index_zone: int = None) Ajoute une infiltration à la liste des infiltrations :param type_name: nom du type d'infiltration :param col_name: nom de la colonne de l'hydrogramme :param factor: facteur multiplicatif :param lag: déphasage .. py:method:: _add_local_injecton(local_vect: wolfhece.PyVertexvectors.vector, type_name: InjectionType, col_name: str, factor: float, lag: float) Ajoute une injection locale à la liste des infiltrations et remplissage de la matrice d'infiltration :param local_vect: vecteur de la zone d'injection :param type_name: nom du type d'injection :param col_name: nom de la colonne de l'hydrogramme :param factor: facteur multiplicatif :param lag: déphasage .. py:method:: _add_along_injection(list_part: list[float, float], type_name: InjectionType, col_name: str, factor: float, lag: float) Ajoute une injection le long de la rivière et remplissage de la matrice d'infiltration :param list_part: liste des coordonnées des points de la rivière :param type_name: nom du type d'injection :param col_name: nom de la colonne de l'hydrogramme :param factor: facteur multiplicatif :param lag: déphasage .. py:method:: write_infil_array(dirout: pathlib.Path) Sauvegarde de la matrice d'infiltration .. py:method:: _get_reaches_in_sub(subbasin: wolfhece.hydrology.PyWatershed.SubWatershed, rivers_names: list[str]) -> list[list[int]] Retourne une liste de listes des biefs dans le sous-bassin :param rivers: liste des noms des rivières :return: liste des biefs dans le sous-bassin .. py:method:: _get_outlet_reaches(subbasin: wolfhece.hydrology.PyWatershed.SubWatershed, idx_reaches: list[int]) -> wolfhece.hydrology.PyWatershed.Node_Watershed Retourne le noeud de sortie du sous-bassin :param reaches: liste des biefs dans le sous-bassin :return: noeud de sortie du sous-bassin .. py:method:: _split_subwatershed(subbasin: wolfhece.hydrology.PyWatershed.SubWatershed, river_names: list[str, list[str]]) .. py:method:: _split_hydrographs(subbasin: wolfhece.hydrology.PyWatershed.SubWatershed | str, river_names: list[str, list[str]]) Séparation de l'hydrogramme partiel en fonction des surfaces drainées par chaque rivère On attend au maximum 2 rivières ou 1 rivière et une liste de rivières. Les rivières seront traitées 2 par 2 de façon récursive. La seconde rivière et l'affluent de la première rivière. .. py:method:: get_locale_injection_names() Print the names of the local injections .. py:method:: get_along_injection_names() -> tuple[list[str], list[str]] Get the names of the along injections :return: The names of the rivers along which the injections are made and the columns of the hydrographs .. py:method:: reset_injections() Reset the injections .. py:method:: spread_infiltrations() Traite les injections .. py:method:: injections_locales(couplings: list[tuple[str, str, InjectionType]] = None) Ajoute les injections locales .. py:method:: link_area2nodes() Searching cells in dem associated to the river nodes in the hydrological model. We use the river axis to select the cells in the dem. Then we search the nearest river nodes in the hydrological model. We create local lists of cells associated to one river node. Due to the fact that the river axis is not exactly the same as the river nodes (not the same spatial resolution, rester vs vector), all river nodes in the hydrological model are not necessarely associated to cells in the dem. .. py:method:: injections_along(along: list[str, str] = None) Injections along rivers .. py:method:: _injection_along(name_subwatershed_river: tuple[str, str]) .. py:method:: create_hydrographs() Création des hydrogrammes Les étapes précédentes ont ajouté à la liste "infiltrations" les éléments suivants: - l'index de la zone d'infiltration (1-based) - l'hydrogramme de référence - le facteur pondérateur - le temps de déphasage Une zone peut contenir plusieurs apports. Il faut donc parcourir l'ensemble des zones et sommer les contributions. Le fichier final est ordonné comme la matrice d'infiltration. Avant de sommer, il faut tout d'abord créer les hydrogrammes associés au BV virtuels (décomposition d'un BV, modélisé comme un tout, en plusieurs rivières distinctes pour la répartition en long) .. py:method:: save_hydrographs(dirout: pathlib.Path, name: str) Write the hydrographs :param dirout: The output directory :param name: The name of the output file (if no suffix .txt, it will be added)