wolfhece 2.1.16__py3-none-any.whl → 2.1.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.
wolfhece/PyDraw.py CHANGED
@@ -852,6 +852,13 @@ class WolfMapViewer(wx.Frame):
852
852
  # self.menu2d_bc = self.menuwolf2d.Append(wx.ID_ANY, _("Manage boundary conditions..."), _("BC manager"))
853
853
  self.menu2d_video = self.menuwolf2d.Append(wx.ID_ANY, _("Create video..."), _("Video/Movie"))
854
854
 
855
+ self.menuwolf2d.AppendSeparator()
856
+
857
+ self.menu2d_dangermap = self.menuwolf2d.Append(wx.ID_ANY, _("Danger map"), _("Compute the danger map"))
858
+ self.menu2d_dangermaph = self.menuwolf2d.Append(wx.ID_ANY, _("Danger map - only h"), _("Compute the danger map"))
859
+
860
+ self.menuwolf2d.AppendSeparator()
861
+
855
862
  self.menubar.Append(self.menuwolf2d, _('Results 2D'))
856
863
 
857
864
  self.menuwolf2d.Bind(wx.EVT_MENU, self.Onmenuwolf2d)
@@ -875,7 +882,12 @@ class WolfMapViewer(wx.Frame):
875
882
 
876
883
 
877
884
  def get_canvas_bounds(self, gridsize:float = None):
878
- """ Retourne les limites de la zone d'affichage """
885
+ """
886
+ Retourne les limites de la zone d'affichage
887
+
888
+ :return: [xmin, ymin, xmax, ymax]
889
+
890
+ """
879
891
 
880
892
  if gridsize is None:
881
893
 
@@ -1182,6 +1194,82 @@ class WolfMapViewer(wx.Frame):
1182
1194
  if self.active_res2d is not None:
1183
1195
  self.create_video()
1184
1196
 
1197
+ elif itemlabel == _("Danger map - only h"):
1198
+ if self.active_res2d is None:
1199
+ logging.warning(_('No active 2D result !'))
1200
+ return
1201
+
1202
+ with wx.NumberEntryDialog(None, _('Danger map'), _('From step'), _('Danger map'), 1, 1, self.active_res2d.get_nbresults()) as dlg:
1203
+
1204
+ if dlg.ShowModal() == wx.ID_CANCEL:
1205
+ return
1206
+
1207
+ start_step = dlg.GetValue()
1208
+
1209
+ with wx.NumberEntryDialog(None, _('Danger map'), _('To step'), _('Danger map'), self.active_res2d.get_nbresults(), start_step, self.active_res2d.get_nbresults()) as dlg:
1210
+
1211
+ if dlg.ShowModal() == wx.ID_CANCEL:
1212
+ return
1213
+
1214
+ end_step = dlg.GetValue()
1215
+
1216
+ with wx.NumberEntryDialog(None, _('Danger map'), _('Every'), _('Danger map'), 1, 1, 60) as dlg:
1217
+
1218
+ if dlg.ShowModal() == wx.ID_CANCEL:
1219
+ return
1220
+
1221
+ every = dlg.GetValue()
1222
+
1223
+ danger_map = self.active_res2d.danger_map_only_h(start_step-1, end_step-1, every)
1224
+
1225
+ with wx.DirDialog(None, _('Choose a directory'), style=wx.DD_DEFAULT_STYLE) as dlg:
1226
+
1227
+ if dlg.ShowModal() == wx.ID_CANCEL:
1228
+ return
1229
+
1230
+ outdir = dlg.GetPath()
1231
+
1232
+ danger_map.write_all(Path(outdir) / 'danger_h.tif')
1233
+
1234
+ elif itemlabel == _("Danger map"):
1235
+ if self.active_res2d is None:
1236
+ logging.warning(_('No active 2D result !'))
1237
+ return
1238
+
1239
+ with wx.NumberEntryDialog(None, _('Danger map'), _('From step'), _('Danger map'), 1, 1, self.active_res2d.get_nbresults()) as dlg:
1240
+
1241
+ if dlg.ShowModal() == wx.ID_CANCEL:
1242
+ return
1243
+
1244
+ start_step = dlg.GetValue()
1245
+
1246
+ with wx.NumberEntryDialog(None, _('Danger map'), _('To step'), _('Danger map'), self.active_res2d.get_nbresults(), start_step, self.active_res2d.get_nbresults()) as dlg:
1247
+
1248
+ if dlg.ShowModal() == wx.ID_CANCEL:
1249
+ return
1250
+
1251
+ end_step = dlg.GetValue()
1252
+
1253
+ with wx.NumberEntryDialog(None, _('Danger map'), _('Every'), _('Danger map'), 1, 1, 60) as dlg:
1254
+
1255
+ if dlg.ShowModal() == wx.ID_CANCEL:
1256
+ return
1257
+
1258
+ every = dlg.GetValue()
1259
+
1260
+ danger_maps = self.active_res2d.danger_map(start_step-1, end_step-1, every)
1261
+
1262
+ with wx.DirDialog(None, _('Choose a directory'), style=wx.DD_DEFAULT_STYLE) as dlg:
1263
+
1264
+ if dlg.ShowModal() == wx.ID_CANCEL:
1265
+ return
1266
+
1267
+ outdir = dlg.GetPath()
1268
+
1269
+ names = ['danger_h.tif', 'danger_u.tif', 'danger_q.tif']
1270
+ for name, danger_map in zip(names, danger_maps):
1271
+ danger_map.write_all(Path(outdir) / name)
1272
+
1185
1273
  elif itemlabel == _("Setup cache..."):
