wolfhece 2.2.3__py3-none-any.whl → 2.2.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,7 +20,7 @@ from datetime import datetime, timedelta
20
20
  try:
21
21
  from ..PyParams import *
22
22
  from ..drawing_obj import Element_To_Draw
23
- from ..Results2DGPU import getkeyblock
23
+ from ..Results2DGPU import getkeyblock
24
24
  from ..PyTranslate import _
25
25
  from ..PyVertex import cloud_vertices
26
26
  from ..wolf_array import WolfArray, header_wolf
@@ -28,16 +28,16 @@ try:
28
28
  except:
29
29
  from wolfhece.PyParams import *
30
30
  from wolfhece.drawing_obj import Element_To_Draw
31
- from wolfhece.Results2DGPU import getkeyblock
31
+ from wolfhece.Results2DGPU import getkeyblock
32
32
  from wolfhece.PyTranslate import _
33
33
  from wolfhece.PyVertex import cloud_vertices
34
34
  from wolfhece.wolf_array import WolfArray
35
35
  from wolfhece.PandasGrid import PandasGrid
36
36
 
37
37
  try:
38
- from .Functions import *
38
+ from .drowning_functions import *
39
39
  except:
40
- from Drowning_victims.Functions import *
40
+ from wolfhece.drowning_victims.drowning_functions import *
41
41
 
42
42
 
43
43
  #index 0 1 2 3 4 5 6 7
@@ -49,9 +49,9 @@ class Drowning_victim:
49
49
  """
50
50
  Initialize the simulation parameters.
51
51
 
52
- :param Path_loading:
52
+ :param Path_loading:
53
53
  Path of the simulation loaded.
54
-
54
+
55
55
  Attributes:
56
56
  Profile_this (bool): Binary parameter to activate the profiling of the code.
57
57
  saving (bool): Binary parameter to save your results.
@@ -94,7 +94,7 @@ class Drowning_victim:
94
94
 
95
95
  def Default_values(self):
96
96
  """
97
- Sets the default values for each parameter by creating a first parameter.param
97
+ Sets the default values for each parameter by creating a first parameter.param
98
98
  """
99
99
  import pandas as pd
100
100
  import math
@@ -122,7 +122,7 @@ class Drowning_victim:
122
122
 
123
123
  self.CFL = 0.01
124
124
  self.dt_min = 0.01
125
- self.dt_max = 1 #s
125
+ self.dt_max = 1 #s
126
126
  self.t_initial = 0*60*60*24
127
127
  self.i_initial = math.floor(self.t_initial/self.dt_max)+1
128
128
 
@@ -540,7 +540,7 @@ class Drowning_victim:
540
540
  self.param_dict = param_dict
541
541
 
542
542
  return
543
-
543
+
544
544
  def from_dictionnary_to_attributes(self):
545
545
  """
546
546
  Update the attributes of the class based on the values in self.param_dict.
@@ -552,7 +552,7 @@ class Drowning_victim:
552
552
  value = param_data.get("value", None)
553
553
  if param_data.get("type", None)=='Integer':
554
554
  value = int(value)
555
-
555
+
556
556
  # Mettre à jour l'attribut correspondant dans self
557
557
  if section == "Options":
558
558
  if key == "Profile":
@@ -643,7 +643,7 @@ class Drowning_victim:
643
643
  self.nby = value
644
644
 
645
645
  # Initialise the parameters of the simulation with default values and values given in the parameters.param file
646
- self.t_initial = 0
646
+ self.t_initial = 0
647
647
  self.i_initial = 0
648
648
  self.time_goal = self.Days*24*60*60 + self.Hours*60*60 + self.Minutes*60 + self.Seconds #s
649
649
  self.wanted_time = np.array([self.t_initial])
@@ -696,7 +696,7 @@ class Drowning_victim:
696
696
  Z_param.ADD = self.time_goal/60/60/24*self.T_w
697
697
  Z_param.ADD_resurface = 5250/self.T_w * rnd.beta(4,4,size=n_b) #source: Heaton 2011 considering a TADS between 14 and 15 as maximum expension
698
698
  self.Z_param = Z_param
699
-
699
+
700
700
  def from_dot_param_to_dictionnary(self,store_dir: Path = None):
