wolfhece 2.1.113__py3-none-any.whl → 2.1.115__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/Results2DGPU.py CHANGED
@@ -156,6 +156,7 @@ class wolfres2DGPU(Wolfresults_2D):
156
156
  store = None):
157
157
 
158
158
  fname = Path(fname)
159
+ self._nap = None
159
160
 
160
161
  if not fname.name.lower() == 'simul_gpu_results':
161
162
  for curdir in fname.iterdir():
@@ -234,6 +235,7 @@ class wolfres2DGPU(Wolfresults_2D):
234
235
  curblock.qx = WolfArray(path.join(sim_path, 'simul.qxbin'))
235
236
  curblock.qy = WolfArray(path.join(sim_path, 'simul.qybin'))
236
237
  curblock.rough_n = WolfArray(path.join(sim_path, 'simul.frot'))
238
+ self._nap = WolfArray(path.join(sim_path, 'simul.napbin'))
237
239
 
238
240
  else:
239
241
 
@@ -304,6 +306,13 @@ class wolfres2DGPU(Wolfresults_2D):
304
306
  logging.error(_('No manning file found in the simulation directory -- Results will not be shown in viewer'))
305
307
  return -8
306
308
 
309
+ pathnap = sim_path / params['maps']['NAP']
310
+ if pathnap.exists():
311
+ self._nap = WolfArray(pathnap)
312
+ else:
313
+ logging.error(_('No nap file found in the simulation directory -- Results will not be shown in viewer'))
314
+ return -9
315
+
307
316
  # Force nullvalue to zero because it will influence the size of the arrow in vector field views
308
317
  curblock.qx.nullvalue = 0.
309
318
  curblock.qy.nullvalue = 0.
@@ -312,7 +321,7 @@ class wolfres2DGPU(Wolfresults_2D):
312
321
 
313
322
  self.head_blocks[getkeyblock(0)] = curblock.top.get_header()
314
323
 
315
- to_check =[curblock.waterdepth, curblock.qx, curblock.qy, curblock.rough_n]
324
+ to_check =[curblock.waterdepth, curblock.qx, curblock.qy, curblock.rough_n, self._nap]
316
325
  check = False
317
326
  for curarray in to_check:
318
327
  check |= curarray.dx != curblock.top.dx
@@ -324,7 +333,7 @@ class wolfres2DGPU(Wolfresults_2D):
324
333
 
325
334
  if check:
326
335
  if (sim_path / 'simul.top').exists():
327
- logging.error(_("Inconsistent header file in .top, .qxbin, .qybin or .frot files"))
336
+ logging.error(_("Inconsistent header file in .top, .qxbin, .qybin, .napbin or .frot files"))
328
337
  logging.error(_("Forcing information into memory from the .top file -- May corrupt spatial positionning -- Please check your data !"))
329
338
  elif pathbathy.exists():
330
339
  logging.error(_("Inconsistent header file"))
@@ -639,17 +648,40 @@ class wolfres2DGPU(Wolfresults_2D):
639
648
  logging.error(_('Bad index for initial conditions'))
640
649
  return
641
650
 
651
+ nap = self._nap
652
+
642
653
  self.set_currentview(views_2D.WATERDEPTH)
643
654
 
644
655
  hini = self.as_WolfArray()
656
+ hini.nullvalue = 0.
657
+ hini.set_nullvalue_in_mask()
658
+
659
+ if hini[nap == 1].max() > 0.:
660
+ logging.warning(_('Some cells are not dry in the initial conditions outside the NAP areas'))
661
+ logging.warning(_('Setting the water depth to zero in these cells'))
662
+ hini[nap == 0] = 0.
645
663
 
646
664
  self.set_currentview(views_2D.QX)
647
665
 
648
666
  qxini = self.as_WolfArray()
667
+ qxini.nullvalue = 0.
668
+ qxini.set_nullvalue_in_mask()
649
669
 
650
670
  self.set_currentview(views_2D.QY)
651
671
 
652
672
  qyini = self.as_WolfArray()
673
+ qyini.nullvalue = 0.
674
+ qyini.set_nullvalue_in_mask()
675
+
676
+ if qxini[nap == 1].max() > 0.:
677
+ logging.warning(_('Some cells are not dry in the initial conditions outside the NAP areas'))
678
+ logging.warning(_('Setting the water depth to zero in these cells'))
679
+ qxini[nap == 0] = 0.
680
+
681
+ if qyini[nap == 1].max() > 0.:
682
+ logging.warning(_('Some cells are not dry in the initial conditions outside the NAP areas'))
683
+ logging.warning(_('Setting the water depth to zero in these cells'))
684
+ qyini[nap == 0] = 0.
653
685
 
654
686
  if (hini is not None) and (qxini is not None) and (qyini is not None):
655
687
 
@@ -657,9 +689,10 @@ class wolfres2DGPU(Wolfresults_2D):
657
689
  # qxini = qxini.as_WolfArray()
658
690
  # qyini = qyini.as_WolfArray()
659
691
 
660
- hini.write_all(self.filename.parent / 'h.npy')
661
- qxini.write_all(self.filename.parent / 'qx.npy')
662
- qyini.write_all(self.filename.parent / 'qy.npy')
692
+ dir = Path(self.filename).parent
693
+ hini.write_all(dir / 'h.npy')
694
+ qxini.write_all(dir / 'qx.npy')
695
+ qyini.write_all(dir / 'qy.npy')
663
696
 
664
697
  logging.info(_('Initial conditions saved as Numpy files'))
665
698
  else: