wolfhece.drowning_victims.drowning_class ======================================== .. py:module:: wolfhece.drowning_victims.drowning_class Module Contents --------------- .. py:data:: COLUMN_Z_PARAM :value: ['vertical', 'U_z', 'z_0', 'mu_stat', 'Time_float', 'T_w', 'ADD', 'ADD_resurface'] .. py:data:: COLUMNS_HUMAN :value: ['Age', 'BMI', 'BSA', 'CAM', 'CDA', 'CLA', 'Death', 'dm', 'eps', 'fp_x', 'fp_y', 'fp_z',... .. py:class:: Drowning_victim(Path_dir: str = None) .. py:method:: Default_values() Sets the default values for each parameter by creating a first parameter.param .. py:method:: victim() Definition of the victim's caracteristics gender : Gender of the victim, 1 for man, 2 for women Age : Age of the victim in years height : Height of the victim in m mass : Mass of the victim in kg BMI : BMI of the victim in kg/m² clothes : clothing type of the victim (0 for naked, 1 for summer clothes, 2 for spring clothes, 3 for winter clothes) T_w : Average water temperature in °C ini_drowning : Time at which the victim drowned in the day (format 24H) .. py:method:: from_attributes_to_dictionnary() Create a dictionnary from the attributes of the class .. py:method:: from_dictionnary_to_attributes() Update the attributes of the class based on the values in self.param_dict. .. py:method:: from_dot_param_to_dictionnary(store_dir: pathlib.Path = None) Update the parameters with the modifications made by the user with the file parameters.param :param store_dir: directory where the file parameters.param is .. py:method:: Human_generation() Generates the bodies for the simulation :return Human Attributes: Human : Dataframe panda with each line representing a body and n_b lines, so one for eahc body gender : Gender of the victim, 1 for man, 2 for women Age : Age of the victim in years height : Height of the victim in m mass : Mass of the victim in kg BMI : BMI of the victim in kg/m² clothes : clothing type of the victim (0 for naked, 1 for summer clothes, 2 for spring clothes, 3 for winter clothes) CAM : Added mass coefficient of the body CDA : Drag area of the body (drag coefficient * a reference area) CLA : Lift area of the body CSA : Side area of the body fp_x : Projection coefficient along the x-axis to go from the BSA to the frontal area fp_y : Projection coefficient along the y-axis to go from the BSA to the frontal area fp_z : Projection coefficient along the z-axis to go from the BSA to the frontal area lungs_volume_TLC : Lungs volume at Total Lungs Capacity lungs_volume_FRC : Lungs volume at Functionnal Residual Capacity (at rest, after normally expiring) dm : Amount of swallowed water BSA : Body surface area (i.e. surface of the skin) Death : Type of death eps : Width of the body V_clothes_o : Initial volume of clothes (according to Barwood et al., 2011) V_clothes_one : Volume of clothes after 20min at rest (according to Barwood et al., 2011) V_clothes_two : Volume of clothes after 20min of swimming (according to Barwood et al., 2011) error_perc_fat : Deviation to the average on the percentage body fat of the body calculated from the equation of Siri et al. 1960 .. py:method:: Initialisation_arrays() Function where the matrixes of body position, speed, time, resurfacing and sinking are initialised, both for computing and saving Initialisation of other variables used in the simulation Attributes: BC_cells : Array containing the index of all cells that are boundary conditions for the hydrodynamic simulation DT_WOLF : Time step of the WOLF simulation NbX : Number of cells in the x-direction for the WOLF simulation NbY : Number of cells in the y-direction for the WOLF simulation ini_drowning : Hour at which the victim fell in the water count_Wolf : Time step of the Wolf simulation that we consider as our initial time in the Lagrangian simulation wanted_Wolf : Array containing all the times at which we have a new Wolf result Delta : Array containing the spatial and time steps Pos : Working array containing the 3D positions of all bodies at time t and t-dt with shape (n_b,3,2) Pos_b : Saving array containing the 3D positions of all bodies at all saving times with shape (n_b,3,n_t) U : Working array containing the 3D velocities of all bodies at time t and t-dt with shape (n_b,3,2) U_b : Saving array containing the 3D velocities of all bodies at all saving times with shape (n_b,3,n_t) time : Working array containing the time associated to each body with shape (n_b,) resurface : Saving array containing the resurfacing time of all bodies with shape (n_b,) sinking : Saving array containing the sinking time of all bodies with shape (n_b,) count : Counter to evaluate the progression of the savings sp : Parameter deserving to work with the working variables .. py:method:: start() Main of the class, runs the code with a parallelised code (n_parallel>1) or without .. py:method:: Parallel_loop() Necessary for the parallelisation as we have to give a list of arguments to the function instead of all the args separately .. py:class:: Drowning_victim_Viewer(idx='', plotted=True, mapviewer=None, need_for_wx=False, filedir=None) Bases: :py:obj:`wolfhece.drawing_obj.Element_To_Draw` .. autoapi-inheritance-diagram:: wolfhece.drowning_victims.drowning_class.Drowning_victim_Viewer :parts: 1 :private-bases: Base class of element to add into WolfMapViewer or another GUI .. py:attribute:: filename :value: None .. py:attribute:: filedir :value: None .. py:attribute:: file_drowning :value: None .. py:attribute:: n_peaks :value: 2 .. py:attribute:: newdrowning .. py:method:: selection_drowning_point(event) Function to select the drowning point in the viewer .. py:method:: selection_progress(event) Function to select the drowning point in the viewer .. py:method:: update_drowning_pos() Update the values of "X-cell" and "Y-cell" in the parameters.param file. .. py:method:: create_exe_file(event) Start the drowning in a separate process .. py:method:: run_code(event) .. py:method:: show_properties() Generic function to show properties of the object .. py:method:: from_dictionnary_to_wp() Return a Wolf_Param object that represents the parameters of the simulation, directly using the attributes of the class. .. py:method:: from_wp_to_dictionnary() Compare the parameters in self.wp with self.newdrowning.param_dict and update the values in self.newdrowning.param_dict when they differ. .. py:method:: hide_properties() Hide properties window .. py:method:: save() Save the parameters in a text file .. py:method:: saveas() Save the parameters in a text file .. py:method:: load_results() Load the results from the 'Results.npz' file and assign the arrays as attributes of the class. .. py:method:: init_plot() .. py:method:: read_oneresult(idx) Read one result of the simulation and update the parameters in the GUI .. py:method:: read_last_result() Read the last results of the simulation and update the parameters in the GUI .. py:method:: find_minmax(update=False) Generic function to find min and max spatial extent in data example : a WolfMapViewer instance needs spatial extent to zoom or test if element must be plotted .. py:method:: plot(sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None) Plot data in OpenGL context .. py:method:: sort_positions_bodies() .. py:method:: prepare_plot_runs_positions() Plot the runs position on a georeferenced map with bodies in blue being at the bottom and red being at the surface. .. py:method:: reset_plot_runs_positions() .. py:method:: kde_on_grid(points, bandwidth, xmin, xmax, ymin, ymax, grid_size) Function used to calculate the kde on a point cloud. Use a large grid size to identify peaks and a small one to refine .. py:method:: detect_peaks(x, y, radius, num_peaks=2) Détecte les pics locaux dans une matrice 2D sans skimage. param: x X coordinate of the points cloud param: y Y coordinate of the points cloud param: radius size of the grid to detect peaks param: n_peaks number of peaks to detect .. py:method:: kde_refined_based_coarse(points, wolfarray, bandwidth=50, coarse_grid_size=50, fine_grid_size=5, window_size=200, radius=150, n_peaks=3) Optimisation à 2 étages : détection des pics sur grille grossière puis raffinement local. Returns: - refined_peaks : coordonnées des pics raffinés - clusters : liste de points pour chaque cluster - coords : coordonnées (x, y) de chaque maille dans les zones raffinées - values : valeur KDE associée à chaque maille .. py:method:: prepare_plot_kde() Plot the kernel density estimation of positions on a georeferenced map with bodies in blue being at the bottom and red being at the surface. .. py:method:: reset_plot_kde() .. py:method:: prepare_plot_cells_positions() Plot the cells of the WOLF simulation, with a colorbar associated to the number of elements in the cell .. py:method:: reset_plot_cells_positions() .. py:method:: zoom_on_hotspots(memory_view) Zoom on the hotspots of the KDE .. py:method:: get_bodies_characteristics() Plots a table of the Dataframe panda "Human" with the characteristics of each run .. py:method:: get_vertical_position_proportion() Gives the proportion of bodies at the surface and at the bottom of the water .. py:class:: ProgressBar(parent, n_processes, total) Bases: :py:obj:`wx.Frame` .. autoapi-inheritance-diagram:: wolfhece.drowning_victims.drowning_class.ProgressBar :parts: 1 :private-bases: Creates and manages the progress frame .. py:attribute:: n_processes .. py:attribute:: total .. py:attribute:: progress_bars .. py:attribute:: progress_text .. py:method:: update_progress(progress_dict) Update the progress bars based on the values in `progress_dict`. .. py:class:: ProgressImage(n_processes, total, *args, **kw) Bases: :py:obj:`wx.Frame` .. autoapi-inheritance-diagram:: wolfhece.drowning_victims.drowning_class.ProgressImage :parts: 1 :private-bases: Creates and manages the progress frame with a fractioned image appearance .. py:attribute:: n_processes .. py:attribute:: total_segments .. py:attribute:: total .. py:attribute:: image_path :value: '' .. py:attribute:: image_segments :value: [] .. py:method:: update_progress(progress_dict) Update the visibility of image segments based on the progress.