wolfhece 2.1.120__py3-none-any.whl → 2.1.122__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/PyCrosssections.py +236 -209
- wolfhece/PyDraw.py +111 -50
- wolfhece/PyGui.py +1 -1
- wolfhece/PyVertexvectors.py +164 -47
- wolfhece/acceptability/acceptability.py +17 -13
- wolfhece/acceptability/acceptability_gui.py +517 -526
- wolfhece/acceptability/func.py +46 -58
- wolfhece/apps/version.py +1 -1
- wolfhece/lazviewer/laz_viewer.py +6 -4
- wolfhece/pybridges.py +6 -1
- wolfhece/scenario/config_manager.py +165 -32
- wolfhece/scenario/update_void.py +31 -0
- wolfhece/wolf_array.py +29 -15
- wolfhece/wolfresults_2D.py +10 -7
- {wolfhece-2.1.120.dist-info → wolfhece-2.1.122.dist-info}/METADATA +1 -1
- {wolfhece-2.1.120.dist-info → wolfhece-2.1.122.dist-info}/RECORD +19 -19
- {wolfhece-2.1.120.dist-info → wolfhece-2.1.122.dist-info}/WHEEL +0 -0
- {wolfhece-2.1.120.dist-info → wolfhece-2.1.122.dist-info}/entry_points.txt +0 -0
- {wolfhece-2.1.120.dist-info → wolfhece-2.1.122.dist-info}/top_level.txt +0 -0
@@ -56,7 +56,7 @@ except:
|
|
56
56
|
# mann_*.tif
|
57
57
|
# infil_*.tif
|
58
58
|
|
59
|
-
ACCEPTED_PREFIX = ['bath_', 'mann_', 'infil_', 'roof_']
|
59
|
+
ACCEPTED_PREFIX = ['bath_', 'mann_', 'infil_', 'roof_', 'deck_']
|
60
60
|
|
61
61
|
def delete_folder(pth:Path):
|
62
62
|
for sub in pth.iterdir():
|
@@ -472,7 +472,14 @@ class Config_Manager_2D_GPU:
|
|
472
472
|
|
473
473
|
logging.info(_('Number of tif files : {}'.format(len(list_tif))))
|
474
474
|
|
475
|
-
standard_files = ['bathymetry.tif',
|
475
|
+
standard_files = ['bathymetry.tif',
|
476
|
+
'manning.tif',
|
477
|
+
'infiltration.tif',
|
478
|
+
'h.tif',
|
479
|
+
'qx.tif',
|
480
|
+
'qy.tif',
|
481
|
+
'roof.tif',
|
482
|
+
'deck.tif']
|
476
483
|
|
477
484
|
log = ''
|
478
485
|
for curtif in list_tif:
|
@@ -509,6 +516,12 @@ class Config_Manager_2D_GPU:
|
|
509
516
|
loclog += _('Did you mean "roof_" ?') + '\n'
|
510
517
|
break
|
511
518
|
|
519
|
+
tests = ['dec_', 'dek_', 'dck_', 'deeck_', 'decq_']
|
520
|
+
for test in tests:
|
521
|
+
if curtif.name.lower().startswith(test):
|
522
|
+
loclog += _('Did you mean "deck_" ?') + '\n'
|
523
|
+
break
|
524
|
+
|
512
525
|
logging.warning(loclog)
|
513
526
|
|
514
527
|
log += loclog
|
@@ -772,7 +785,7 @@ class Config_Manager_2D_GPU:
|
|
772
785
|
|
773
786
|
return curdict
|
774
787
|
|
775
|
-
def _select_tif_partname(self, curdict:dict, tifstr:Literal['bath_', 'mann_', 'infil_', 'roof_']):
|
788
|
+
def _select_tif_partname(self, curdict:dict, tifstr:Literal['bath_', 'mann_', 'infil_', 'roof_', 'deck_']):
|
776
789
|
""" Select tif files with a 'str' as name's prefix """
|
777
790
|
|
778
791
|
assert tifstr in ACCEPTED_PREFIX, _('Bad prefix !')
|
@@ -785,6 +798,8 @@ class Config_Manager_2D_GPU:
|
|
785
798
|
forced_add = ['infiltration.tif']
|
786
799
|
elif tifstr == 'roof_':
|
787
800
|
forced_add = ['roof.tif']
|
801
|
+
elif tifstr == 'deck_':
|
802
|
+
forced_add = ['deck.tif']
|
788
803
|
|
789
804
|
tif_list = [curtif for curtif in curdict[GPU_2D_file_extensions.TIF.value] \
|
790
805
|
if curtif.name.lower().startswith(tifstr) or \
|
@@ -807,14 +822,16 @@ class Config_Manager_2D_GPU:
|
|
807
822
|
all_tif_mann = [self._select_tif_partname(curdict, 'mann_') for curdict in curdicts]
|
808
823
|
all_tif_infil = [self._select_tif_partname(curdict, 'infil_') for curdict in curdicts]
|
809
824
|
all_tif_roof = [self._select_tif_partname(curdict, 'roof_') for curdict in curdicts]
|
825
|
+
all_tif_deck = [self._select_tif_partname(curdict, 'deck_') for curdict in curdicts]
|
810
826
|
|
811
827
|
# flatten list of lists
|
812
828
|
all_tif_bath = [curel for curlist in all_tif_bath if len(curlist)>0 for curel in curlist]
|
813
829
|
all_tif_mann = [curel for curlist in all_tif_mann if len(curlist)>0 for curel in curlist]
|
814
830
|
all_tif_infil = [curel for curlist in all_tif_infil if len(curlist)>0 for curel in curlist]
|
815
831
|
all_tif_roof = [curel for curlist in all_tif_roof if len(curlist)>0 for curel in curlist]
|
832
|
+
all_tif_deck = [curel for curlist in all_tif_deck if len(curlist)>0 for curel in curlist]
|
816
833
|
|
817
|
-
for cur_lst in [all_tif_bath, all_tif_mann, all_tif_infil, all_tif_roof]:
|
834
|
+
for cur_lst in [all_tif_bath, all_tif_mann, all_tif_infil, all_tif_roof, all_tif_deck]:
|
818
835
|
for cur_tif in cur_lst:
|
819
836
|
curarray:WolfArray = WolfArray(cur_tif)
|
820
837
|
if curarray.nullvalue != 99999.:
|
@@ -840,12 +857,14 @@ class Config_Manager_2D_GPU:
|
|
840
857
|
all_tif_mann = [self._select_tif_partname(curdict, 'mann_') for curdict in curdicts]
|
841
858
|
all_tif_infil = [self._select_tif_partname(curdict, 'infil_') for curdict in curdicts]
|
842
859
|
all_tif_roof = [self._select_tif_partname(curdict, 'roof_') for curdict in curdicts]
|
860
|
+
all_tif_deck = [self._select_tif_partname(curdict, 'deck_') for curdict in curdicts]
|
843
861
|
|
844
862
|
# flatten list of lists
|
845
863
|
all_tif_bath = [curel for curlist in all_tif_bath if len(curlist)>0 for curel in curlist]
|
846
864
|
all_tif_mann = [curel for curlist in all_tif_mann if len(curlist)>0 for curel in curlist]
|
847
865
|
all_tif_infil = [curel for curlist in all_tif_infil if len(curlist)>0 for curel in curlist]
|
848
866
|
all_tif_roof = [curel for curlist in all_tif_roof if len(curlist)>0 for curel in curlist]
|
867
|
+
all_tif_deck = [curel for curlist in all_tif_deck if len(curlist)>0 for curel in curlist]
|
849
868
|
|
850
869
|
# création du fichier vrt
|
851
870
|
create_vrt_from_files_first_based(all_tif_bath, from_path / '__bath_assembly.vrt')
|
@@ -861,9 +880,14 @@ class Config_Manager_2D_GPU:
|
|
861
880
|
else:
|
862
881
|
logging.info(_('No roof files found ! -> no __roof_assembly.vrt file created !'))
|
863
882
|
|
883
|
+
if len(all_tif_deck)>0:
|
884
|
+
create_vrt_from_files_first_based(all_tif_deck, from_path / '__deck_assembly.vrt')
|
885
|
+
else:
|
886
|
+
logging.info(_('No deck files found ! -> no __deck_assembly.vrt file created !'))
|
887
|
+
|
864
888
|
def create_vec(self,
|
865
889
|
from_path:Path,
|
866
|
-
which:Literal['bath_', 'mann_', 'infil_', 'roof_'] = 'bath_') -> Zones:
|
890
|
+
which:Literal['bath_', 'mann_', 'infil_', 'roof_', 'deck_'] = 'bath_') -> Zones:
|
867
891
|
""" Create a vec file from a path """
|
868
892
|
|
869
893
|
assert which in ACCEPTED_PREFIX, _('Bad prefix !')
|
@@ -923,17 +947,17 @@ class Config_Manager_2D_GPU:
|
|
923
947
|
def translate_vrt2tif(self, from_path:Path):
|
924
948
|
""" Translate vrt to tif """
|
925
949
|
|
926
|
-
vrtin = ['__bath_assembly.vrt', '__mann_assembly.vrt', '__infil_assembly.vrt', '__roof_assembly.vrt']
|
927
|
-
fout = ['__bathymetry.tif' , '__manning.tif', '__infiltration.tif', '__roof.tif']
|
950
|
+
vrtin = ['__bath_assembly.vrt', '__mann_assembly.vrt', '__infil_assembly.vrt', '__roof_assembly.vrt', '__deck_assembly.vrt']
|
951
|
+
fout = ['__bathymetry.tif' , '__manning.tif', '__infiltration.tif', '__roof.tif', '__deck.tif']
|
928
952
|
|
929
953
|
for curin, curout in zip(vrtin, fout):
|
930
954
|
if (from_path / curin).exists():
|
931
955
|
translate_vrt2tif(from_path / curin, from_path / curout)
|
932
956
|
|
933
|
-
def
|
957
|
+
def apply_scripts_bath_mann_inf_roof_deck(self, from_path:Path):
|
934
958
|
""" Apply all scripts """
|
935
959
|
|
936
|
-
filenames = ['__bathymetry.tif', '__manning.tif', '__infiltration.tif', '__roof.tif']
|
960
|
+
filenames = ['__bathymetry.tif', '__manning.tif', '__infiltration.tif', '__roof.tif', '__deck.tif']
|
937
961
|
|
938
962
|
# check if present on disk
|
939
963
|
if not all([(from_path / curfile).exists() for curfile in filenames]):
|
@@ -946,13 +970,15 @@ class Config_Manager_2D_GPU:
|
|
946
970
|
|
947
971
|
arrays = [WolfArray(from_path / curfile) for curfile in filenames]
|
948
972
|
|
949
|
-
self.
|
973
|
+
self._apply_scripts_update_topo_maning_inf_roof_deck(from_path, arrays[0], arrays[1], arrays[2], arrays[3], arrays[4])
|
950
974
|
|
951
975
|
# write the files
|
952
976
|
arrays[0].write_all(from_path / '__bathymetry_after_scripts.tif')
|
953
977
|
arrays[1].write_all(from_path / '__manning_after_scripts.tif')
|
954
978
|
arrays[2].write_all(from_path / '__infiltration_after_scripts.tif')
|
955
979
|
arrays[3].write_all(from_path / '__roof_after_scripts.tif')
|
980
|
+
arrays[4].write_all(from_path / '__deck_after_scripts.tif')
|
981
|
+
|
956
982
|
|
957
983
|
def _import_scripts(self, from_path:Path, which) -> list[types.ModuleType]:
|
958
984
|
""" List all modules in structure and import them.
|
@@ -994,24 +1020,25 @@ class Config_Manager_2D_GPU:
|
|
994
1020
|
|
995
1021
|
return imported_mod
|
996
1022
|
|
997
|
-
def
|
1023
|
+
def _import_scripts_topo_manning_inf_roof_deck(self, from_path:Path) -> list[types.ModuleType]:
|
998
1024
|
""" import all topo and manning scripts from a path """
|
999
1025
|
|
1000
1026
|
return self._import_scripts(from_path, WOLF_UPDATE)
|
1001
1027
|
|
1002
|
-
def
|
1028
|
+
def _apply_scripts_update_topo_maning_inf_roof_deck(self,
|
1003
1029
|
modules:list[types.ModuleType] | Path | str,
|
1004
1030
|
array_bat:WolfArray,
|
1005
1031
|
array_mann:WolfArray,
|
1006
1032
|
array_inf:WolfArray,
|
1007
|
-
array_roof:WolfArray
|
1033
|
+
array_roof:WolfArray,
|
1034
|
+
array_deck:WolfArray):
|
1008
1035
|
""" Apply all scripts from a list of modules """
|
1009
1036
|
|
1010
1037
|
if isinstance(modules, str):
|
1011
1038
|
modules = Path(modules)
|
1012
1039
|
|
1013
1040
|
if isinstance(modules, Path):
|
1014
|
-
modules = self.
|
1041
|
+
modules = self._import_scripts_topo_manning_inf_roof_deck(modules)
|
1015
1042
|
|
1016
1043
|
for curmod in modules:
|
1017
1044
|
instmod = curmod.Update_Sim_Scenario()
|
@@ -1047,6 +1074,13 @@ class Config_Manager_2D_GPU:
|
|
1047
1074
|
except Exception as e:
|
1048
1075
|
logging.error(_('An error occured during roof script - {}!').format(e))
|
1049
1076
|
|
1077
|
+
try:
|
1078
|
+
if not hasattr(instmod, "update_deck"):
|
1079
|
+
logging.info(_('No update_deck method found in the script {}!').format(curmod))
|
1080
|
+
else:
|
1081
|
+
instmod.update_deck(array_deck)
|
1082
|
+
except Exception as e:
|
1083
|
+
logging.error(_('An error occured during deck script - {}!').format(e))
|
1050
1084
|
|
1051
1085
|
def _import_scripts_bc(self, from_path:Path) -> list[types.ModuleType]:
|
1052
1086
|
""" Import all BC's scripts from a path """
|
@@ -1165,23 +1199,81 @@ class Config_Manager_2D_GPU:
|
|
1165
1199
|
else:
|
1166
1200
|
logging.error(_("No 'bathymetry.tif' file found in the root directory !"))
|
1167
1201
|
|
1202
|
+
def create_void_deck(self):
|
1203
|
+
""" create void deck file """
|
1204
|
+
|
1205
|
+
if (self.workingdir / 'bathymetry.tif').exists():
|
1206
|
+
locheader = self.get_header()
|
1207
|
+
deck = WolfArray(srcheader=locheader, whichtype= WOLF_ARRAY_FULL_SINGLE)
|
1208
|
+
deck.array.data[:,:] = 99999.
|
1209
|
+
deck.nullvalue = 99999.
|
1210
|
+
deck.write_all(str(self.workingdir / 'deck.tif'))
|
1211
|
+
|
1212
|
+
if (self.workingdir / 'deck.tif').exists():
|
1213
|
+
logging.info(_('deck.tif created and set to 99999. ! -- Please edit it !'))
|
1214
|
+
else:
|
1215
|
+
logging.error(_("deck.tif not created ! -- Does 'bathymetry.tif' or any '.tif' file exist in the root directory ?"))
|
1216
|
+
else:
|
1217
|
+
logging.error(_("No 'bathymetry.tif' file found in the root directory !"))
|
1218
|
+
|
1168
1219
|
|
1169
|
-
def
|
1220
|
+
def combine_bath_roof_deck(self, bathymetry:WolfArray,
|
1221
|
+
bridge_roof:WolfArray, bridge_deck:WolfArray,
|
1222
|
+
threshold:float = .05) -> str:
|
1170
1223
|
""" Verify bathymetry, roof and deck """
|
1171
1224
|
|
1225
|
+
ret = ''
|
1172
1226
|
if bridge_roof is None:
|
1173
|
-
|
1174
|
-
|
1227
|
+
ret += _('No bridge roof found !')
|
1228
|
+
if bridge_deck is None:
|
1229
|
+
ret += _('No bridge deck found !')
|
1230
|
+
|
1231
|
+
if ret != '':
|
1232
|
+
logging.error(ret)
|
1233
|
+
return ret
|
1234
|
+
|
1175
1235
|
# si la matrice de toit de pont est plus basse que la bathymétrie, on met à 99999
|
1176
1236
|
# la bathymétrie et le toit de pont.
|
1177
1237
|
# Ainsi, ces maille seront infranchissables.
|
1178
|
-
#
|
1238
|
+
# Cela peut être utile pour discrétiser les piles dans les données du toit, plutôt que de les
|
1179
1239
|
# laisser inclure dans un fichier bath_ séparé.
|
1180
|
-
mask = bridge_roof.array.data < bathymetry.array.data
|
1181
|
-
bridge_roof.array.data[mask] = 99999.
|
1182
|
-
bathymetry.array.data[mask] = 99999.
|
1183
|
-
|
1184
1240
|
|
1241
|
+
mask_roof = np.where(bridge_roof.array.data != 99999.)
|
1242
|
+
mask_deck = np.where(bridge_deck.array.data != 99999.)
|
1243
|
+
if mask_roof[0].shape != mask_deck[0].shape:
|
1244
|
+
ret += _('Roof and deck have different shapes !\n')
|
1245
|
+
ret += _(' -- If not desired, please check your data\n')
|
1246
|
+
|
1247
|
+
mask = np.where(bridge_roof.array.data > bridge_deck.array.data)
|
1248
|
+
if mask[0].shape[0] > 0:
|
1249
|
+
ret += _('Some roof values are higher than deck values !\n')
|
1250
|
+
ret += _('-- Roof values will be set to deck values\n')
|
1251
|
+
bridge_roof.array.data[mask] = bridge_deck.array.data[mask]
|
1252
|
+
|
1253
|
+
mask = np.where(bridge_roof.array.data <= bathymetry.array.data)
|
1254
|
+
if mask[0].shape[0] > 0:
|
1255
|
+
ret += _('Some roof values are lower than or equal to bathymetry values !\n')
|
1256
|
+
ret += _(' -- Roof values will be set to 99999\n')
|
1257
|
+
ret += _(' -- Bathymetry values will be set to max(bath, deck)\n')
|
1258
|
+
ret += _(' -- These cells will remain impassable until the water level rises above them\n')
|
1259
|
+
bridge_roof.array.data[mask] = 99999.
|
1260
|
+
bathymetry.array.data[mask] = np.maximum(bridge_deck.array.data[mask], bathymetry.array.data[mask])
|
1261
|
+
|
1262
|
+
mask = np.where(bridge_roof.array.data - bathymetry.array.data < threshold)
|
1263
|
+
if mask[0].shape[0] > 0:
|
1264
|
+
ret += _('Some roof values are close to bathymetry values (threshold is {} cm) !\n').format(int(threshold*100))
|
1265
|
+
ret += _(' -- Bathymetry will be impose to the deck level\n')
|
1266
|
+
ret += _(' -- New roof values will be set to 99999\n')
|
1267
|
+
ret += _(' -- New deck values will be set to 99999\n')
|
1268
|
+
bathymetry.array.data[mask] = bridge_deck.array.data[mask]
|
1269
|
+
bridge_deck.array.data[mask] = 99999.
|
1270
|
+
bridge_roof.array.data[mask] = 99999.
|
1271
|
+
|
1272
|
+
if ret != '':
|
1273
|
+
logging.warning(ret)
|
1274
|
+
|
1275
|
+
return ret
|
1276
|
+
|
1185
1277
|
def create_simulation(self,
|
1186
1278
|
dir:Path,
|
1187
1279
|
idx_hydros:list[int] = [-1],
|
@@ -1301,16 +1393,28 @@ class Config_Manager_2D_GPU:
|
|
1301
1393
|
roof = WolfArray(srcheader=bat.get_header(), whichtype= WOLF_ARRAY_FULL_SINGLE)
|
1302
1394
|
roof.array.data[:,:] = 99999.
|
1303
1395
|
|
1396
|
+
# check for deck
|
1397
|
+
if exists(dir / '__deck.tif'):
|
1398
|
+
deck = WolfArray(str(dir / '__deck.tif'))
|
1399
|
+
if deck.wolftype != WOLF_ARRAY_FULL_SINGLE:
|
1400
|
+
logging.error(_('Deck .tif must be a full single array ! -- The array will be ignored !'))
|
1401
|
+
deck = WolfArray(srcheader=bat.get_header(), whichtype= WOLF_ARRAY_FULL_SINGLE)
|
1402
|
+
deck.array.data[:,:] = 99999.
|
1403
|
+
else:
|
1404
|
+
deck = WolfArray(srcheader=bat.get_header(), whichtype= WOLF_ARRAY_FULL_SINGLE)
|
1405
|
+
deck.array.data[:,:] = 99999.
|
1406
|
+
|
1304
1407
|
# applying Python scrpitps on ARRAYS
|
1305
|
-
self.
|
1408
|
+
self._apply_scripts_update_topo_maning_inf_roof_deck(dir, bat, man, infiltration, roof, deck)
|
1306
1409
|
|
1307
|
-
self.
|
1410
|
+
self.combine_bath_roof_deck(bat, roof, deck)
|
1308
1411
|
|
1309
1412
|
# save arrays on disk
|
1310
1413
|
bat.write_all(str(dir / '__bathymetry_after_scripts.tif'))
|
1311
1414
|
man.write_all(str(dir / '__manning_after_scripts.tif'))
|
1312
1415
|
infiltration.write_all(str(dir / '__infiltration_after_scripts.tif'))
|
1313
1416
|
roof.write_all(str(dir / '__roof_after_scripts.tif'))
|
1417
|
+
deck.write_all(str(dir / '__deck_after_scripts.tif'))
|
1314
1418
|
|
1315
1419
|
# create simulation
|
1316
1420
|
allsims = []
|
@@ -1386,6 +1490,15 @@ class Config_Manager_2D_GPU:
|
|
1386
1490
|
cursim.bridge_roof = roof.array.data
|
1387
1491
|
logging.info(_("You have {} cells defined as roof").format(roof.nbnotnull))
|
1388
1492
|
|
1493
|
+
# if deck.nbnotnull == 0:
|
1494
|
+
# cursim.bridge_deck = None
|
1495
|
+
# logging.info(_("No cells defined as deck ! -- Deck will be ignored !"))
|
1496
|
+
# else:
|
1497
|
+
# cursim.bridge_deck = deck.array.data
|
1498
|
+
# logging.info(_("You have {} cells defined as deck").format(deck.nbnotnull))
|
1499
|
+
|
1500
|
+
# paramétrage hydro
|
1501
|
+
|
1389
1502
|
# add hydrograph
|
1390
1503
|
for idx, curline in curhydro.data.iterrows():
|
1391
1504
|
cursim.add_infiltration(float(idx), [float(cur) for cur in curline.values])
|
@@ -1631,33 +1744,41 @@ class UI_Manager_2D_GPU():
|
|
1631
1744
|
self._create_void_infil.Bind(wx.EVT_BUTTON,self.oncreate_void_infil)
|
1632
1745
|
self._create_void_infil.SetToolTip(_('Create a void infiltration zones file based on bathymetry.tif'))
|
1633
1746
|
|
1747
|
+
bridge_sizer = wx.BoxSizer(wx.HORIZONTAL)
|
1634
1748
|
self._create_void_roof = wx.Button(self._frame,label = _('Create .tif bridge/culvert roof elevation'))
|
1635
1749
|
self._create_void_roof.Bind(wx.EVT_BUTTON,self.oncreate_void_roof)
|
1636
1750
|
self._create_void_roof.SetToolTip(_('Create a void roof file based on bathymetry.tif'))
|
1637
1751
|
|
1752
|
+
self._create_void_deck = wx.Button(self._frame,label = _('Create .tif bridge/culvert deck elevation'))
|
1753
|
+
self._create_void_deck.Bind(wx.EVT_BUTTON,self.oncreate_void_deck)
|
1754
|
+
self._create_void_deck.SetToolTip(_('Create a void deck file based on bathymetry.tif'))
|
1755
|
+
|
1756
|
+
bridge_sizer.Add(self._create_void_roof, 1, wx.EXPAND)
|
1757
|
+
bridge_sizer.Add(self._create_void_deck, 1, wx.EXPAND)
|
1758
|
+
|
1638
1759
|
self._create_void_scripts = wx.Button(self._frame,label = _('Create void scripts'))
|
1639
1760
|
self._create_void_scripts.Bind(wx.EVT_BUTTON,self.oncreate_void_scripts)
|
1640
1761
|
self._create_void_scripts.SetToolTip(_('Create void script files for topography, manning and infiltration'))
|
1641
1762
|
|
1642
1763
|
self._create_vrt = wx.Button(self._frame,label = _('Assembly .vrt to current level'))
|
1643
1764
|
self._create_vrt.Bind(wx.EVT_BUTTON,self.oncreatevrt)
|
1644
|
-
self._create_vrt.SetToolTip(_('Create a .vrt file from all bathymetry, manning, infiltration and
|
1765
|
+
self._create_vrt.SetToolTip(_('Create a .vrt file from all bathymetry, manning, infiltration, roof and deck .tif files\nBe sure that all files are right named !\n\n - bathymetry must contain "bath"\n - manning must contain "mann"\n - infiltration must contain "infil"\n - roof must contain "roof"\n - deck must contain "deck"'))
|
1645
1766
|
|
1646
1767
|
self._translate_vrt = wx.Button(self._frame,label = _('Translate .vrt to .tif'))
|
1647
1768
|
self._translate_vrt.Bind(wx.EVT_BUTTON,self.ontranslatevrt2tif)
|
1648
|
-
self._translate_vrt.SetToolTip(_('Translate .vrt files to .tif files\n\n - __bath_assembly.vrt -> __bathymetry.tif\n - __mann_assembly.vrt -> __manning.tif\n - __infil_assembly.vrt -> __infiltration.tif\n - __roof_assembly.vrt -> __roof.tif'))
|
1769
|
+
self._translate_vrt.SetToolTip(_('Translate .vrt files to .tif files\n\n - __bath_assembly.vrt -> __bathymetry.tif\n - __mann_assembly.vrt -> __manning.tif\n - __infil_assembly.vrt -> __infiltration.tif\n - __roof_assembly.vrt -> __roof.tif\n - __deck_assembly.vrt -> __deck.tif'))
|
1649
1770
|
|
1650
|
-
self._apply_scripts = wx.Button(self._frame,label = _('Apply scripts on bathymetry, manning, infiltration and
|
1771
|
+
self._apply_scripts = wx.Button(self._frame,label = _('Apply scripts on bathymetry, manning, infiltration, roof and deck elevation'))
|
1651
1772
|
self._apply_scripts.Bind(wx.EVT_BUTTON,self.onapply_scripts)
|
1652
|
-
self._apply_scripts.SetToolTip(_('Apply scripts on bathymetry, manning and infiltration\n\n - bathymetry.tif\n - manning.tif\n - infiltration.tif\n - roof.tif\n\nThe scripts must be in the structure starting with parent directory and descending.'))
|
1773
|
+
self._apply_scripts.SetToolTip(_('Apply scripts on bathymetry, manning and infiltration\n\n - bathymetry.tif\n - manning.tif\n - infiltration.tif\n - roof.tif\n - deck.tif\n\nThe scripts must be in the structure starting with parent directory and descending.'))
|
1653
1774
|
|
1654
1775
|
self._create_vec = wx.Button(self._frame,label = _('Search spatial coverage from current level'))
|
1655
1776
|
self._create_vec.Bind(wx.EVT_BUTTON,self.oncreatevec)
|
1656
|
-
self._create_vec.SetToolTip(_('Create a .vecz file (with contour and global bounds) from all bathymetry and manning .tif files\nBe sure that all files are right named !\n\n - bathymetry must contain "bath"\n - manning must contain "mann"\n - infiltration must contain "infil"\n - roof must contain "roof"'))
|
1777
|
+
self._create_vec.SetToolTip(_('Create a .vecz file (with contour and global bounds) from all bathymetry and manning .tif files\nBe sure that all files are right named !\n\n - bathymetry must contain "bath"\n - manning must contain "mann"\n - infiltration must contain "infil"\n - roof must contain "roof"\n - deck must contain "deck"'))
|
1657
1778
|
|
1658
1779
|
self._check_prefix = wx.Button(self._frame,label = _('Check prefix (tif files)'))
|
1659
1780
|
self._check_prefix.Bind(wx.EVT_BUTTON,self.oncheck_prefix)
|
1660
|
-
self._check_prefix.SetToolTip(_('Check prefix of .tif files\n\n - bath_*.tif\n - mann_*.tif\n - infil_*.tif\n - roof_*.tif\n\nThe prefix must be "bath_", "mann_", "infil_" and "
|
1781
|
+
self._check_prefix.SetToolTip(_('Check prefix of .tif files\n\n - bath_*.tif\n - mann_*.tif\n - infil_*.tif\n - roof_*.tif\n - deck_*.tif\n\nThe prefix must be "bath_", "mann_", "infil_", "roof_" and "deck__"'))
|
1661
1782
|
|
1662
1783
|
self._checkconsistency = wx.Button(self._frame,label = _('Check consistency'))
|
1663
1784
|
self._checkconsistency.Bind(wx.EVT_BUTTON,self.oncheck_consistency)
|
@@ -1707,7 +1828,7 @@ class UI_Manager_2D_GPU():
|
|
1707
1828
|
# buttons -> sizer
|
1708
1829
|
sizer_buttons.Add(self._reload,1,wx.EXPAND)
|
1709
1830
|
sizer_buttons.Add(self._create_void_infil,1,wx.EXPAND)
|
1710
|
-
sizer_buttons.Add(
|
1831
|
+
sizer_buttons.Add(bridge_sizer,1,wx.EXPAND)
|
1711
1832
|
sizer_buttons.Add(self._create_void_scripts,1,wx.EXPAND)
|
1712
1833
|
sizer_buttons.Add(self._check_prefix,1,wx.EXPAND)
|
1713
1834
|
sizer_buttons.Add(self._create_vrt,1,wx.EXPAND)
|
@@ -1782,6 +1903,12 @@ class UI_Manager_2D_GPU():
|
|
1782
1903
|
self._parent.create_void_roof()
|
1783
1904
|
self.reload()
|
1784
1905
|
|
1906
|
+
def oncreate_void_deck(self, e:wx.MouseEvent):
|
1907
|
+
""" Création d'un fichier de tablier de pont vide """
|
1908
|
+
|
1909
|
+
self._parent.create_void_deck()
|
1910
|
+
self.reload()
|
1911
|
+
|
1785
1912
|
def oncreate_void_scripts(self,e:wx.MouseEvent):
|
1786
1913
|
""" Création d'un script vide """
|
1787
1914
|
|
@@ -1898,6 +2025,7 @@ class UI_Manager_2D_GPU():
|
|
1898
2025
|
if self._selected_item is None or self._selected_item == self._treelist.GetRootItem():
|
1899
2026
|
logging.info(_('No item selected ! -- using root item'))
|
1900
2027
|
with wx.MessageDialog(None, _('No item selected ! -- using root item'), _('Warning'), wx.OK | wx.CANCEL | wx.ICON_WARNING) as dlg:
|
2028
|
+
dlg:wx.MessageDialog
|
1901
2029
|
ret = dlg.ShowModal()
|
1902
2030
|
if ret != wx.ID_OK:
|
1903
2031
|
return
|
@@ -1920,6 +2048,7 @@ class UI_Manager_2D_GPU():
|
|
1920
2048
|
if self._selected_item is None or self._selected_item == self._treelist.GetRootItem():
|
1921
2049
|
logging.info(_('No item selected ! -- using root item'))
|
1922
2050
|
with wx.MessageDialog(None, _('No item selected ! -- using root item'), _('Warning'), wx.OK | wx.CANCEL | wx.ICON_WARNING) as dlg:
|
2051
|
+
dlg:wx.MessageDialog
|
1923
2052
|
ret = dlg.ShowModal()
|
1924
2053
|
if ret != wx.ID_OK:
|
1925
2054
|
return
|
@@ -1932,7 +2061,7 @@ class UI_Manager_2D_GPU():
|
|
1932
2061
|
return
|
1933
2062
|
|
1934
2063
|
# application des scripts
|
1935
|
-
self._parent.
|
2064
|
+
self._parent.apply_scripts_bath_mann_inf_roof_deck(mydata['path'])
|
1936
2065
|
|
1937
2066
|
self.reload()
|
1938
2067
|
logging.info(_('... done !'))
|
@@ -1944,6 +2073,7 @@ class UI_Manager_2D_GPU():
|
|
1944
2073
|
if self._selected_item is None or self._selected_item == self._treelist.GetRootItem():
|
1945
2074
|
logging.info(_('No item selected ! -- using root item'))
|
1946
2075
|
with wx.MessageDialog(None, _('No item selected ! -- using root item ?'), _('Warning'), wx.OK | wx.CANCEL | wx.ICON_WARNING) as dlg:
|
2076
|
+
dlg:wx.MessageDialog
|
1947
2077
|
ret = dlg.ShowModal()
|
1948
2078
|
if ret != wx.ID_OK:
|
1949
2079
|
return
|
@@ -2015,6 +2145,7 @@ class UI_Manager_2D_GPU():
|
|
2015
2145
|
sims = self.get_sims_only()
|
2016
2146
|
|
2017
2147
|
with wx.DirDialog(None, _('Choose a directory to store tif files'), style = wx.DD_DIR_MUST_EXIST) as dlg:
|
2148
|
+
dlg:wx.DirDialog
|
2018
2149
|
ret = dlg.ShowModal()
|
2019
2150
|
if ret != wx.ID_OK:
|
2020
2151
|
return
|
@@ -2034,6 +2165,7 @@ class UI_Manager_2D_GPU():
|
|
2034
2165
|
logging.info(_('Transferring initial conditions ...'))
|
2035
2166
|
|
2036
2167
|
with wx.DirDialog(None, _('Choose the source scenario directory'), style = wx.DD_DIR_MUST_EXIST) as dlg:
|
2168
|
+
dlg:wx.DirDialog
|
2037
2169
|
ret = dlg.ShowModal()
|
2038
2170
|
if ret != wx.ID_OK:
|
2039
2171
|
return
|
@@ -2041,6 +2173,7 @@ class UI_Manager_2D_GPU():
|
|
2041
2173
|
wdir = dlg.GetPath()
|
2042
2174
|
|
2043
2175
|
with wx.DirDialog(None, _('Choose the destination scenario directory'), style = wx.DD_DIR_MUST_EXIST) as dlg:
|
2176
|
+
dlg:wx.DirDialog
|
2044
2177
|
ret = dlg.ShowModal()
|
2045
2178
|
if ret != wx.ID_OK:
|
2046
2179
|
return
|
wolfhece/scenario/update_void.py
CHANGED
@@ -150,6 +150,37 @@ class Update_Sim:
|
|
150
150
|
"""
|
151
151
|
pass
|
152
152
|
|
153
|
+
def update_deck(self, roof:WolfArray):
|
154
|
+
"""
|
155
|
+
FR
|
156
|
+
|
157
|
+
Cette fonction doit être particularisée afin d'appliquer des modifications
|
158
|
+
à l'altimétrie des ponts et ponceaux (toits)'.
|
159
|
+
|
160
|
+
L'information de base se trouve dans le paramètre 'deck' de classe 'WolfArray'.
|
161
|
+
|
162
|
+
La matrice Numpy, en <Float32>, (avec masque - cf np.ma ) est accessible via :
|
163
|
+
- deck.array[:,:]
|
164
|
+
- deck.array.mask[:,:]
|
165
|
+
- deck.array.data[:,:]
|
166
|
+
|
167
|
+
Il n'est pas permis de remplacer la matrice (création d'une nouvelle matrice et/ou pointage d'una autre matrice). Toutes les operations doivent se faire dans l'espace alloué.
|
168
|
+
|
169
|
+
EN
|
170
|
+
|
171
|
+
This function must be customized to apply modifications to the deck elevation of bridges/culverts.
|
172
|
+
|
173
|
+
The basic information is located in the 'deck' parameter ('WolfArray' class).
|
174
|
+
|
175
|
+
The Numpy array, in <Float32>, (with a mask - see np.ma), can be accessed via:
|
176
|
+
- deck.array[:,:]
|
177
|
+
- deck.array.mask[:,:]
|
178
|
+
- deck.array.data[:,:]
|
179
|
+
|
180
|
+
It is not allowed to replace the array (creating a new array and/or pointing an other array). All operations must be performed within the allocated space.
|
181
|
+
"""
|
182
|
+
pass
|
183
|
+
|
153
184
|
def create_empty_method(method_name, method_signature, docstring, imports):
|
154
185
|
# Fonction utilitaire pour créer des méthodes vides avec la même signature, la documentation et les importations
|
155
186
|
imports_str = '\n'.join(f'import {module}' for module in imports)
|
wolfhece/wolf_array.py
CHANGED
@@ -781,8 +781,12 @@ class header_wolf():
|
|
781
781
|
geotr = raster.GetGeoTransform()
|
782
782
|
self.dx = geotr[1]
|
783
783
|
self.dy = abs(geotr[5])
|
784
|
-
|
785
|
-
|
784
|
+
if geotr[5] < 0.:
|
785
|
+
self.origx = geotr[0]
|
786
|
+
self.origy = geotr[3] + raster.RasterYSize * geotr[5]
|
787
|
+
else:
|
788
|
+
self.origx = geotr[0]
|
789
|
+
self.origy = geotr[3]
|
786
790
|
self.nbx = raster.RasterXSize
|
787
791
|
self.nby = raster.RasterYSize
|
788
792
|
|
@@ -833,6 +837,10 @@ class header_wolf():
|
|
833
837
|
self.dy = abs(geotr[5])
|
834
838
|
self.origx = geotr[0]
|
835
839
|
self.origy = geotr[3]
|
840
|
+
|
841
|
+
if geotr[5] < 0.:
|
842
|
+
self.origy = geotr[3] + raster.RasterYSize * geotr[5]
|
843
|
+
|
836
844
|
self.nbx = raster.RasterXSize
|
837
845
|
self.nby = raster.RasterYSize
|
838
846
|
|
@@ -6024,21 +6032,26 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
6024
6032
|
|
6025
6033
|
proj = raster_in.GetProjection()
|
6026
6034
|
# check if proj is epsg:31370
|
6027
|
-
if 'Lambert 72' not in proj and "31370" not in proj:
|
6035
|
+
if ('Lambert 72' not in proj and "31370" not in proj) and proj != 'LOCAL_CS["unnamed",UNIT["unknown",1],AXIS["Easting",EAST],AXIS["Northing",NORTH]]':
|
6028
6036
|
logging.error(_('{} projection is not Lambert 72 - EPSG:31370').format(fn))
|
6029
6037
|
|
6030
|
-
|
6031
|
-
|
6038
|
+
try:
|
6039
|
+
raster_in2 = gdal.Dataset()
|
6040
|
+
gdal.Warp(raster_in2, raster_in, dstSRS='EPSG:31370')
|
6032
6041
|
|
6033
|
-
|
6034
|
-
|
6035
|
-
|
6042
|
+
# Close the raster_in
|
6043
|
+
raster_in.FlushCache()
|
6044
|
+
raster_in = None
|
6036
6045
|
|
6037
|
-
|
6046
|
+
raster_in = raster_in2
|
6038
6047
|
|
6039
|
-
|
6040
|
-
|
6041
|
-
|
6048
|
+
if raster_in is None:
|
6049
|
+
logging.error(_('Could not reproject the file {fn}'))
|
6050
|
+
return
|
6051
|
+
except Exception as e:
|
6052
|
+
logging.error(f'Error in reprojection: {e}')
|
6053
|
+
logging.info('Using the original file')
|
6054
|
+
raster_in = gdal.Open(fn)
|
6042
6055
|
|
6043
6056
|
geotr = raster_in.GetGeoTransform()
|
6044
6057
|
self.dx = geotr[1]
|
@@ -6208,9 +6221,10 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
6208
6221
|
style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) as fileDialog:
|
6209
6222
|
|
6210
6223
|
if fileDialog.ShowModal() == wx.ID_CANCEL:
|
6211
|
-
|
6212
|
-
|
6213
|
-
|
6224
|
+
from tempfile import NamedTemporaryFile
|
6225
|
+
tmpfile = str(NamedTemporaryFile(suffix='.tif').name)
|
6226
|
+
else:
|
6227
|
+
fn_crop = fileDialog.GetPath()
|
6214
6228
|
|
6215
6229
|
if uly > lly:
|
6216
6230
|
raster = gdal.Translate(fn_crop, fn, projWin=[xmin, ymax, xmax, ymin])
|
wolfhece/wolfresults_2D.py
CHANGED
@@ -4104,7 +4104,7 @@ class Wolfresults_2D(Element_To_Draw):
|
|
4104
4104
|
|
4105
4105
|
def get_all_values_xyorpoly_series(self, xy:Union[list[float], vector], for_steps:tuple[int] | list[int] = (0,-1,1)):
|
4106
4106
|
"""
|
4107
|
-
Get
|
4107
|
+
Get variables at one or multiple coordinates.
|
4108
4108
|
|
4109
4109
|
:param xy : list of coordinates
|
4110
4110
|
:param for_steps : tuple of start, end and step -- 0-based -- default is all steps (0,-1,1)
|
@@ -4350,7 +4350,7 @@ class Wolfresults_2D(Element_To_Draw):
|
|
4350
4350
|
filename: str | Path,
|
4351
4351
|
for_steps:tuple[int] | list[int] = (0,-1,1),
|
4352
4352
|
erase_if_exists:bool = True,
|
4353
|
-
|
4353
|
+
all_values:bool = GL_FRAGMENT_INTERPOLATION_OFFSET_BITS):
|
4354
4354
|
""" Export some results at one or multiple coordinates defined by a vector or a list of coordinates
|
4355
4355
|
or a polygon as CSV file
|
4356
4356
|
"""
|
@@ -4363,6 +4363,9 @@ class Wolfresults_2D(Element_To_Draw):
|
|
4363
4363
|
if erase_if_exists and filename.exists():
|
4364
4364
|
filename.unlink()
|
4365
4365
|
|
4366
|
+
if erase_if_exists and filename.with_stem(filename.stem + '_stats').exists():
|
4367
|
+
filename.with_stem(filename.stem + '_stats').unlink()
|
4368
|
+
|
4366
4369
|
(times, steps), vals = self.get_values_xyorpoly_series(xy, which, for_steps)
|
4367
4370
|
|
4368
4371
|
mean= []
|
@@ -4393,16 +4396,16 @@ class Wolfresults_2D(Element_To_Draw):
|
|
4393
4396
|
for i in range(len(times)):
|
4394
4397
|
f.write(f'{times[i]}\t{steps[i]}\t{mean[i]}\t{median[i]}\t{min[i]}\t{max[i]}\n')
|
4395
4398
|
|
4396
|
-
if
|
4399
|
+
if all_values:
|
4397
4400
|
|
4398
4401
|
with open(filename, 'a') as f:
|
4399
4402
|
if isinstance(xy, list):
|
4400
|
-
f.write(_('Selected nodes'))
|
4401
|
-
f.write('X [m]\tY [m]')
|
4403
|
+
f.write(_('Selected nodes\n'))
|
4404
|
+
f.write('X [m]\tY [m]\n')
|
4402
4405
|
for cur in xy:
|
4403
|
-
f.write(f'{cur[0]}\t{cur[1]}')
|
4406
|
+
f.write(f'{cur[0]}\t{cur[1]}\n')
|
4404
4407
|
|
4405
|
-
f.write('\n')
|
4408
|
+
f.write('\n\n')
|
4406
4409
|
|
4407
4410
|
f.write(f'Time [s]\tStep [-]\t{which.value[0]}\n')
|
4408
4411
|
|