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
wolfhece/acceptability/func.py
CHANGED
@@ -152,7 +152,7 @@ class Accept_Manager():
|
|
152
152
|
|
153
153
|
def __init__(self,
|
154
154
|
main_dir:str = 'Data',
|
155
|
-
Study_area
|
155
|
+
Study_area = None,
|
156
156
|
scenario = None,
|
157
157
|
Original_gdb:str = 'GT_Resilence_dataRisques202010.gdb',
|
158
158
|
CaPa_Walloon:str = 'Cadastre_Walloon.gpkg',
|
@@ -171,9 +171,7 @@ class Accept_Manager():
|
|
171
171
|
# If it is a string, concatenate it with the current directory
|
172
172
|
if not self.main_dir.is_absolute():
|
173
173
|
self.main_dir = Path(os.getcwd()) / self.main_dir
|
174
|
-
|
175
|
-
self._study_area = str(Study_area)
|
176
|
-
|
174
|
+
self._study_area = Study_area
|
177
175
|
if Study_area is not None:
|
178
176
|
if not str(self._study_area).endswith('.shp'):
|
179
177
|
self._study_area += '.shp'
|
@@ -391,7 +389,7 @@ class Accept_Manager():
|
|
391
389
|
self._study_area = None
|
392
390
|
self._scenario = None
|
393
391
|
else:
|
394
|
-
if Study_area in self.get_list_studyareas(with_suffix=True):
|
392
|
+
if Study_area in self.get_list_studyareas(with_suffix=True) or Study_area+".shp" in self.get_list_studyareas(with_suffix=True):
|
395
393
|
self._study_area = Path(Study_area)
|
396
394
|
else:
|
397
395
|
logging.error("The study area does not exist in the study area directory")
|
@@ -474,18 +472,17 @@ class Accept_Manager():
|
|
474
472
|
sims = self.get_sims_files_for_scenario()
|
475
473
|
|
476
474
|
if len(sims)==0:
|
477
|
-
logging.info("No simulations found
|
475
|
+
logging.info("No simulations found at this stage")
|
478
476
|
return None
|
479
477
|
|
480
478
|
if "_h.tif" in sims[0].name:
|
481
479
|
for cursim in sims:
|
482
|
-
if cursim.stem.find("_T{}_".format(return_period)) != -1:
|
480
|
+
if cursim.stem.find("_T{}_".format(return_period)) != -1 or cursim.stem.find("_Q{}_".format(return_period)) != -1:
|
483
481
|
return cursim
|
484
482
|
else:
|
485
483
|
for cursim in sims:
|
486
|
-
if cursim.stem.find("T{}".format(return_period)) != -1:
|
484
|
+
if cursim.stem.find("T{}".format(return_period)) != -1 or cursim.stem.find("Q{}".format(return_period)) != -1:
|
487
485
|
return cursim
|
488
|
-
|
489
486
|
return None
|
490
487
|
|
491
488
|
def get_types_in_file(self, file:str) -> list[str]:
|
@@ -560,44 +557,36 @@ class Accept_Manager():
|
|
560
557
|
|
561
558
|
# List files in directory
|
562
559
|
sims = self.get_sims_files_for_scenario()
|
563
|
-
|
560
|
+
sims_modif = [
|
561
|
+
os.path.join(os.path.dirname(path), os.path.basename(path).replace("Q", "T"))
|
562
|
+
for path in sims
|
563
|
+
]
|
564
|
+
|
564
565
|
if len(sims)==0:
|
565
|
-
logging.info("No simulations found
|
566
|
+
logging.info("No simulations found at this stage.")
|
566
567
|
return []
|
567
568
|
|
568
|
-
#
|
569
|
-
#
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
idx_T = [cursim.name.find("_T") for cursim in sims]
|
576
|
-
idx_h = [cursim.name.find("_h.tif") for cursim in sims]
|
577
|
-
|
578
|
-
assert len(idx_T) == len(idx_h), "The number of T and h are not the same"
|
579
|
-
for curT, curh in zip(idx_T, idx_h):
|
580
|
-
assert curT != -1, "The T is not found"
|
581
|
-
assert curh != -1, "The h is not found"
|
582
|
-
assert curh > curT, "The h is before the T"
|
583
|
-
|
584
|
-
# Create the list of return periods -- only the numeric part
|
585
|
-
sims = [int(cursim.name[idx_T[i]+2:idx_h[i]]) for i, cursim in enumerate(sims)]
|
586
|
-
else:
|
587
|
-
# searching for the position of the return period in the name
|
588
|
-
idx_T = [cursim.name.find("T") for cursim in sims]
|
589
|
-
idx_h = [cursim.name.find(".tif") for cursim in sims]
|
590
|
-
|
591
|
-
assert len(idx_T) == len(idx_h), "The number of T and h are not the same"
|
592
|
-
for curT, curh in zip(idx_T, idx_h):
|
593
|
-
assert curT != -1, "The T is not found"
|
594
|
-
assert curh != -1, "The h is not found"
|
595
|
-
assert curh > curT, "The h is before the T"
|
596
|
-
|
597
|
-
# create the list of return periods -- only the numeric part
|
598
|
-
sims = [int(cursim.name[idx_T[i]+1:idx_h[i]]) for i, cursim in enumerate(sims)]
|
599
|
-
|
569
|
+
# - Return periods are named as T2.tif, T5.tif, T10.tif, ... or with Q instead of T
|
570
|
+
# searching for the position of the return period in the name
|
571
|
+
idx_T = [Path(cursim).name.find("T") for cursim in sims_modif]
|
572
|
+
idx_h = [Path(cursim).name.find(".tif") for cursim in sims_modif]
|
573
|
+
|
574
|
+
# create the list of return periods -- only the numeric part
|
575
|
+
sims = [int(Path(cursim).name[idx_T[i]+1:idx_h[i]]) for i, cursim in enumerate(sims_modif)]
|
600
576
|
return sorted(sims)
|
577
|
+
|
578
|
+
def get_modifiedrasters(self):
|
579
|
+
folder = Path(self.IN_CH_SA_SC)
|
580
|
+
vuln_tiff_files = [str(file.name) for file in folder.rglob("*.tiff") if file.name.startswith('vuln_')]
|
581
|
+
vuln_tif_files = [str(file.name)for file in folder.rglob("*.tif") if file.name.startswith('vuln_')]
|
582
|
+
vuln_files = vuln_tiff_files + vuln_tif_files
|
583
|
+
|
584
|
+
folder = Path(self.IN_CH_SA_SC)
|
585
|
+
mnt_tiff_files = [str(file.name) for file in folder.rglob("*.tiff") if file.name.startswith('MNTmodifs_')]
|
586
|
+
mnt_tif_files = [str(file.name) for file in folder.rglob("*.tif") if file.name.startswith('MNTmodifs_')]
|
587
|
+
mnt_files = mnt_tiff_files + mnt_tif_files
|
588
|
+
|
589
|
+
return vuln_files + mnt_files
|
601
590
|
|
602
591
|
def get_ponderations(self) -> pd.DataFrame:
|
603
592
|
""" Get the ponderation data from available simulations """
|
@@ -605,11 +594,11 @@ class Accept_Manager():
|
|
605
594
|
rt = self.get_return_periods()
|
606
595
|
|
607
596
|
if len(rt)==0:
|
608
|
-
logging.info("No simulations found")
|
597
|
+
logging.info("No simulations found at this stage.")
|
609
598
|
return None
|
610
599
|
|
611
600
|
if len(rt)<2:
|
612
|
-
logging.info("There is only one simulation!")
|
601
|
+
logging.info("There is only one simulation! Weigthing coefficient is unique and set to 1.")
|
613
602
|
return pd.DataFrame(1, columns=["Ponderation"], index=rt)
|
614
603
|
|
615
604
|
else :
|
@@ -979,7 +968,7 @@ class Accept_Manager():
|
|
979
968
|
|
980
969
|
def select_name_tif(self, path_baseline: Path, folder_path: Path, name) -> list[Path]:
|
981
970
|
"""
|
982
|
-
Collects and appends all .tiff files starting with '
|
971
|
+
Collects and appends all .tiff files starting with 'name' from folder_path into a list.
|
983
972
|
"""
|
984
973
|
files = []
|
985
974
|
#first element must be vulnerability_baseline
|
@@ -991,23 +980,21 @@ class Accept_Manager():
|
|
991
980
|
files.append(tree[-1].as_posix())
|
992
981
|
return files
|
993
982
|
|
994
|
-
def check_nodata(self, name):
|
983
|
+
def check_nodata(self, name, path_baseline):
|
995
984
|
""" Check nodata in a path """
|
996
|
-
|
997
|
-
list_tif = Accept_Manager.select_name_tif(self, self.OUT_VULN, self.IN_CH_SA_SC, name)
|
985
|
+
list_tif = Accept_Manager.select_name_tif(self, path_baseline, self.IN_CH_SA_SC, name)
|
998
986
|
for cur_lst in list_tif:
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
logging.warning(_('nodata changed in favor of 99999. value for file {} !'.format(cur_lst)))
|
987
|
+
curarray:WolfArray = WolfArray(cur_lst)
|
988
|
+
if curarray.nullvalue != 99999.:
|
989
|
+
curarray.nullvalue = 99999.
|
990
|
+
curarray.set_nullvalue_in_mask()
|
991
|
+
curarray.write_all()
|
992
|
+
logging.warning(_('nodata changed in favor of 99999. value for file {} !'.format(cur_lst)))
|
1006
993
|
|
1007
994
|
def create_vrtIfExists(self, fn_baseline, fn_scenario, fn_vrt, name):
|
1008
995
|
""" Create a vrt file from a path """
|
1009
996
|
logging.info(_('Checking nodata values...'))
|
1010
|
-
self.check_nodata(name)
|
997
|
+
self.check_nodata(name, fn_baseline)
|
1011
998
|
list_tif = Accept_Manager.select_name_tif(self, fn_baseline, fn_scenario, name)
|
1012
999
|
#création du fichier vrt - assembly/agglomération
|
1013
1000
|
if len(list_tif)>1:
|
@@ -1536,7 +1523,8 @@ def match_vulnerability2sim(inRas:Path, outRas:Path, MODREC:Path):
|
|
1536
1523
|
def update_accept(accept, model_h, ij, bounds, loc_accept):
|
1537
1524
|
for idx in range(len(bounds)):
|
1538
1525
|
for i,j in ij:
|
1539
|
-
|
1526
|
+
#lit dans wd vs Ti où on est et associe son score d'accept
|
1527
|
+
if bounds[idx,0] < model_h[i,j] <= bounds[idx,1]:
|
1540
1528
|
accept[i,j] = loc_accept[idx]
|
1541
1529
|
|
1542
1530
|
def compute_acceptability(manager:Accept_Manager,
|
wolfhece/apps/version.py
CHANGED
wolfhece/lazviewer/laz_viewer.py
CHANGED
@@ -553,7 +553,7 @@ class xyz_laz_grids():
|
|
553
553
|
return np.asarray([])
|
554
554
|
else:
|
555
555
|
ret = np.concatenate(ret)
|
556
|
-
logging.info(_('Data found -- {} points'.format(ret.shape[0])))
|
556
|
+
logging.info(_('Data found -- {:_} points'.format(ret.shape[0])))
|
557
557
|
return ret
|
558
558
|
|
559
559
|
def find_files_in_bounds(self, bounds:Union[tuple[tuple[float,float],tuple[float,float]], list[list[float, float],list[float, float]]]):
|
@@ -565,7 +565,7 @@ class xyz_laz_grids():
|
|
565
565
|
logging.info(_('No data found'))
|
566
566
|
return []
|
567
567
|
else:
|
568
|
-
logging.info(_('Data found -- {} files'.format(len(ret))))
|
568
|
+
logging.info(_('Data found -- {:_} files'.format(len(ret))))
|
569
569
|
return ret
|
570
570
|
|
571
571
|
def copy_files_in_bounds(self, bounds:Union[tuple[tuple[float,float],tuple[float,float]], list[list[float, float],list[float, float]]], dirout:str):
|
@@ -578,7 +578,7 @@ class xyz_laz_grids():
|
|
578
578
|
files = self.find_files_in_bounds(bounds)
|
579
579
|
|
580
580
|
for curdir, curfiles in files:
|
581
|
-
locdir =
|
581
|
+
locdir = out / Path(curdir).name
|
582
582
|
locdir.mkdir(exist_ok=True)
|
583
583
|
for curfile in curfiles:
|
584
584
|
shutil.copy(curfile, locdir / Path(curfile).name)
|
@@ -762,6 +762,7 @@ class Wolf_LAZ_Data(Element_To_Draw):
|
|
762
762
|
self._data:np.ndarray = None # Numpy data array -- to be plotted
|
763
763
|
self._colors:np.ndarray = None # NumPy array of colors for each point --> see viewer attributes for details
|
764
764
|
self.classification = Classification_LAZ() # Classification of LAZ data --> defining colors if codification is used
|
765
|
+
self.classification.init_2023() # Default classification for LAZ data
|
765
766
|
|
766
767
|
self._associated_color:int = Colors_Lazviewer.CODE_2023.value # Associated color type for LAZ data
|
767
768
|
|
@@ -1204,7 +1205,8 @@ class Wolf_LAZ_Data(Element_To_Draw):
|
|
1204
1205
|
|
1205
1206
|
def from_file(self, fn:str):
|
1206
1207
|
""" Create data from LAZ file """
|
1207
|
-
|
1208
|
+
laz = read_laz(fn)
|
1209
|
+
self.data = np.column_stack((laz.x, laz.y, laz.z, laz.classification)).astype(np.float32)
|
1208
1210
|
self.bounds = [[np.min(self.data[:,0]), np.max(self.data[:,0])],[np.min(self.data[:,1]), np.max(self.data[:,1])]]
|
1209
1211
|
|
1210
1212
|
def descimate(self, step:int):
|
wolfhece/pybridges.py
CHANGED
@@ -340,7 +340,12 @@ class Bridge(Zones):
|
|
340
340
|
|
341
341
|
if self.leftbank is not None and self.riverbed is not None and self.rightbank is not None:
|
342
342
|
|
343
|
-
|
343
|
+
keys_zones = [curzone.myname for curzone in self.myzones]
|
344
|
+
if "_river_auto" in keys_zones:
|
345
|
+
logging.warning(_('Polygons already created'))
|
346
|
+
return
|
347
|
+
|
348
|
+
self.polygons_zone = zone(name= "_river_auto")
|
344
349
|
self.add_zone(self.polygons_zone, forceparent=True)
|
345
350
|
self.polygons_zone.myvectors = [self.leftbank, self.riverbed, self.rightbank] #inverse order to be up -> down
|
346
351
|
|