wolfhece 2.0.16__py3-none-any.whl → 2.0.18__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.
Files changed (39) hide show
  1. wolfhece/CpGrid.py +10 -13
  2. wolfhece/PyCrosssections.py +18 -13
  3. wolfhece/PyHydrographs.py +2 -2
  4. wolfhece/PyParams.py +15 -27
  5. wolfhece/PyPictures.py +48 -45
  6. wolfhece/PyVertexvectors.py +14 -19
  7. wolfhece/apps/curvedigitizer.py +4 -1
  8. wolfhece/apps/wolfcompare2Darrays.py +11 -7
  9. wolfhece/clientserver/clientserver.py +62 -0
  10. wolfhece/friction_law.py +39 -34
  11. wolfhece/ftp/downloader.py +8 -7
  12. wolfhece/gpuview.py +14 -13
  13. wolfhece/hydrology/Catchment.py +2 -2
  14. wolfhece/hydrology/PyWatershed.py +2 -2
  15. wolfhece/hydrology/SubBasin.py +13 -11
  16. wolfhece/hydrometry/kiwis_gui.py +9 -9
  17. wolfhece/irm_qdf.py +12 -10
  18. wolfhece/mar/Interface_MAR_WOLF_objet.py +260 -161
  19. wolfhece/opengl/py3d.py +231 -16
  20. wolfhece/pyshields.py +4 -4
  21. wolfhece/pythonfortran/example_makendarray.py +46 -41
  22. wolfhece/pythonfortran/example_numpy_memory.py +87 -83
  23. wolfhece/pythonfortran/tools.py +1 -1
  24. wolfhece/scenario/imposebc_void.py +2 -3
  25. wolfhece/scenario/update_void.py +6 -6
  26. wolfhece/wolf_array.py +17 -16
  27. wolfhece/wolfresults_2D.py +2 -4
  28. {wolfhece-2.0.16.dist-info → wolfhece-2.0.18.dist-info}/METADATA +7 -1
  29. {wolfhece-2.0.16.dist-info → wolfhece-2.0.18.dist-info}/RECORD +33 -38
  30. wolfhece/apps/wolfBernoulli.py +0 -18
  31. wolfhece/bernoulli/ModelJockgrim.py +0 -226
  32. wolfhece/bernoulli/NetworkOpenGL.py +0 -6461
  33. wolfhece/bernoulli/ReadNeupotzData.py +0 -223
  34. wolfhece/bernoulli/opti_results_interactive_plot.py +0 -212
  35. wolfhece/debug.py +0 -8
  36. /wolfhece/{bernoulli → clientserver}/__init__.py +0 -0
  37. {wolfhece-2.0.16.dist-info → wolfhece-2.0.18.dist-info}/WHEEL +0 -0
  38. {wolfhece-2.0.16.dist-info → wolfhece-2.0.18.dist-info}/entry_points.txt +0 -0
  39. {wolfhece-2.0.16.dist-info → wolfhece-2.0.18.dist-info}/top_level.txt +0 -0