701
701
  """
702
702
  Update the parameters with the modifications made by the user with the file parameters.param
@@ -716,7 +716,7 @@ class Drowning_victim:
716
716
  with open(text_file_path, 'r', encoding='ISO-8859-1') as file:
717
717
  for line in file:
718
718
  line = line.strip()
719
-
719
+
720
720
  # Vérifier si la ligne est un nom de section (par exemple, 'Options:', 'Path:', etc.)
721
721
  if line.endswith(":"):
722
722
  # Crée une nouvelle sous-section
@@ -725,13 +725,13 @@ class Drowning_victim:
725
725
  elif "\t" in line and current_section:
726
726
  # Split clé et valeur
727
727
  key, value = line.split("\t", 1)
728
-
728
+
729
729
  # Convertir la valeur en nombre si possible
730
730
  try:
731
731
  value = float(value)
732
732
  except ValueError:
733
733
  pass # Garde la valeur comme chaîne de caractères si non convertible
734
-
734
+
735
735
  # Ajout de la clé et de la valeur dans la section actuelle
736
736
  data[current_section][key] = value
737
737
 
@@ -748,7 +748,7 @@ class Drowning_victim:
748
748
 
749
749
  # Sauvegarder le dictionnaire mis à jour dans self.param_dict
750
750
  self.param_dict = param_dict
751
-
751
+
752
752
  return
753
753
 
754
754
  def Human_generation(self):
@@ -786,7 +786,7 @@ class Drowning_victim:
786
786
  """
787
787
 
788
788
  Human = pd.DataFrame(data=None,columns=COLUMNS_HUMAN,dtype=np.int32)
789
-
789
+
790
790
  n_b = self.n_b
791
791
 
792
792
  ##Gender
@@ -803,8 +803,8 @@ class Drowning_victim:
803
803
  if self.Age==-1:
804
804
  age_min = 18
805
805
  age_max = 90 + 1
806
- Human.Age = rnd.randint(age_min,age_max,size=(n_b))
807
-
806
+ Human.Age = rnd.randint(age_min,age_max,size=(n_b))
807
+
808
808
  #Height
809
809
  h_av = self.height
810
810
  h_max = np.array([205, 190]) /100
@@ -816,7 +816,7 @@ class Drowning_victim:
816
816
  if h_av == -1:
817
817
  Human.loc[ind_m,'height'] = rnd.beta(5.8697,6.075,size=(len(ind_m)))*(h_max[0]-h_min[0])+h_min[0] #men
818
818
  Human.loc[ind_w,'height'] = rnd.beta(3.976,5.965,size=(len(ind_w)))*(h_max[1]-h_min[1])+h_min[1] #women
819
-
819
+
820
820
  ##Mass or BMI
821
821
  m_av = self.mass
822
822
  m_max = np.array([135, 130])
@@ -828,7 +828,7 @@ class Drowning_victim:
828
828
  Human.BMI = Human.mass / Human.height**2
829
829
  known = 1
830
830
  if m_av < 0:
831
- BMI = self.BMI
831
+ BMI = self.BMI
832
832
  BMI_min = 16
833
833
  BMI_max = 40
834
834
  BMI_25 = [20, 21.3, 22.5, 23.3, 22.9, 23.7, 23.1]
@@ -850,7 +850,7 @@ class Drowning_victim:
850
850
  clothes = self.clothes #simpledialog.askinteger('Dialog title','Clothing type with: \n-1 if unknown \n0 for naked or in underwear\n1 for summer clothes (short and a t-shirt or dress)\n2 for autumn/spring clothes (trousers, a t-shirt, a sweater, and eventually a water/windproof jacket)\n3 for winter clothes (trousers, a t-shirt, a sweater, and a heavy warm jacket or more clothes)',minvalue=-1,maxvalue=3,parent=root) #0 for naked, 1 for summer clothes, 2 for autumn/spring clothes, 3 for winter clothes
851
851
  if clothes==-1:
852
852
  clothes=2
853
-
853
+
854
854
  Human,error_perc_fat = Skinfold(n_b,known,Human)
855
855
 
856
856
 
@@ -863,50 +863,50 @@ class Drowning_victim:
863
863
  # Human.CDA = rnd.normal(0.4181,0.03434,n_b)*(clothes<2) + rnd.normal(0.5172,0.0406,n_b)*(clothes>=2)
864
864
  # Human.CLA = rnd.normal(0.07019,0.05035,n_b)*(clothes<2) + rnd.normal(0.08387,0.08138,n_b)*(clothes>=2)
865
865
  # Human.CSA = rnd.normal(0.03554,0.02545,n_b)*(clothes<2) + rnd.normal(0.04047,0.04311,n_b)*(clothes>=2)
866
-
866
+
867
867
  #Mandatory for the structure of the numpy variable Human generated for the calculations
