wolfhece.Results2DGPU
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
- class wolfhece.Results2DGPU.Cache_Results2DGPU(fname: str, start_idx: int, end_idx: int = -1, only_h=False, every: int = 1, mode: Literal['TILED', 'UNTILED'] = 'TILED', memory_max_size: int = 12 * 1024 * 1024 * 1024)[source]
Gestion en mémoire de plusieurs résultats GPU Stockage CSR afin d’économiser la mémoire (Scipy CSR) ou Numpy array dense
- _results: dict[str, tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]] | dict[str, numpy.ndarray][source]
- property memory_size: int[source]
Estimation de la taille mémoire des résultats en cache
- Returns:
taille mémoire en Mega-octets
- property list_cached: list[int][source]
Retourne la liste des indices des résultats en cache
- Returns:
liste des indices (1-based)
- check_if_cached(idx: int) bool[source]
Vérifie si le résultat idx est dans le cache
- Parameters:
idx – index du résultat (1-based)
- Returns:
True si le résultat est dans le cache, False sinon
- get_h(idx: int, dense: bool = True) numpy.ndarray | scipy.sparse.csr_array[source]
- Retourne la matrice de hauteur d’eau de la position idx (0-based)
en CSR (Scipy CSR)
en dense (Numpy array)
- Parameters:
idx – index du résultat (1-based)
dense – si True, retourne un Numpy array dense, sinon retourne un Scipy CSR array
- get_qx(idx: int, dense: bool = True) numpy.ndarray | scipy.sparse.csr_array[source]
- Retourne la matrice de débit X d’eau de la position idx (0-based)
en CSR (Scipy CSR)
en dense (Numpy array)
- Parameters:
idx – index du résultat (1-based)
dense – si True, retourne un Numpy array dense, sinon retourne un Scipy CSR array
- get_qy(idx: int, dense: bool = True) numpy.ndarray | scipy.sparse.csr_array[source]
- Retourne la matrice de débit Y d’eau de la position idx (0-based)
en CSR (Scipy CSR)
en dense (Numpy array)
- Parameters:
idx – index du résultat (1-based)
dense – si True, retourne un Numpy array dense, sinon retourne un Scipy CSR array
- class wolfhece.Results2DGPU.wolfres2DGPU(fname: str, eps=0.0, idx: str = '', plotted: bool = True, mapviewer=None, store=None, load_from_cache: bool = True)[source]
Bases:
wolfhece.wolfresults_2D.Wolfresults_2D
Gestion des résultats du code GPU 2D Surcharge de “Wolfresults_2D”
- setup_cache(start_idx: int = 0, end_idx: int = -1, only_h: bool = False)[source]
Setup cache from start_idx result to end_idx result
if only_h is True, only waterdepth is loaded into memory
- Parameters:
start_idx – start index (0-based)
end_idx – end index (0-based)
only_h – only waterdepth is loaded into memory
- get_nbresults(force_update_timessteps=True)[source]
Récupération du nombre de résultats
Lecture du fichier de tracking afin de permettre une mise à jour en cours de calcul
- danger_map_gpu_tiled(start: int = 0, end: int = -1, every: int = 1, callback=None, hmin: float = None) tuple[wolfhece.wolf_array.WolfArray, wolfhece.wolf_array.WolfArray, wolfhece.wolf_array.WolfArray, wolfhece.wolf_array.WolfArray, wolfhece.wolf_array.WolfArray, wolfhece.wolf_array.WolfArray, wolfhece.wolf_array.WolfArray, wolfhece.wolf_array.WolfArray, wolfhece.wolf_array.WolfArray][source]
Create Danger Maps without untiling GPU arrays.
For better performance, use tiled results directly from the GPU simulation. The array is most compact in memory and the operations are faster.
Returned arrays are untiled WolfArray for easier manipulation.
Take care that Tile Packer untile arrays in transposed mode. So we need to transpose the arrays to store them in WolfArray objects.
- Returned arrays are:
Maximum water depth H
Maximum velocity U_norm
Maximum momentum Q_norm
Maximum water level Z
Maximum total head Head
Time of arrival Time_of_arrival
Time of maximum Time_of_maximum
Duration of inundation Duration_of_inundation
Time of ending Time_of_ending
- Parameters:
start – start time step - 0-based
end – end time step - 0-based
every – step interval
callback – optional callback to update progress
hmin – minimum water depth to consider for time of arrival. If None, uses epsilon value.
:return : tuple of WolfArray or WolfArrayMB - H, U_norm, Q_norm, Z, Head, Time_of_arrival, Time_of_maximum, Duration_of_inundation, Time_of_ending
- _read_oneresult_tiled(which: int = -1)[source]
Read one result in tiled mode
- Parameters:
which – result number to read; 0-based; -1 == last one
- read_oneresult(which: int = -1)[source]
Lecture d’un pas de sauvegarde
which: result number to read; 0-based; -1 == last one
- _read_oneresult_only_h(which: int = -1)[source]
Lecture d’un pas de sauvegarde
which: result number to read; 0-based; -1 == last one
- read_oneresult_subarray(which: int = -1, bounds: list[list[float, float], list[float, float]] | wolfhece.wolfresults_2D.vector | tuple[tuple[float, float], tuple[float, float]] = None, nullify_all_outside: bool = True, border: float = None) None[source]
Read one result but only in a subarray footprint defined by bounds
which: result number to read; 0-based; -1 == last one
- read_oneresult_subarrays(which: int = -1, vectors: list[wolfres2DGPU.read_oneresult_subarrays.vector] = None, nullify_all_outside: bool = True, border: float = None) None[source]
Read one result but only in subarray footprints defined by vectors
which: result number to read; 0-based; -1 == last one
- get_packed_indices_from_xy(x: float, y: float)[source]
Get the packed tile indices from real world coordinates x,y.
- Parameters:
x – real world X coordinate
y – real world Y coordinate
- get_packed_indices_from_ij(i: int, j: int)[source]
Get the packed tile indices from array indices i,j.
- Parameters:
i – array index along X (0-based)
j – array index along Y (0-based)
- get_packed_indices_from_ijs(ijs: tuple[numpy.ndarray])[source]
Get the packed tile indices from array indices i,j.
- Parameters:
ijs – tuple of two np.ndarray (i_array, j_array), like np.where(…) output
- _update_result_view()[source]
Procédure interne de mise à jour du pas
Etapes partagées par read_next et read_previous
- get_times_steps(nb: int = None)[source]
Récupération des temps réels et les pas de calcul de chaque résultat sur disque
:param nb : nombre de résultats à lire
- set_hqxqy_as_initial_conditions(idx: int = None, as_multiblocks: bool = False)[source]
Set the result as IC
:param idx : 0-based index
- get_hydrographs(vect: wolfhece.wolfresults_2D.vector | list[wolfhece.wolfresults_2D.vector] | wolfhece.wolfresults_2D.zone, progress_callback=None, i_start: int = 0, i_end: int = -1, i_step: int = 1, to_rasterize: bool = True) tuple[list[float], list[float] | dict[str, list[float]]][source]
Get hydrograph across a vector or list of vectors or a zone.
If you provide rastrized vectors, set to_rasterize=False for better performance.
The returned hydrographs are lists of discharge values at each time step. The first returned value is the array of time values. The second returned value is either a list of discharge values (if vect is a single vector) or a dictionary of lists of discharge values (if vect is a list of vectors or a zone). The keys of the dictionary are the vectors objects.
- Parameters:
vect – wolf polyline or list of wolf polylines or zone
progress_callback – optional callback to update progress
i_start – start index (0-based)
i_end – end index (0-based), -1 for last
i_step – step index
to_rasterize – force to rasterize the vector(s) along the grid