wolfhece 2.2.23__py3-none-any.whl → 2.2.25__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/Coordinates_operations.py +3 -1
- wolfhece/PyDraw.py +120 -3
- wolfhece/PyVertex.py +14 -1
- wolfhece/PyVertexvectors.py +13 -4
- wolfhece/Results2DGPU.py +157 -39
- wolfhece/apps/check_install.py +139 -6
- wolfhece/apps/version.py +1 -1
- wolfhece/irm_qdf.py +67 -1
- wolfhece/mesh2d/wolf2dprev.py +4 -2
- wolfhece/pypolygons_scen.py +12 -7
- wolfhece/report/tools.py +1902 -0
- wolfhece/wolf_array.py +55 -6
- wolfhece/wolfresults_2D.py +124 -1
- {wolfhece-2.2.23.dist-info → wolfhece-2.2.25.dist-info}/METADATA +1 -1
- {wolfhece-2.2.23.dist-info → wolfhece-2.2.25.dist-info}/RECORD +18 -17
- {wolfhece-2.2.23.dist-info → wolfhece-2.2.25.dist-info}/WHEEL +0 -0
- {wolfhece-2.2.23.dist-info → wolfhece-2.2.25.dist-info}/entry_points.txt +0 -0
- {wolfhece-2.2.23.dist-info → wolfhece-2.2.25.dist-info}/top_level.txt +0 -0
wolfhece/apps/check_install.py
CHANGED
@@ -8,6 +8,99 @@ Copyright (c) 2024 University of Liege. All rights reserved.
|
|
8
8
|
This script and its content are protected by copyright law. Unauthorized
|
9
9
|
copying or distribution of this file, via any medium, is strictly prohibited.
|
10
10
|
"""
|
11
|
+
def test_conversion_LBT72_LBT08():
|
12
|
+
|
13
|
+
from pyproj.transformer import TransformerGroup
|
14
|
+
|
15
|
+
# Créer le groupe de transformateurs
|
16
|
+
tg = TransformerGroup(31370, 3812)
|
17
|
+
|
18
|
+
# Choisir le premier transformateur (ou un autre selon ton besoin)
|
19
|
+
transformer = tg.transformers[0]
|
20
|
+
|
21
|
+
print(transformer.description)
|
22
|
+
if '(3)' in transformer.description:
|
23
|
+
# This is the Belgian Lambert 72 + BD72 to ETRS89 (3) + Belgian Lambert 2008
|
24
|
+
return True
|
25
|
+
elif '(2)' in transformer.description:
|
26
|
+
# This is the Belgian Lambert 72 + BD72 to ETRS89 (2) + Belgian Lambert 2008
|
27
|
+
return False
|
28
|
+
elif '(1)' in transformer.description:
|
29
|
+
# This is the Belgian Lambert 72 + BD72 to ETRS89 (1) + Belgian Lambert 2008
|
30
|
+
return False
|
31
|
+
else:
|
32
|
+
# This is not the expected transformer
|
33
|
+
return False
|
34
|
+
|
35
|
+
def test_conversion_LBT08_LBT72():
|
36
|
+
|
37
|
+
from pyproj.transformer import TransformerGroup
|
38
|
+
|
39
|
+
# Créer le groupe de transformateurs
|
40
|
+
tg = TransformerGroup(3812, 31370)
|
41
|
+
|
42
|
+
# Choisir le premier transformateur (ou un autre selon ton besoin)
|
43
|
+
transformer = tg.transformers[0]
|
44
|
+
|
45
|
+
print(transformer.description)
|
46
|
+
if '(3)' in transformer.description:
|
47
|
+
# This is the Belgian Lambert 72 + BD72 to ETRS89 (3) + Belgian Lambert 2008
|
48
|
+
return True
|
49
|
+
elif '(2)' in transformer.description:
|
50
|
+
# This is the Belgian Lambert 72 + BD72 to ETRS89 (2) + Belgian Lambert 2008
|
51
|
+
return False
|
52
|
+
elif '(1)' in transformer.description:
|
53
|
+
# This is the Belgian Lambert 72 + BD72 to ETRS89 (1) + Belgian Lambert 2008
|
54
|
+
return False
|
55
|
+
else:
|
56
|
+
# This is not the expected transformer
|
57
|
+
return False
|
58
|
+
|
59
|
+
def test_transform_coordinates():
|
60
|
+
from pyproj.transformer import TransformerGroup
|
61
|
+
from pyproj import Transformer
|
62
|
+
import numpy as np
|
63
|
+
from wolfhece.Coordinates_operations import transform_coordinates
|
64
|
+
tg = TransformerGroup(31370, 3812)
|
65
|
+
|
66
|
+
ret = True
|
67
|
+
|
68
|
+
ret = ret and len(tg.transformers) > 0
|
69
|
+
ret = ret and len(tg.transformers) == 3
|
70
|
+
ret = ret and '(3)' in tg.transformers[0].description
|
71
|
+
ret = ret and '(2)' in tg.transformers[1].description
|
72
|
+
ret = ret and '(1)' in tg.transformers[2].description
|
73
|
+
|
74
|
+
tg_inv = TransformerGroup(3812, 31370)
|
75
|
+
ret = ret and len(tg_inv.transformers) > 0
|
76
|
+
ret = ret and len(tg_inv.transformers) == 3
|
77
|
+
ret = ret and '(3)' in tg_inv.transformers[0].description
|
78
|
+
ret = ret and '(2)' in tg_inv.transformers[1].description
|
79
|
+
ret = ret and '(1)' in tg_inv.transformers[2].description
|
80
|
+
|
81
|
+
tr = Transformer.from_crs(31370, 3812)
|
82
|
+
|
83
|
+
points = np.array([[100000, 200000], [110000, 210000], [120000, 220000]])
|
84
|
+
|
85
|
+
transformed_points_3 = tg.transformers[0].transform(points[:, 0], points[:, 1])
|
86
|
+
transformed_points_2 = tg.transformers[1].transform(points[:, 0], points[:, 1])
|
87
|
+
transformed_points_1 = tg.transformers[2].transform(points[:, 0], points[:, 1])
|
88
|
+
transformed_points = tr.transform(points[:, 0], points[:, 1])
|
89
|
+
transform_wolf = transform_coordinates(points, inputEPSG='EPSG:31370', outputEPSG='EPSG:3812')
|
90
|
+
|
91
|
+
# Convert to numpy arrays
|
92
|
+
transformed_points_3 = np.array(transformed_points_3).T
|
93
|
+
transformed_points_2 = np.array(transformed_points_2).T
|
94
|
+
transformed_points_1 = np.array(transformed_points_1).T
|
95
|
+
transformed_points = np.array(transformed_points).T
|
96
|
+
|
97
|
+
# Assert that the transformed points are equal
|
98
|
+
ret = ret and np.all(transformed_points_3 == transform_wolf)
|
99
|
+
ret = ret and np.all(transformed_points_3 == transformed_points)
|
100
|
+
ret = ret and not np.all(transformed_points_2 == transformed_points)
|
101
|
+
ret = ret and not np.all(transformed_points_1 == transformed_points)
|
102
|
+
|
103
|
+
return ret
|
11
104
|
|
12
105
|
def main():
|
13
106
|
# Check if installation is complete
|
@@ -32,17 +125,57 @@ def main():
|
|
32
125
|
ret += 'Error during osgeo import - GDAL/OGR not/bad installed\n Please (re)install GDAL (64 bits version) from https://github.com/cgohlke/geospatial-wheels/releases\n\n'
|
33
126
|
ret += 'Error : ' + str(e) + '\n\n'
|
34
127
|
|
128
|
+
if 'pyproj' in packages:
|
129
|
+
ret += 'PyProj seems installed\n\n'
|
130
|
+
try:
|
131
|
+
conv = test_conversion_LBT72_LBT08()
|
132
|
+
|
133
|
+
if conv:
|
134
|
+
ret += 'NTv2 conversion from Lambert 72 to Lambert 2008 seems available\n\n'
|
135
|
+
else:
|
136
|
+
ret += 'NTv2 conversion from Lambert 72 to Lambert 2008 seems NOT available\n\n'
|
137
|
+
ret += 'Please check if the PROJ data files are installed correctly - See OSGOE4W instructions\n\n'
|
138
|
+
except ImportError as e:
|
139
|
+
ret += 'PyProj not installed properly\n Please install PyProj from "pip install pyproj"\n\n'
|
140
|
+
ret += 'Error : ' + str(e) + '\n\n'
|
141
|
+
|
142
|
+
try:
|
143
|
+
conv = test_conversion_LBT08_LBT72()
|
144
|
+
|
145
|
+
if conv:
|
146
|
+
ret += 'NTv2 conversion from Lambert 2008 to Lambert 72 seems available\n\n'
|
147
|
+
else:
|
148
|
+
ret += 'NTv2 conversion from Lambert 2008 to Lambert 72 seems NOT available\n\n'
|
149
|
+
ret += 'Please check if the PROJ data files are installed correctly - See OSGOE4W instructions\n\n'
|
150
|
+
except ImportError as e:
|
151
|
+
ret += 'PyProj not installed properly\n Please install PyProj from "pip install pyproj"\n\n'
|
152
|
+
ret += 'Error : ' + str(e) + '\n\n'
|
153
|
+
|
154
|
+
try:
|
155
|
+
conv = test_transform_coordinates()
|
156
|
+
if conv:
|
157
|
+
ret += 'Transform coordinates function seems working fine\n\n'
|
158
|
+
else:
|
159
|
+
ret += 'Transform coordinates function seems NOT available\n\n'
|
160
|
+
ret += 'Please check if the PROJ data files are installed correctly - See OSGOE4W instructions\n\n'
|
161
|
+
except ImportError as e:
|
162
|
+
ret += 'PyProj not installed properly\n Please install PyProj from "pip install pyproj"\n\n'
|
163
|
+
ret += 'Error : ' + str(e) + '\n\n'
|
164
|
+
|
165
|
+
else:
|
166
|
+
ret += 'PyProj not installed\n Please install PyProj from "pip install pyproj"\n\n'
|
167
|
+
|
35
168
|
if 'wolfgpu' in packages:
|
36
169
|
ret += 'WolfGPU seems installed\n\n'
|
37
170
|
else:
|
38
171
|
ret += 'WolfGPU not installed\n Please install WolfGPU if needed\n\n'
|
39
172
|
|
40
|
-
try:
|
41
|
-
|
42
|
-
|
43
|
-
except ImportError as e:
|
44
|
-
|
45
|
-
|
173
|
+
# try:
|
174
|
+
# from wolf_libs import wolfpy
|
175
|
+
# ret += 'Wolfpy accessible\n\n'
|
176
|
+
# except ImportError as e:
|
177
|
+
# ret += 'Wolfpy not accessible\n\n'
|
178
|
+
# ret += 'Error : ' + str(e) + '\n\n'
|
46
179
|
|
47
180
|
try:
|
48
181
|
from ..PyGui import MapManager
|
wolfhece/apps/version.py
CHANGED
wolfhece/irm_qdf.py
CHANGED
@@ -746,4 +746,70 @@ class QDF_Belgium():
|
|
746
746
|
return None
|
747
747
|
else:
|
748
748
|
logging.error(f"Name {key} not found in the data")
|
749
|
-
return None
|
749
|
+
return None
|
750
|
+
|
751
|
+
|
752
|
+
class Climate_IRM():
|
753
|
+
|
754
|
+
def __init__(self, store_path= 'irm', ins:Literal['2018', '2019', '2025', 2018, 2019, 2025] = 2018) -> None:
|
755
|
+
self.store_path = Path(store_path)
|
756
|
+
self.localities = Localities(ins)
|
757
|
+
|
758
|
+
self._climate_data = {}
|
759
|
+
|
760
|
+
def __getitem__(self, key):
|
761
|
+
return self._climate_data[key]
|
762
|
+
|
763
|
+
@classmethod
|
764
|
+
def importfromwebsite(cls, store_path= 'irm', verbose:bool= False, waitingtime:float= .01, ins:Literal['2018', '2019', '2025', 2018, 2019, 2025] = 2018, ins_code: int = None):
|
765
|
+
""" Import Excel files for one or all municipalities from the IRM website
|
766
|
+
|
767
|
+
:param store_path: Where to store the downloaded data. Directory will be created if it doesn't exists.
|
768
|
+
:param verbose: If `True`, will print some progress information.
|
769
|
+
If `False`, will do nothing.
|
770
|
+
If a callable, then will call it with a float in [0, 1].
|
771
|
+
0 means nothing downloaded, 1 means everything downloaded.
|
772
|
+
|
773
|
+
:param waitingtime: How long to wait (in seconds) betwenn the download
|
774
|
+
of each station (will make sure we don't overwhelm IRM's website).
|
775
|
+
|
776
|
+
:param ins: The year of the INS codes to use.
|
777
|
+
:param code: Restricts the data download to a specific NIS code. `None` means full download.
|
778
|
+
"""
|
779
|
+
import requests
|
780
|
+
|
781
|
+
myloc = Localities(ins)
|
782
|
+
|
783
|
+
if ins_code is not None:
|
784
|
+
codes_to_load = [ins_code]
|
785
|
+
else:
|
786
|
+
if not path.exists(store_path):
|
787
|
+
mkdir(store_path)
|
788
|
+
codes_to_load = myloc.inscode2name
|
789
|
+
|
790
|
+
for key,myins in enumerate(codes_to_load):
|
791
|
+
#chaîne URL du fichier Excel
|
792
|
+
url="https://www.meteo.be//resources//climatology//climateCity//pdf//climate_INS"+str(myins)+"_9120_fr.pdf"
|
793
|
+
#Obtention du fichiers depuis le site web de l'IRM
|
794
|
+
response=requests.get(url)
|
795
|
+
|
796
|
+
if str(response.content).find("Page not found")==-1 :
|
797
|
+
|
798
|
+
# Make sure we create the store path only if we have
|
799
|
+
# something to put inside.
|
800
|
+
if ins_code is not None and not path.exists(store_path):
|
801
|
+
mkdir(store_path)
|
802
|
+
|
803
|
+
file=open(path.join(store_path,str(myins)+".pdf"), 'wb')
|
804
|
+
file.write(response.content)
|
805
|
+
file.close()
|
806
|
+
if verbose:
|
807
|
+
if callable(verbose):
|
808
|
+
verbose(key/len(codes_to_load))
|
809
|
+
else:
|
810
|
+
print(myins)
|
811
|
+
else:
|
812
|
+
#logging.error(response.content)
|
813
|
+
logging.error(f"Failed to load IRM data: {url} --> {response}")
|
814
|
+
|
815
|
+
sleep(waitingtime)
|
wolfhece/mesh2d/wolf2dprev.py
CHANGED
@@ -11484,7 +11484,8 @@ class prev_sim2D():
|
|
11484
11484
|
if len(lst) == 0:
|
11485
11485
|
logging.warning('No potential BC found -- Test can not be performed -- I continue anyway')
|
11486
11486
|
else:
|
11487
|
-
|
11487
|
+
candidate_cells = list(zip(lst[0], lst[1]))
|
11488
|
+
if (i, j) not in candidate_cells:
|
11488
11489
|
logging.error(f'Invalid indices ({i},{j}) - BC not added')
|
11489
11490
|
return
|
11490
11491
|
|
@@ -11506,7 +11507,8 @@ class prev_sim2D():
|
|
11506
11507
|
if len(lst) == 0:
|
11507
11508
|
logging.warning('No potential BC found -- Test can not be performed -- I continue anyway')
|
11508
11509
|
else:
|
11509
|
-
|
11510
|
+
candidate_cells = list(zip(lst[0], lst[1]))
|
11511
|
+
if (i, j) not in candidate_cells:
|
11510
11512
|
logging.error(f'Invalid indices ({i},{j}) - BC not added')
|
11511
11513
|
return
|
11512
11514
|
|
wolfhece/pypolygons_scen.py
CHANGED
@@ -445,6 +445,8 @@ class Polygons_Analyze(Zones):
|
|
445
445
|
return float(obj)
|
446
446
|
elif isinstance(obj, np.ndarray):
|
447
447
|
return obj.tolist()
|
448
|
+
elif isinstance(obj, tuple):
|
449
|
+
return [list(lst1) for lst1 in obj]
|
448
450
|
elif obj == Wolfresults_2D:
|
449
451
|
return 'CPU'
|
450
452
|
elif obj == wolfres2DGPU:
|
@@ -919,7 +921,8 @@ class Polygons_Analyze(Zones):
|
|
919
921
|
operator:operators=operators.MEDIAN,
|
920
922
|
options:dict=None,
|
921
923
|
label=True,
|
922
|
-
show=False
|
924
|
+
show=False,
|
925
|
+
which_sim:str=None):
|
923
926
|
""" Plot the values of the river polygons
|
924
927
|
|
925
928
|
:param figax: tuple (fig, ax) for the plot
|
@@ -929,6 +932,8 @@ class Polygons_Analyze(Zones):
|
|
929
932
|
:param options: options for the plot
|
930
933
|
:param label: show the labels or not
|
931
934
|
:param show: show the plot or not
|
935
|
+
:param which_sim: simulation to plot (if None, all simulations are plotted)
|
936
|
+
:return: tuple (fig, ax) of the plot
|
932
937
|
"""
|
933
938
|
|
934
939
|
if figax is None:
|
@@ -1022,9 +1027,9 @@ class Polygons_Analyze(Zones):
|
|
1022
1027
|
figax=(fig,ax)
|
1023
1028
|
self.plot_unk(figax, stored_values_unk.WATERLEVEL, which_group, operator, options={'color':'blue', 'linewidth':2}, label=True, show=False)
|
1024
1029
|
|
1025
|
-
ax.set_ylabel(_('Water
|
1030
|
+
ax.set_ylabel(_('Water surface elevation [mDNG]'))
|
1026
1031
|
ax.set_xlabel(_('Abscissa from upstream [m]'))
|
1027
|
-
fig.suptitle(self.myname + ' -- ' +_('Water surface
|
1032
|
+
fig.suptitle(self.myname + ' -- ' +_('Water surface elevation'))
|
1028
1033
|
|
1029
1034
|
if show:
|
1030
1035
|
fig.show()
|
@@ -1055,10 +1060,10 @@ class Polygons_Analyze(Zones):
|
|
1055
1060
|
return fig,ax
|
1056
1061
|
|
1057
1062
|
def plot_stage(self,
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1063
|
+
figax=None,
|
1064
|
+
which_group=None,
|
1065
|
+
operator:operators=operators.MEDIAN,
|
1066
|
+
show=False):
|
1062
1067
|
""" Plot the water stage /water level
|
1063
1068
|
|
1064
1069
|
:param figax: tuple (fig, ax) for the plot
|