wolfhece.hydrology.PyWatershed ============================== .. py:module:: wolfhece.hydrology.PyWatershed .. autoapi-nested-parse:: Author: HECE - University of Liege, Pierre Archambeau, Christophe Dessers 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:: LISTDEM :value: ['dem_before_corr', 'dem_after_corr', 'dem_10m', 'dem_20m', 'crosssection'] .. py:class:: Node_Watershed Noeud du modèle hydrologique maillé .. py:attribute:: i :type: int .. py:attribute:: j :type: int .. py:attribute:: x :type: float .. py:attribute:: y :type: float .. py:attribute:: index :type: int .. py:attribute:: dem :type: dict[str, float] .. py:attribute:: demdelta :type: float .. py:attribute:: crosssections :type: list .. py:attribute:: time :type: float .. py:attribute:: slope :type: float .. py:attribute:: sloped8 :type: float .. py:attribute:: slopecorr :type: dict .. py:attribute:: demcorr :type: dict .. py:attribute:: river :type: bool .. py:attribute:: reach :type: int .. py:attribute:: sub :type: int .. py:attribute:: forced :type: bool .. py:attribute:: uparea :type: float .. py:attribute:: strahler :type: int .. py:attribute:: reachlevel :type: int .. py:attribute:: cums :type: float .. py:attribute:: incrs :type: float .. py:attribute:: down :type: Node_Watershed .. py:attribute:: up :type: list[Node_Watershed] .. py:attribute:: upriver :type: list[Node_Watershed] .. py:attribute:: flatindex :type: int :value: -1 .. py:method:: incr_curvi() Incrémentation de la longueur curviligne .. py:method:: mean_slope_up(threshold: float) -> float Pente moyenne sur depuis les mailles amont .. py:method:: slope_down(threshold: float) -> float Recherche d'une pente supérieure à un seuil Parcours vers l'aval .. py:method:: slope_upriver(threshold: float) -> float Recherche d'une pente supérieure à un seuil Parcours vers l'amont uniquement selon les rivières .. py:method:: set_strahler(strahler: int) .. py:method:: distance(x: float, y: float) -> float Distance euclidienne .. py:method:: get_up_nodes(excluded_node: list[Node_Watershed] = []) Get all upstream nodes .. py:method:: get_up_nodes_same_sub(excluded_node: list[Node_Watershed] = []) Get all upstream nodes in the same sub-basin .. py:method:: get_up_runoff_nodes() Get all upstream runoff nodes .. py:method:: get_up_runoff_nodes_same_sub() Get all upstream runoff nodes in the same sub-basin .. py:method:: get_up_rivernodes() Get all upstream river nodes .. py:method:: get_up_rivernodes_same_sub() Get all upstream river nodes in the same sub-basin .. py:method:: get_up_reaches_same_sub() -> list[int] Get all upstream reaches in the same sub-basin .. py:method:: get_down_reaches_same_sub() -> list[int] Get all downstream reaches in the same sub-basin .. py:method:: get_down_nodes() Get all downstream nodes .. py:method:: get_down_nodes_same_sub() Get all downstream nodes in the same sub-basin .. py:class:: RiverSystem(rivers: list[Node_Watershed], parent: Watershed, thslopemin: float, thslopemax: float, savedir: str = '', computecorr: bool = False, *args, **kwargs) Classe du réseau de rivières d'un modèle hydrologique WOLF .. py:attribute:: nbreaches :type: int .. py:attribute:: reaches :type: dict .. py:attribute:: kdtree :type: scipy.spatial.KDTree .. py:attribute:: upmin :type: dict .. py:attribute:: upmax :type: dict .. py:attribute:: parent :type: Watershed .. py:attribute:: upstreams :type: dict .. py:attribute:: maxlevels :type: int .. py:attribute:: maxstrahler :type: int .. py:attribute:: tslopemin :type: float :value: None .. py:attribute:: tslopemax :type: float :value: None .. py:attribute:: plotter :type: wolfhece.GraphNotebook.PlotNotebook :value: None .. py:attribute:: savedir :type: str .. py:attribute:: all_nodes .. py:method:: init_kdtree(nodes: list[Node_Watershed]) Create a KDTree structure from coordinates .. py:method:: get_nearest_nodes(xy: wolfhece.hydrology.read.np.ndarray | wolfhece.wolf_array.vector, nb: int = 1) -> tuple[wolfhece.hydrology.read.np.ndarray | float, list[Node_Watershed] | Node_Watershed] Return the distance and the nearest Node_Watershed :param xy = np.ndarray - shape (n,2) :param nb = number of neighbors return .. py:method:: get_nodes_in_reaches(reaches: list[int]) -> list[Node_Watershed] Get nodes in a reaches .. py:method:: get_downstream_node_in_reach(reach: int) -> Node_Watershed Get downstream node in a reach .. py:method:: get_upstream_node_in_reach(reach: int) -> Node_Watershed Get upstream node in a reach .. py:method:: get_downstream_reaches(node: Node_Watershed) -> list[int] Get index of downstream reaches .. py:method:: get_kdtree_downstream(node: Node_Watershed) -> tuple[list[Node_Watershed], scipy.spatial.KDTree] Get KDTree of downstream reaches .. py:method:: get_kdtree_from_reaches(reaches: list[int]) -> tuple[list[Node_Watershed], scipy.spatial.KDTree] Get KDTree from a list of reaches .. py:method:: get_downstream_reaches_excluded(node: Node_Watershed, excluded: list[int]) -> list[int] Get index of downstream reaches, excepted the excluded ones .. py:method:: go_downstream_until_reach_found(node: Node_Watershed, reach: int | list[int]) -> Node_Watershed Go downstream until a reach is found .. py:method:: get_cums(whichreach: int = None, whichup: int = None) Récupération de la position curvi .. py:method:: get_dem(whichdem: str, whichreach: int = None, whichup: int = None) Récupération de l'altitude pour une matrice spécifique .. py:method:: get_dem_corr(whichdem: str, whichreach: int = None, whichup: int = None) Récupération de l'altitude corrigée pour une matrice spécifique .. py:method:: get_slope(whichslope: str = None, whichreach: int = None, whichup: int = None) Récupération de la pente .. py:method:: get_upstreams_coords() Récupération des coordonnées des amonts .. py:method:: get_nearest_upstream(xy: wolfhece.hydrology.read.np.ndarray, nb: int) -> tuple[wolfhece.hydrology.read.np.ndarray, list[Node_Watershed]] Recherche des amonts les plus proches .. py:method:: create_index() Incrément d'index depuis l'amont jusque l'exutoire final Parcours des mailles rivières depuis tous les amonts et Incrémentation d'une unité Résultat : - tous les biefs en amont sont à 1 - Les autres biefs contiennent le nombre de biefs en amont Indice de Strahler .. py:method:: set_strahler_in_nodes(whichreach: int, strahler: int) Mise à jour de la propriété dans chaque noeud du bief .. py:method:: plot_dem(which: int = -1) Graphiques .. py:method:: plot_dem_and_corr(which: int = -1, whichdem: str = 'dem_after_corr') Graphiques .. py:method:: plot_slope(which: int = -1) Graphiques .. py:method:: write_slopes() Ecriture sur disque .. py:method:: slope_correctionmin() Correction pente minimale .. py:method:: slope_correctionmax() Correction pente maximale .. py:method:: selectmin() Sélection des valeurs minimales afin de conserver une topo décroissante vers l'aval --> une pente positive .. py:method:: selectmax() Sélection des valeurs maximales afin de conserver une topo décroissante vers l'aval --> une pente positive .. py:method:: compute_slopescorr(whichdict: dict) Calcul des pents corrigées .. py:method:: compute_slope_down(x, y) Calcul de pente sur base de x et y .. py:method:: plot_all_in_notebook() Graphiques .. py:class:: RunoffSystem(runoff: list[Node_Watershed], parent: Watershed, thslopemin: float = None, thslopemax: float = None, computecorr: bool = False, *args, **kwargs) Classe de l'ensemble des mailles de ruissellement d'un modèle hydrologique WOLF .. py:attribute:: nodes :type: list[Node_Watershed] .. py:attribute:: parent :type: Watershed .. py:attribute:: upstreams :type: dict .. py:attribute:: tslopemin :type: float .. py:attribute:: tslopemax :type: float .. py:attribute:: upmin :type: dict .. py:attribute:: upmax :type: dict .. py:method:: get_oneup(idx: int) -> Node_Watershed Récupération d'un amont sur base de l'index .. py:method:: get_cums(whichup: int = None) .. py:method:: get_dem(whichdem: str, whichup: int = None) .. py:method:: get_dem_corr(whichdem: str, whichup: int = None) .. py:method:: get_slope(whichslope: str = None, whichup: int = None) .. py:method:: plot_dem(which: int = -1) .. py:method:: plot_dem_and_corr(which: int = -1, whichdem: str = 'dem_after_corr') .. py:method:: write_slopes() .. py:method:: slope_correctionmin() .. py:method:: slope_correctionmax() .. py:method:: selectmin() .. py:method:: selectmax() .. py:method:: compute_slopescorr(whichdict: dict) .. py:method:: compute_slope_down(x, y) Calcul de la pente sur base de listes X et Y .. py:class:: SubWatershed(parent: Watershed, name: str, idx: int, mask: wolfhece.wolf_array.WolfArray, nodes: list[Node_Watershed], runoff: list[Node_Watershed], rivers: list[Node_Watershed]) Classe sous-bassin versant .. py:attribute:: parent :type: Watershed .. py:attribute:: index :type: int .. py:attribute:: name :type: str .. py:attribute:: mask :type: wolfhece.wolf_array.WolfArray .. py:attribute:: nodes :type: list[Node_Watershed] .. py:attribute:: rivers :type: list[Node_Watershed] .. py:attribute:: runoff :type: list[Node_Watershed] .. py:attribute:: idx_reaches .. py:attribute:: _index_sorted .. py:attribute:: _is_virtual :type: bool :value: False .. py:attribute:: _src_sub :type: SubWatershed :value: None .. py:property:: is_virtual :type: bool Vérification si le sous-bassin est virtuel .. py:property:: surface :type: float Surface du bassin versant en m² .. py:property:: area :type: float Surface du bassin versant en km² .. py:property:: area_outlet :type: float Surface du bassin à l'exutoire .. py:property:: outlet :type: Node_Watershed Outlet of the subbasin .. py:method:: is_reach_in_sub(idx_reach: int) -> bool Vérification si un bief est dans le sous-bassin .. py:method:: is_in_rivers(node: Node_Watershed) -> bool Vérification si un noeud est dans les rivières .. py:method:: get_list_nodes_river(idx_reach: int) -> list[Node_Watershed] Récupération des noeuds d'une rivière .. py:method:: get_nearest_river(x, y) -> Node_Watershed Récupération du noeud de rivière le plus proche .. py:method:: get_max_area_in_reach(idx_reach: int) -> float Récupération de la surface maximale dans un bief .. py:method:: get_min_area_in_reach(idx_reach: int) -> float Récupération de la surface minimale dans un bief .. py:method:: get_min_area_along_reaches(reaches: list[int], starting_node: Node_Watershed = None) -> float Aire drainée à la limite amont du ss-bassin .. py:method:: get_up_rivernode_outside_sub(starting_node: Node_Watershed, reaches: list[int]) -> Node_Watershed Récupération du noeud de rivière en amont du sous-bassin .. py:method:: get_area_outside_sub_if_exists(starting_node: Node_Watershed, reaches: list[int]) -> float Aire drainée en amont du sous-bassin .. py:method:: get_river_nodes_from_upareas(min_area: float, max_area: float) -> list[Node_Watershed] Récupération des noeuds de rivière entre deux surfacesde BV. Les surfaces sont exprimées en km². Les bornes sont incluses. :param min_area: surface minimale :param max_area: surface maximale .. py:method:: is_in_subwatershed(vec: wolfhece.wolf_array.vector) -> bool Vérification si un vecteur est dans le sous-bassin .. py:method:: filter_zones(zones_to_filter: wolfhece.wolf_array.Zones, force_virtual_if_any: bool = False) -> list[wolfhece.wolf_array.vector] Filtrage des zones pour ne garder que celle se trouvant dans le sous-bassin .. py:method:: get_virtual_subwatershed(outlet: Node_Watershed, excluded_nodes: list[Node_Watershed] = []) -> SubWatershed Création d'un sous-bassin virtuel sur base d'une maille rivière aval .. py:method:: get_downstream_node_in_reach(reach: int) -> Node_Watershed Récupération du noeud aval dans un bief .. py:class:: Watershed(dir: str, thzmin: float = None, thslopemin: float = None, thzmax: float = None, thslopemax: float = None, crosssections: wolfhece.PyCrosssections.crosssections = None, computestats: bool = False, computecorr: bool = False, plotstats: bool = False, plotriversystem=False, dir_mnt_subpixels: str = None, *args, **kwargs) Classe bassin versant .. py:attribute:: header :type: wolfhece.wolf_array.header_wolf .. py:attribute:: dir :type: str .. py:attribute:: outlet :type: Node_Watershed .. py:attribute:: subs_array :type: wolfhece.wolf_array.WolfArray .. py:attribute:: nodes :type: list[Node_Watershed] .. py:attribute:: nodesindex :type: wolfhece.hydrology.read.np.ndarray .. py:attribute:: rivers :type: list[Node_Watershed] .. py:attribute:: runoff :type: list[Node_Watershed] .. py:attribute:: couplednodes :type: list .. py:attribute:: subcatchments :type: list[SubWatershed] .. py:attribute:: virtualcatchments :type: list[SubWatershed] .. py:attribute:: statisticss :type: dict .. py:attribute:: couplednodesxy :type: list[float, float, float, float] .. py:attribute:: couplednodesij :type: list[tuple[int, int], tuple[int, int]] .. py:attribute:: riversystem :type: RiverSystem .. py:attribute:: runoffsystem :type: RunoffSystem .. py:attribute:: to_update_times :type: bool .. py:attribute:: dir_mnt_subpixels :value: None .. py:attribute:: up :value: None .. py:property:: nb_subs .. py:property:: resolution .. py:method:: set_names_subbasins(new_names: list[tuple[int, str]]) Renommage des sous-bassins .. py:method:: add_virtual_subwatershed(subwater: SubWatershed) Ajout d'un sous-bassin virtuel .. py:method:: create_virtual_subwatershed(outlet: Node_Watershed, excluded_nodes: list[Node_Watershed] = []) Création d'un sous-bassin virtuel .. py:method:: get_xy_downstream_node(starting_node: Node_Watershed, limit_to_sub: bool = False) Récupération des coordonnées du noeud aval .. py:method:: get_xy_upstream_node(starting_node: Node_Watershed, limit_to_sub: bool = False, limit_to_river: bool = False, limit_to_runoff: bool = False) -> list[list[float]] Récupération des coordonnées des noeuds amont .. py:method:: get_array_from_upstream_node(starting_node: Node_Watershed, limit_to_sub: bool = False) Récupération de l'array à partir d'un noeud amont .. py:method:: get_vector_from_upstream_node(starting_node: Node_Watershed, limit_to_sub: bool = False) Return a vector contouring the upstream area .. py:method:: get_subwatershed(idx_sorted_or_name: int | str) -> SubWatershed Récupération d'un sous-bassin sur base de l'index trié .. py:method:: get_node_from_ij(i: int, j: int) Récupération d'un objet Node_Watershed sur base des indices (i,j) .. py:method:: get_node_from_xy(x: float, y: float) Récupération d'un objet Node_Watershed sur base des coordonnées (x,y) .. py:method:: write_slopes() Ecriture sur disque .. py:method:: write_dem() Ecriture sur disque .. py:property:: crosssections .. py:method:: attrib_cs_to_nodes() Attribution des sections en travers aux noeuds .. py:method:: init_nodes() Initialisation des noeuds .. py:method:: find_rivers(whichsub: int = 0, whichreach: int = 0) -> tuple[list[Node_Watershed], Node_Watershed] Recherche des mailles rivières :param whichsub : numéro du sous-bassin à traiter :param whicreach : numéro du tronçon à identifier .. py:method:: find_sub(whichsub: int = 0) -> list[Node_Watershed] Recherche des mailles du sous-bassin versant :param whichsub : numéro du sous-bassin à traiter .. py:method:: init_subs() Initialize Sub-Catchments .. py:method:: find_runoffnodes(whichsub: int = 0) -> list[Node_Watershed] Recherche des mailles du bassin versant seul (sans les rivières) :param whichsub : numéro du sous-bassin à traiter .. py:method:: index_flatzone(listofsortednodes: list, threshold: float) Indexation des zones de plat .. py:method:: find_flatnodes(listofsortednodes: list) Recherche des mailles dans des zones de faibles pentes :param listofsortednodes : liste triée de mailles .. py:method:: find_flatzones(listofsortednodes: list, maxindex: int) Recherche des mailles dans des zones de faibles pentes :param listofsortednodes : liste triée de mailles .. py:method:: find_dem_subpixels() Recherche des altitudes dans un mnt plus dense .. py:method:: compute_stats(plot: bool = False) Calcul des statistiques de pente .. py:method:: plot_stats() .. py:method:: analyze_flatzones() Analyse des zones de plat .. py:method:: update_times(wolf_time=None) .. py:method:: get_subwatershed_from_ij(i: int, j: int) -> SubWatershed Récupération d'un sous-bassin sur base des indices (i,j) :return: SubWatershed : sous-bassin or None .. py:method:: get_subwatershed_from_xy(x: float, y: float) -> SubWatershed Récupération d'un sous-bassin sur base des coordonnées (x,y) :return: SubWatershed : sous-bassin or None .. py:method:: get_subwatershed_from_vector(vec: wolfhece.wolf_array.vector) -> tuple[SubWatershed, bool, list[SubWatershed]] Récupération d'un sous-bassin sur base d'un vecteur. Recherche sur base du centroid du vecteur :param vec: vecteur :return: tuple(SubWatershed, bool, list[SubWatershed]) : sous-bassin, entièrement dans le sous-bassin, autres sous-bassins