wolfhece 2.1.107__py3-none-any.whl → 2.1.108__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 +38 -9
- wolfhece/PyGui.py +1 -1
- wolfhece/PyVertexvectors.py +12 -0
- wolfhece/PyWMS.py +61 -1
- wolfhece/acceptability/acceptability.py +59 -51
- wolfhece/acceptability/acceptability_gui.py +1043 -153
- wolfhece/acceptability/func.py +83 -48
- wolfhece/apps/version.py +1 -1
- wolfhece/picc.py +2 -2
- wolfhece/scenario/config_manager.py +25 -6
- wolfhece/wolf_array.py +94 -40
- wolfhece/wolf_texture.py +12 -3
- wolfhece/wolf_tiles.py +2 -0
- {wolfhece-2.1.107.dist-info → wolfhece-2.1.108.dist-info}/METADATA +2 -2
- {wolfhece-2.1.107.dist-info → wolfhece-2.1.108.dist-info}/RECORD +18 -18
- {wolfhece-2.1.107.dist-info → wolfhece-2.1.108.dist-info}/WHEEL +1 -1
- {wolfhece-2.1.107.dist-info → wolfhece-2.1.108.dist-info}/entry_points.txt +0 -0
- {wolfhece-2.1.107.dist-info → wolfhece-2.1.108.dist-info}/top_level.txt +0 -0
wolfhece/acceptability/func.py
CHANGED
@@ -186,7 +186,6 @@ class Accept_Manager():
|
|
186
186
|
|
187
187
|
self.IN_DIR = self.main_dir / "INPUT"
|
188
188
|
self.IN_CH_VULN = self.IN_DIR / "CHANGE_VULNE"
|
189
|
-
self.IN_CH_SA_SC = self.IN_CH_VULN / str(Study_area).rsplit('.', 1)[0] / str(scenario)
|
190
189
|
self.IN_DATABASE = self.IN_DIR / "DATABASE"
|
191
190
|
self.IN_STUDY_AREA = self.IN_DIR / "STUDY_AREA"
|
192
191
|
self.IN_CSV = self.IN_DIR / "CSVs"
|
@@ -290,11 +289,17 @@ class Accept_Manager():
|
|
290
289
|
|
291
290
|
self.scenario:str = str(self._scenario)
|
292
291
|
|
292
|
+
|
293
|
+
self.IN_SA_BASE = self.IN_WATER_DEPTH / self.SA.stem / "Scenario_baseline"
|
294
|
+
self.IN_SA_BASE_INTERP = self.IN_SA_BASE / "INTERP_WD"
|
295
|
+
|
293
296
|
self.IN_SCEN_DIR = self.IN_WATER_DEPTH / self.SA.stem / self.scenario
|
294
|
-
self.IN_SA_Base = self.IN_WATER_DEPTH / self.SA.stem / "Scenario_baseline"
|
295
297
|
self.IN_SA_INTERP = self.IN_SCEN_DIR / "INTERP_WD"
|
296
298
|
self.IN_SA_EXTRACTED = self.IN_SCEN_DIR / "EXTRACTED_LAST_STEP_WD"
|
297
|
-
self.IN_SA_DEM = self.IN_SCEN_DIR / "DEM_FILES"
|
299
|
+
self.IN_SA_DEM = self.IN_SCEN_DIR / "DEM_FILES"
|
300
|
+
self.IN_CH_SA_SC = self.IN_CH_VULN /self.SA.stem / self.scenario
|
301
|
+
self.IN_CH_SA_SC_MNT_VRT = self.IN_CH_SA_SC / "__MNT_assembly.vrt"
|
302
|
+
self.IN_CH_SA_SC_MNT_tif = self.IN_CH_SA_SC / "MNTassembly"
|
298
303
|
|
299
304
|
self.IN_RM_BUILD_DIR = self.IN_SCEN_DIR / "REMOVED_BUILDINGS"
|
300
305
|
|
@@ -302,21 +307,26 @@ class Accept_Manager():
|
|
302
307
|
self.TMP_RM_BUILD_DIR = self.TMP_SCEN_DIR / "REMOVED_BUILDINGS"
|
303
308
|
self.TMP_QFILES = self.TMP_SCEN_DIR / "Q_FILES"
|
304
309
|
|
305
|
-
self.TMP_VULN = self.TMP_SCEN_DIR / "
|
306
|
-
self.TMP_CODE = self.TMP_SCEN_DIR / "
|
310
|
+
self.TMP_VULN = self.TMP_SCEN_DIR / "Vulnerability_baseline.tiff"
|
311
|
+
self.TMP_CODE = self.TMP_SCEN_DIR / "Vulnerability_Code_baseline.tiff"
|
307
312
|
|
308
313
|
self.OUT_SCEN_DIR = self.OUT_STUDY_AREA / self.scenario
|
309
314
|
|
310
|
-
self.
|
311
|
-
self.OUT_VULN_VRT = self.
|
312
|
-
self.OUT_VULN_S = self.
|
313
|
-
self.OUT_VULN_Stif = self.
|
314
|
-
self.
|
315
|
-
self.
|
316
|
-
self.
|
317
|
-
|
318
|
-
self.
|
319
|
-
self.
|
315
|
+
self.OUT_WITHVULN = self.OUT_SCEN_DIR / "vuln_ scenarios"
|
316
|
+
self.OUT_VULN_VRT = self.OUT_WITHVULN / "__vuln_assembly.vrt"
|
317
|
+
self.OUT_VULN_S = self.OUT_WITHVULN / "Vulnerability_scenarios"
|
318
|
+
self.OUT_VULN_Stif = self.OUT_WITHVULN / "Vulnerability_scenarios.tif"
|
319
|
+
self.OUT_MASKED_RIVER_S = self.OUT_WITHVULN / "Masked_River_extent_scenarios.tiff"
|
320
|
+
self.OUT_ACCEPT_Stif = self.OUT_WITHVULN / "Acceptability_scenarios.tiff"
|
321
|
+
self.OUT_ACCEPT_RESAMP_Stif = self.OUT_WITHVULN / "Acceptability_scenarios_resampled.tiff"
|
322
|
+
|
323
|
+
self.OUT_BASELINE = self.OUT_SCEN_DIR / "baseline"
|
324
|
+
self.OUT_VULN = self.OUT_BASELINE / "Vulnerability_baseline.tiff"
|
325
|
+
self.OUT_CODE = self.OUT_BASELINE / "Vulnerability_Code_baseline.tiff"
|
326
|
+
self.OUT_MASKED_RIVER = self.OUT_BASELINE / "Masked_River_extent_baseline.tiff"
|
327
|
+
self.OUT_ACCEPT = self.OUT_BASELINE / "Acceptability_baseline.tiff"
|
328
|
+
self.OUT_ACCEPT_RESAMP = self.OUT_BASELINE / "Acceptability_baseline_resampled.tiff"
|
329
|
+
|
320
330
|
else:
|
321
331
|
self.scenario = None
|
322
332
|
|
@@ -330,12 +340,20 @@ class Accept_Manager():
|
|
330
340
|
self.TMP_VULN = None
|
331
341
|
self.TMP_CODE = None
|
332
342
|
|
333
|
-
self.OUT_SCEN_DIR
|
334
|
-
self.
|
335
|
-
self.
|
336
|
-
self.
|
337
|
-
self.
|
338
|
-
self.
|
343
|
+
self.OUT_SCEN_DIR = None
|
344
|
+
self.OUT_WITHVULN = None
|
345
|
+
self.OUT_VULN_VRT = None
|
346
|
+
self.OUT_VULN_S = None
|
347
|
+
self.OUT_VULN_Stif = None
|
348
|
+
self.OUT_MASKED_RIVER_S = None
|
349
|
+
self.OUT_ACCEPT_Stif = None
|
350
|
+
self.OUT_ACCEPT_RESAMP_Stif = None
|
351
|
+
self.OUT_BASELINE = None
|
352
|
+
self.OUT_VULN = None
|
353
|
+
self.OUT_CODE = None
|
354
|
+
self.OUT_MASKED_RIVER = None
|
355
|
+
self.OUT_ACCEPT = None
|
356
|
+
self.OUT_ACCEPT_RESAMP = None
|
339
357
|
|
340
358
|
@property
|
341
359
|
def is_valid_inputs(self) -> bool:
|
@@ -437,17 +455,17 @@ class Accept_Manager():
|
|
437
455
|
if self.IN_SA_INTERP.exists() :
|
438
456
|
files = [Path(a) for a in glob.glob(str(self.IN_SA_INTERP / "*.tif"))]
|
439
457
|
else :
|
440
|
-
logging.error("No
|
458
|
+
logging.error("No such scenario")
|
441
459
|
return files
|
442
460
|
|
443
461
|
def get_sims_files_for_baseline(self) -> list[Path]:
|
444
462
|
files = [] #to avoid NoneType
|
445
|
-
if self.
|
446
|
-
logging.info("Getting the _baseline
|
447
|
-
track = Path(str(self.
|
463
|
+
if self.IN_SA_BASE_INTERP.exists() :
|
464
|
+
logging.info("Getting the _baseline interpolated free surfaces files.")
|
465
|
+
track = Path(str(self.IN_SA_BASE_INTERP / "*.tif"))
|
448
466
|
files = [Path(a) for a in glob.glob(str(track))]
|
449
467
|
else :
|
450
|
-
logging.error("No _baseline
|
468
|
+
logging.error("No _baseline interpolated free surfaces files")
|
451
469
|
|
452
470
|
return files
|
453
471
|
|
@@ -591,8 +609,8 @@ class Accept_Manager():
|
|
591
609
|
return None
|
592
610
|
|
593
611
|
if len(rt)<2:
|
594
|
-
logging.info("
|
595
|
-
return
|
612
|
+
logging.info("There is only one simulation!")
|
613
|
+
return pd.DataFrame(1, columns=["Ponderation"], index=rt)
|
596
614
|
|
597
615
|
else :
|
598
616
|
pond = []
|
@@ -723,6 +741,9 @@ class Accept_Manager():
|
|
723
741
|
|
724
742
|
if self.scenario is not None:
|
725
743
|
self.OUT_SCEN_DIR.mkdir(parents=True, exist_ok=True)
|
744
|
+
self.OUT_WITHVULN.mkdir(parents=True, exist_ok=True)
|
745
|
+
self.OUT_BASELINE.mkdir(parents=True, exist_ok=True)
|
746
|
+
|
726
747
|
|
727
748
|
return True
|
728
749
|
|
@@ -938,11 +959,11 @@ class Accept_Manager():
|
|
938
959
|
the search of a more specific word ('vuln', and not 'bath', 'mann', or 'inf').
|
939
960
|
"""
|
940
961
|
|
941
|
-
def
|
962
|
+
def tree_name_tif(folder_path, name):
|
942
963
|
"""Find all .tiff files starting with 'vuln' in the directory and return paths"""
|
943
964
|
folder = Path(folder_path)
|
944
|
-
vuln_tiff_files = {file for file in folder.rglob("*.tiff") if file.name.startswith(
|
945
|
-
vuln_tif_files = {file for file in folder.rglob("*.tif") if file.name.startswith(
|
965
|
+
vuln_tiff_files = {file for file in folder.rglob("*.tiff") if file.name.startswith(name)}
|
966
|
+
vuln_tif_files = {file for file in folder.rglob("*.tif") if file.name.startswith(name)}
|
946
967
|
|
947
968
|
vuln_files = vuln_tiff_files.union(vuln_tif_files)
|
948
969
|
|
@@ -956,24 +977,24 @@ class Accept_Manager():
|
|
956
977
|
tiff_trees.append(curtree)
|
957
978
|
return tiff_trees
|
958
979
|
|
959
|
-
def
|
980
|
+
def select_name_tif(self, path_baseline: Path, folder_path: Path, name) -> list[Path]:
|
960
981
|
"""
|
961
982
|
Collects and appends all .tiff files starting with 'vuln' from folder_path into a list.
|
962
983
|
"""
|
963
984
|
files = []
|
964
985
|
#first element must be vulnerability_baseline
|
965
986
|
files.append(path_baseline.as_posix())
|
966
|
-
tiff_trees = Accept_Manager.
|
987
|
+
tiff_trees = Accept_Manager.tree_name_tif(folder_path, name)
|
967
988
|
|
968
989
|
#only the 'final' path of the tree
|
969
990
|
for tree in tiff_trees:
|
970
991
|
files.append(tree[-1].as_posix())
|
971
992
|
return files
|
972
993
|
|
973
|
-
def check_nodata(self):
|
994
|
+
def check_nodata(self, name):
|
974
995
|
""" Check nodata in a path """
|
975
996
|
|
976
|
-
list_tif = Accept_Manager.
|
997
|
+
list_tif = Accept_Manager.select_name_tif(self, self.OUT_VULN, self.IN_CH_SA_SC, name)
|
977
998
|
for cur_lst in list_tif:
|
978
999
|
if "Vulnerability.tiff" not in cur_lst:
|
979
1000
|
curarray:WolfArray = WolfArray(cur_lst)
|
@@ -983,24 +1004,25 @@ class Accept_Manager():
|
|
983
1004
|
curarray.write_all()
|
984
1005
|
logging.warning(_('nodata changed in favor of 99999. value for file {} !'.format(cur_lst)))
|
985
1006
|
|
986
|
-
def create_vrtIfExists(self):
|
1007
|
+
def create_vrtIfExists(self, fn_baseline, fn_scenario, fn_vrt, name):
|
987
1008
|
""" Create a vrt file from a path """
|
988
1009
|
logging.info(_('Checking nodata values...'))
|
989
|
-
self.check_nodata()
|
990
|
-
list_tif = Accept_Manager.
|
1010
|
+
self.check_nodata(name)
|
1011
|
+
list_tif = Accept_Manager.select_name_tif(self, fn_baseline, fn_scenario, name)
|
991
1012
|
#création du fichier vrt - assembly/agglomération
|
992
1013
|
if len(list_tif)>1:
|
993
1014
|
logging.info(_('Creating .vrt from files (first based)...'))
|
994
|
-
create_vrt_from_diverged_files_first_based(list_tif,
|
1015
|
+
create_vrt_from_diverged_files_first_based(list_tif, fn_vrt)
|
995
1016
|
return True
|
996
1017
|
else:
|
997
1018
|
return False
|
998
1019
|
|
999
1020
|
|
1000
|
-
def translate_vrt2tif(self):
|
1001
|
-
""" Translate vrt from OUTPUT > ... > Scenario to tif saved in the same folder """
|
1002
|
-
if (
|
1003
|
-
translate_vrt2tif(
|
1021
|
+
def translate_vrt2tif(self, fn_VRT, fn_vuln_s):
|
1022
|
+
""" Translate vrt from OUTPUT > ... > Scenario to tif saved in the same folder, and delete the vrt file """
|
1023
|
+
if (fn_VRT).exists():
|
1024
|
+
translate_vrt2tif(fn_VRT, fn_vuln_s)
|
1025
|
+
os.remove(fn_VRT)
|
1004
1026
|
|
1005
1027
|
def copy_tif_files(self, files: list[Path], destination_dir: Path) -> None:
|
1006
1028
|
destination_dir.mkdir(parents=True, exist_ok=True)
|
@@ -1016,7 +1038,20 @@ class Accept_Manager():
|
|
1016
1038
|
|
1017
1039
|
dataset = None
|
1018
1040
|
|
1019
|
-
logging.info("All .tif files have been copied to the destination directory.")
|
1041
|
+
logging.info("All the existing .tif files have been copied to the destination directory.")
|
1042
|
+
|
1043
|
+
def wich_river_trace(self):
|
1044
|
+
""" Searches for existing riverbed traces: if none ending with '_scenarios' are found, it selects the baseline trace."""
|
1045
|
+
trace = None
|
1046
|
+
if os.path.exists(self.OUT_MASKED_RIVER):
|
1047
|
+
trace = self.OUT_MASKED_RIVER
|
1048
|
+
if os.path.exists(self.OUT_MASKED_RIVER_S):
|
1049
|
+
trace = self.OUT_MASKED_RIVER_S
|
1050
|
+
else :
|
1051
|
+
logging.error("No Masked_River_extent files. Please provide them.")
|
1052
|
+
return trace
|
1053
|
+
|
1054
|
+
|
1020
1055
|
|
1021
1056
|
|
1022
1057
|
def clip_layer(layer:str,
|
@@ -1287,7 +1322,7 @@ def compute_vulnerability(manager:Accept_Manager):
|
|
1287
1322
|
return array_vuln
|
1288
1323
|
|
1289
1324
|
for i in tqdm(range(len(rasters_vuln)), 'Computing Vulnerability : '):
|
1290
|
-
logging.info("Computing layer {} / {}".format(i, len(rasters_vuln)))
|
1325
|
+
#logging.info("Computing layer {} / {}".format(i, len(rasters_vuln)))
|
1291
1326
|
|
1292
1327
|
locvuln = vuln_csv.get_vulnerability_level(rasters_vuln[i].stem)
|
1293
1328
|
|
@@ -1378,7 +1413,7 @@ def compute_code(manager:Accept_Manager):
|
|
1378
1413
|
return array_code
|
1379
1414
|
|
1380
1415
|
for i in tqdm(range(len(rasters_code)), 'Computing Code : '):
|
1381
|
-
logging.info("Computing layer {} / {}".format(i, len(rasters_code)))
|
1416
|
+
#logging.info("Computing layer {} / {}".format(i, len(rasters_code)))
|
1382
1417
|
|
1383
1418
|
loccode = vuln_csv.get_vulnerability_code(rasters_code[i].stem.removesuffix("_CODE"))
|
1384
1419
|
|
@@ -1481,7 +1516,7 @@ def match_vulnerability2sim(inRas:Path, outRas:Path, MODREC:Path):
|
|
1481
1516
|
:param MODREC: the MODREC/simulation extent file
|
1482
1517
|
|
1483
1518
|
"""
|
1484
|
-
|
1519
|
+
|
1485
1520
|
inRas = str(inRas)
|
1486
1521
|
outRas = str(outRas)
|
1487
1522
|
MODREC = str(MODREC)
|
@@ -1525,7 +1560,7 @@ def compute_acceptability(manager:Accept_Manager,
|
|
1525
1560
|
|
1526
1561
|
"""
|
1527
1562
|
|
1528
|
-
logging.info(interval)
|
1563
|
+
#logging.info(interval)
|
1529
1564
|
|
1530
1565
|
points_accept = pd.read_csv(manager.POINTS_CSV)
|
1531
1566
|
|
wolfhece/apps/version.py
CHANGED
wolfhece/picc.py
CHANGED
@@ -64,10 +64,10 @@ class Picc_data(Element_To_Draw):
|
|
64
64
|
if datafile.exists():
|
65
65
|
self.zones = Zones(data_dir / self._filename_vector, bbox = bbox, mapviewer=self.mapviewer, colors= self._colors)
|
66
66
|
else:
|
67
|
-
logging.
|
67
|
+
logging.info(_('File not found : {}').format(datafile))
|
68
68
|
|
69
69
|
if self.mapviewer is not None:
|
70
|
-
dlg = wx.SingleChoiceDialog(None, _('Would you like to select a
|
70
|
+
dlg = wx.SingleChoiceDialog(None, _('Would you like to select a Shape file or a GDB database ?'), _('Choose data source'), ['Shape file/GPKG', 'GDB database'], wx.CHOICEDLG_STYLE)
|
71
71
|
ret = dlg.ShowModal()
|
72
72
|
|
73
73
|
if ret == wx.ID_CANCEL:
|
@@ -202,7 +202,7 @@ class Config_Manager_2D_GPU:
|
|
202
202
|
Gestionnaire de configurations 2D - code GPU
|
203
203
|
"""
|
204
204
|
|
205
|
-
def __init__(self, workingdir:str = '', mapviewer:WolfMapViewer = None, python_venv:Path = None) -> None:
|
205
|
+
def __init__(self, workingdir:str = '', mapviewer:WolfMapViewer = None, python_venv:Path = None, create_ui_if_wx:bool = False) -> None:
|
206
206
|
"""
|
207
207
|
Recherche de toutes les modélisation dans un répertoire et ses sous-répertoires
|
208
208
|
"""
|
@@ -235,6 +235,7 @@ class Config_Manager_2D_GPU:
|
|
235
235
|
|
236
236
|
self._txtctrl = None
|
237
237
|
self._ui = None
|
238
|
+
self._create_ui_if_wx = create_ui_if_wx
|
238
239
|
|
239
240
|
self._epsilon = 0.01
|
240
241
|
self._filter_independent = True
|
@@ -287,7 +288,7 @@ class Config_Manager_2D_GPU:
|
|
287
288
|
# la fenêtre est déjà ouverte
|
288
289
|
self._ui.refill_data(self.configs)
|
289
290
|
else:
|
290
|
-
if self.wx_exists:
|
291
|
+
if self.wx_exists and self._create_ui_if_wx:
|
291
292
|
self._ui = UI_Manager_2D_GPU(self.configs, parent=self)
|
292
293
|
|
293
294
|
|
@@ -1165,6 +1166,22 @@ class Config_Manager_2D_GPU:
|
|
1165
1166
|
logging.error(_("No 'bathymetry.tif' file found in the root directory !"))
|
1166
1167
|
|
1167
1168
|
|
1169
|
+
def verify_bath_roof_deck(self, bathymetry:WolfArray, bridge_roof:WolfArray):
|
1170
|
+
""" Verify bathymetry, roof and deck """
|
1171
|
+
|
1172
|
+
if bridge_roof is None:
|
1173
|
+
return
|
1174
|
+
|
1175
|
+
# si la matrice de toit de pont est plus basse que la bathymétrie, on met à 99999
|
1176
|
+
# la bathymétrie et le toit de pont.
|
1177
|
+
# Ainsi, ces maille seront infranchissables.
|
1178
|
+
# Cale peut être utile pour discrétiser les piles dans les données du toit, plutôt que de les
|
1179
|
+
# 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
|
+
|
1168
1185
|
def create_simulation(self,
|
1169
1186
|
dir:Path,
|
1170
1187
|
idx_hydros:list[int] = [-1],
|
@@ -1280,6 +1297,8 @@ class Config_Manager_2D_GPU:
|
|
1280
1297
|
# applying Python scrpitps on ARRAYS
|
1281
1298
|
self._apply_scripts_update_topo_maning_inf_roof(dir, bat, man, infiltration, roof)
|
1282
1299
|
|
1300
|
+
self.verify_bath_roof_deck(bat, roof)
|
1301
|
+
|
1283
1302
|
# save arrays on disk
|
1284
1303
|
bat.write_all(str(dir / '__bathymetry_after_scripts.tif'))
|
1285
1304
|
man.write_all(str(dir / '__manning_after_scripts.tif'))
|
@@ -1398,12 +1417,12 @@ class Config_Manager_2D_GPU:
|
|
1398
1417
|
f.write(str(curdir.drive) + '\n')
|
1399
1418
|
f.write('cd {}\n'.format(str(curdir.parent)))
|
1400
1419
|
f.write("\n")
|
1401
|
-
f.write("WOLFGPU_PARAMS=-quickrun " + str(curdir.name) + "\n")
|
1420
|
+
f.write("set WOLFGPU_PARAMS=-quickrun " + str(curdir.name) + "\n")
|
1402
1421
|
f.write("\n")
|
1403
1422
|
f.write("where wolfgpu.exe\n")
|
1404
1423
|
f.write("IF %ERRORLEVEL%==0 (\n")
|
1405
1424
|
f.write("wolfgpu %WOLFGPU_PARAMS%\n")
|
1406
|
-
f.write("goto :
|
1425
|
+
f.write("goto :exit\n")
|
1407
1426
|
f.write(")\n")
|
1408
1427
|
f.write("\n")
|
1409
1428
|
f.write("echo -------------------------------\n")
|
@@ -1417,7 +1436,7 @@ class Config_Manager_2D_GPU:
|
|
1417
1436
|
f.write("echo -------------------------------\n")
|
1418
1437
|
f.write("pause\n")
|
1419
1438
|
f.write("python -m wolfgpu.cli %WOLFGPU_PARAMS%\n")
|
1420
|
-
f.write(":
|
1439
|
+
f.write(":exit\n")
|
1421
1440
|
|
1422
1441
|
allsims.append(curdir / 'quickrun.bat')
|
1423
1442
|
|
@@ -2588,4 +2607,4 @@ class UI_Manager_2D_GPU():
|
|
2588
2607
|
newroot = self._treelist.AppendItem(root, k, data = v)
|
2589
2608
|
|
2590
2609
|
for curfile in v:
|
2591
|
-
self._treelist.AppendItem(newroot, curfile.name, data = curfile)
|
2610
|
+
self._treelist.AppendItem(newroot, curfile.name, data = curfile)
|
wolfhece/wolf_array.py
CHANGED
@@ -3335,9 +3335,16 @@ class SelectionData():
|
|
3335
3335
|
else:
|
3336
3336
|
destxy = self.myselection
|
3337
3337
|
|
3338
|
-
|
3338
|
+
if len(destxy) == 0:
|
3339
|
+
logging.error(_('No selection to unmask'))
|
3340
|
+
return
|
3341
|
+
|
3342
|
+
if destxy == 'all':
|
3343
|
+
curarray.array.mask[:, :] = False
|
3344
|
+
else:
|
3345
|
+
destij = np.asarray([list(curarray.get_ij_from_xy(x, y)) for x, y in destxy])
|
3339
3346
|
|
3340
|
-
|
3347
|
+
curarray.array.mask[destij[:, 0], destij[:, 1]] = False
|
3341
3348
|
|
3342
3349
|
if resetplot:
|
3343
3350
|
curarray.reset_plot()
|
@@ -5629,7 +5636,7 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
5629
5636
|
- Float32
|
5630
5637
|
- Float64
|
5631
5638
|
|
5632
|
-
:param outdir: directory - If provided, the file will be savd as "outdir/idx+extent.tif"
|
5639
|
+
:param outdir: directory - If provided, the file will be savd as "outdir/idx+extent.tif"
|
5633
5640
|
If not provided, we use the filename attribute
|
5634
5641
|
|
5635
5642
|
:param extent: suffix to add to the filename before the extension '.tif' (only if outdir is provided)
|
@@ -5749,7 +5756,7 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
5749
5756
|
assert locarray.shape[1] == self.nby, _('Incompatible dimensions')
|
5750
5757
|
|
5751
5758
|
if crop is not None :
|
5752
|
-
logging.error(_('Cropping not yet implemented for numpy files'))
|
5759
|
+
# logging.error(_('Cropping not yet implemented for numpy files'))
|
5753
5760
|
|
5754
5761
|
imin, jmin = self.get_ij_from_xy(crop[0][0], crop[1][0])
|
5755
5762
|
imax, jmax = self.get_ij_from_xy(crop[0][1], crop[1][1])
|
@@ -5795,6 +5802,7 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
5795
5802
|
else:
|
5796
5803
|
return
|
5797
5804
|
|
5805
|
+
raster:gdal.Dataset
|
5798
5806
|
if crop is not None :
|
5799
5807
|
if not os.path.exists(fn):
|
5800
5808
|
logging.error(_('File not found'))
|
@@ -5812,12 +5820,35 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
5812
5820
|
logging.error(_('Crop must be a list or a numpy array with 4 values - xmin, xmax, ymin, ymax'))
|
5813
5821
|
return
|
5814
5822
|
|
5815
|
-
|
5816
|
-
|
5817
|
-
|
5823
|
+
raster_in:gdal.Dataset
|
5824
|
+
raster_in = gdal.Open(fn)
|
5825
|
+
|
5826
|
+
proj = raster_in.GetProjection()
|
5827
|
+
# check if proj is epsg:31370
|
5828
|
+
if 'Lambert 72' not in proj and "31370" not in proj:
|
5829
|
+
logging.error(_('{} projection is not Lambert 72 - EPSG:31370').format(fn))
|
5830
|
+
|
5831
|
+
raster_in2 = gdal.Dataset()
|
5832
|
+
gdal.Warp(raster_in2, raster_in, dstSRS='EPSG:31370')
|
5833
|
+
|
5834
|
+
# Close the raster_in
|
5835
|
+
raster_in.FlushCache()
|
5836
|
+
raster_in = None
|
5837
|
+
|
5838
|
+
raster_in = raster_in2
|
5839
|
+
|
5840
|
+
if raster_in is None:
|
5841
|
+
logging.error(_('Could not reproject the file {fn}'))
|
5842
|
+
return
|
5843
|
+
|
5844
|
+
geotr = raster_in.GetGeoTransform()
|
5818
5845
|
self.dx = geotr[1]
|
5819
5846
|
self.dy = abs(geotr[5])
|
5820
5847
|
|
5848
|
+
ulx = geotr[0]
|
5849
|
+
uly = geotr[3]
|
5850
|
+
llx = ulx + geotr[1] * raster_in.RasterXSize
|
5851
|
+
lly = uly + geotr[5] * raster_in.RasterYSize
|
5821
5852
|
|
5822
5853
|
newcrop = CropDialog(None)
|
5823
5854
|
|
@@ -5868,20 +5899,29 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
5868
5899
|
|
5869
5900
|
fn_crop = fileDialog.GetPath()
|
5870
5901
|
|
5902
|
+
if uly > lly:
|
5903
|
+
raster = gdal.Translate(fn_crop, fn, projWin=[xmin, ymax, xmax, ymin])
|
5904
|
+
else:
|
5905
|
+
raster = gdal.Translate(fn_crop, fn, projWin=[xmin, ymin, xmax, ymax])
|
5871
5906
|
|
5872
|
-
gdal.Translate(fn_crop, fn, projWin=[xmin, ymax, xmax, ymin])
|
5873
5907
|
fn = fn_crop
|
5874
5908
|
else:
|
5875
5909
|
from tempfile import NamedTemporaryFile
|
5876
5910
|
tmpfile = NamedTemporaryFile(suffix='.tif')
|
5877
|
-
|
5911
|
+
|
5912
|
+
if uly > lly:
|
5913
|
+
raster = gdal.Translate(str(tmpfile.name), fn, projWin=[xmin, ymax, xmax, ymin])
|
5914
|
+
else:
|
5915
|
+
raster = gdal.Translate(str(tmpfile.name), fn, projWin=[xmin, ymin, xmax, ymax])
|
5916
|
+
|
5878
5917
|
fn = str(tmpfile.name)
|
5918
|
+
else:
|
5919
|
+
raster = gdal.Open(fn)
|
5879
5920
|
|
5880
|
-
raster:gdal.Dataset
|
5881
|
-
raster = gdal.Open(fn)
|
5882
5921
|
|
5883
|
-
|
5884
|
-
|
5922
|
+
if raster is None:
|
5923
|
+
logging.error(_('Could not open the file {fn}'))
|
5924
|
+
return
|
5885
5925
|
|
5886
5926
|
# Dimensions
|
5887
5927
|
self.nbx = raster.RasterXSize
|
@@ -7936,41 +7976,51 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
7936
7976
|
elif type(self.cropini) is list:
|
7937
7977
|
pass
|
7938
7978
|
else:
|
7939
|
-
|
7979
|
+
if self.wx_exists:
|
7980
|
+
newcrop = CropDialog(None)
|
7940
7981
|
|
7941
|
-
|
7942
|
-
|
7982
|
+
if self.mapviewer is not None:
|
7983
|
+
bounds = self.mapviewer.get_canvas_bounds()
|
7943
7984
|
|
7944
|
-
|
7945
|
-
|
7985
|
+
newcrop.dx.Value = str(self.dx)
|
7986
|
+
newcrop.dy.Value = str(self.dy)
|
7946
7987
|
|
7947
|
-
|
7948
|
-
|
7988
|
+
# newcrop.dx.Enable(False)
|
7989
|
+
# newcrop.dy.Enable(False)
|
7949
7990
|
|
7950
|
-
|
7951
|
-
|
7952
|
-
|
7953
|
-
|
7991
|
+
newcrop.ox.Value = str(float((bounds[0] // 50.) * 50.))
|
7992
|
+
newcrop.ex.Value = str(float((bounds[2] // 50.) * 50.))
|
7993
|
+
newcrop.oy.Value = str(float((bounds[1] // 50.) * 50.))
|
7994
|
+
newcrop.ey.Value = str(float((bounds[3] // 50.) * 50.))
|
7954
7995
|
|
7955
|
-
|
7956
|
-
|
7957
|
-
|
7996
|
+
badvalues = True
|
7997
|
+
while badvalues:
|
7998
|
+
badvalues = False
|
7958
7999
|
|
7959
|
-
|
7960
|
-
|
7961
|
-
|
7962
|
-
|
7963
|
-
|
7964
|
-
|
7965
|
-
|
7966
|
-
|
7967
|
-
|
8000
|
+
ret = newcrop.ShowModal()
|
8001
|
+
if ret == wx.ID_CANCEL:
|
8002
|
+
newcrop.Destroy()
|
8003
|
+
return
|
8004
|
+
else:
|
8005
|
+
self.cropini = [[float(newcrop.ox.Value), float(newcrop.ex.Value)],
|
8006
|
+
[float(newcrop.oy.Value), float(newcrop.ey.Value)]]
|
8007
|
+
tmpdx = float(newcrop.dx.Value)
|
8008
|
+
tmpdy = float(newcrop.dy.Value)
|
8009
|
+
|
8010
|
+
if self.dx != tmpdx or self.dy != tmpdy:
|
8011
|
+
if tmpdx / self.dx != tmpdy / self.dy:
|
8012
|
+
badvalues = True
|
8013
|
+
|
8014
|
+
newcrop.Destroy()
|
8015
|
+
|
8016
|
+
self.cropini = [[self.cropini[0][0] + self.dx/2., self.cropini[0][1] + self.dx/2.],
|
8017
|
+
[self.cropini[1][0] + self.dy/2., self.cropini[1][1] + self.dy/2.]]
|
8018
|
+
else:
|
8019
|
+
logging.warning(_('No crop defined and no wxPython available'))
|
8020
|
+
logging.info(_('Abort reading data !'))
|
8021
|
+
return
|
7968
8022
|
|
7969
|
-
if self.dx != tmpdx or self.dy != tmpdy:
|
7970
|
-
if tmpdx / self.dx != tmpdy / self.dy:
|
7971
|
-
badvalues = True
|
7972
8023
|
|
7973
|
-
newcrop.Destroy()
|
7974
8024
|
|
7975
8025
|
with open(self.filename, 'rb') as f:
|
7976
8026
|
if self.wolftype == WOLF_ARRAY_FULL_SINGLE or self.wolftype == WOLF_ARRAY_FULL_SINGLE_3D:
|
@@ -8007,6 +8057,10 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
8007
8057
|
|
8008
8058
|
self.array = ma.masked_array(locarray, dtype=np.float32)
|
8009
8059
|
|
8060
|
+
else:
|
8061
|
+
logging.warning(_('Unsupported wolftype for cropping'))
|
8062
|
+
return
|
8063
|
+
|
8010
8064
|
if self.filename.endswith('.flt'):
|
8011
8065
|
# fichier .flt --> miroir "horizontal"
|
8012
8066
|
self.array = np.fliplr(self.array)
|
wolfhece/wolf_texture.py
CHANGED
@@ -26,7 +26,7 @@ import math
|
|
26
26
|
import numpy as np
|
27
27
|
|
28
28
|
from .PyTranslate import _
|
29
|
-
from .PyWMS import getIGNFrance, getWalonmap
|
29
|
+
from .PyWMS import getIGNFrance, getWalonmap, getVlaanderen
|
30
30
|
from .textpillow import Font_Priority, Text_Image,Text_Infos
|
31
31
|
from .drawing_obj import Element_To_Draw
|
32
32
|
|
@@ -250,8 +250,10 @@ class imagetexture(Element_To_Draw):
|
|
250
250
|
France: bool
|
251
251
|
epsg: str
|
252
252
|
|
253
|
-
def __init__(self, which: str, label: str, cat: str, subc: str, mapviewer,
|
254
|
-
|
253
|
+
def __init__(self, which: str, label: str, cat: str, subc: str, mapviewer,
|
254
|
+
xmin:float, xmax:float, ymin:float, ymax:float,
|
255
|
+
width:int = 1000, height:int = 1000,
|
256
|
+
France:bool = False, epsg='31370', Vlaanderen:bool = False) -> None:
|
255
257
|
|
256
258
|
super().__init__(label+cat+subc, plotted=False, mapviewer=mapviewer, need_for_wx=False)
|
257
259
|
|
@@ -261,6 +263,8 @@ class imagetexture(Element_To_Draw):
|
|
261
263
|
logging.error(_('Opengl setcurrent -- Do you have a active canvas ?'))
|
262
264
|
|
263
265
|
self.France = France
|
266
|
+
self.Vlaanderen = Vlaanderen
|
267
|
+
|
264
268
|
self.epsg = epsg
|
265
269
|
|
266
270
|
self.xmin = xmin
|
@@ -297,6 +301,11 @@ class imagetexture(Element_To_Draw):
|
|
297
301
|
mybytes = getIGNFrance(self.category, self.epsg,
|
298
302
|
self.xmin, self.ymin, self.xmax, self.ymax,
|
299
303
|
self.width, self.height, False)
|
304
|
+
|
305
|
+
elif self.Vlaanderen:
|
306
|
+
mybytes = getVlaanderen(self.category,
|
307
|
+
self.xmin, self.ymin, self.xmax, self.ymax,
|
308
|
+
self.width, self.height, False)
|
300
309
|
else:
|
301
310
|
mybytes = getWalonmap(self.category + '/' + self.subcategory,
|
302
311
|
self.xmin, self.ymin, self.xmax, self.ymax,
|
wolfhece/wolf_tiles.py
CHANGED
@@ -91,6 +91,8 @@ class Tiles(Zones):
|
|
91
91
|
# pas de comparaison car répertoire source et comp identique
|
92
92
|
|
93
93
|
# récupération du fichier .tif avec le nom associé au vecteur
|
94
|
+
if boundname.endswith('.tif'):
|
95
|
+
boundname = boundname[:-4]
|
94
96
|
file = glob.glob(join(self.linked_data_dir,'*{}*.tif').format(boundname))
|
95
97
|
|
96
98
|
if len(file)>0:
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.2
|
2
2
|
Name: wolfhece
|
3
|
-
Version: 2.1.
|
3
|
+
Version: 2.1.108
|
4
4
|
Author-email: Pierre Archambeau <pierre.archambeau@uliege.be>
|
5
5
|
License: Copyright (c) 2024 University of Liege. All rights reserved.
|
6
6
|
Project-URL: Homepage, https://uee.uliege.be/hece
|