wolfhece.pyGui1D
Author: HECE - University of Liege, Pierre Archambeau, Utashi Ciraane Docile 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.pyGui1D.Titles[source]
Bases:
enum.Enum
Titles (string names) of buttons, menus, etc, used by this module and seen in the interface.
@ the sign _() enclosing strings is required for translation purposes (see .pytranslate).
- class wolfhece.pyGui1D.Colors[source]
Bases:
enum.Enum
Color names and parameters used in this module.
- class wolfhece.pyGui1D.fileExtensions[source]
Bases:
enum.Enum
File extensions (end of file name after the dot) used in this module.
- class wolfhece.pyGui1D.Page(parent)[source]
Bases:
wx.dataview.wx.Panel
A wx.page format used by the different tabs.
@ Could be better customized though. It means don’t refrain your creativity.
- class wolfhece.pyGui1D.GuiNotebook1D(page_names=[Titles.MAIN.value, Titles.INFILTRATIONS.value, Titles.BC_CONDITIONS.value, Titles.VERBOSITY.value, Titles.PARAMETERS.value], style=wx.DEFAULT_FRAME_STYLE | wx.STAY_ON_TOP, mapviewer=None)[source]
Bases:
wx.dataview.wx.Frame
Notebook frame (GUI in wx) that allow a user to interact with a wolf-1D model.
Interaction means: (creation, execution and soon results visualization) of wolf-1D models.
- cross_section: wolfhece.PyCrosssections.crosssections[source]
- update_cells_name()[source]
Update the list of cells name.
Note
It’s basically the list of all cross sections minus the last one.
- add_new_page(page: wx.dataview.wx.Panel, name: str, cells_related_page=True)[source]
Add a new page to the notebook.
- Parameters:
page (wx.Panel) – The page panel
name (str) – page name to be used across the whole notebook
cells_related_page – The page is visible only when
cross sections are sorted, defaults to True :type cells_related_page: bool, optional
- find_page_number(name: str) int [source]
Return the page index base on its name.
- Parameters:
name (str) – page name used across the whole notebook.
- Returns:
the page index
- Return type:
int
- delete_page(name: str)[source]
Delete a page based on its name.
- Parameters:
name (str) – page name used across the whole notebook.
Delete all pages related to the cells name.
Empty the list of pages related to the cells name.
- enable_action_select_profile_in_mapviewer()[source]
Enable the selection, highlight, and plot of the nearest profile of the user’s click (right down) in the mapviewer interface (2D).
- enable_action_set_1D_profile_in_mapviewer()[source]
Enable the selection, highlight, and plot of a profile in the mapviewer interface if the profile was selected in the notebook.
- disable_action_in_mapviewer()[source]
Disable every action activated in the mapviewer interface (2D).
- setting_active_profile_in_mapviewer()[source]
Set the active profile in the notebook as the active profile in the mapviewer.
- double_click_methods(event: wx.propgrid.EVT_PG_DOUBLE_CLICK)[source]
Select the appropriated method based on its id if the double click event is called in the property grid.
- Parameters:
event (pg.EVT_PG_DOUBLE_CLICK) – wx.Event
- changing_methods(event: wx.propgrid.EVT_PG_CHANGED)[source]
Select the appropriated method based on its id if a property has changed event.
- Parameters:
event (pg.EVT_PG_CHANGED) – wx.Event
- tab_changed(event)[source]
Bind the right method for locating the selected cell (profile) when the page(tab) has changed.
The selection is based on the cell’s name displayed on the tree list.
- Parameters:
event (wx.EVT_NOTEBOOK_PAGE_CHANGED) – wx.Event
- element_selected_on_infitltration_tree(event: TreeListEvent)[source]
Bind the event tree list changed each time the selected cell is changed on the infiltration page.
- Parameters:
event (TreeListEvent) – EVT_TREELIST_SELECTION_CHANGED
- element_selected_on_bounds_conditions_tree(event: TreeListEvent)[source]
Bind the event tree list changed each time the selected cell is changed on the boundary condition page.
- Parameters:
event (TreeListEvent) – EVT_TREELIST_SELECTION_CHANGED
- get_page_hydrographs()[source]
Return the infiltration page (page of hydrographs).
- Returns:
infiltration page
- Return type:
- get_page_boundary_conditions()[source]
Return the page of boundary conditions.
- Returns:
page of boundary conditions
- Return type:
- set_active_profile(profile_name: str)[source]
In case the profile_name is in the list of sorted cross sections, that profile is set as the active profile in both the notebook and the mapviewer. Simultaneously, the action Set 1D profile in mapviewer is enabled.
- Parameters:
profile_name (str) – name of the chosen profile.
- add_object(file, id: str)[source]
Add the given wolfhece object in both the GUI and mapviewer.
- Parameters:
file (every wolfhece.object) – the object to add
id (str) – object name displayed in mapviewer
- Returns:
a boolean value for checking whether
the process succeeded or aborted. :rtype: bool
- add_in_WolfMapViewer(file: str, id: str = '') int [source]
Add a new object in the interface by providing its path.
- Parameters:
file (str) – object’s path (computer’s path)
id (str, optional) – object name displayed in mapviewer, defaults to ‘’
- Returns:
a boolean value for checking whether
the process succeeded or aborted. :rtype: int
- select_mapviewer_data(data_type: Literal[array, cross_sections, wolfhece.PyVertexvectors.vector])[source]
Return the selected data from the mapviewer.
- Parameters:
data_type – type of the wolfhece.object to add
but should be among the implemented literals. :type data_type: Literal['array','cross_sections','vector'] :return: _description_ :rtype: wolfhece.object
- get_object_from_WolfMapViewer(id: str)[source]
Get object from the interface (wolf map viewer) based on its id.
- Parameters:
id (str) – object name displayed in mapviewer
- Returns:
the chosen object
- Return type:
wolfhece.object
Add a cross section file using the submenu.
- Parameters:
event (wx.Event) – `wx.EVT_MENU
Add bed and banks using the submenu.
- Parameters:
event (wx.Event) – wx.EVT_MENU
Add bathymetric array using the submenu.
- Parameters:
event (wx.Event) – wx.EVT_MENU
Add friction array using the submenu.
- Parameters:
event (wx.Event) – wx.EVT_MENU
Add land marks from using the submenu.
- Parameters:
event (wx.Event) – wx.EVT_MENU
- delete_data(variable_name: str, object_id: str)[source]
Delete an object from both the notebook and the interface (mapviewer).
- Parameters:
variable_name (str) – object name used by the notebook
object_id (str) – name displayed in the mapviewer
- remove_from_WolfMapViewer(id: str)[source]
Remove an object from the interface (mapviewer) based on its id.
- Parameters:
id (str) – name displayed in the mapviewer
- delete_crossection(remove_in_mapviewer=True)[source]
Delete the cross section from both this GUI and the interface.
- Parameters:
remove_in_mapviewer – remove the object from the mapviewer
(this option skips the removal from mapviewer in case of unavailable object in the mapviewer), defaults to True :type remove_in_mapviewer: bool, optional
- delete_bed_and_banks(remove_in_mapviewer=True)[source]
Delete the bed and banks from both this GUI and the interface.
- Parameters:
remove_in_mapviewer – remove the object from the mapviewer
(this option skips the removal from mapviewer in case of unavailable object in the mapviewer), defaults to True :type remove_in_mapviewer: bool, optional
- delete_bathymetry(remove_in_mapviewer=True)[source]
Delete the bathymetry from both this GUI and the interface.
- Parameters:
remove_in_mapviewer – remove the object from the mapviewer
(this option skips the removal from mapviewer in case of unavailable object in the mapviewer), defaults to True :type remove_in_mapviewer: bool, optional
- delete_friction(remove_in_mapviewer=True)[source]
Delete the friction from both this GUI and the interface.
- Parameters:
remove_in_mapviewer – remove the object from the mapviewer
(this option skips the removal from mapviewer in case of unavailable object in the mapviewer), defaults to True :type remove_in_mapviewer: bool, optional
- delete_land_mark(remove_in_mapviewer=True)[source]
Delete the landmarks from both this GUI and the interface.
- Parameters:
remove_in_mapviewer – remove the object from the mapviewer
(this option skips the removal from mapviewer in case of unavailable object in the mapviewer), defaults to True :type remove_in_mapviewer: bool, optional
- delete_line_in_txt_file(file_path: str, line_to_delete: str)[source]
Delete a specific line (known) in a given text file.
- Parameters:
file_path (str) – computer path to the text file,
line_to_delete (str) – line that should be deleted.
- update_data(variable_name: str, new_object_id: str)[source]
update (link) to the right data (object) in the interface.
- Parameters:
variable_name (str) – new object’s name in this notebook.
new_object_id (str) – new object’s name in the mapviewer
- correct_parameters(directory='')[source]
Correct the content of the parameter files (.param and .param.default created by the fortran executable.)
- Parameters:
directory (str, optional) – computer’s path to the directory containing the files, defaults to ‘’
Freeze all commands which require the presence of sorted cross sections.
Unfreeze all commands which require the presence of sorted cross sections.
- selection_friction_mode_changed()[source]
Based on a selected friction mode, enable either the option for agglomeration of friction or for forcing a unique friction value on all profiles.
- enable_infiltration_preprocess()[source]
Allow the choice between continuous hydrographs or a stepwise ones (pre-processed).
- disable_infiltration_preprocess()[source]
Restrict the choice between continuous hydrographs or a stepwise ones (pre-processed).
- cross_check_sections()[source]
Automatically enable or disable the cross section property check box.
- get_boundary_conditions() dict [source]
Return the dictionnary of boundary conditions.
- Returns:
dictionnary of boundary conditions.
- Return type:
dict
- get_hydrographs() dict [source]
Return the dictionnary of hydrographs. (infiltrations).
- Returns:
dictionnary of hydrographs
- Return type:
dict
- get_frictions()[source]
Return the friction values.
- Raises:
Exception – in case friction values are still missing and wx.exist.
Exception – in case friction values are still missing
- Returns:
friction values
- Return type:
wolfarray or int
- get_agglomeration_mode() str [source]
Return the agglomeration mode of frictions selected on the main page.
- Returns:
agglomeration mode of values
(mean, median, min, max, etc). :rtype: str
- get_roughness_option() str [source]
Return the selection mode of frictions chosen on the main page.
- Returns:
selected mode
- Return type:
str
- get_initial_water_depth() float [source]
Return the encoded value of the initial water depth.
- Returns:
intial water depth
- Return type:
float
- get_initial_discharge()[source]
Return the encoded value of the discharge.
- Returns:
initial discharge
- Return type:
float or None
- get_ic_file_format() str [source]
Return the file format of intial conditions.
- Returns:
file format
- Return type:
str
- get_infiltration_preprocess() str [source]
Return the selected mode in which the infiltrations hydrographs will be preprocessed.
- Returns:
preprossing mode (stepwise or continuous)
- Return type:
str
- get_epsilon() float [source]
Return the margin used to preprocess the infiltrations in case the stepwise option is selected.
- Returns:
epsilon (margin)
- Return type:
float
- get_computation_mode() str [source]
Return the computation mode used by the 1D executable.
- Returns:
computation mode (evolutive or fixed)
- Return type:
_type_
- get_steadiness_mode() str [source]
Return the steadiness mode which will be used by the executable.
- Returns:
steadiness mode
(No precomputation, precomputation, and steady) :rtype: str
- get_executable() str [source]
Return the executable type to be used in .bat file.
- Returns:
excecutable type (currently wolfcli and wolfclid)
- Return type:
str
- get_folder_executable() str [source]
return the computer path to the folder containing the executable.
- Returns:
folder(computer path in full)
- Return type:
str
- get_run_command() str [source]
Return the status of the run command. whether the simulation should be run or not after its creation.
- Returns:
status(yes or no)
- Return type:
str
- get_extrapolation_of_extremities() float [source]
Return the value encode in the extrapolation of extremities.
- Returns:
Value of how far the 2 extremities of each
profile should be elevated vertically. :rtype: float
- test_required_data() bool [source]
Test if all the required data are available to create and save a wolf 1D model.
- Returns:
True or False
- Return type:
bool
- initialize_param_file()[source]
Create the parameters file (.param ` and `.param.default) from the wolf executable (.exe).
This method initialize a temporary directory in which it copies the executable and create 2 files create_simul.txt and temporary.bat.
The create_simul file contains the commands necessary
to generate the parameter files from the executable by just passing in the directory;
Whereas, the .bat file contains
a command to launch the executable (.exe).
After running the wolf executable (.exe), the param file created, is first corected and then copied in the simulation directory. This file is then read by wolfparam to allow the modification of parameters through the wolfparam window (wx.notebook).
- initialize_file(directory_path: str, filename: str) str [source]
Initialize a computer path to a new file.
- Parameters:
directory_path (str) – Path to the folder
filename (str) – filename
- Returns:
full computer path to the new file
- Return type:
str
- click_on_parameters(event: wx.dataview.wx.Event)[source]
- The click on the parameters button launch the process:
to create a simulatin directory (folder)
to initialize the param file
to disable the button parameters while enabling the button save.
- Parameters:
event (wx.Event) – wx.EVT_BUTTON
- create_simulation_directory() str [source]
Create and return the simulation directory.
- Returns:
computer path to the folder
in which the simulation files wil be written. :rtype: str
- infiltration_preprocess_changed()[source]
Manage the choice of the infiltration preprocessing mode.
- quit(event: wx.dataview.wx.Event)[source]
Destroy safely this window from the menu.
- Parameters:
event (wx.Event) – wx.event
- get_bathymetry()[source]
Return the bathymetry object from the notebook.
- Returns:
bathymetry object
- Return type:
WolfArray
- button_save_clicked(event: wx.dataview.wx.Event)[source]
Gather all the inputs in the notebook and generate a 1D model (simulation).
- Parameters:
event (wx.Event) – wx.EVT_BUTTON
- Raises:
Exception – In case, the model fails to create the simulation
for whatever reasons.
- __call_parameters()[source]
FIXME outdated no longer used A temporary .param file is created to initialize the panel of parameters.
If the panel is closed (destroyed), the information are lost.
FIXME wolf_Param should be a panel not a frame.
- __button_save_clicked(event: wx.dataview.wx.Event)[source]
Gather all the inputs in the notebook and generate a 1D model (simulation).
- Parameters:
event (wx.Event) – wx.EVT_BUTTON
- Raises:
Exception – In case, the model fails to create the simulation
for whatever reasons.
- __add_bed_and_banks(event: wx.propgrid.EVT_PG_DOUBLE_CLICK)[source]
Add or change the river and bank data.
- __delete_bed_and_banks(event: wx.propgrid.EVT_PG_CHANGED)[source]
Delete the bed and banks from both this GUI and the interface.
- __delete_crossection(event: wx.propgrid.EVT_PG_CHANGED)[source]
Delete the cross section from both this GUI and the interface.
- __create_id(curdict: dict, id: str = None) str [source]
- Dialog box to create the object name
curdict: directory selfmapviewer
@ The object name is created at this step and then passed to the wolfpy interface with suffix to clearly distinguish the elements in use.
FIXME It would have been nice to have a select ID though.
- class wolfhece.pyGui1D.MultigridPage(parent)[source]
Bases:
wx.dataview.wx.Panel
Grid of hydrographs. It’s a plug and play panel on a given page. The panel contains a grid which allow the user to encode manually or automatically (upload) the hydrographs (infiltrations) of a 1D model.
- Parameters:
wx (wx.panel) – The panel on which the grid is displayed.
- tree_profiles(profile_names: list[str], title='Hydrographs', number_of_rows=1, number_of_columns=2)[source]
A table containing the daata.
- Parameters:
profile_names (list[str]) – List of profile names
title – The page name that will be
displayed to the users, defaults to ‘Hydrographs’ :type title: str, optional :param number_of_rows: Intializes the numbers of rows (ent), defaults to 1 :type number_of_rows: int, optional :param number_of_columns: the number of columns in the grid (in case of new variables), defaults to 2 :type number_of_columns: int, optional .. todo:: FIXME add a graph plot between the variables and the buttons (to give to the user a visual trend the entries).
- get_tree_list_first_item()[source]
Set the the first item on the tree list as the curname (current name).
Note
FIXME It still does not work properly.
- add_hydrographs_to_dict()[source]
Get the users inputs and append them to the page’s dictionary as the hydrograph associated to the key of the selected cell.
- add_hydrographs_to_dict_wx(event: TreeListEvent)[source]
Add the hydrograph to the dictionnary through a wx.Event.
- Parameters:
event (TreeListEvent) – wx.EVT_BUTTON
- add_row(event: wx.dataview.wx.Event)[source]
Adds new row in the table of records (grid)
- Parameters:
event (wx.Event) – wx.EVT_BUTTON
- load_hydrogaph(event: wx.dataview.wx.Event)[source]
Load an hydrograph (list of discharges evolution through time) from a text file on the wolfhece hydrograph format.
- Parameters:
event (wx.Event) – wx.EVT_BUTTON
- delete_hydrograph_from_dict(event: wx.dataview.wx.Event)[source]
Removes the entry saved by the user on the selected cell.
- Parameters:
event (wx.Event) – wx.EVT_BUTTON
- block_check_item(event: wx.dataview.wx.Event)[source]
Controls which item is checked or not based on the mouse operations (events).
- Parameters:
event (wx.Event) – EVT_TREELIST_ITEM_CHECKED
- on_select_item(event: TreeListEvent)[source]
Return the name of the cell selected by the user after, displaying the infiltration informations on the screen.
- Parameters:
event (TreeListEvent) – EVT_TREELIST_SELECTION_CHANGED
- Returns:
name of the selected item
- Return type:
str
- load_from_Hydrograph(hydrograph: wolfhece.PyHydrographs.Hydrograph)[source]
Fills the grid of infiltration from the hydrograph object available from the wolfhece library.
- Parameters:
hydrograph (Hydrograph) – Hydrrograph on the wolfhece format
- class wolfhece.pyGui1D.Boundary_condition_Page(parent)[source]
Bases:
wx.dataview.wx.Panel
Grid of Boundary conditions. It’s a plug and play panel on a given page. The panel contains a grid which allow the user to encode manually or automatically (upload) the boundary conditions of a 1D model.
- Parameters:
wx (_type_) – _description_
Note
FIXME it would have been nice to have unifom format
(file) of boundary conditions for all wolf models (1,2 or 3D). In that way, one class can be used to manage all operations regardless of the dimensions (1,2 or 3D).
- tree_profiles(profile_names: list[str], title='Boundary conditions', number_of_rows=1, number_of_columns=2)[source]
A table containing the data.
- Parameters:
profile_names (list[str]) – List of profile names.
title – The page name that will be
displayed to the users, defaults to ‘Boundary conditions’ :type title: str, optional :param number_of_rows: Intializes the numbers of rows (ent), defaults to 1 :type number_of_rows: int, optional :param number_of_columns: the number of columns in the grid (in case of new variables), defaults to 2 :type number_of_columns: int, optional
- get_tree_list_first_item()[source]
Set the the first item on the tree list as the curname (current name).
Note
FIXME It still does not work properly.
- add_boundary_conditions_to_dict()[source]
Get the users inputs and append them to the page’s dictionary. In the dictionnary, the boundary conditions are associated to the key of the selected cells.
- convert_cell_side_value(value: int) str [source]
Return the location of the boundary condition on a selected cell (upstream or downstream).
- Parameters:
value (int) – 1 for upstream or 2 for downstream
- Returns:
upstream `or `downstream
- Return type:
str
- convert_type_boundary_condition(value: int) str [source]
- Return the type of boundary condition
corresponding to the encoded integer.
- Parameters:
value (int) – _description_
- Returns:
_description_
- Return type:
str
- add_boundary_condition_to_dict_wx(event: TreeListEvent)[source]
Add the boundary condition to the dictionnary through a wx.Event.
- Parameters:
event (TreeListEvent) – wx.EVT_BUTTON
- delete_boundary_condition_from_dict(event: wx.dataview.wx.Event)[source]
Removes the entry saved by the user on specified cell.
- Parameters:
event (wx.Event) – wx.EVT_BUTTON
- block_check_item(event: wx.dataview.wx.Event)[source]
Controls which item is checked or not based on the mouse operations (events).
- Parameters:
event (wx.Event) – EVT_TREELIST_ITEM_CHECKED
- oncheckitem(event: TreeListEvent)[source]
Return the name of the cell selected by the user after, displaying the informations regarding the boundary conditions in the grid.
- Parameters:
event (TreeListEvent) – EVT_TREELIST_SELECTION_CHANGED
- Returns:
name of the selected item
- Return type:
str
- load_from_boundary_conditions(condition: tuple[str, str, float])[source]
Fills the grid of boundary conditions from a tuple containing:
condition[0] : cell side,
condition[1]: type of boundary condition,
condition[2]: Value of boundary condition.
- Parameters:
condition (tuple[str, str, float]) – information about the boundary conditon.