@@ -1,223 +0,0 @@
1
-
2
- def Read_File(filename,filename_out,filename_resume,filename_period,Aggreg_Hours):
3
- #out_file = open(filename_out,'w')
4
- file = open(filename,'r')
5
- file_out = open(filename_out,'w')
6
- Value_Q=[]
7
- Value_Hour=[]
8
- cpt_val=0
9
- First_NewDay=0
10
- Good_Period=True
11
- Cur_Value=0
12
- for New_Word in file:
13
- #Extraction des différentes données utiles : heure, valeurs
14
- New_Word=New_Word.split()
15
- #Selon numéro de l'élément, on sait ce que cela représente
16
- #Analyse pour extraire minutes
17
- if(bool(New_Word)):
18
- Day=New_Word[0].split('.')
19
- Date=New_Word[1].split(':')
20
- Hour=int(Date[0])
21
- Hour_f=float(Date[0])
22
- New_Word[4]=New_Word[4].replace(",", ".")
23
- if(Day[2]=='2020' and Day[1]=='01' and Day[0]=='09' and Hour>12):
24
- Good_Period=False
25
- New_Improve=True
26
- if(Good_Period):
27
- New_Value=float(New_Word[4])
28
- #if(New_Value<-5):
29
- # New_Value=Cur_Value
30
- if(cpt_val>0):
31
- New_Day=int(Date[0])
32
- New_Minute=int(Date[1])
33
- if(New_Day==Old_Day):
34
- Diff_Day=New_Minute-Old_Minute
35
- else:
36
- Old_Minute=60-Old_Minute
37
- Diff_Day=Old_Minute+New_Minute
38
- Old_Day=New_Day
39
- if(First_NewDay==0):
40
- Hour_Val=int(Date[0])
41
- if(Hour_Val==0):
42
- PosNewDay=len(Value_Q) #On commence le comptage au début de la première nouvelle journée
43
- First_NewDay=1
44
- else:
45
- if(First_NewDay==1):
46
- PosLastDay=len(Value_Q)
47
- if(PosLastDay==1037):
48
- Test=1
49
- DiffDay=PosLastDay-PosNewDay
50
- Mod=DiffDay%60
51
- if(Mod>0):
52
- Test=1
53
- if(Diff_Day==1):
54
- Value_Q.append(New_Value)
55
- Value_Hour.append(Hour_f)
56
- Cur_Value=New_Value
57
- else:
58
- Added_V=(Cur_Value+New_Value)/2.0
59
- New_Improve=False
60
- for Min in range(Diff_Day):
61
- Sentence=Day[0]+','+Day[1]+','+Date[0]+','+Date[1]+','+New_Word[4]+'\n'
62
- file_out.write(Sentence)
63
- Value_Q.append(Cur_Value)
64
- Value_Hour.append(Hour_f)
65
- Old_Minute=New_Minute
66
-
67
- else:
68
- Value_Q.append(New_Value)
69
- Value_Hour.append(Hour_f)
70
- Old_Minute=int(Date[1])
71
- Old_Day=int(Date[0])
72
- Cur_Value=New_Value
73
-
74
- cpt_val+=1
75
- if(New_Improve):
76
- Sentence=Day[0]+','+Day[1]+','+Date[0]+','+Date[1]+','+New_Word[4]+'\n'
77
- file_out.write(Sentence)
78
- file.close()
79
- file_out.close()
80
- IERR=0
81
- #On va analyser le nombre de journées : on commence première journée à minuit pour terminer aussi à minuit
82
- NbHour=(PosLastDay-PosNewDay)/60
83
- Mod=NbHour%24
84
- NbElem=Mod*60
85
- PosLastDay=PosLastDay-NbElem
86
- NbHour=int((PosLastDay-PosNewDay)/60)
87
- NbDays=int(NbHour/24)
88
- #On évalue alors l'évolution des données selon durée choisie par l'utilisateur
89
- Nb_Period=int((PosLastDay-PosNewDay)/Time)
90
-
91
- ID_Pos=PosNewDay
92
- Value_P=[]
93
- Period_P=[]
94
- Period_Hour=[]
95
- Pos_P=[]
96
- filename_period=filename_period+str(Time)+'min.txt'
97
- file_out = open(filename_period,'w')
98
- cpt_pos=0
99
- Prev_P=0
100
- for Id_Period in range(Nb_Period):
101
- Moy_P=sum(Value_Q[ID_Pos:ID_Pos+Time])/Time
102
- Moy_Hour=sum(Value_Hour[ID_Pos:ID_Pos+Time])/Time
103
- #Certaines données incohérentes sont observées durant la nuit : on vient donc évaluer plutôt récupérer une valeur précédente
104
- if(cpt_pos==2455):
105
- Test=2
106
- if(Moy_P<-5):
107
- Moy_P=Prev_P
108
- Test=1
109
- Value_P.append(Moy_Hour)
110
- Prev_P=Moy_P
111
- #On exporte la valeur à chaque nouvelle période de temps
112
- Sum_P=Moy_P*Time
113
- #Sum_Hour=Moy_Hour*Time
114
- cpt_pos+=1
115
- Period_P.append(Sum_P)
116
- Pos_P.append(ID_Pos)
117
- #Period_Hour.append(Sum_Hour)
118
- ID_Pos+=Time
119
- Sentence=str(Sum_P)+'\n'
120
- file_out.write(Sentence)
121
-
122
- file_out.close()
123
- #On évalue ensuite la variance selon chaque période
124
- ID_Pos=PosNewDay
125
- STD_P=[]
126
- for Id_Period in range(Nb_Period):
127
- Var_P=0
128
- for El in range(Time):
129
- Var_P+=(Value_Q[ID_Pos+El]-Value_P[Id_Period])**2.0/float(Time)
130
- Var_P=Var_P**0.5
131
- ID_Pos+=Time
132
- STD_P.append(Var_P)
133
- #On va également obtenir la distribution selon la journée
134
- Nb_Elem=int(60*24/Time)
135
- Elem_Var=[]
136
- for ID_Elem in range(Nb_Elem):
137
- Elem_Var.append([])
138
- for ID_Day in range(NbDays):
139
- for ID_Elem in range(Nb_Elem):
140
- Elem_Var[ID_Elem].append(Value_P[ID_Elem+ID_Day*Nb_Elem])
141
- Test=1
142
- Test=1
143
- #On trie les listes
144
- for ID_Elem in range(Nb_Elem):
145
- Elem_Var[ID_Elem]=sorted(Elem_Var[ID_Elem])
146
- #On vient récupérer valeur médiane
147
- Perc=[0.5,0.05,0.95]
148
- PosEl=[]
149
- for Position in Perc:
150
- PosEl.append(int(Position*NbDays))
151
- Val_El=[]
152
- filename_resume=filename_resume+str(Time)+'min.txt'
153
- file = open(filename_resume,'w')
154
- for ID_Elem in range(Nb_Elem):
155
- Mean_Val=sum(Elem_Var[ID_Elem])/NbDays
156
- Val_El.append([])
157
- Val_El[ID_Elem].append(Mean_Val)
158
- Sentence=str(Mean_Val)
159
- for Perc_Pos in PosEl:
160
- Val_El[ID_Elem].append(Elem_Var[ID_Elem][Perc_Pos])
161
- Sentence+=','
162
- Sentence+=str(Elem_Var[ID_Elem][Perc_Pos])
163
- Sentence+='\n'
164
- file.write(Sentence)
165
- file.write(Sentence)
166
- file.close()
167
- return Period_P,Value_P,Pos_P
168
-
169
- def Write_File_Demand(file_demand,Period_Neupotz,Period_Leimer,Period_Hour,Pos_Period,Time):
170
- file_demand1=file_demand+str(Time)+'min.txt'
171
- file_out = open(file_demand1,'w')
172
- file_demand2=file_demand+'Neupotz_Upd_'+str(Time)+'min.txt'
173
- file_out2 = open(file_demand2,'w')
174
- file_demand3=file_demand+'LeimerUpd_'+str(Time)+'min.txt'
175
- file_out3 = open(file_demand3,'w')
176
- file_demand4=file_demand+'Bad_Period.txt'
177
- file_out4 = open(file_demand4,'w')
178
- Bad_Periods=0 #Period where the water demand that is available is lower than 0
179
- Bad_Periods2=0
180
- for ID_Period in range(len(Period_Neupotz)):
181
- Avail_Water=Period_Neupotz[ID_Period]+Period_Leimer[ID_Period]
182
- if(Avail_Water<0):
183
- Bad_Periods+=1
184
- if(Period_Hour[ID_Period]>7 and Period_Hour[ID_Period]<22):
185
- Test=3
186
- Bad_Periods2+=1
187
- #On vient assurer la continuité
188
- Period_Neupotz[ID_Period]=Period_Neupotz[ID_Period]-Avail_Water/2
189
- Period_Leimer[ID_Period]=Period_Leimer[ID_Period]-Avail_Water/2
190
- Sentence4=str(Period_Hour[ID_Period])+str(Pos_Period[ID_Period])+'\n'
191
- Avail_Water=0
192
- file_out4.write(Sentence4)
193
-
194
- Sentence=str(Avail_Water)+'\n'
195
- Sentence2=str(Period_Neupotz[ID_Period])+'\n'
196
- Sentence3=str(Period_Leimer[ID_Period])+'\n'
197
- file_out.write(Sentence)
198
- file_out2.write(Sentence2)
199
- file_out3.write(Sentence3)
200
- file_out.close()
201
- file_out2.close()
202
- file_out3.close()
203
- file_out4.close()
204
- IERR=0
205
- return IERR
206
-
207
- #Analyse injection Neupotz
208
- filename='D:\\PIRARD_Thomas\\Reseau_Jockgrim\\FlowmetersData\\FlowSensorData\\NeupotzData.txt'
209
- filename_out='D:\\PIRARD_Thomas\\Reseau_Jockgrim\\FlowmetersData\\FlowSensorData\\NeupotzData_Improved.txt'
210
- filename_resume='D:\\PIRARD_Thomas\\Reseau_Jockgrim\\FlowmetersData\\FlowSensorData\\Neupotz_Resume_'
211
- filename_period='D:\\PIRARD_Thomas\\Reseau_Jockgrim\\FlowmetersData\\FlowSensorData\\Neupotz_Periods_'
212
- Time=60
213
- Period_Neupotz,Period_Hour_Neupotz,Pos_Period_Neu=Read_File(filename,filename_out,filename_resume,filename_period,Time)
214
- #Analyse injection Leimer
215
- filename='D:\\PIRARD_Thomas\\Reseau_Jockgrim\\FlowmetersData\\FlowSensorData\\LeimerData.txt'
216
- filename_out='D:\\PIRARD_Thomas\\Reseau_Jockgrim\\FlowmetersData\\FlowSensorData\\LeimerData_Improved.txt'
217
- filename_resume='D:\\PIRARD_Thomas\\Reseau_Jockgrim\\FlowmetersData\\FlowSensorData\\Leimer_Resume_'
218
- filename_period='D:\\PIRARD_Thomas\\Reseau_Jockgrim\\FlowmetersData\\FlowSensorData\\Leimer_Periods_'
219
- Period_Leimer,Period_Hour_Leimer,Pos_Period_Lei=Read_File(filename,filename_out,filename_resume,filename_period,Time)
220
- #Récupération information sur eau disponible sur utilisateurs
221
- file_demand='D:\\PIRARD_Thomas\\Reseau_Jockgrim\\FlowmetersData\\FlowSensorData\\Demand_Periods_'
222
- IERR=Write_File_Demand(file_demand,Period_Neupotz,Period_Leimer,Period_Hour_Neupotz,Pos_Period_Lei,Time)
223
- Test=1
@@ -1,212 +0,0 @@
1
- # %% Libraries
2
- import sys
3
- import csv
4
- import numpy as np
5
- import matplotlib.pyplot as plt
6
- # Import slider package
7
- from matplotlib.widgets import Slider
8
-
9
- # ===================================================================================
10
- # PARAMETERS
11
- # ===================================================================================
12
-
13
-
14
- # %% Parameters
15
-
16
- # Parameter to display -> TO CHANGE BEFORE SIMULATION
17
- # 0: X1, 1: X2, 2: X3, 3: X4
18
- id1_fixed = 0 # parameter to tune 1
19
- id2_fixed = 3 # parameter to tune 2
20
- id1 = 1 # parameter on the x axis
21
- id2 = 2 # parameter on the y axis
22
-
23
-
24
- # File name
25
- # dirName = "F:/Christophe/Simulations/Optimisation/Screening_GR4/10_13/"
26
- #dir_path = os.path.dirname(os.path.realpath(__file__))
27
- #dirName = dir_path + "/Opti_GR4_25Params/"
28
- dirName = "D:/PIRARD_Thomas/Opti_GR4_25Params/"
29
- fileName = "example.rpt"
30
-
31
- # Nomber of parameters
32
- nbParams = 4
33
-
34
- # Steps for each parameter
35
- dx1 = 3
36
- dx2 = 0.2
37
- dx3 = 8
38
- dx4 = 1.6
39
- dx = [dx1, dx2, dx3, dx4]
40
-
41
- # Range for each parameter
42
- p_min = [75, -5, 100, 10]
43
- p_max = [150, 0, 300, 45]
44
-
45
- # Label of parameters
46
- my_labels = ["X1 [mm]", "X2 [mm/hour]", "X3 [mm]", "X4 [hour]"]
47
- my_labelsSlider = ["X1 ", "X2 ", "X3 ", "X4 "]
48
- my_valfmt = ["%3.1f [mm]", "%1.1f [mm/hour]", "%3.1f [mm]", "%2.1f [hour]"]
49
-
50
- # Number of simulations
51
- nbSimul = 13
52
-
53
-
54
-
55
-
56
-
57
-
58
- # ===================================================================================
59
- # FUNCTIONS
60
- # ===================================================================================
61
-
62
- def get_Nash(i1: int, P1: float, i2: int, P2: float, xi: int, yi:int) -> float:
63
- Dx = []
64
- for i in range(nbEl):
65
- if(matrixData[i][i1]==P1 and matrixData[i][i2]==P2):
66
- if Dx == []:
67
- Dx = [matrixData[i,:]]
68
- else:
69
- Dx = np.vstack([Dx, matrixData[i,:]])
70
-
71
- xMax = 0.0
72
- xMin = 0.0
73
- yMin = 0.0
74
- yMax = 0.0
75
-
76
- xMax = np.max(Dx[:,xi])
77
- xMin = np.min(Dx[:,xi])
78
- x = np.arange(xMin,xMax+dx[xi],dx[xi])
79
- yMin = np.min(Dx[:,yi])
80
- yMax = np.max(Dx[:,yi])
81
- y = np.arange(yMin,yMax+dx[yi],dx[yi])
82
-
83
- n = len(Dx[:,0])
84
- Nash = np.zeros((len(y),len(x)))
85
- for i in range(n):
86
- tmp_ix = (Dx[i][xi]-xMin)/dx[xi]
87
- tmp_iy = (Dx[i][yi]-yMin)/dx[yi]
88
- if(tmp_ix%1>0.00001 and tmp_ix%1<0.99999 and tmp_iy%1>0.00001 and tmp_iy%1<0.99999):
89
- print("Potential error, please check!")
90
- sys.exit()
91
- else:
92
- ix = int(round(tmp_ix))
93
- iy = int(round(tmp_iy))
94
- Nash[iy][ix] = Dx[i][4]
95
-
96
- return Nash, xMin,xMax,yMin,yMax
97
-
98
-
99
- # Update values
100
- def update(val):
101
- curX2 = round(s_X2.val,1)
102
- curX4 = round(s_X4.val,1)
103
- Nash,xMin,xMax,yMax,yMin = get_Nash(id1_fixed,curX2,id2_fixed,curX4,id1,id2)
104
- # f_d, = [ax.imshow(Nash, interpolation='None', extent=[xMin,xMax,yMax,yMin], aspect='auto')]
105
- # cbar.draw_all()
106
- # cbar = fig.colorbar(f_d,ax=ax)
107
- f_d.set_data(Nash)
108
- f_d.set_clim(vmin=Nash.min(), vmax=Nash.max())
109
- fig.canvas.draw_idle()
110
-
111
-
112
-
113
-
114
- # %% Reading of the file(s)
115
- list_data = []
116
- for simul in range(nbSimul):
117
- # data_reader = []
118
- fileAccess = dirName + str(simul+1) + "_" + str(nbSimul) + "/" + fileName
119
- with open(fileAccess, newline='') as fileID:
120
- data_reader = []
121
- data_reader = csv.reader(fileID,delimiter='|')
122
- i=0
123
- for raw in data_reader:
124
- if i>2:
125
- list_data.append(raw)
126
- i += 1
127
-
128
-
129
- nbEl = len(list_data[:]) - nbSimul # - nbSimul because the last line of each file is composed of only '*'
130
- matrixData = np.zeros((nbEl,nbParams+1))
131
- counter = 0
132
- for i in range(len(list_data[:])):
133
- if len(list_data[i]) != nbParams+1+3:
134
- if(len(list_data[i])==1 and list_data[i][0][0] == '*'):
135
- continue
136
- else:
137
- print("ERROR: Something went wrong with the number of elements in the input file!")
138
- sys.exit()
139
- for j in range(nbParams+1):
140
- matrixData[counter][j] = float(list_data[i][2+j].strip())
141
- counter += 1
142
-
143
-
144
- # %% Best parameters
145
- best_NS = np.max(matrixData[:,4])
146
- min_NS = np.min(matrixData[:,4])
147
- i_bNS = np.argmax(matrixData[:,4])
148
- i_mNS = np.argmin(matrixData[:,4])
149
- print("Best parameters : ", matrixData[i_bNS,:-1])
150
- print("Best Nash = ", matrixData[i_bNS,-1])
151
- bX1 = matrixData[i_bNS][0]
152
- bX2 = matrixData[i_bNS][1]
153
- bX3 = matrixData[i_bNS][2]
154
- bX4 = matrixData[i_bNS][3]
155
-
156
- best_param = [bX1, bX2, bX3, bX4]
157
-
158
-
159
- # %% ----- Interactive plot -----
160
-
161
- # %% Construct plane (X1,X3) with variable parameters X2 & X4
162
-
163
-
164
- # Create main axis
165
- fig = plt.figure(figsize=(6, 4))
166
- ax = fig.add_subplot(111)
167
- fig.subplots_adjust(bottom=0.2, top=0.75)
168
-
169
-
170
- # Create axes for sliders
171
-
172
- ax_T = fig.add_axes([0.3, 0.92, 0.4, 0.05])
173
- ax_T.spines['top'].set_visible(True)
174
- ax_T.spines['right'].set_visible(True)
175
-
176
- ax_Ef = fig.add_axes([0.3, 0.85, 0.4, 0.05])
177
- ax_Ef.spines['top'].set_visible(True)
178
- ax_Ef.spines['right'].set_visible(True)
179
-
180
-
181
-
182
- # Create sliders
183
- s_X2 = Slider(ax=ax_T, label=my_labelsSlider[id1_fixed], valmin=p_min[id1_fixed], valmax=p_max[id1_fixed], valstep=dx[id1_fixed],valinit=best_param[id1_fixed], valfmt=my_valfmt[id1_fixed], facecolor='#cc7000')
184
- s_X4 = Slider(ax=ax_Ef, label=my_labelsSlider[id2_fixed],valmin=p_min[id2_fixed], valmax=p_max[id2_fixed], valstep=dx[id2_fixed],valinit=best_param[id2_fixed], valfmt=my_valfmt[id2_fixed], facecolor='#cc7000')
185
-
186
-
187
- # Plot default data
188
- Nash = []
189
- # x = np.linspace(-0, 1, 100)
190
- X2_0 = best_param[id1_fixed]
191
- X4_0 = best_param[id2_fixed]
192
- Nash,xMin,xMax,yMax,yMin = get_Nash(id1_fixed,X2_0,id2_fixed,X4_0,id1,id2)
193
- # f_d, = ax.imshow(Nash, interpolation='None', extent=[xMin,xMax,yMax,yMin], aspect='auto')
194
- f_d, = [ax.imshow(Nash, interpolation='None', extent=[xMin,xMax,yMin,yMax], aspect='auto')]
195
- ax.set_xlabel(my_labels[id1])
196
- ax.set_ylabel(my_labels[id2])
197
- cbar = fig.colorbar(f_d,ax=ax)
198
- # f_d, = ax.plot(x, y, linewidth=2.5)
199
-
200
- s_X2.on_changed(update)
201
- s_X4.on_changed(update)
202
-
203
-
204
-
205
-
206
-
207
- plt.show()
208
-
209
- t=1
210
- # import pickle
211
- # pickle.dump(fig, open('FigureObject.fig.pickle', 'wb')) # This is for Python 3 - py2 may need `file` instead of `open`
212
-
wolfhece/debug.py DELETED
@@ -1,8 +0,0 @@
1
- from .PyVertex import wolfvertex
2
-
3
- my=wolfvertex(1.0,2.0,3.0)
4
- c=my.coords
5
-
6
- c[0]=3.
7
- d=my.coords
8
- print(my.x,c[0],d[0])
File without changes