868
868
  Human.fp_x = rnd.beta(1,1,size=(n_b))*(0.36-0.16)+0.16
869
869
  Human.fp_y = 0.36-Human.fp_x+0.16
870
870
  Human.fp_z = np.ones((n_b)) * 0.2
871
-
872
-
871
+
872
+
873
873
  Human.lungs_volume_TLC = 10**-3 * ((7.99*Human.height-7.08) * (2-Human.gender) + (6.6*Human.height-5.79) * (Human.gender-1)) #Formulas ERC valid for men between 1.55 and 1.95 m and women between 1.45 and 1.8 m
874
874
  Human.lungs_volume_FRC = 10**-3 * ((2.34*Human.height+0.01*Human.Age-1.09) * (2-Human.gender) + (2.24*Human.height+0.001*Human.Age-1) * (Human.gender-1)) #Formulas ERC valid for men between 1.55 and 1.95 m and women between 1.45 and 1.8 m
875
875
  Human.lungs_volume_TLC = Human.lungs_volume_TLC * (0.0403*Human.BMI**2 - 3.1049*Human.BMI + 149.58)/100 #Digitalization of TOTAL part of figure 4 of doi:10.1136/bmjresp-2017-000231
876
876
  Human.lungs_volume_FRC = Human.lungs_volume_FRC * (0.102*Human.BMI**2 - 7.4504*Human.BMI + 229.61)/100 #Digitalization of TOTAL part of figure 4 of doi:10.1136/bmjresp-2017-000231
877
-
877
+
878
878
  Human.dm = Human.mass * (0.1 * rnd.beta(1.5,1.5,size=((n_b))) + 0.0) #Between x and y% of the body mass (usually around 10 according to test on dogs)
879
879
  Human.dm += self.m_b_add
880
880
 
881
881
  Human.BSA = ((128.1 * Human.mass**0.44 * (Human.height*100)**0.6) * (2-Human.gender) + (147.4 * Human.mass**0.47 * (Human.height*100)**0.55) * (Human.gender-1))*10**-4
882
-
882
+
883
883
  Human.Death = np.ones(n_b)
884
-
884
+
885
885
  Human.eps = np.ones(n_b)*0.2
886
-
887
-
886
+
887
+
888
888
  clothes_alpha_m = np.array([[1,0.1771,0.0192,0.0082],[1,5.7342e-6,0.0253,0.8511],[1,5.9719e-6,0.333,4.981e-6]])
889
889
  clothes_alpha_w = np.array([[1,0.7676,4.4037,0.8523],[1,0.5375,0.3333,3.5128],[1,0.5375,0.7082,2.333]])
890
890
  clothes_beta_m = np.array([[1,0.3542,0.0385,0.0095],[1,9.9565e-6,0.0505,1.7022],[1,1.1522e-5,0.667,8.7348e-6]])
891
891
  clothes_beta_w = np.array([[1,1.5353,8.8072,1.7046],[1,1.0749,0.6667,7.0255],[1,1.0749,1.4165,4.6659]])
892
-
892
+
893
893
  clothes_mean_m = np.array([[0.5,0.6127,2.7573,4.3912],[0.5,0.204,0.715,1.021],[0.5,0.408,1.1233,0.613]])*10**-3
894
894
  clothes_mean_w = np.array([[0.5,1.123,2.655,4.493],[0.5,0.9191,1.1233,1.94],[0.5,0.9191,1.2254,2.0424]])*10**-3
895
895
  clothes_std_m = np.array([[0.5,0.7148,0.817,0.6127],[0.5,0.9191,1.1233,0.817],[0.5,0.817,1.1233,2.451]])*10**-3
896
896
  clothes_std_w = np.array([[0.5,0.9191,1.6339,1.6339],[0.5,0.817,1.1233,1.225],[0.5,0.817,1.0212,0.817]])*10**-3
897
-
897
+
898
898
  clothes_max_m = clothes_mean_m + 2*clothes_std_m
899
899
  clothes_min_m = clothes_mean_m - 2*clothes_std_m
900
900
  clothes_max_w = clothes_mean_w + 2*clothes_std_w
901
901
  clothes_min_w = clothes_mean_w - 2*clothes_std_w
902
902
 
903
-
903
+
904
904
  Human.V_clothes_o = (clothes!=0)* ((rnd.beta(clothes_alpha_m[0,clothes],clothes_beta_m[0,clothes],size=(n_b))*(clothes_max_m[0,clothes]-clothes_min_m[0,clothes])+clothes_min_m[0,clothes])*(2-Human.gender) + (rnd.beta(clothes_alpha_w[0,clothes],clothes_beta_w[0,clothes],size=(n_b))*(clothes_max_w[0,clothes]-clothes_min_w[0,clothes])+clothes_min_w[0,clothes])*(Human.gender-1))
