wolfhece.hydrology.Optimisation
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
- class wolfhece.hydrology.Optimisation.CaseOpti(*args, **kw)[source]
Bases:
wolfhece.PyGui.GenMapManager
Default class for a Wolf Map Manager.
Will be overriden by the specific classes MapManager, GPU2DModel, HydrologyModel, Wolf2DModel.
It is not suitable for direct use.
- class wolfhece.hydrology.Optimisation.Optimisation(parent=None, title='', w=500, h=500, init_wx=True, debugDLL=False)[source]
Bases:
wolfhece.wolf_array.wx.Frame
- all_intervals: list[tuple[wolfhece.hydrology.Comparison.datetime.datetime, wolfhece.hydrology.Comparison.datetime.datetime]][source]
- apply_optim(event, idLauncher: int = 0, replace_only_if_better: bool = False, optim_params: wolfhece.wolf_array.np.ndarray = None)[source]
Apply optimal parameters based on the results file of the optimisation : “.rpt”.
- Parameters:
event – The event from the GUI.
(optional (replace_only_if_better) – int(0)): The ID of the launcher.
(optional – bool(False) by default): A boolean indicating whether to replace the current parameters if the new ones are better.
- Returns:
If replace_only_if_better is False, returns the best parameters found. If replace_only_if_better is True and the new parameters are better, returns the best parameters found. Otherwise, returns None.
- launch_semiDistributed_optimisation(event, idOpti=1, idLauncher=0)[source]
Procedure launching the semi-distributed optimisation process.
- Parameters:
event – The event triggering the optimisation.
idOpti (int) – The ID of the optimizer in Fortran.
idLauncher (int) – The ID of the launcher.
- Returns:
None
- reload_hydro(idCompar, firstLevel: int = 1, lastLevel: int = -1, fromStation: str = '', updateAll: bool = False)[source]
- remove_py_params(idLauncher: int = 0)[source]
Removes the Python parameters from the optimization configuration.
- Parameters:
idLauncher (int, optional) – The ID of the launcher. Defaults to 0.
- _read_opti_intervals(idLauncher: int = 0) list[tuple[wolfhece.hydrology.Comparison.datetime.datetime, wolfhece.hydrology.Comparison.datetime.datetime]] [source]
- _save_opti_intervals(idLauncher: int = 0, stationOut: str = '', intervals: list[tuple[wolfhece.hydrology.Comparison.datetime.datetime, wolfhece.hydrology.Comparison.datetime.datetime]] = None) int [source]
- select_opti_intervals(all_intervals: list[tuple[wolfhece.hydrology.Comparison.datetime.datetime, wolfhece.hydrology.Comparison.datetime.datetime]] = None, idLauncher: int = 0, stationOut='', filter_nan: bool = True) list[tuple] [source]
- _define_intervals_with_nan_measures(intervals: list[tuple[wolfhece.hydrology.Comparison.datetime.datetime, wolfhece.hydrology.Comparison.datetime.datetime]], measures: dict[str, wolfhece.hydrology.Comparison.SubBasin], idLauncher: int = 0, stationOut: str = '')[source]
Defines new intervals excluding all NaN measures based on the given intervals and measures dictionary. For instance, if there is continuous NaN measures within a given interval, the function will split that interval into smaller that do not contain NaN measures.
- Parameters:
intervals (list[tuple[datetime.datetime, datetime.datetime]]) – A list of intervals represented as tuples of start and end datetime objects.
measures (dict[str, SubBasin]) – A dictionary of measures where the keys are station names and the values are SubBasin objects.
idLauncher (int, optional) – The id of the launcher. Defaults to 0.
stationOut (str, optional) – The station name. Defaults to “”.
- Returns:
A list of intervals with NaN measures.
- Return type:
list[tuple[datetime.datetime, datetime.datetime]]
- Raises:
None –
- save_opti_dates_to_file(opti_dates: list[tuple[wolfhece.hydrology.Comparison.datetime.datetime, wolfhece.hydrology.Comparison.datetime.datetime]])[source]
Here the procedure is saving the intervals of dates for calibration in the compare.how.param
- prepare_init_params_from_best(best_params: wolfhece.wolf_array.np.array, idLauncher: int = 0)[source]
- save_current_compare_file(stationOut: str)[source]
Save the current compare file for a given station to prepare optimisation with Fortran.
- Parameters:
stationOut (str) – The station identifier.
- Returns:
None
- Raises:
None –
- prepare_simulation(opti_intervals: list[tuple[wolfhece.hydrology.Comparison.datetime.datetime, wolfhece.hydrology.Comparison.datetime.datetime]], idLauncher: int = 0)[source]
- reset_simulation_intervals(default_interval: list[tuple[wolfhece.hydrology.Comparison.datetime.datetime, wolfhece.hydrology.Comparison.datetime.datetime]], idLauncher: int = 0)[source]
- test_equifinality_with_Nash(event, idLauncher: int = 0, idOpti: int = 1, quantile_Nash: float = 0.01, std_Nash: float = 0.3, clustering_Nash: bool = True)[source]
Test the equifinality of the model.
- Parameters:
idLauncher (int, optional) – The id of the launcher. Defaults to 0.
- Returns:
None
- Raises:
None –
- get_best_params(stationOut: str, criterion: str = 'Nash', quantile: float = 0.99, std: float = 0.05, eps: float = 0.1, objective_fct: bool = True, apply_clustering: bool = False)[source]
- _get_exceedance(idLauncher: int = 0, stationOut: str = '', intervals: list[tuple[wolfhece.hydrology.Comparison.datetime.datetime, wolfhece.hydrology.Comparison.datetime.datetime]] = []) float [source]
- _get_cur_fractions(idLauncher: int = 0, stationOut: str = '', intervals: list[tuple[wolfhece.hydrology.Comparison.datetime.datetime, wolfhece.hydrology.Comparison.datetime.datetime]] = []) dict[list[str], list[float]] [source]
Save the evaluations of the model.
- Parameters:
idOpti (int, optional) – The id of the optimisation. Defaults to 1.
stationOut (str, optional) – The station identifier. Defaults to “”.
fct_list (list[str], optional) – A list of functions. Defaults to [].
- Returns:
None
- Raises:
None –
- _get_volume_fractions(idLauncher: int = 0, stationOut: str = '', intervals: list[tuple[wolfhece.hydrology.Comparison.datetime.datetime, wolfhece.hydrology.Comparison.datetime.datetime]] = []) dict[list[str], list[float]] [source]
- _get_max_runoff(idLauncher: int = 0, stationOut: str = '', intervals: list[tuple[wolfhece.hydrology.Comparison.datetime.datetime, wolfhece.hydrology.Comparison.datetime.datetime]] = []) dict[list[str], list[float]] [source]