1186
1274
 
1187
1275
  if self.active_res2d is None:
@@ -2689,13 +2777,26 @@ class WolfMapViewer(wx.Frame):
2689
2777
  '2015': 'ORTHO_2015', '2016': 'ORTHO_2016', '2017': 'ORTHO_2017',
2690
2778
  '2018': 'ORTHO_2018', '2019': 'ORTHO_2019', '2020': 'ORTHO_2020',
2691
2779
  '2021': 'ORTHO_2021', '2022 printemps': 'ORTHO_2022_PRINTEMPS', '2022 été': 'ORTHO_2022_ETE',
2692
- '2023 été': 'ORTHO_2023_ETE'}}
2780
+ '2023 été': 'ORTHO_2023_ETE',
2781
+ }}
2782
+ data_2021 = {'EAU': {'IDW': 'ZONES_INONDEES_IDW',
2783
+ 'Emprise': 'ZONES_INONDEES',
2784
+ 'Emprise wo Alea': 'ZONES_INONDEES_wo_alea'}}
2785
+
2693
2786
  for idx, (k, item) in enumerate(orthos.items()):
2694
2787
  for kdx, (m, subitem) in enumerate(item.items()):
2695
2788
  self.add_object(which='wmsback',
2696
2789
  newobj=imagetexture('PPNC', m, k, subitem,
2697
2790
  self, xmin, xmax, ymin, ymax, -99999, 1024),
2698
2791
  ToCheck=False, id='PPNC ' + m)