905
905
  Human.V_clothes_one = (clothes!=0)* ((rnd.beta(clothes_alpha_m[1,clothes],clothes_beta_m[1,clothes],size=(n_b))*(clothes_max_m[1,clothes]-clothes_min_m[1,clothes])+clothes_min_m[1,clothes])*(2-Human.gender) + (rnd.beta(clothes_alpha_w[1,clothes],clothes_beta_w[1,clothes],size=(n_b))*(clothes_max_w[1,clothes]-clothes_min_w[1,clothes])+clothes_min_w[1,clothes])*(Human.gender-1))
906
906
  Human.V_clothes_two = (clothes!=0)* ((rnd.beta(clothes_alpha_m[2,clothes],clothes_beta_m[2,clothes],size=(n_b))*(clothes_max_m[2,clothes]-clothes_min_m[2,clothes])+clothes_min_m[2,clothes])*(2-Human.gender) + (rnd.beta(clothes_alpha_w[2,clothes],clothes_beta_w[2,clothes],size=(n_b))*(clothes_max_w[2,clothes]-clothes_min_w[2,clothes])+clothes_min_w[2,clothes])*(Human.gender-1))
907
-
907
+
908
908
  Human.error_perc_fat = error_perc_fat
909
-
909
+
910
910
  self.Human = Human
911
911
 
912
912
  def Initialisation_arrays(self):
@@ -938,7 +938,7 @@ class Drowning_victim:
938
938
  self.Human_generation()
939
939
  n_b = self.n_b
940
940
  n_saved = self.n_saved
941
-
941
+
942
942
  self.BC_cells,self.DT_WOLF,DX,DY,H_mat,self.NbX,self.NbY,t_tot_Wolf = Read_Wolf_GPU_metadata(self.Path_Wolf)
943
943
 
944
944
  X = np.arange(0,DX*self.NbX,DX)+DX/2
@@ -955,9 +955,9 @@ class Drowning_victim:
955
955
  Delta[3] = self.dt_max
956
956
  Delta[4] = np.sqrt(DX**2+DY**2)
957
957
  self.Delta = Delta
958
-
959
- ind_pos_0_x = self.ind_pos_0_x
960
- ind_pos_0_y = self.ind_pos_0_y
958
+
959
+ ind_pos_0_x = self.ind_pos_0_x
960
+ ind_pos_0_y = self.ind_pos_0_y
961
961
  NbZ = H_mat[ind_pos_0_y,ind_pos_0_x]/Delta[2]
962
962
  ind_pos_0_z = NbZ.astype(int)
963
963
 
@@ -997,14 +997,14 @@ class Drowning_victim:
997
997
 
998
998
  else:
999
999
  self.count_initial,self.Human,n_loaded,Pos_b,self.time_b,U_b,self.Z_param = Loading(self.Path_loading,Pos_b,self.time_b,U_b)
1000
-
1000
+
1001
1001
  Pos[:,0,0] = Pos_b[:,0,n_loaded]
1002
1002
  Pos[:,1,0] = Pos_b[:,1,n_loaded]
1003
1003
  Pos[:,2,0] = Pos_b[:,2,n_loaded]
1004
1004
  Pos[:,0,1] = Pos_b[:,0,n_loaded]
1005
1005
  Pos[:,1,1] = Pos_b[:,1,n_loaded]
1006
1006
  Pos[:,2,1] = Pos_b[:,2,n_loaded]
1007
-
1007
+
1008
1008
  U[:,0,0] = U_b[:,0,n_loaded]
1009
1009
  U[:,1,0] = U_b[:,1,n_loaded]
1010
1010
  U[:,2,0] = U_b[:,2,n_loaded]
@@ -1028,7 +1028,7 @@ class Drowning_victim:
1028
1028
 
1029
1029
  """
1030
1030
  Main of the class, runs the code with a parallelised code (n_parallel>1) or without
1031
-
1031
+
1032
1032
  """
1033
1033
 
1034
1034
  start = timeit.default_timer()
@@ -1058,7 +1058,7 @@ class Drowning_victim:
1058
1058
  else:
1059
1059
  frame = ProgressBar(None,n_processes=self.n_parallel,total=self.time_goal)
1060
1060
  frame.Show()
