wolfhece 2.1.95__py3-none-any.whl → 2.1.96__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 +125 -91
- wolfhece/apps/version.py +1 -1
- wolfhece/wolf_array.py +24 -5
- wolfhece/wolfresults_2D.py +264 -1
- {wolfhece-2.1.95.dist-info → wolfhece-2.1.96.dist-info}/METADATA +1 -1
- {wolfhece-2.1.95.dist-info → wolfhece-2.1.96.dist-info}/RECORD +9 -9
- {wolfhece-2.1.95.dist-info → wolfhece-2.1.96.dist-info}/WHEEL +0 -0
- {wolfhece-2.1.95.dist-info → wolfhece-2.1.96.dist-info}/entry_points.txt +0 -0
- {wolfhece-2.1.95.dist-info → wolfhece-2.1.96.dist-info}/top_level.txt +0 -0
wolfhece/PyDraw.py
CHANGED
@@ -1027,10 +1027,6 @@ class WolfMapViewer(wx.Frame):
|
|
1027
1027
|
_("Apply mask from sim2D"))
|
1028
1028
|
filterinund = self.analyzemenu.Append(wx.ID_ANY, _("Filter inundation arrays..."),
|
1029
1029
|
_("Filter arrays"))
|
1030
|
-
exporttif = self.analyzemenu.Append(wx.ID_ANY, _("Export arrays as Geotif..."),
|
1031
|
-
_("Export arrays as Geotif"))
|
1032
|
-
exportshape = self.analyzemenu.Append(wx.ID_ANY, _("Export arrays as Shapefile..."),
|
1033
|
-
_("Export arrays as Shapefile"))
|
1034
1030
|
plotqvect = self.analyzemenu.Append(wx.ID_ANY, _("Integrate Q along active vector..."),
|
1035
1031
|
_("Integrate Q along the active vector"))
|
1036
1032
|
plotqvect = self.analyzemenu.Append(wx.ID_ANY, _("Integrate Q along active zone..."),
|
@@ -1462,6 +1458,11 @@ class WolfMapViewer(wx.Frame):
|
|
1462
1458
|
|
1463
1459
|
self.menuwolf2d.AppendSeparator()
|
1464
1460
|
|
1461
|
+
self.menu2d_export_as = self.menuwolf2d.Append(wx.ID_ANY, _("Export results as..."), _("Export results as Geotif or Shapefile"))
|
1462
|
+
|
1463
|
+
self.menuwolf2d.AppendSeparator()
|
1464
|
+
# Possible cache entries will be added after this separator
|
1465
|
+
|
1465
1466
|
self.menubar.Append(self.menuwolf2d, _('Results 2D'))
|
1466
1467
|
|
1467
1468
|
self.menuwolf2d.Bind(wx.EVT_MENU, self.Onmenuwolf2d)
|
@@ -1665,6 +1666,10 @@ class WolfMapViewer(wx.Frame):
|
|
1665
1666
|
|
1666
1667
|
self.read_last_result()
|
1667
1668
|
|
1669
|
+
elif itemlabel == _("Export results as..."):
|
1670
|
+
|
1671
|
+
self.export_results_as()
|
1672
|
+
|
1668
1673
|
elif itemlabel == _("Change current view"):
|
1669
1674
|
|
1670
1675
|
# Change view for results
|
@@ -5385,16 +5390,6 @@ class WolfMapViewer(wx.Frame):
|
|
5385
5390
|
fig.canvas.draw()
|
5386
5391
|
fig.canvas.flush_events()
|
5387
5392
|
|
5388
|
-
elif itemlabel == _("Export arrays as Geotif..."):
|
5389
|
-
autoscale = False
|
5390
|
-
|
5391
|
-
self.export_results_as('geotiff')
|
5392
|
-
|
5393
|
-
elif itemlabel == _("Export arrays as Shapefile..."):
|
5394
|
-
autoscale = False
|
5395
|
-
|
5396
|
-
self.export_results_as('shape')
|
5397
|
-
|
5398
5393
|
elif itemlabel == _("Compute and apply unique colormap on all..."):
|
5399
5394
|
autoscale = False
|
5400
5395
|
|
@@ -6407,16 +6402,13 @@ class WolfMapViewer(wx.Frame):
|
|
6407
6402
|
|
6408
6403
|
logging.info(_('Filtering done !'))
|
6409
6404
|
|
6410
|
-
def export_results_as(self,which
|
6411
|
-
|
6405
|
+
def export_results_as(self, which:Literal['geotiff','shape'] = None, multiband:bool = None):
|
6412
6406
|
"""
|
6413
6407
|
Export des résultats WOLF2D vers le format GeoTiff
|
6414
6408
|
On attend que les matrices ".hbin" aient été chargées dans l'interface
|
6415
|
-
|
6416
|
-
TODO : Modifier la routine pour prendre les classe de résultats 2D
|
6417
6409
|
"""
|
6418
6410
|
|
6419
|
-
dlg = wx.DirDialog(self,_('Choose output directory'),style = wx.DD_DIR_MUST_EXIST)
|
6411
|
+
dlg = wx.DirDialog(self,_('Choose output directory'), style = wx.DD_DIR_MUST_EXIST)
|
6420
6412
|
ret=dlg.ShowModal()
|
6421
6413
|
|
6422
6414
|
if ret == wx.ID_CANCEL:
|
@@ -6426,63 +6418,81 @@ class WolfMapViewer(wx.Frame):
|
|
6426
6418
|
outdir = dlg.GetPath()
|
6427
6419
|
dlg.Destroy()
|
6428
6420
|
|
6429
|
-
|
6430
|
-
|
6431
|
-
|
6432
|
-
|
6433
|
-
if curarray.plotted:
|
6421
|
+
if which not in ['geotiff','shape']:
|
6422
|
+
dlg = wx.SingleChoiceDialog(self,_('Choose output format'), _('Format'), ['Geotiff','Shape file'])
|
6423
|
+
dlg.ShowModal()
|
6424
|
+
sel = dlg.GetSelection()
|
6434
6425
|
|
6435
|
-
|
6436
|
-
|
6437
|
-
|
6438
|
-
|
6439
|
-
qx = WolfArray(fn+'.qxbin')
|
6440
|
-
qx.array.mask = curarray.array.mask
|
6441
|
-
qx.array.data[np.where(qx.array.mask)] = 0.
|
6442
|
-
qy = WolfArray(fn+'.qybin')
|
6443
|
-
qy.array.mask = curarray.array.mask
|
6444
|
-
qy.array.data[np.where(qy.array.mask)] = 0.
|
6426
|
+
if sel == 0:
|
6427
|
+
which = 'geotiff'
|
6428
|
+
else:
|
6429
|
+
which = 'shape'
|
6445
6430
|
|
6446
|
-
|
6447
|
-
vnorm=qnorm/curarray
|
6448
|
-
froude=vnorm/(curarray*9.81)**.5
|
6431
|
+
dlg.Destroy()
|
6449
6432
|
|
6450
|
-
|
6433
|
+
if which == 'geotiff':
|
6434
|
+
if multiband is None:
|
6435
|
+
dlg = wx.SingleChoiceDialog(self,_('Choose output format'), _('Format'), ['Multiband (single file)',
|
6436
|
+
'Single band (multiple files)'])
|
6437
|
+
dlg.ShowModal()
|
6451
6438
|
|
6452
|
-
|
6439
|
+
sel = dlg.GetSelection()
|
6440
|
+
if sel == 1:
|
6441
|
+
multiband = False
|
6442
|
+
else:
|
6443
|
+
multiband = True
|
6444
|
+
dlg.Destroy()
|
6453
6445
|
|
6454
|
-
|
6446
|
+
logging.info(_('Exporting results -- Be patient !'))
|
6455
6447
|
|
6456
|
-
|
6457
|
-
diamcrit_izbach = WolfArray(mold=h)
|
6448
|
+
loaded_res = self.get_list_keys(drawing_type= draw_type.RES2D, checked_state=None)
|
6458
6449
|
|
6459
|
-
|
6450
|
+
dlg = wx.MultiChoiceDialog(self,_('Choose results to export'), _('Results'), choices=loaded_res)
|
6451
|
+
dlg.SetSelections([idx for idx, res in enumerate(loaded_res) if self.get_obj_from_id(res, drawtype=draw_type.RES2D).plotted])
|
6452
|
+
dlg.ShowModal()
|
6453
|
+
sel = dlg.GetSelections() # Get a list if integers
|
6454
|
+
sel_res = [self.get_obj_from_id(loaded_res[cursel], drawtype=draw_type.RES2D) for cursel in sel] # convert to list of objects
|
6460
6455
|
|
6461
|
-
|
6462
|
-
diamcrit_izbach.array[ij[:,0],ij[:,1]] = diam[:,1]
|
6456
|
+
dlg.Destroy()
|
6463
6457
|
|
6464
|
-
|
6458
|
+
if len(sel) == 0:
|
6459
|
+
logging.warning(_('No results selected for export'))
|
6460
|
+
return
|
6461
|
+
|
6462
|
+
fields = [(views_2D.TOPOGRAPHY, True),
|
6463
|
+
(views_2D.WATERDEPTH, True),
|
6464
|
+
(views_2D.QX, True),
|
6465
|
+
(views_2D.QY, True),
|
6466
|
+
(views_2D.UNORM, True),
|
6467
|
+
(views_2D.FROUDE, True),
|
6468
|
+
(views_2D.HEAD, True),
|
6469
|
+
(views_2D.CRITICAL_DIAMETER_SHIELDS, False),
|
6470
|
+
(views_2D.CRITICAL_DIAMETER_IZBACH, False),
|
6471
|
+
(views_2D.QNORM, False),
|
6472
|
+
(views_2D.WATERLEVEL, False),
|
6473
|
+
(views_2D.CRITICAL_DIAMETER_SUSPENSION_50, False),
|
6474
|
+
(views_2D.CRITICAL_DIAMETER_SUSPENSION_100, False),]
|
6475
|
+
|
6476
|
+
dlg = wx.MultiChoiceDialog(self,_('Choose fields to export'), _('Fields'), choices= [str(field[0]) for field in fields])
|
6477
|
+
dlg.SetSelections([idx for idx, field in enumerate(fields) if field[1]])
|
6478
|
+
dlg.ShowModal()
|
6479
|
+
sel_fields = dlg.GetSelections() # Get a list if integers
|
6480
|
+
dlg.Destroy()
|
6465
6481
|
|
6466
|
-
|
6482
|
+
if len(sel_fields) == 0:
|
6483
|
+
logging.warning(_('No fields selected for export'))
|
6484
|
+
return
|
6467
6485
|
|
6468
|
-
|
6469
|
-
|
6470
|
-
'H [m]',
|
6471
|
-
'QX [m2s-1]',
|
6472
|
-
'QY [m2s-1]',
|
6473
|
-
'Un [ms-1]',
|
6474
|
-
'Fr [-]',
|
6475
|
-
'D_Sh [m]',
|
6476
|
-
'D_Iz [m]']
|
6486
|
+
# Get the views_2D values associated with the selected field names
|
6487
|
+
fields = [fields[cursel][0] for cursel in sel_fields]
|
6477
6488
|
|
6478
|
-
|
6479
|
-
|
6489
|
+
for cur_res in tqdm(sel_res):
|
6490
|
+
cur_res:Wolfresults_2D
|
6491
|
+
cur_res.export_as(outdir, fields, which, multiband)
|
6480
6492
|
|
6481
|
-
|
6482
|
-
self.export_shape(outdir,curarray.idx,myarrays,mynames,curarray)
|
6483
|
-
del wait
|
6493
|
+
logging.info(_('Export done -- Thanks for your patience !'))
|
6484
6494
|
|
6485
|
-
def export_shape(self, outdir='', fn = '', myarrays=[], descr=[], mask:WolfArray=None):
|
6495
|
+
def export_shape(self, outdir:str= '', fn:str = '', myarrays:list[WolfArray]= [], descr:list[str]= [], mask:WolfArray=None):
|
6486
6496
|
""" Export multiple arrays to shapefile
|
6487
6497
|
|
6488
6498
|
:param outdir: output directory
|
@@ -6559,7 +6569,7 @@ class WolfMapViewer(wx.Frame):
|
|
6559
6569
|
# Save and close DataSource
|
6560
6570
|
ds = None
|
6561
6571
|
|
6562
|
-
def export_geotif(self, outdir='', fn = '', myarrays=[], descr=[]):
|
6572
|
+
def export_geotif(self, outdir:str= '', fn:str = '', myarrays:list[WolfArray]= [], descr:list[str]= [], multiband:bool= True):
|
6563
6573
|
""" Export multiple arrays to geotiff
|
6564
6574
|
|
6565
6575
|
:param outdir: output directory
|
@@ -6578,38 +6588,62 @@ class WolfMapViewer(wx.Frame):
|
|
6578
6588
|
srs = osr.SpatialReference()
|
6579
6589
|
srs.ImportFromEPSG(31370)
|
6580
6590
|
|
6581
|
-
filename = join(outdir,fn)
|
6582
|
-
if not filename.endswith('.tif'):
|
6583
|
-
filename+='.tif'
|
6584
|
-
|
6585
|
-
arr=myarrays[0].array
|
6586
|
-
if arr.dtype == np.float32:
|
6587
|
-
arr_type = gdal.GDT_Float32
|
6588
|
-
else:
|
6589
|
-
arr_type = gdal.GDT_Int32
|
6590
|
-
|
6591
6591
|
driver: gdal.Driver
|
6592
6592
|
out_ds: gdal.Dataset
|
6593
6593
|
band: gdal.Band
|
6594
6594
|
driver = gdal.GetDriverByName("GTiff")
|
6595
|
-
|
6596
|
-
|
6597
|
-
|
6598
|
-
|
6599
|
-
|
6600
|
-
|
6601
|
-
|
6602
|
-
|
6603
|
-
|
6604
|
-
|
6605
|
-
|
6606
|
-
|
6607
|
-
|
6608
|
-
|
6609
|
-
|
6610
|
-
|
6611
|
-
|
6612
|
-
|
6595
|
+
|
6596
|
+
if multiband:
|
6597
|
+
filename = join(outdir,fn)
|
6598
|
+
if not filename.endswith('.tif'):
|
6599
|
+
filename+='.tif'
|
6600
|
+
|
6601
|
+
arr = myarrays[0]
|
6602
|
+
out_ds = driver.Create(filename, arr.shape[0], arr.shape[1], len(myarrays), arr.dtype_gdal, options=['COMPRESS=LZW'])
|
6603
|
+
out_ds.SetProjection(srs.ExportToWkt())
|
6604
|
+
out_ds.SetGeoTransform([myarrays[0].origx+myarrays[0].translx,
|
6605
|
+
myarrays[0].dx,
|
6606
|
+
0.,
|
6607
|
+
myarrays[0].origy+myarrays[0].transly,
|
6608
|
+
0.,
|
6609
|
+
myarrays[0].dy])
|
6610
|
+
|
6611
|
+
k=1
|
6612
|
+
for arr, name in zip(myarrays,descr):
|
6613
|
+
band = out_ds.GetRasterBand(k)
|
6614
|
+
band.SetNoDataValue(0.)
|
6615
|
+
band.SetDescription(name)
|
6616
|
+
band.WriteArray(arr.array.transpose())
|
6617
|
+
band.FlushCache()
|
6618
|
+
band.ComputeStatistics(True)
|
6619
|
+
k+=1
|
6620
|
+
|
6621
|
+
out_ds = None
|
6622
|
+
|
6623
|
+
else:
|
6624
|
+
for arr, name in zip(myarrays,descr):
|
6625
|
+
|
6626
|
+
if filename.endswith('.tif'):
|
6627
|
+
filename = filename[:-4]
|
6628
|
+
filename = join(outdir,fn+'_'+name)
|
6629
|
+
filename += '.tif'
|
6630
|
+
|
6631
|
+
out_ds = driver.Create(filename, arr.shape[0], arr.shape[1], 1, arr.dtype_gdal, options=['COMPRESS=LZW'])
|
6632
|
+
out_ds.SetProjection(srs.ExportToWkt())
|
6633
|
+
out_ds.SetGeoTransform([myarrays[0].origx+myarrays[0].translx,
|
6634
|
+
myarrays[0].dx,
|
6635
|
+
0.,
|
6636
|
+
myarrays[0].origy+myarrays[0].transly,
|
6637
|
+
0.,
|
6638
|
+
myarrays[0].dy])
|
6639
|
+
|
6640
|
+
band = out_ds.GetRasterBand(1)
|
6641
|
+
band.SetNoDataValue(0.)
|
6642
|
+
band.SetDescription(name)
|
6643
|
+
band.WriteArray(arr.array.transpose())
|
6644
|
+
band.FlushCache()
|
6645
|
+
band.ComputeStatistics(True)
|
6646
|
+
out_ds = None
|
6613
6647
|
|
6614
6648
|
def get_linked_arrays(self, linked:bool = True) -> dict:
|
6615
6649
|
""" Get all arrays in the viewer and linked viewers """
|
wolfhece/apps/version.py
CHANGED
wolfhece/wolf_array.py
CHANGED
@@ -2600,7 +2600,7 @@ class Ops_Array(wx.Frame):
|
|
2600
2600
|
|
2601
2601
|
def OnContourInt(self, event:wx.MouseEvent):
|
2602
2602
|
""" Create contour - number of contours """
|
2603
|
-
|
2603
|
+
|
2604
2604
|
with wx.NumberEntryDialog(None, 'Number of contours', 'Number of contours', 'Number of contours', 20, 1, 1000) as dlg:
|
2605
2605
|
if dlg.ShowModal() == wx.ID_OK:
|
2606
2606
|
nbcontours = dlg.GetValue()
|
@@ -2617,7 +2617,7 @@ class Ops_Array(wx.Frame):
|
|
2617
2617
|
def OnContourList(self, event:wx.MouseEvent):
|
2618
2618
|
""" Create contour - list of values """
|
2619
2619
|
|
2620
|
-
with wx.TextEntryDialog(None, 'List of specific values separated by comma or tuple (min;max;step)',
|
2620
|
+
with wx.TextEntryDialog(None, 'List of specific values separated by comma or tuple (min;max;step)',
|
2621
2621
|
'List of values', f'{self.parentarray.array.min()}, {self.parentarray.array.max()}') as dlg:
|
2622
2622
|
|
2623
2623
|
if dlg.ShowModal() == wx.ID_OK:
|
@@ -5358,6 +5358,25 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
5358
5358
|
|
5359
5359
|
return dtype
|
5360
5360
|
|
5361
|
+
@property
|
5362
|
+
def dtype_gdal(self):
|
5363
|
+
""" Return the GDAL dtype corresponding to the WOLF type """
|
5364
|
+
|
5365
|
+
if self.wolftype in [WOLF_ARRAY_FULL_DOUBLE, WOLF_ARRAY_SYM_DOUBLE, WOLF_ARRAY_CSR_DOUBLE]:
|
5366
|
+
dtype = gdal.GDT_Float64
|
5367
|
+
elif self.wolftype in [WOLF_ARRAY_FULL_SINGLE, WOLF_ARRAY_FULL_SINGLE_3D, WOLF_ARRAY_MB_SINGLE]:
|
5368
|
+
dtype = gdal.GDT_Float32
|
5369
|
+
elif self.wolftype in [WOLF_ARRAY_FULL_INTEGER, WOLF_ARRAY_MB_INTEGER, WOLF_ARRAY_MNAP_INTEGER]:
|
5370
|
+
dtype = gdal.GDT_Int32
|
5371
|
+
elif self.wolftype in [WOLF_ARRAY_FULL_INTEGER16, WOLF_ARRAY_FULL_INTEGER16_2]:
|
5372
|
+
dtype = gdal.GDT_Int16
|
5373
|
+
elif self.wolftype == WOLF_ARRAY_FULL_INTEGER8:
|
5374
|
+
dtype = gdal.GDT_Byte
|
5375
|
+
elif self.wolftype == WOLF_ARRAY_FULL_LOGICAL:
|
5376
|
+
dtype = gdal.GDT_Int16
|
5377
|
+
|
5378
|
+
return dtype
|
5379
|
+
|
5361
5380
|
@property
|
5362
5381
|
def dtype_str(self):
|
5363
5382
|
"""
|
@@ -5597,7 +5616,7 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
5597
5616
|
# Check if estimated file size exceeds 4GB
|
5598
5617
|
if (estimated_file_size > 4 * 1024**3): # 4GB in bytes
|
5599
5618
|
options = ['COMPRESS=LZW', 'BIGTIFF=YES']
|
5600
|
-
|
5619
|
+
logging.info('BigTIFF format will be used!')
|
5601
5620
|
else:
|
5602
5621
|
options = ['COMPRESS=LZW']
|
5603
5622
|
|
@@ -9059,7 +9078,7 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
9059
9078
|
|
9060
9079
|
if isinstance(levels, int):
|
9061
9080
|
levels = np.linspace(self.array.min(), self.array.max(), levels)
|
9062
|
-
|
9081
|
+
|
9063
9082
|
x, y = self.meshgrid()
|
9064
9083
|
cs = plt.contour(x, y, self.array, levels=levels)
|
9065
9084
|
|
@@ -10275,7 +10294,7 @@ class WolfArrayMNAP(WolfArrayMB):
|
|
10275
10294
|
key = which
|
10276
10295
|
|
10277
10296
|
return self.myblocks[key].array.data != 1
|
10278
|
-
|
10297
|
+
|
10279
10298
|
def get_all_masks(self):
|
10280
10299
|
"""
|
10281
10300
|
Return all masks
|
wolfhece/wolfresults_2D.py
CHANGED
@@ -1430,6 +1430,17 @@ class views_2D(Enum):
|
|
1430
1430
|
T_WD_Q = _('Top + WD + Q')
|
1431
1431
|
T_WD_U = _('Top + WD + U')
|
1432
1432
|
|
1433
|
+
@classmethod
|
1434
|
+
def get_view(cls, value):
|
1435
|
+
for cur in views_2D:
|
1436
|
+
if cur.value == value:
|
1437
|
+
return cur
|
1438
|
+
|
1439
|
+
return None
|
1440
|
+
|
1441
|
+
def __str__(self):
|
1442
|
+
return self.value
|
1443
|
+
|
1433
1444
|
VIEWS_SEDIMENTARY = [views_2D.SHIELDS_NUMBER,
|
1434
1445
|
views_2D.CRITICAL_DIAMETER_SHIELDS,
|
1435
1446
|
views_2D.CRITICAL_DIAMETER_IZBACH,
|
@@ -1899,7 +1910,7 @@ class OneWolfResult:
|
|
1899
1910
|
logging.info(_('End of computing critical diameters'))
|
1900
1911
|
|
1901
1912
|
return diamcrit
|
1902
|
-
|
1913
|
+
|
1903
1914
|
def get_u_shear(self) -> WolfArray:
|
1904
1915
|
"""
|
1905
1916
|
Calcul de la vitesse de cisaillement
|
@@ -4420,3 +4431,255 @@ class Wolfresults_2D(Element_To_Draw):
|
|
4420
4431
|
danger_map_matrix_h.mask_lower(self.epsilon)
|
4421
4432
|
|
4422
4433
|
return danger_map_matrix_h
|
4434
|
+
|
4435
|
+
def export_as(self,
|
4436
|
+
outdir:str,
|
4437
|
+
fields:list[views_2D],
|
4438
|
+
which:Literal['geotiff', 'shape'],
|
4439
|
+
multiband:bool=True):
|
4440
|
+
""" Export as geotiff or shapefile """
|
4441
|
+
|
4442
|
+
oldview = self.get_currentview()
|
4443
|
+
old_plotted = self.plotted
|
4444
|
+
|
4445
|
+
arrays:dict[views_2D, WolfArray] = {}
|
4446
|
+
for curfield in tqdm(fields, _('Concatenating fields')):
|
4447
|
+
self.set_currentview(curfield)
|
4448
|
+
arrays[curfield] = self.as_WolfArray()
|
4449
|
+
arrays[curfield].nullvalue = 0.
|
4450
|
+
arrays[curfield].set_nullvalue_in_mask()
|
4451
|
+
|
4452
|
+
if which =='geotiff':
|
4453
|
+
self.export_as_geotif(outdir,
|
4454
|
+
self.idx,
|
4455
|
+
[arr for arr in arrays.values()],
|
4456
|
+
[key.value for key,arr in arrays.items()],
|
4457
|
+
multiband= multiband)
|
4458
|
+
|
4459
|
+
elif which=='shape':
|
4460
|
+
if views_2D.WATERDEPTH in arrays:
|
4461
|
+
shape_mask = arrays[views_2D.WATERDEPTH]
|
4462
|
+
else:
|
4463
|
+
logging.warning(_('No waterdepth found for shape export'))
|
4464
|
+
logging.warning(_('The first field will be used as mask for shape export'))
|
4465
|
+
shape_mask = arrays[fields[0]]
|
4466
|
+
|
4467
|
+
self.export_as_shape(outdir,
|
4468
|
+
self.idx,
|
4469
|
+
[arr for arr in arrays.values()],
|
4470
|
+
[key.value for key,arr in arrays.items()],
|
4471
|
+
shape_mask)
|
4472
|
+
|
4473
|
+
self.plotted = old_plotted
|
4474
|
+
self.set_currentview(oldview)
|
4475
|
+
|
4476
|
+
def export_as_shape(self,
|
4477
|
+
outdir:str= '',
|
4478
|
+
fn:str = '',
|
4479
|
+
myarrays:list[WolfArray]= [],
|
4480
|
+
descr:list[str]= [],
|
4481
|
+
mask:WolfArray=None):
|
4482
|
+
""" Export multiple arrays to shapefile
|
4483
|
+
|
4484
|
+
:param outdir: output directory
|
4485
|
+
:param fn: filename -- .shp will be added if not present
|
4486
|
+
:param myarrays: list of Wolfarrays to export
|
4487
|
+
:param descr: list of descriptions
|
4488
|
+
:param mask: mask array -- export only where mask > 0
|
4489
|
+
"""
|
4490
|
+
|
4491
|
+
if len(myarrays)==0:
|
4492
|
+
logging.warning(_('No arrays provided for shapefile export'))
|
4493
|
+
return
|
4494
|
+
|
4495
|
+
if mask is None:
|
4496
|
+
logging.warning(_('No mask provided for shapefile export'))
|
4497
|
+
return
|
4498
|
+
|
4499
|
+
from osgeo import gdal, osr, gdalconst,ogr
|
4500
|
+
|
4501
|
+
# create the spatial reference system, Lambert72
|
4502
|
+
srs = osr.SpatialReference()
|
4503
|
+
srs.ImportFromEPSG(31370)
|
4504
|
+
|
4505
|
+
# create the data source
|
4506
|
+
driver: ogr.Driver
|
4507
|
+
driver = ogr.GetDriverByName("ESRI Shapefile")
|
4508
|
+
|
4509
|
+
# create the data source
|
4510
|
+
filename = join(outdir,fn)
|
4511
|
+
if not filename.endswith('.shp'):
|
4512
|
+
filename+='.shp'
|
4513
|
+
|
4514
|
+
ds = driver.CreateDataSource(filename)
|
4515
|
+
|
4516
|
+
# create one layer
|
4517
|
+
layer = ds.CreateLayer("results", srs, ogr.wkbPolygon)
|
4518
|
+
|
4519
|
+
# Convert Fields
|
4520
|
+
new_descr = []
|
4521
|
+
for curfield in descr:
|
4522
|
+
if curfield == views_2D.TOPOGRAPHY.value:
|
4523
|
+
new_descr.append('TOP[m]')
|
4524
|
+
elif curfield == views_2D.WATERDEPTH.value:
|
4525
|
+
new_descr.append('WD[m]')
|
4526
|
+
elif curfield == views_2D.QX.value:
|
4527
|
+
new_descr.append('QX[m2/s]')
|
4528
|
+
elif curfield == views_2D.QY.value:
|
4529
|
+
new_descr.append('QY[m2/s]')
|
4530
|
+
elif curfield == views_2D.UNORM.value:
|
4531
|
+
new_descr.append('UN[m/s]')
|
4532
|
+
elif curfield == views_2D.FROUDE.value:
|
4533
|
+
new_descr.append('FR[-]')
|
4534
|
+
elif curfield == views_2D.HEAD.value:
|
4535
|
+
new_descr.append('HEAD[m]')
|
4536
|
+
elif curfield == views_2D.CRITICAL_DIAMETER_SHIELDS.value:
|
4537
|
+
new_descr.append('DSh[m]')
|
4538
|
+
elif curfield == views_2D.CRITICAL_DIAMETER_IZBACH.value:
|
4539
|
+
new_descr.append('DIz[m]')
|
4540
|
+
elif curfield == views_2D.QNORM.value:
|
4541
|
+
new_descr.append('QN[m2/s]')
|
4542
|
+
elif curfield == views_2D.WATERLEVEL.value:
|
4543
|
+
new_descr.append('WL[m]')
|
4544
|
+
elif curfield == views_2D.CRITICAL_DIAMETER_SUSPENSION_50.value:
|
4545
|
+
new_descr.append('DS50[m]')
|
4546
|
+
elif curfield == views_2D.CRITICAL_DIAMETER_SUSPENSION_100.value:
|
4547
|
+
new_descr.append('DS100[m]')
|
4548
|
+
|
4549
|
+
descr = new_descr
|
4550
|
+
|
4551
|
+
# Add ID fields
|
4552
|
+
idFields=[]
|
4553
|
+
for curlab in descr:
|
4554
|
+
idFields.append(ogr.FieldDefn(curlab, ogr.OFTReal))
|
4555
|
+
layer.CreateField(idFields[-1])
|
4556
|
+
|
4557
|
+
# Create the feature and set values
|
4558
|
+
featureDefn = layer.GetLayerDefn()
|
4559
|
+
feature = ogr.Feature(featureDefn)
|
4560
|
+
|
4561
|
+
usednodes = np.argwhere(mask.array>0.)
|
4562
|
+
for i,j in tqdm(usednodes):
|
4563
|
+
|
4564
|
+
x,y = mask.get_xy_from_ij(i,j)
|
4565
|
+
# Creating a line geometry
|
4566
|
+
ring = ogr.Geometry(ogr.wkbLinearRing)
|
4567
|
+
ring.AddPoint(x-mask.dx/2,y-mask.dy/2)
|
4568
|
+
ring.AddPoint(x+mask.dx/2,y-mask.dy/2)
|
4569
|
+
ring.AddPoint(x+mask.dx/2,y+mask.dy/2)
|
4570
|
+
ring.AddPoint(x-mask.dx/2,y+mask.dy/2)
|
4571
|
+
ring.AddPoint(x-mask.dx/2,y-mask.dy/2)
|
4572
|
+
|
4573
|
+
# Create polygon
|
4574
|
+
poly = ogr.Geometry(ogr.wkbPolygon)
|
4575
|
+
poly.AddGeometry(ring)
|
4576
|
+
|
4577
|
+
feature.SetGeometry(poly)
|
4578
|
+
|
4579
|
+
for arr, id in zip(myarrays,descr):
|
4580
|
+
|
4581
|
+
feature.SetField(id, float(arr.array[i,j]))
|
4582
|
+
|
4583
|
+
layer.CreateFeature(feature)
|
4584
|
+
|
4585
|
+
feature = None
|
4586
|
+
|
4587
|
+
# Save and close DataSource
|
4588
|
+
ds = None
|
4589
|
+
|
4590
|
+
def export_as_geotif(self,
|
4591
|
+
outdir:str= '',
|
4592
|
+
fn:str = '',
|
4593
|
+
myarrays:list[WolfArray]= [],
|
4594
|
+
descr:list[str]= [],
|
4595
|
+
multiband:bool= True):
|
4596
|
+
""" Export results as geotiff
|
4597
|
+
|
4598
|
+
:param outdir: output directory
|
4599
|
+
:param fn: filename -- .tif will be added if not present
|
4600
|
+
:param myarrays: list of Wolfarrays to export
|
4601
|
+
:param descr: list of descriptions -- Bands names
|
4602
|
+
|
4603
|
+
"""
|
4604
|
+
|
4605
|
+
if len(myarrays)==0:
|
4606
|
+
logging.warning(_('No arrays provided for geotiff export'))
|
4607
|
+
return
|
4608
|
+
|
4609
|
+
from osgeo import gdal, osr, gdalconst
|
4610
|
+
|
4611
|
+
srs = osr.SpatialReference()
|
4612
|
+
srs.ImportFromEPSG(31370)
|
4613
|
+
|
4614
|
+
driver: gdal.Driver
|
4615
|
+
out_ds: gdal.Dataset
|
4616
|
+
band: gdal.Band
|
4617
|
+
driver = gdal.GetDriverByName("GTiff")
|
4618
|
+
|
4619
|
+
if multiband:
|
4620
|
+
filename = join(outdir,fn)
|
4621
|
+
if not filename.endswith('.tif'):
|
4622
|
+
filename+='.tif'
|
4623
|
+
|
4624
|
+
arr = myarrays[0]
|
4625
|
+
|
4626
|
+
# Check if estimated file size exceeds 4GB
|
4627
|
+
estimated_file_size = arr.memory_usage * len(myarrays)
|
4628
|
+
if (estimated_file_size > 4 * 1024**3): # 4GB in bytes
|
4629
|
+
options = ['COMPRESS=LZW', 'BIGTIFF=YES']
|
4630
|
+
logging.info('BigTIFF format will be used!')
|
4631
|
+
else:
|
4632
|
+
options = ['COMPRESS=LZW']
|
4633
|
+
|
4634
|
+
out_ds = driver.Create(filename, arr.shape[0], arr.shape[1], len(myarrays), arr.dtype_gdal, options= options)
|
4635
|
+
out_ds.SetProjection(srs.ExportToWkt())
|
4636
|
+
out_ds.SetGeoTransform([myarrays[0].origx+myarrays[0].translx,
|
4637
|
+
myarrays[0].dx,
|
4638
|
+
0.,
|
4639
|
+
myarrays[0].origy+myarrays[0].transly,
|
4640
|
+
0.,
|
4641
|
+
myarrays[0].dy])
|
4642
|
+
|
4643
|
+
k=1
|
4644
|
+
for arr, name in tqdm(zip(myarrays,descr), 'Writing geotiff - bands'):
|
4645
|
+
band = out_ds.GetRasterBand(k)
|
4646
|
+
band.SetNoDataValue(arr.nullvalue)
|
4647
|
+
band.SetDescription(name)
|
4648
|
+
band.WriteArray(arr.array.transpose())
|
4649
|
+
band.FlushCache()
|
4650
|
+
band.ComputeStatistics(True)
|
4651
|
+
k+=1
|
4652
|
+
|
4653
|
+
out_ds = None
|
4654
|
+
|
4655
|
+
else:
|
4656
|
+
for arr, name in tqdm(zip(myarrays,descr), 'Writing geotiff'):
|
4657
|
+
|
4658
|
+
filename = join(outdir,fn)
|
4659
|
+
if filename.endswith('.tif'):
|
4660
|
+
filename = filename[:-4]
|
4661
|
+
filename = filename+'_'+name+'.tif'
|
4662
|
+
|
4663
|
+
estimated_file_size = arr.memory_usage
|
4664
|
+
if (estimated_file_size > 4 * 1024**3): # 4GB in bytes
|
4665
|
+
options = ['COMPRESS=LZW', 'BIGTIFF=YES']
|
4666
|
+
logging.info('BigTIFF format will be used!')
|
4667
|
+
else:
|
4668
|
+
options = ['COMPRESS=LZW']
|
4669
|
+
|
4670
|
+
out_ds = driver.Create(filename, arr.shape[0], arr.shape[1], 1, arr.dtype_gdal, options= options)
|
4671
|
+
out_ds.SetProjection(srs.ExportToWkt())
|
4672
|
+
out_ds.SetGeoTransform([myarrays[0].origx+myarrays[0].translx,
|
4673
|
+
myarrays[0].dx,
|
4674
|
+
0.,
|
4675
|
+
myarrays[0].origy+myarrays[0].transly,
|
4676
|
+
0.,
|
4677
|
+
myarrays[0].dy])
|
4678
|
+
|
4679
|
+
band = out_ds.GetRasterBand(1)
|
4680
|
+
band.SetNoDataValue(arr.nullvalue)
|
4681
|
+
band.SetDescription(name)
|
4682
|
+
band.WriteArray(arr.array.transpose())
|
4683
|
+
band.FlushCache()
|
4684
|
+
band.ComputeStatistics(True)
|
4685
|
+
out_ds = None
|
@@ -7,7 +7,7 @@ wolfhece/ManageParams.py,sha256=EeuUI5Vvh9ixCvYf8YShMC1s1Yacc7OxOCN7q81gqiQ,517
|
|
7
7
|
wolfhece/Model1D.py,sha256=SI4oNF_J3MdjiWZoizS8kuRXLMVyymX9dYfYJNVCQVI,476989
|
8
8
|
wolfhece/PyConfig.py,sha256=UNtl5UzZ399JqjJT67-4DWaIkv76sc1FiEsSDJpXlL0,10458
|
9
9
|
wolfhece/PyCrosssections.py,sha256=FnmM9DWY_SAF2EDH9Gu2PojXNtSTRF4-aYQuAAJXBh4,112771
|
10
|
-
wolfhece/PyDraw.py,sha256=
|
10
|
+
wolfhece/PyDraw.py,sha256=k1XDmBIohV4sGYxotU-BTD4m0KXQh-VbT6nv2itS_Oo,443861
|
11
11
|
wolfhece/PyGui.py,sha256=HY0beOMSp1JEyq8-vfVynzVrmKxvaO_sJSMwlNqCNrg,105289
|
12
12
|
wolfhece/PyGuiHydrology.py,sha256=f60E8K9eGTnRq5RDF6yvt-ahf2AYegwQ9t25zZ2Mk1A,14946
|
13
13
|
wolfhece/PyHydrographs.py,sha256=jwtSNMMACwarxrtN1UeQYth99UNrhwPx1IGgUwcooHA,3774
|
@@ -48,13 +48,13 @@ wolfhece/pywalous.py,sha256=yRaWJjKckXef1d9D5devP0yFHC9uc6kRV4G5x9PNq9k,18972
|
|
48
48
|
wolfhece/rain_SPWMI.py,sha256=qCfcmF7LajloOaCwnTrrSMzyME03YyilmRUOqrPrv3U,13846
|
49
49
|
wolfhece/textpillow.py,sha256=map7HsGYML_o5NHRdFg2s_TVQed_lDnpYNDv27MM0Vw,14130
|
50
50
|
wolfhece/tools_mpl.py,sha256=gQ3Jg1iuZiecmMqa5Eli2ZLSkttu68VXL8YmMDBaEYU,564
|
51
|
-
wolfhece/wolf_array.py,sha256=
|
51
|
+
wolfhece/wolf_array.py,sha256=Pv7Kbimou7t-wXkixwZ0Gcv2N9kTPWJxiHI8VYD8sCk,407304
|
52
52
|
wolfhece/wolf_hist.py,sha256=7jeVrgSkM3ErJO6SRMH_PGzfLjIdw8vTy87kesldggk,3582
|
53
53
|
wolfhece/wolf_texture.py,sha256=DS5eobLxrq9ljyebYfpMSQPn8shkUAZZVfqrOKN_QUU,16951
|
54
54
|
wolfhece/wolf_tiles.py,sha256=2Ho2I20rHRY81KXxjgLOYISdF4OkJ2d6omeY4shDoGI,10386
|
55
55
|
wolfhece/wolf_vrt.py,sha256=89XoDhCJMHiwPQUuOduxtTRKuIa8RDxgNqX65S4xp9M,10569
|
56
56
|
wolfhece/wolf_zi_db.py,sha256=baE0niMCzybWGSvPJc5FNxo9ZxsGfU4p-FmfiavFHAs,12967
|
57
|
-
wolfhece/wolfresults_2D.py,sha256
|
57
|
+
wolfhece/wolfresults_2D.py,sha256=-Un0F7GsfSJetycyYc-6UeOrXEFCu9eH9Fumj-Qe4cM,179603
|
58
58
|
wolfhece/xyz_file.py,sha256=Se4nCPwYAYLSA5i0zsbnZUKoAMAD0mK1FJea5WSZUkk,5755
|
59
59
|
wolfhece/acceptability/Parallels.py,sha256=h4tu3SpC_hR5Hqa68aruxhtAyhs8u666YuZ40_fR5zg,3979
|
60
60
|
wolfhece/acceptability/__init__.py,sha256=hfgoPKLDpX7drN1Vpvux-_5Lfyc_7feT2C2zQr5v-Os,258
|
@@ -75,7 +75,7 @@ wolfhece/apps/curvedigitizer.py,sha256=Yps4bcayzbsz0AoVc_dkSk35dEhhn_esIBy1Ziefg
|
|
75
75
|
wolfhece/apps/hydrometry.py,sha256=lhhJsFeb4zGL4bNQTs0co85OQ_6ssL1Oy0OUJCzhfYE,656
|
76
76
|
wolfhece/apps/isocurrent.py,sha256=dagmGR8ja9QQ1gwz_8fU-N052hIw-W0mWGVkzLu6C7I,4247
|
77
77
|
wolfhece/apps/splashscreen.py,sha256=SrustmIQeXnsiD-92OzjdGhBi-S7c_j-cSvuX4T6rtg,2929
|
78
|
-
wolfhece/apps/version.py,sha256=
|
78
|
+
wolfhece/apps/version.py,sha256=5EAPTzfatYqx9GXoy44yzHoCW1DnjWdiOvkS-fo60-c,388
|
79
79
|
wolfhece/apps/wolf.py,sha256=j_CgvsL8rwixbVvVD5Z0s7m7cHZ86gmFLojKGuetMls,729
|
80
80
|
wolfhece/apps/wolf2D.py,sha256=4z_OPQ3IgaLtjexjMKX9ppvqEYyjFLt1hcfFABy3-jU,703
|
81
81
|
wolfhece/apps/wolf_logo.bmp,sha256=ruJ4MA51CpGO_AYUp_dB4SWKHelvhOvd7Q8NrVOjDJk,3126
|
@@ -285,8 +285,8 @@ wolfhece/ui/wolf_multiselection_collapsiblepane.py,sha256=8PlMYrb_8jI8h9F0_EagpM
|
|
285
285
|
wolfhece/ui/wolf_times_selection_comparison_models.py,sha256=ORy7fz4dcp691qKzaOZHrRLZ0uXNhL-LIHxmpDGL6BI,5007
|
286
286
|
wolfhece/wintab/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
287
287
|
wolfhece/wintab/wintab.py,sha256=8A-JNONV6ujgsgG3lM5Uw-pVgglPATwKs86oBzzljoc,7179
|
288
|
-
wolfhece-2.1.
|
289
|
-
wolfhece-2.1.
|
290
|
-
wolfhece-2.1.
|
291
|
-
wolfhece-2.1.
|
292
|
-
wolfhece-2.1.
|
288
|
+
wolfhece-2.1.96.dist-info/METADATA,sha256=woDxgeDItCFEgqYP3HLrY3xiLGjHxXRQ-rV9TyNDgFQ,2570
|
289
|
+
wolfhece-2.1.96.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
290
|
+
wolfhece-2.1.96.dist-info/entry_points.txt,sha256=ZZ-aSfbpdcmo-wo84lRFzBN7LaSnD1XRGSaAKVX-Gpc,522
|
291
|
+
wolfhece-2.1.96.dist-info/top_level.txt,sha256=EfqZXMVCn7eILUzx9xsEu2oBbSo9liWPFWjIHik0iCI,9
|
292
|
+
wolfhece-2.1.96.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|