2792
+
2793
+ for idx, (k, item) in enumerate(data_2021.items()):
2794
+ for kdx, (m, subitem) in enumerate(item.items()):
2795
+ self.add_object(which='wmsback',
2796
+ newobj=imagetexture('PPNC', m, k, subitem,
2797
+ self, xmin, xmax, ymin, ymax, -99999, 1024),
2798
+ ToCheck=False, id='Data 2021 ' + m)
2799
+
2699
2800
  self.add_object(which='wmsback',
2700
2801
  newobj=imagetexture('PPNC', 'Orthos France', 'OI.OrthoimageCoverage.HR', '',
2701
2802
  self, xmin, xmax, ymin, ymax, -99999, 1024, France=True, epsg='EPSG:27563'),
@@ -5511,7 +5612,7 @@ class WolfMapViewer(wx.Frame):
5511
5612
  Add object to current Frame/Drawing area
5512
5613
  """
5513
5614
 
5514
- filterArray = "bin (*.bin)|*.bin|Elevation WOLF2D (*.top)|*.top|Geotif (*.tif)|*.tif|Float ESRI (*.flt)|*.flt|Numpy (*.npy)|*.npy|Numpy named arrays(*.npz)|*.npz|all (*.*)|*.*"
5615
+ filterArray = "All supported formats|*.bin;*.tif;*.tiff;*.top;*.flt;*.npy;*.npz|bin (*.bin)|*.bin|Elevation WOLF2D (*.top)|*.top|Geotif (*.tif)|*.tif|Float ESRI (*.flt)|*.flt|Numpy (*.npy)|*.npy|Numpy named arrays(*.npz)|*.npz|all (*.*)|*.*"
5515
5616
  filterjson = "json (*.json)|*.json|all (*.*)|*.*"
5516
5617
  filterall = "all (*.*)|*.*"
5517
5618
  filterres2d = "all (*.*)|*.*"
@@ -3,6 +3,9 @@ import wx
3
3
  from .PyTranslate import _
4
4
  from .PyDraw import WolfMapViewer
5
5
  from .RatingCurve import *
6
+ from.PyVertexvectors import vector, Zones, zone, getIfromRGB, getRGBfromI
7
+
8
+ import logging
6
9
 
7
10
 
8
11
  class selectpoint(wx.Frame):
@@ -112,32 +115,62 @@ class selectpoint(wx.Frame):
112
115
 
113
116
 
114
117
  class GuiHydrology(WolfMapViewer):
118
+ """ Mapviewer of the hydrology model -- see HydrologyModel in PyGui.py """
119
+
120
+ def __init__(self, parent=None, title='WOLF Hydrological model - viewer', w=500, h=500, treewidth=200, wolfparent=None, wxlogging=None):
121
+ """ Constructor
122
+
123
+ :param parent: parent window - wx.Frame
124
+ :param title: title of the window - str
125
+ :param w: width of the window - int
126
+ :param h: height of the window - int
127
+ :param treewidth: width of the tree - int
128
+ :param wolfparent: wolf parent instance -- PyGui.HydrologyModel
129
+ :type wolfparent: HydrologyModel
130
+ :param wxlogging: logging instance -- PyGui.WolfLog
131
+ """
115
132
 
116
- def __init__(self, parent=None, title='MyForm', w=500, h=500, treewidth=200, wolfparent=None, wxlogging=None):
117
133
  super(GuiHydrology, self).__init__(parent, title=title, w=w, h=h,
118
- treewidth=treewidth, wolfparent=wolfparent,wxlogging=wxlogging)
134
+ treewidth=treewidth,
135
+ wolfparent=wolfparent,
136
+ wxlogging=wxlogging)
119
137
 
120
- self.parent = parent
138
+ from .PyGui import HydrologyModel
121
139
 
122
- self.filemenu.Insert(0, 1100, _('New from scratch'), _('Create a new simulation from scratch...'))
140
+ self.wolfparent:HydrologyModel
123
141
 
124
- self.toolsmenu = wx.Menu()
125
- self.toolsmenu.Append(1200, _('Forced exchanges'), _('Manage the forced exchanges...'))
126
- self.toolsmenu.Append(1201, _('Crop MNT/MNS'), _('Cropping data...'))
127
- self.toolsmenu.Append(1202, _('Crop land use (COSW)'), _('Cropping data...'))
128
- self.toolsmenu.Append(1205, _('Analyze slope'), _('Slope analyzer...'))
129
- self.toolsmenu.Append(1203, _('IRM - QDF'), _('Manage data...'))
130
- self.toolsmenu.Append(1204, _('SPW - Hydrometry'), _('Manage data...'))
131
- self.menubar.Append(self.toolsmenu, _('&Tools'))
142
+ # self.filemenu.Insert(0, wx.ID_ANY, _('New from scratch'), _('Create a new simulation from scratch...'))
132
143
 
133
144
  self.modelmenu = wx.Menu()
134
- paramgen = self.modelmenu.Append(1500, _('New'), _('Wizard !'))
135
- paramgen = self.modelmenu.Append(1501, _('Interior points'), _('Interior points'))
136
- paramgen = self.modelmenu.Append(1502, _('Topology'), _('Topology manager'))
137
- paramgen = self.modelmenu.Append(1503, _('Main model'), _('General parameters'))
138
- paramgen = self.modelmenu.Append(1504, _('Basin'), _('Basin parameters'))
139
- paramgen = self.modelmenu.Append(1505, _('Subbasins'), _('Sub-Basin parameters'))
140
- self.menubar.Append(self.modelmenu, _('&Model'))
145
+ paramgen = self.modelmenu.Append(wx.ID_ANY, _('Choose outlet'), _('Wizard !'))
146
+ paramgen = self.modelmenu.Append(wx.ID_ANY, _('Interior points'), _('Interior points'))
147
+ paramgen = self.modelmenu.Append(wx.ID_ANY, _('Topology'), _('Topology manager'))
148
+ paramgen = self.modelmenu.Append(wx.ID_ANY, _('Main model'), _('General parameters'))
149
+ paramgen = self.modelmenu.Append(wx.ID_ANY, _('Basin'), _('Basin parameters'))
150
+ paramgen = self.modelmenu.Append(wx.ID_ANY, _('Subbasins'), _('Sub-Basin parameters'))
151
+ self.menubar.Append(self.modelmenu, _('&Hydrological model'))
152
+
153
+ self.toolsmenu = wx.Menu()
154
+ self.toolsmenu.Append(wx.ID_ANY, _('Forced exchanges'), _('Manage the forced exchanges...'))
155
+ self.toolsmenu.Append(wx.ID_ANY, _('Crop MNT/MNS'), _('Cropping data...'))
156
+ self.toolsmenu.Append(wx.ID_ANY, _('Crop land use (COSW)'), _('Cropping data...'))
157
+ self.toolsmenu.Append(wx.ID_ANY, _('Analyze slope'), _('Slope analyzer...'))
158
+ self.toolsmenu.Append(wx.ID_ANY, _('IRM - QDF'), _('Manage data...'))
159
+
160
+ self.toolsmenu.AppendSeparator()
161
+
162
+ self.toolsmenu.Append(wx.ID_ANY, _('Find upstream watershed'), _('Find upstream watershed based on click...'))
163
+ self.toolsmenu.Append(wx.ID_ANY, _('Find upstream watershed - limit to sub'), _('Find upstream watershed based on click but limit to subbasin...'))
164
+
165
+ self.toolsmenu.AppendSeparator()
166
+
167
+ self.toolsmenu.Append(wx.ID_ANY, _('Select upstream watershed'), _('Select upstream watershed based on click...'))
168
+ self.toolsmenu.Append(wx.ID_ANY, _('Select upstream watershed - limit to sub'), _('Select upstream watershed based on click but limit to subbasin...'))
169
+ self.toolsmenu.Append(wx.ID_ANY, _('Select upstream rivers'), _('Select upstream rivers based on click...'))
170
+ self.toolsmenu.Append(wx.ID_ANY, _('Select upstream rivers - limit to sub'), _('Select upstream rivers based on click but limit to subbasin...'))
171
+ self.toolsmenu.Append(wx.ID_ANY, _('Select downstream rivers'), _('Select downstream rivers based on click...'))
172
+
173
+ self.menubar.Append(self.toolsmenu, _('&Tools Hydrology'))
141
174
 
142
175
  # self.computemenu = wx.Menu()
143
176
  # paramgen = self.computemenu.Append(1300,_('Calibration/Optimisation'),_('Parameters calibration of the model'))
@@ -149,23 +182,169 @@ class GuiHydrology(WolfMapViewer):
149
182
  # paramgen = self.resultsmenu.Append(1401,_('Plot'),_('Plot'))
150
183
  # self.menubar.Append(self.resultsmenu,_('&Results'))
151
184
 
185
+ @property
186
+ def watershed(self):
187
+
188
+ if self.wolfparent is None:
189
+ return None
190
+
191
+ if self.wolfparent.mycatchment is None:
192
+ return None
193
+
194
+ return self.wolfparent.mycatchment.charact_watrshd
195
+
152
196
  def OnMenubar(self, event):
197
+ """ Event handler for the menubar """
153
198
 
199
+ # Call the parent event handler
154
200
  super().OnMenubar(event)
155
201
 
202
+ # If not handled by the parent, handle it here
203
+
156
204
  id = event.GetId()
157
205
  item = self.menubar.FindItemById(id)
206
+ if item is None:
207
+ return
208
+
209
+ itemlabel = item.ItemLabel
158
210
 
159
- if id == wx.ID_EXECUTE:
160
- print(_('Do anything !!'))
161
- elif id == 1503:
162
- self.parent.mainparams.Show()
163
- elif id == 1504:
164
- self.parent.basinparams.Show()
165
- # elif id==1300:
166
- # self.myoptimisation = Optimisation()
167
- # self.myoptimisation.Show()
168
- elif id == 1500:
169
- myselect = selectpoint(title=_('Outlet'), SPWstations=self.parent.SPWstations,
170
- DCENNstations=self.parent.DCENNstations)
211
+ if itemlabel == _('Choose outlet'):
212
+ myselect = selectpoint(title=_('Outlet'),
213
+ SPWstations=self.wolfparent.SPWstations,
214
+ DCENNstations=self.wolfparent.DCENNstations)
171
215
  myselect.Show()
216
+
217
+ elif itemlabel == _('Interior points'):
218
+ logging.warning(_('Not yet implemented !'))
219
+
220
+ elif itemlabel == _('Topology'):
221
+ logging.warning(_('Not yet implemented !'))
222
+
223
+ elif itemlabel == _('Main model'):
224
+ self.wolfparent.mainparams.Show()
225
+
226
+ elif itemlabel == _('Basin'):
227
+ self.wolfparent.basinparams.Show()
228
+
229
+ elif itemlabel == _('Subbasins'):
230
+ logging.warning(_('Not yet implemented !'))
231
+
232
+ elif itemlabel == _('Forced exchanges'):
233
+ logging.warning(_('Not yet implemented !'))
234
+
235
+ elif itemlabel == _('Crop MNT/MNS'):
236
+ logging.warning(_('Not yet implemented !'))
237
+
238
+ elif itemlabel == _('Crop land use (COSW)'):
239
+ logging.warning(_('Not yet implemented !'))
240
+
241
+ elif itemlabel == _('Analyze slope'):
242
+ logging.warning(_('Not yet implemented !'))
243
+
244
+ elif itemlabel == _('IRM - QDF'):
245
+ logging.warning(_('Not yet implemented !'))
246
+
247
+ elif itemlabel == _('Find upstream watershed'):
248
+ self.action = 'Find upstream watershed'
249
+
250
+ elif itemlabel == _('Find upstream watershed - limit to sub'):
251
+ self.action = 'Find upstream watershed - limit to sub'
252
+
253
+ elif itemlabel == _('Select upstream watershed'):
254
+ self.action = 'Select upstream watershed'
255
+
256
+ elif itemlabel == _('Select upstream watershed - limit to sub'):
257
+ self.action = 'Select upstream watershed - limit to sub'
258
+
259
+ elif itemlabel == _('Select upstream rivers'):
260
+ self.action = 'Select upstream rivers'
261
+
262
+ elif itemlabel == _('Select upstream rivers - limit to sub'):
263
+ self.action = 'Select upstream rivers - limit to sub'
264
+
265
+ elif itemlabel == _('Select downstream rivers'):
266
+ self.action = 'Select downstream rivers'
267
+
268
+
269
+ def OnRightDown(self, e: wx.MouseEvent):
270
+
271
+ # Call the parent event handler
272
+ super().OnRightDown(e)
273
+
274
+ if self.action is None:
275
+ logging.info(_('No action selected !'))
276
+ return
277
+
278
+ if self.action == '':
279
+ logging.info(_('No action selected !'))
280
+ return
281
+
282
+ pos = e.GetPosition()
283
+ x, y = self.getXY(pos)
284
+
285
+ alt = e.AltDown()
286
+ ctrl = e.ControlDown()
287
+ shiftdown = e.ShiftDown()
288
+
289
+ if self.active_array is None:
290
+ logging.warning(_('No active array !'))
291
+ return
292
+
293
+ if not (self.active_array.dx == self.watershed.header.dx and self.active_array.dy == self.watershed.header.dy):
294
+ logging.warning(_('Active array and watershed do not have the same resolution !'))
295
+ return
296
+
297
+ if 'Find upstream watershed' in self.action:
298
+
299
+ starting_node = self.watershed.get_node_from_xy(x,y)
300
+ up_vect = self.watershed.get_vector_from_upstream_node(starting_node, limit_to_sub='limit to sub' in self.action)
301
+
302
+ if up_vect is None:
303
+ logging.warning(_('No upstream watershed found !'))
304
+ return
305
+
306
+ def props_vec(vec:vector):
307
+ vec.myprop.color = getIfromRGB((255,0,0))
308
+ vec.myprop.width = 3
309
+ vec.myprop.transparent = False
310
+ vec.myprop.alpha = 122
311
+ vec.myprop.filled = False
312
+
313
+ if self.active_array.Operations is not None:
314
+ newzone = zone(name = str(starting_node.sub))
315
+
316
+ self.active_array.Operations.show_structure_OpsVectors()
317
+ self.active_array.Operations.myzones.add_zone(newzone, forceparent=True)
318
+ newzone.add_vector(up_vect, forceparent=True)
319
+
320
+ props_vec(up_vect)
321
+
322
+ self.active_array.Operations.myzones.prep_listogl()
323
+ self.active_array.Operations.myzones.fill_structure()
324
+
325
+ self.Refresh()
326
+ else:
327
+ logging.warning(_('No operations frame in the active array!'))
328
+
329
+ elif 'Select upstream watershed' in self.action:
330
+
331
+ xy = self.watershed.get_xy_upstream_node(self.watershed.get_node_from_xy(x,y), limit_to_sub='limit to sub' in self.action)
332
+ self.active_array.SelectionData.set_selection_from_list_xy(xy)
333
+ self.Refresh()
334
+
335
+ elif 'Select upstream rivers' in self.action:
336
+
337
+ xy = self.watershed.get_xy_upstream_node(self.watershed.get_node_from_xy(x,y),
338
+ limit_to_sub='limit to sub' in self.action,
339
+ limit_to_river=True)
340
+
341
+ self.active_array.SelectionData.set_selection_from_list_xy(xy)
342
+ self.Refresh()
343
+
344
+ elif 'Select downstream rivers' in self.action:
345
+
346
+ xy = self.watershed.get_xy_downstream_node(self.watershed.get_node_from_xy(x,y))
347
+ self.active_array.SelectionData.set_selection_from_list_xy(xy)
348
+ self.Refresh()
349
+
350
+
wolfhece/PyParams.py CHANGED
@@ -927,6 +927,7 @@ class Wolf_Param(wx.Frame):
927
927
  # priority to default parameters
928
928
  if key_Param.ADDED_JSON in param_def.keys():
929
929
  param[key_Param.ADDED_JSON] = param_def[key_Param.ADDED_JSON]
930
+
930
931
  param[key_Param.COMMENT] = param_def[key_Param.COMMENT]
931
932
  param[key_Param.TYPE] = param_def[key_Param.TYPE]
932
933
 
@@ -1223,6 +1224,7 @@ class Wolf_Param(wx.Frame):
1223
1224
  # PARAMETRE
1224
1225
  # ---------
1225
1226
  curparam = self._add_param_from_str(param, groupname, groupdict)
1227
+ curparam[key_Param.ADDED_JSON]=None
1226
1228
 
1227
1229
  def _CreateDefaultFile(self):
1228
1230
  """ Create a default file """
@@ -2266,7 +2268,8 @@ class Wolf_Param(wx.Frame):
2266
2268
  self.myparams[curGroup][curParam][key_Param.TYPE] = templateDict[key_Param.TYPE]
2267
2269
  if key_Param.ADDED_JSON in templateDict:
2268
2270
  self.myparams[curGroup][curParam][key_Param.ADDED_JSON] = templateDict[key_Param.ADDED_JSON]
2269
-
2271
+ else:
2272
+ self.myparams[curGroup][curParam][key_Param.ADDED_JSON] = None
2270
2273
  # transfert des paramètres en surplus dans le dictionnaire savedDict
2271
2274
  for i in range(nbElements+1, iterMax+1):
2272
2275
  curParam = curIncParam.replace("$n$",str(i))
@@ -729,6 +729,10 @@ class vectorproperties:
729
729
  try:
730
730
  if updateOGL:
731
731
  self.parent.parentzone.prep_listogl()
732
+
733
+ if self.parent.parentzone.parent is None:
734
+ logging.critical('Problem with OpenGL update - parent/mapviewer is None -- Track this issue')
735
+
732
736
  self.parent.parentzone.parent.mapviewer.Refresh()
733
737
  except:
734
738
  logging.warning('Problem with OpenGL update - vectorproperties.fill_property')
wolfhece/PyWMS.py CHANGED
@@ -12,7 +12,7 @@ from .PyTranslate import _
12
12
  def to_image(mybytes:BytesIO) -> Image:
13
13
  return Image.open(mybytes)
14
14
 
15
- def getWalonmap(cat:Literal['IMAGERIE/ORTHO_2021', 'ALEA', 'CADMAP', 'LIDAXES', '$IDW', 'ZONES_INONDEES'],
15
+ def getWalonmap(cat:Literal['IMAGERIE/ORTHO_2021', 'ALEA', 'CADMAP', 'LIDAXES', '$IDW', 'EAU/ZONES_INONDEES'],
16
16
  xl:float,
17
17
  yl:float,
18
18
  xr:float,
@@ -23,6 +23,8 @@ def getWalonmap(cat:Literal['IMAGERIE/ORTHO_2021', 'ALEA', 'CADMAP', 'LIDAXES',
23
23
 
24
24
  if cat.find('$')>0:
25
25
  catloc=cat[:cat.find('$')]
26
+ elif cat.find('_wo_alea')>0:
27
+ catloc=cat[:cat.find('_wo_alea')]
26
28
  else:
27
29
  catloc=cat
28
30
 
@@ -78,18 +80,17 @@ def getWalonmap(cat:Literal['IMAGERIE/ORTHO_2021', 'ALEA', 'CADMAP', 'LIDAXES',
78
80
  elif cat.find('LIDAXES')>0:
79
81
  curcont=['4,5,6,7,8,9,11,13']
80
82
  curstyles=['default,default,default,default,default,default,default,default']
81
- elif cat.find('$IDW')>0:
82
- curcont=[ul.quote('Zones inondées - Modélisation IDW')]
83
+ elif cat.find('IDW')>0:
84
+ curcont=['0']
83
85
  curstyles=['default']
84
86
  elif cat.find('ZONES_INONDEES')>0:
85
- layers=[
86
- ul.quote('Zones inondables'),
87
- ul.quote('Zones inondées - Satellites'),
88
- ul.quote('Zones indondées - Verviers'),
89
- ul.quote('Zones inondées - Enquêtes SPW'),
90
- ul.quote('Zones inondées - Digitalisations')]
91
- curcont=['{},{},{},{},{},{}'.format(layers[0],layers[1],layers[2],layers[3],layers[4])]
92
- curstyles=['default,default,default,default,default']
87
+
88
+ if 'wo_alea' in cat:
89
+ curcont = list(wms.contents)[1:]
90
+ curstyles=['default']*len(curcont)
91
+ else:
92
+ curcont = list(wms.contents)
93
+ curstyles=['default']*len(curcont)
93
94
 
94
95
  try:
95
96
  img=wms.getmap(layers=curcont,styles=curstyles,srs='EPSG:31370',bbox=(xl,yl,xr,yr),size=(w,h),format='image/png',transparent=True)
wolfhece/RatingCurve.py CHANGED
@@ -501,13 +501,13 @@ class SPWMIGaugingStations(Element_To_Draw):
501
501
  self.ymin = min(y)
502
502
  self.ymax = max(y)
503
503
 
504
- def _plot(self, size:float=10.):
505
- for curstation in self.mystations.values:
504
+ def _plot(self, sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size:float=10.):
505
+ for curstation in self.mystations.values():
506
506
  curstation.plot(size)
507
507
 
508
508
  class SPWDCENNGaugingStations(Element_To_Draw):
509
509
 
510
- mystations:dict
510
+ mystations:dict[int:gaugingstation]
511
511
  myrivers:dict
512
512
  gaugings:SPWGaugings
513
513
  hrefs:SPWhrefs
@@ -633,6 +633,18 @@ class SPWDCENNGaugingStations(Element_To_Draw):
633
633
 
634
634
  pass
635
635
 
636
- def plot(self,size:float=10.):
637
- for id in self.mystations:
638
- self.mystations[id].plot(size)
636
+ def plot(self, sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size:float=10.):
637
+ self._plot(size)
638
+
639
+ def find_minmax(self,update=False):
640
+ x = [cur.x for cur in self.mystations.values()]
641
+ y = [cur.y for cur in self.mystations.values()]
642
+
643
+ self.xmin = min(x)
644
+ self.xmax = max(x)
645
+ self.ymin = min(y)
646
+ self.ymax = max(y)
647
+
648
+ def _plot(self, size:float=10.):
649
+ for curstation in self.mystations.values():
650
+ curstation.plot(size)
wolfhece/Results2DGPU.py CHANGED
@@ -380,24 +380,94 @@ class wolfres2DGPU(Wolfresults_2D):
380
380
  else:
381
381
  _, _, _, _, wd_np, qx_np, qy_np = self._result_store.get_result(which+1)
382
382
  else:
383
- _, _, _, _, wd_np, qx_np, qy_np = self._result_store.get_result(which+1)
383
+ __, __, __, __, wd_np, qx_np, qy_np = self._result_store.get_result(which+1)
384
+
385
+ wd_np = wd_np.T
386
+ qx_np = qx_np.T
387
+ qy_np = qy_np.T
384
388
 
385
389
  curblock = self.myblocks[getkeyblock(1,False)]
390
+
391
+ curblock.waterdepth.array.data[:,:] = curblock.waterdepth.nullvalue
392
+ curblock.qx.array.data[:,:] = curblock.qx.nullvalue
393
+ curblock.qy.array.data[:,:] = curblock.qy.nullvalue
394
+
395
+ curblock.waterdepth.array.mask[:,:] = True
396
+ curblock.qx.array.mask[:,:] = True
397
+ curblock.qy.array.mask[:,:] = True
398
+
386
399
  if self.epsilon > 0.:
387
- curblock.waterdepth.array=ma.masked_less_equal(wd_np.astype(np.float32).T, self.epsilon)
400
+ # curblock.waterdepth.array=ma.masked_less_equal(wd_np.astype(np.float32).T, self.epsilon)
401
+
402
+ ij = np.where(wd_np >= self.epsilon)
403
+ curblock.waterdepth.array.data[ij] = wd_np[ij]
404
+ curblock.waterdepth.array.mask[ij] = False
388
405
  else:
389
- curblock.waterdepth.array=ma.masked_equal(wd_np.astype(np.float32).T, 0.)
406
+ # curblock.waterdepth.array=ma.masked_equal(wd_np.astype(np.float32).T, 0.)
407
+
408
+ ij = np.where(wd_np > 0.)
409
+ curblock.waterdepth.array.data[ij] = wd_np[ij]
410
+ curblock.waterdepth.array.mask[ij] = False
411
+
412
+ # curblock.qx.array=ma.masked_where(curblock.waterdepth.array.mask,qx_np.astype(np.float32).T)
413
+ # curblock.qy.array=ma.masked_where(curblock.waterdepth.array.mask,qy_np.astype(np.float32).T)
390
414
 
391
- curblock.qx.array=ma.masked_where(curblock.waterdepth.array.mask,qx_np.astype(np.float32).T)
392
- curblock.qy.array=ma.masked_where(curblock.waterdepth.array.mask,qy_np.astype(np.float32).T)
415
+ curblock.qx.array.data[ij] = qx_np[ij]
416
+ curblock.qy.array.data[ij] = qy_np[ij]
417
+
418
+ curblock.qx.array.mask[ij] = False
419
+ curblock.qy.array.mask[ij] = False
393
420
 
394
421
  curblock.waterdepth.count()
395
422
  curblock.qx.count()
396
423
  curblock.qy.count()
397
424
 
398
- curblock.waterdepth.set_nullvalue_in_mask()
399
- curblock.qx.set_nullvalue_in_mask()
400
- curblock.qy.set_nullvalue_in_mask()
425
+ # curblock.waterdepth.set_nullvalue_in_mask()
426
+ # curblock.qx.set_nullvalue_in_mask()
427
+ # curblock.qy.set_nullvalue_in_mask()
428
+
429
+ if self.to_filter_independent:
430
+ self.filter_independent_zones()
431
+
432
+ self.current_result = which
433
+ self.loaded=True
434
+
435
+ def _read_oneresult_only_h(self, which:int=-1):
436
+ """
437
+ Lecture d'un pas de sauvegarde
438
+
439
+ which: result number to read; 0-based; -1 == last one
440
+ """
441
+
442
+ which = self._sanitize_result_step(which)
443
+
444
+ # stored result files are 1-based -> which+1
445
+ if self._cache is not None:
446
+ if (which >= self._cache.start_idx and which < self._cache.end_idx):
447
+ wd_np = self._cache.get_h(which+1, True)
448
+ else:
449
+ _, _, _, _, wd_np, qx_np, qy_np = self._result_store.get_result(which+1)
450
+ else:
451
+ __, __, __, __, wd_np, qx_np, qy_np = self._result_store.get_result(which+1)
452
+
453
+ wd_np = wd_np.T
454
+
455
+ curblock = self.myblocks[getkeyblock(1,False)]
456
+
457
+ curblock.waterdepth.array.data[:,:] = curblock.waterdepth.nullvalue
458
+
459
+ curblock.waterdepth.array.mask[:,:] = True
460
+
461
+ if self.epsilon > 0.:
462
+ ij = np.where(wd_np >= self.epsilon)
463
+ curblock.waterdepth.array.data[ij] = wd_np[ij]
464
+ curblock.waterdepth.array.mask[ij] = False
465
+ else:
466
+ ij = np.where(wd_np > 0.)
467
+ curblock.waterdepth.array.data[ij] = wd_np[ij]
468
+ curblock.waterdepth.array.mask[ij] = False
469
+
470
+ curblock.waterdepth.count()
401
471
 
402
472
  if self.to_filter_independent:
403
473
  self.filter_independent_zones()
wolfhece/apps/version.py CHANGED
@@ -5,7 +5,7 @@ class WolfVersion():
5
5
 
6
6
  self.major = 2
7
7
  self.minor = 1
8
- self.patch = 16
8
+ self.patch = 18
9
9
 
10
10
  def __str__(self):
11
11