1061
-
1061
+
1062
1062
  tasks = Preparation_parallelisation(progress_queue,self.a_RK,self.BC_cells,self.count,self.count_Wolf,self.CFL,self.Delta,Human_np,self.i_initial,self.n_b,self.n_saved,self.n_parallel,self.n_t,self.NbX,self.NbY,self.Path_saving,self.Path_Wolf,self.Pos,self.Pos_b,self.resurface,self.sinking,self.time,self.time_b,self.time_goal,self.U,self.U_b,self.wanted_time,self.wanted_Wolf,Z_param_np)
1063
1063
 
1064
1064
  # Création de la thread de suivi de la progression
@@ -1073,7 +1073,7 @@ class Drowning_victim:
1073
1073
  wx.Yield() # This allows the GUI to update while waiting for the results
1074
1074
  # Wait for the result to be ready
1075
1075
  results = result_async.get()
1076
-
1076
+
1077
1077
 
1078
1078
  def on_close(event):
1079
1079
  frame.Close() # Ferme la fenêtre
@@ -1092,7 +1092,7 @@ class Drowning_victim:
1092
1092
  # No use of multiprocessing
1093
1093
  else:
1094
1094
  self.Pos_b,self.resurface,self.sinking,self.time_b,self.U_b = Loop_management(-1,-1,self.a_RK,self.BC_cells,self.count,self.count_Wolf,self.CFL,self.Delta,Human_np,self.i_initial,self.n_b,self.n_saved,self.n_t,self.NbX,self.NbY,self.Path_saving,self.Path_Wolf,self.Pos,self.Pos_b,self.resurface,self.sinking,self.time,self.time_b,self.time_goal,self.U,self.U_b,self.wanted_time,self.wanted_Wolf,Z_param_np)
1095
-
1095
+
1096
1096
 
1097
1097
  stop = timeit.default_timer()
1098
1098
  execution_time = stop - start
@@ -1111,7 +1111,7 @@ class Drowning_victim:
1111
1111
  stats = pstats.Stats(profiler).sort_stats('ncalls')
1112
1112
  stats.sort_stats('tottime')
1113
1113
  stats.print_stats()
1114
-
1114
+
1115
1115
 
1116
1116
  if self.saving == 1:
1117
1117
  np.savez(self.Path_saving,Pos_b=self.Pos_b,U_b=self.U_b,Human=self.Human,Z_param=self.Z_param,wanted_time=self.wanted_time,time_b=self.time_b)
@@ -1121,7 +1121,7 @@ class Drowning_victim:
1121
1121
  Necessary for the parallelisation as we have to give a list of arguments to the function instead of all the args separately
1122
1122
  """
1123
1123
 
1124
- result = Loop_management(*args)
1124
+ result = Loop_management(*args)
1125
1125
 
1126
1126
  return result
1127
1127
 
@@ -1150,13 +1150,13 @@ class Drowning_victim_Viewer(Element_To_Draw):
1150
1150
 
1151
1151
  if not liste:
1152
1152
  dialog = wx.DirDialog(None, "Folder containing the wanted simulation WOLF 2D GPU", style=wx.DD_DEFAULT_STYLE)
1153
-
1153
+
1154
1154
  # Afficher la boîte de dialogue et attendre l'interaction de l'utilisateur
1155
1155
  if dialog.ShowModal() == wx.ID_OK:
1156
1156
  # Récupérer le chemin sélectionné
1157
1157
  self.newdrowning.Path_Wolf = dialog.GetPath()
1158
1158
  self.wp.change_param('Paths','Results of Wolf GPU simulation path',self.newdrowning.Path_Wolf)
1159
-
1159
+
1160
1160
  # Ajouter l'objet avec le chemin sélectionné
1161
1161
  self.mapviewer.add_object(which='res2d_gpu', ToCheck=True, filename=join(self.newdrowning.Path_Wolf, 'Results'))
1162
1162
  self.mapviewer.menu_wolf2d()
@@ -1169,7 +1169,7 @@ class Drowning_victim_Viewer(Element_To_Draw):
1169
1169
  # Détruire la boîte de dialogue pour libérer les ressources
1170
1170
  dialog.Destroy()
1171
1171
  return
1172
-
1172
+
1173
1173
  else:
1174
1174
  myitem = self.mapviewer.single_choice_key(draw_type.RES2D,checked_state=None)
1175
1175
  # nameitem = self.mapviewer.treelist.GetItemText(myitem).lower()
@@ -1208,7 +1208,7 @@ class Drowning_victim_Viewer(Element_To_Draw):
1208
1208
  if self.mapviewer.active_res2d.SelectionData.nb==0:
1209
1209
  wx.MessageBox(_("No point selected, please select a drowning point"), "Error", wx.OK | wx.ICON_ERROR)
1210
1210
  return
1211
-
1211
+
1212
1212
  elif self.mapviewer.active_res2d.SelectionData.nb==1:
1213
1213
  value_got = self.mapviewer.active_res2d.myblocks[getkeyblock(0)].SelectionData.myselection
1214
1214
  x,y = value_got[0]
@@ -1218,7 +1218,7 @@ class Drowning_victim_Viewer(Element_To_Draw):
1218
1218
  self.button_selection_progress.SetBackgroundColour(wx.Colour(50, 190, 50))
1219
1219
  self.file_drowning = 1
1220
1220
  return
1221
-
1221
+
1222
1222
  elif self.mapviewer.active_res2d.SelectionData.nb>1:
1223
1223
  wx.MessageBox(_("More than one point selected, please select only one drowning point"), "Error", wx.OK | wx.ICON_ERROR)
1224
1224
  return
@@ -1237,10 +1237,10 @@ class Drowning_victim_Viewer(Element_To_Draw):
1237
1237
  """
