wolfhece 2.2.28__py3-none-any.whl → 2.2.30__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/PyConfig.py +27 -3
- wolfhece/PyCrosssections.py +36 -33
- wolfhece/PyDraw.py +204 -20
- wolfhece/PyVertexvectors.py +417 -121
- wolfhece/PyWMS.py +6 -3
- wolfhece/__init__.py +27 -0
- wolfhece/acceptability/acceptability.py +25 -20
- wolfhece/acceptability/acceptability_gui.py +150 -92
- wolfhece/acceptability/func.py +169 -82
- wolfhece/apps/version.py +1 -1
- wolfhece/irm_qdf.py +71 -7
- wolfhece/lb7208_ntv2/__init__.py +0 -0
- wolfhece/lb7208_ntv2/be_ign_README.txt +36 -0
- wolfhece/lb7208_ntv2/be_ign_bd72lb72_etrs89lb08.tif +0 -0
- wolfhece/lb7208_ntv2/be_ign_hBG18.tif +0 -0
- wolfhece/mesh2d/gpu_2d.py +11 -2
- wolfhece/pyshields.py +166 -105
- wolfhece/report/compare_arrays.py +268 -58
- wolfhece/report/simplesimgpu.py +25 -6
- wolfhece/scenario/config_manager.py +243 -7
- wolfhece/ui/wolf_multiselection_collapsiblepane.py +153 -1
- wolfhece/wolf_array.py +67 -62
- wolfhece/wolf_texture.py +4 -0
- {wolfhece-2.2.28.dist-info → wolfhece-2.2.30.dist-info}/METADATA +1 -1
- {wolfhece-2.2.28.dist-info → wolfhece-2.2.30.dist-info}/RECORD +28 -24
- {wolfhece-2.2.28.dist-info → wolfhece-2.2.30.dist-info}/WHEEL +0 -0
- {wolfhece-2.2.28.dist-info → wolfhece-2.2.30.dist-info}/entry_points.txt +0 -0
- {wolfhece-2.2.28.dist-info → wolfhece-2.2.30.dist-info}/top_level.txt +0 -0
wolfhece/PyWMS.py
CHANGED
@@ -293,9 +293,12 @@ def getNGI(cat:Literal['orthoimage_coverage',
|
|
293
293
|
tofile=True,
|
294
294
|
format:Literal['image/png', 'image/GeoTIFF']='image/png') -> BytesIO:
|
295
295
|
|
296
|
-
|
297
|
-
|
298
|
-
|
296
|
+
try:
|
297
|
+
wms=WebMapService(f'https://wms.ngi.be/inspire/ortho/service?',
|
298
|
+
version='1.3.0', timeout=10)
|
299
|
+
except:
|
300
|
+
logging.warning(_('Impossible to get data from web services'))
|
301
|
+
return None
|
299
302
|
ppkm = 300
|
300
303
|
if w is None and h is None:
|
301
304
|
real_w = (xr-xl)/1000
|
wolfhece/__init__.py
CHANGED
@@ -11,10 +11,37 @@ except ImportError as e:
|
|
11
11
|
# print(e)
|
12
12
|
raise Exception(_('Error importing GDAL library\nPlease ensure GDAL is installed and the Python bindings are available\n\ngdal wheels can be found at https://github.com/cgohlke/geospatial-wheels'))
|
13
13
|
|
14
|
+
try:
|
15
|
+
import pyproj
|
16
|
+
except ImportError as e:
|
17
|
+
raise ImportError(_('pyproj is not installed. Please install it to use this function.')) from e
|
18
|
+
|
14
19
|
from .apps.version import WolfVersion
|
15
20
|
from packaging.version import Version
|
21
|
+
from pathlib import Path
|
22
|
+
|
23
|
+
|
24
|
+
def ensure_ntv2grid_exists():
|
25
|
+
"""
|
26
|
+
Check if the NTV2 grid file exists in the expected location.
|
27
|
+
"""
|
28
|
+
|
29
|
+
from shutil import copyfile
|
30
|
+
|
31
|
+
# print('Version de pyproj :', pyproj.__version__)
|
32
|
+
files = ['be_ign_bd72lb72_etrs89lb08.tif', 'be_ign_hBG18.tif', 'be_ign_README.txt']
|
33
|
+
|
34
|
+
pyproj_datadir = Path(pyproj.datadir.get_data_dir())
|
35
|
+
|
36
|
+
for file in files:
|
37
|
+
if not (pyproj_datadir / file).exists():
|
38
|
+
# copy the NTV2 grid file to the pyproj data directory
|
39
|
+
ntv2_grid_path = Path(__file__).parent / 'lb7208_ntv2' / file
|
40
|
+
copyfile(ntv2_grid_path, pyproj_datadir / file)
|
41
|
+
print(f"Copied {file} to {pyproj_datadir}")
|
16
42
|
|
17
43
|
__version__ = WolfVersion().get_version()
|
44
|
+
ensure_ntv2grid_exists()
|
18
45
|
|
19
46
|
def is_enough(version: str) -> bool:
|
20
47
|
"""
|
@@ -8,7 +8,7 @@ This script and its content are protected by copyright law. Unauthorized
|
|
8
8
|
copying or distribution of this file, via any medium, is strictly prohibited.
|
9
9
|
"""
|
10
10
|
|
11
|
-
from .Parallels import parallel_gpd_clip, parallel_v2r, parallel_datamod
|
11
|
+
from .Parallels import parallel_gpd_clip, parallel_v2r, parallel_datamod
|
12
12
|
from .func import data_modification, compute_vulnerability, compute_vulnerability4scenario
|
13
13
|
from .func import match_vulnerability2sim, compute_acceptability, shp_to_raster, clip_layer
|
14
14
|
from .func import Accept_Manager, cleaning_directory, EXTENT, Vulnerability_csv, compute_code
|
@@ -316,13 +316,13 @@ def Vulnerability(main_dir:str = 'Data',
|
|
316
316
|
|
317
317
|
"""
|
318
318
|
|
319
|
-
#Call of the Manager Class --> allows structure
|
319
|
+
#Call of the Manager Class --> allows structure
|
320
320
|
manager = Accept_Manager(main_dir,
|
321
321
|
Study_area,
|
322
322
|
scenario=scenario,
|
323
323
|
Vuln_csv=Vuln_csv,
|
324
324
|
Intermediate_csv=Intermediate_csv)
|
325
|
-
|
325
|
+
|
326
326
|
if not manager.check_before_vulnerability():
|
327
327
|
logging.error("The necessary files are missing - Verify logs for more information")
|
328
328
|
return
|
@@ -340,7 +340,7 @@ def Vulnerability(main_dir:str = 'Data',
|
|
340
340
|
cleaning_directory(manager.TMP_SCEN_DIR)
|
341
341
|
|
342
342
|
if 10 in steps or steps_vulnerability.CREATE_RASTERS_VULN in steps:
|
343
|
-
compute_vulnerability(manager)
|
343
|
+
compute_vulnerability(manager)
|
344
344
|
done.append(steps_vulnerability.CREATE_RASTERS_VULN)
|
345
345
|
|
346
346
|
if 11 in steps or steps_vulnerability.CREATE_RASTERS_CODE in steps:
|
@@ -382,12 +382,12 @@ def Vulnerability(main_dir:str = 'Data',
|
|
382
382
|
if TMAX is None:
|
383
383
|
logging.error("The file for the maximum return period is missing")
|
384
384
|
return
|
385
|
-
|
385
|
+
|
386
386
|
match_vulnerability2sim(manager.SA_MASKED_RIVER, manager.OUT_MASKED_RIVER, TMAX)
|
387
387
|
match_vulnerability2sim(manager.SA_VULN, manager.OUT_VULN, TMAX)
|
388
388
|
match_vulnerability2sim(manager.SA_CODE, manager.OUT_CODE, TMAX)
|
389
389
|
done.append(steps_vulnerability.MATCH_SIMUL)
|
390
|
-
|
390
|
+
|
391
391
|
if 4 in steps or steps_vulnerability.APPLY_SCENARIOSVULN in steps:
|
392
392
|
if os.path.exists(manager.OUT_VULN):
|
393
393
|
existence=False
|
@@ -398,7 +398,7 @@ def Vulnerability(main_dir:str = 'Data',
|
|
398
398
|
else :
|
399
399
|
logging.error(f"The baseline vulnerability does not exist ({manager.OUT_VULN}). Please, compute first the vulnerability without scenarios vuln_.")
|
400
400
|
done.append(steps_vulnerability.APPLY_SCENARIOSVULN)
|
401
|
-
#Delete _scenario folder is no scenario
|
401
|
+
#Delete _scenario folder is no scenario
|
402
402
|
if os.path.isdir(manager.OUT_WITHVULN) and not os.listdir(manager.OUT_WITHVULN):
|
403
403
|
os.rmdir(manager.OUT_WITHVULN)
|
404
404
|
return done
|
@@ -409,7 +409,7 @@ def Acceptability(main_dir:str = 'Vesdre',
|
|
409
409
|
coeff_auto:bool = True,
|
410
410
|
Ponderation_csv:str = 'Ponderation.csv',
|
411
411
|
resample_size:int = 100,
|
412
|
-
steps:list[int] | list[steps_acceptability] = [1,2,3,4,5,6]):
|
412
|
+
steps:list[int] | list[steps_acceptability] = [1,2,3,4,5,6]):
|
413
413
|
""" Compute acceptability for the scenario """
|
414
414
|
|
415
415
|
done = []
|
@@ -418,30 +418,35 @@ def Acceptability(main_dir:str = 'Vesdre',
|
|
418
418
|
Study_area,
|
419
419
|
scenario=scenario,
|
420
420
|
Ponderation_csv=Ponderation_csv)
|
421
|
-
|
422
|
-
# Load the vulnerability raster **for the scenario**, and check if an assembly exists and is asked by the user
|
423
|
-
# Initialization of lists to read/ write according to the needed steps
|
421
|
+
|
422
|
+
# Load the vulnerability raster **for the scenario**, and check if an assembly exists and is asked by the user
|
423
|
+
# Initialization of lists to read/ write according to the needed steps
|
424
424
|
VulneToCompute, PathsToSaveA, PathsToSaveA100 = [], [], []
|
425
|
-
if 4 in steps or steps_acceptability.COMPUTE_BASELINE_WITHOUT_SCENARIOS in steps:
|
425
|
+
if 4 in steps or steps_acceptability.COMPUTE_BASELINE_WITHOUT_SCENARIOS in steps:
|
426
426
|
VulneToCompute.append(manager.OUT_VULN)
|
427
427
|
PathsToSaveA.append(manager.OUT_ACCEPT)
|
428
428
|
PathsToSaveA100.append(manager.OUT_ACCEPT_RESAMP)
|
429
429
|
river_trace = manager.OUT_MASKED_RIVER
|
430
430
|
|
431
|
-
if 5 in steps or steps_acceptability.COMPUTE_WITH_SCENARIOS in steps:
|
432
|
-
river_trace = manager.wich_river_trace()
|
431
|
+
if 5 in steps or steps_acceptability.COMPUTE_WITH_SCENARIOS in steps:
|
432
|
+
river_trace = manager.wich_river_trace()
|
433
433
|
change_vuln_files = [Path(a) for a in glob.glob(str(manager.IN_CH_SA_SC / "vuln_*.tif")) + glob.glob(str(manager.IN_CH_SA_SC / "vuln_*.tiff"))]
|
434
434
|
if len(change_vuln_files) != 0:
|
435
435
|
VulneToCompute.append(manager.OUT_VULN_Stif)
|
436
436
|
PathsToSaveA.append(manager.OUT_ACCEPT_Stif)
|
437
437
|
PathsToSaveA100.append(manager.OUT_ACCEPT_RESAMP_Stif)
|
438
|
-
else :
|
438
|
+
else :
|
439
439
|
logging.info("No vulnerability rasters in CHANGE_VULNE. The code goes on without them.")
|
440
|
+
|
441
|
+
if len(VulneToCompute) == 0:
|
442
|
+
logging.error("No vulnerability rasters to compute acceptability. Please, compute the vulnerability first.")
|
443
|
+
return done
|
444
|
+
|
440
445
|
for i in range(len(VulneToCompute)) :
|
441
446
|
vulne = gdal.Open(str(VulneToCompute[i]))
|
442
447
|
saveA = PathsToSaveA[i]
|
443
448
|
saveA100 = PathsToSaveA100[i]
|
444
|
-
# Load the river mask
|
449
|
+
# Load the river mask
|
445
450
|
riv = gdal.Open(str(river_trace))
|
446
451
|
|
447
452
|
# Get the geotransform and projection for the output tiff
|
@@ -566,7 +571,7 @@ def Acceptability(main_dir:str = 'Vesdre',
|
|
566
571
|
|
567
572
|
comb += part_accept[curT] * float(pond["Ponderation"][curT])
|
568
573
|
|
569
|
-
y_pixels, x_pixels = comb.shape
|
574
|
+
y_pixels, x_pixels = comb.shape
|
570
575
|
|
571
576
|
driver = gdal.GetDriverByName('GTiff')
|
572
577
|
|
@@ -583,14 +588,14 @@ def Acceptability(main_dir:str = 'Vesdre',
|
|
583
588
|
dataset.SetGeoTransform(geotrans)
|
584
589
|
dataset.SetProjection(proj)
|
585
590
|
band = dataset.GetRasterBand(1)
|
586
|
-
band.WriteArray(comb)
|
587
|
-
band.FlushCache()
|
591
|
+
band.WriteArray(comb)
|
592
|
+
band.FlushCache()
|
588
593
|
dataset.SetGeoTransform(geotrans)
|
589
594
|
dataset.SetProjection(proj)
|
590
595
|
dataset = None
|
591
596
|
|
592
597
|
done.append(steps_acceptability.COMPUTE_MEAN_ACCEPT)
|
593
|
-
|
598
|
+
|
594
599
|
if 6 in steps or steps_acceptability.RESAMPLING in steps:
|
595
600
|
if os.path.exists(manager.OUT_ACCEPT):
|
596
601
|
Agg = gdal.Warp(str(saveA100),
|