1238
1238
  import subprocess
1239
1239
  try:
1240
- if self.filedir is None:
1240
+ if self.filedir is None:
1241
1241
  wx.MessageBox(_("No directory selected for the simulation. \nPlease, save your drowning in a directory."), "Error", wx.OK | wx.ICON_ERROR)
1242
1242
  return
1243
-
1243
+
1244
1244
  self.filedir = Path(self.filedir)
1245
1245
  # Créer le répertoire self.Path_saving s'il n'existe pas
1246
1246
  self.filedir.mkdir(parents=True, exist_ok=True)
@@ -1299,7 +1299,7 @@ if __name__ == "__main__":
1299
1299
 
1300
1300
  self.wp._set_gui(title='Parameters for the drowning simulation', toShow=True, w=self.w)
1301
1301
  self.wp.hide_selected_buttons([Buttons.Reload,Buttons.Save])
1302
-
1302
+
1303
1303
  select_button = wx.Button(self.wp,id=10,label="Wolf2D simulation")
1304
1304
  select_button.SetToolTip(_("Select reference Wolf2D simulation to choose your drowning point"))
1305
1305
  create_file_button = wx.Button(self.wp,id=11,label="Create exe file")
@@ -1435,7 +1435,7 @@ if __name__ == "__main__":
1435
1435
 
1436
1436
  else:
1437
1437
  self.wp.Save(self.filename)
1438
-
1438
+
1439
1439
  def saveas(self):
1440
1440
  '''
1441
1441
  Save the parameters in a text file
@@ -1448,14 +1448,14 @@ if __name__ == "__main__":
1448
1448
  self.Path_saving = self.filedir
1449
1449
  self.wp.change_param("Paths","Save path",self.filedir)
1450
1450
  self.save()
1451
-
1451
+
1452
1452
  fdlg.Destroy()
1453
1453
 
1454
1454
  def load_results(self):
1455
1455
  """
1456
1456
  Load the results from the 'Results.npz' file and assign the arrays as attributes of the class.
1457
1457
  """
1458
-
1458
+
1459
1459
  # Construire le chemin du fichier Results.npz
1460
1460
  results_file = join(self.filedir, 'Results.npz')
1461
1461
 
@@ -1495,7 +1495,7 @@ if __name__ == "__main__":
1495
1495
  """
1496
1496
  Read one result of the simulation and update the parameters in the GUI
1497
1497
  """
1498
-
1498
+
1499
1499
  count=0
1500
1500
 
1501
1501
  self.time_id = idx
@@ -1521,11 +1521,11 @@ if __name__ == "__main__":
1521
1521
  """
1522
1522
 
1523
1523
  self.time_id = -1
1524
-
1524
+
1525
1525
  self.read_oneresult(idx=-1)
1526
1526
 
1527
1527
  return
1528
-
1528
+
1529
1529
  def find_minmax(self, update=False):
1530
1530
  """
1531
1531
  Generic function to find min and max spatial extent in data
@@ -1572,7 +1572,7 @@ if __name__ == "__main__":
1572
1572
  self.ymin = min(self.ymin, self.vertex_bottom_run.ymin)
1573
1573
  self.ymax = max(self.ymax, self.vertex_bottom_run.ymax)
1574
1574
  if self.vertex_surface_run is not None:
1575
- self.vertex_surface_run.find_minmax(update)
1575
+ self.vertex_surface_run.find_minmax(update)
1576
1576
  self.xmin = min(self.xmin, self.vertex_surface_run.xmin)
1577
1577
  self.xmax = max(self.xmax, self.vertex_surface_run.xmax)
1578
1578
  self.ymin = min(self.ymin, self.vertex_surface_run.ymin)
@@ -1605,7 +1605,7 @@ if __name__ == "__main__":
1605
1605
  if self.vertex_bottom_run is not None:
1606
1606
  self.vertex_bottom_run.plot()
1607
1607
  if self.vertex_surface_run is not None:
1608
- self.vertex_surface_run.plot()
1608
+ self.vertex_surface_run.plot()
1609
1609
 
1610
1610
  self.plotting = False
1611
1611
 
@@ -1651,7 +1651,7 @@ if __name__ == "__main__":
1651
1651
  self.vertex_bottom_run = None
1652
1652
  self.vertex_surface_run = None
1653
1653
  self.plot_runs = None
1654
-
1654
+
1655
1655
  def kde_on_grid(self,points, bandwidth, xmin, xmax, ymin, ymax, grid_size):
1656
1656
  """
1657
1657
  Function used to calculate the kde on a point cloud. Use a large grid size to identify peaks and a small one to refine
@@ -1814,7 +1814,7 @@ if __name__ == "__main__":
1814
1814
  values_array = np.concatenate(all_values) if all_values else np.array([])
1815
1815
 
1816
1816
  return coords_array,values_array
1817
-
1817
+
1818
1818
  def prepare_plot_kde(self):
1819
1819
  """
1820
1820
  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.
@@ -1823,7 +1823,7 @@ if __name__ == "__main__":
1823
1823
  self.plot_KDE = 1
1824
1824
 
1825
1825
  self.n_peaks = 2
1826
-
1826
+
1827
1827
  ind_bottom,ind_surface,time_id = self.sort_positions_bodies()
1828
1828
 
1829
1829
  head = header_wolf()
@@ -1836,9 +1836,9 @@ if __name__ == "__main__":
1836
1836
  self.bottom_kde = WolfArray(mapviewer=self.mapviewer, srcheader= head, nullvalue= 0.)
1837
1837
  self.surface_kde = WolfArray(mapviewer=self.mapviewer, srcheader= head, nullvalue= 0.)
1838
1838
 
1839
- for locarray, locind in zip([self.bottom_kde, self.surface_kde],
1839
+ for locarray, locind in zip([self.bottom_kde, self.surface_kde],
1840
1840
  [ind_bottom, ind_surface]):
1841
-
1841
+
1842
1842
  xy = self.Pos_b[locind,:2,time_id]
1843
1843
  coords,values = self.kde_refined_based_coarse(xy,locarray,bandwidth=50,coarse_grid_size=200,fine_grid_size=5,window_size=50,radius=25,n_peaks=self.n_peaks)
1844
1844
 
@@ -1853,7 +1853,7 @@ if __name__ == "__main__":
1853
1853
  self.surface_kde.reset_plot()
1854
1854
 
1855
1855
  return
1856
-
1856
+
1857
1857
  def reset_plot_kde(self):
1858
1858
  self.bottom_kde = None
1859
1859
  self.surface_kde = None
@@ -1877,7 +1877,7 @@ if __name__ == "__main__":
1877
1877
  self.bottom_cells = WolfArray(mapviewer=self.mapviewer, srcheader= head, nullvalue= 0.)
1878
1878
  self.surface_cells = WolfArray(mapviewer=self.mapviewer, srcheader= head, nullvalue= 0.)
1879
1879
 
1880
- for locarray, locind in zip([self.bottom_cells, self.surface_cells],
1880
+ for locarray, locind in zip([self.bottom_cells, self.surface_cells],
1881
1881
  [ind_bottom, ind_surface]):
1882
1882
 
1883
1883
  # i_bottom,j_bottom = self.bottom_cells.get_ij_from_xy_array(self.Pos_b[ind_bottom,:2,time_id])
@@ -1905,7 +1905,7 @@ if __name__ == "__main__":
1905
1905
 
1906
1906
  self.bottom_cells.reset_plot()
1907
1907
  self.surface_cells.reset_plot()
1908
-
1908
+
1909
1909
  return
1910
1910
 
1911
1911
  def reset_plot_cells_positions(self):
@@ -1930,7 +1930,7 @@ if __name__ == "__main__":
1930
1930
 
1931
1931
  for locxy,locname in zip(xy_peaks,names):
1932
1932
  xmin = locxy[0] - delta
1933
- xmax = locxy[0] + delta
1933
+ xmax = locxy[0] + delta
1934
1934
  ymin = locxy[1] - delta
1935
1935
  ymax = locxy[1] + delta
1936
1936
 
@@ -1952,7 +1952,7 @@ if __name__ == "__main__":
1952
1952
  self.grid.ShowModal()
1953
1953
  self.grid.Destroy()
1954
1954
 
1955
- return
1955
+ return
1956
1956
 
1957
1957
  def get_vertical_position_proportion(self):
1958
1958
  """
@@ -1981,7 +1981,7 @@ if __name__ == "__main__":
1981
1981
  counts = [len(surface)/self.newdrowning.n_b*100, len(bottom)/self.newdrowning.n_b*100]
1982
1982
  labels = ['Surface', 'Bottom']
1983
1983
  colors = [[1,0.7,0.6,1], [0.6,0.7,1,1]]
1984
-
1984
+
1985
1985
  ax.pie(counts, labels=labels, colors=colors, autopct='%1.1f%%')
1986
1986
 
1987
1987
  # Rafraîchissement du graphique
@@ -1989,7 +1989,7 @@ if __name__ == "__main__":
1989
1989
 
1990
1990
  # Initialisation de la figure et des axes
1991
1991
  fig, ax = plt.subplots()
1992
-
1992
+
1993
1993
  time_idx_initial = 0
1994
1994
  z = self.Pos_b[:,2,time_idx_initial]
1995
1995
 
@@ -1999,7 +1999,7 @@ if __name__ == "__main__":
1999
1999
  counts = [len(surface)/self.newdrowning.n_b*100, len(bottom)/self.newdrowning.n_b*100]
2000
2000
  labels = ['Surface', 'Bottom']
2001
2001
  colors = [[1,0.7,0.6,1], [0.6,0.7,1,1]]
2002
-
2002
+
2003
2003
  ax.pie(counts, labels=labels, colors=colors, autopct='%1.1f%%')
2004
2004
 
2005
2005
  # Création du slider pour ajuster l'indice temporel
@@ -2084,7 +2084,7 @@ class ProgressImage(wx.Frame):
2084
2084
 
2085
2085
  # Initialize a 2D list to hold each segment for each process
2086
2086
  self.image_segments = []
2087
-
2087
+
2088
2088
  # Create a grid of segments for each process
2089
2089
  for row in range(total_segments):
2090
2090
  row_segments = []
@@ -2093,13 +2093,13 @@ class ProgressImage(wx.Frame):
2093
2093
  x = col * segment_width
2094
2094
  y = row * segment_height
2095
2095
  segment = image.GetSubImage((x, y, segment_width, segment_height))
2096
-
2096
+
2097
2097
  # Create a bitmap for the segment and add it to the grid, initially hidden
2098
2098
  segment_bitmap = wx.StaticBitmap(panel, bitmap=wx.Bitmap(segment))
2099
2099
  segment_bitmap.Hide() # Hide initially; show as progress advances
2100
2100
  grid_sizer.Add(segment_bitmap, flag=wx.ALIGN_CENTER)
2101
2101
  row_segments.append(segment_bitmap)
2102
-
2102
+
2103
2103
  self.image_segments.append(row_segments)
2104
2104
 
2105
2105
  panel.SetSizer(grid_sizer)
@@ -2114,7 +2114,7 @@ class ProgressImage(wx.Frame):
2114
2114
  if progress is not None:
2115
2115
  # Calculate the number of segments to show based on progress
2116
2116
  num_segments_to_show = int((progress / self.total) * (self.total_segments // self.n_processes))
2117
-
2117
+
2118
2118
  # Show the segments that correspond to the current progress
2119
2119
  for segment_id in range(num_segments_to_show):
2120
2120
  self.image_segments[segment_id][process_id].Show()
@@ -2122,44 +2122,3 @@ class ProgressImage(wx.Frame):
2122
2122
  # Refresh the layout after updating visibility
2123
2123
  self.Layout()
2124
2124
  self.Refresh()
2125
-
2126
-
2127
-
2128
-
2129
-
2130
-
2131
-
2132
-
2133
-
2134
-
2135
-
2136
-
2137
-
2138
-
2139
-
2140
-
2141
-
2142
-
2143
-
2144
-
2145
-
2146
-
2147
-
2148
-
2149
-
2150
-
2151
-
2152
-
2153
-
2154
-
2155
-
2156
-
2157
-
2158
-
2159
-
2160
-
2161
-
2162
-
2163
-
2164
-
2165
-