wolfhece 2.1.129__py3-none-any.whl → 2.2.2__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 +110 -47
- wolfhece/PyGui.py +3 -0
- wolfhece/PyGuiHydrology.py +24 -24
- wolfhece/PyHydrographs.py +2 -3
- wolfhece/PyPalette.py +27 -11
- wolfhece/PyParams.py +2 -3
- wolfhece/PyVertex.py +7 -7
- wolfhece/PyVertexvectors.py +1 -0
- wolfhece/Results2DGPU.py +17 -0
- wolfhece/acceptability/Parallels.py +25 -19
- wolfhece/acceptability/acceptability_gui.py +85 -45
- wolfhece/acceptability/func.py +34 -26
- wolfhece/apps/version.py +2 -2
- wolfhece/eikonal.py +1 -1
- wolfhece/hydrology/Catchment.py +2 -2
- wolfhece/hydrology/Comparison.py +26 -28
- wolfhece/hydrology/plot_hydrology.py +2 -2
- wolfhece/lagrangian/particle_system_ui.py +1 -1
- wolfhece/lagrangian/particles.py +1 -1
- wolfhece/lazviewer/processing/estimate_normals/estimate_normals.cp310-win_amd64.pyd +0 -0
- wolfhece/lazviewer/vfuncsdir/vfuncs.cp310-win_amd64.pyd +0 -0
- wolfhece/lazviewer/viewer/viewer.exe +0 -0
- wolfhece/lazviewer/viewer/viewer_np1_23_5.exe +0 -0
- wolfhece/libs/Wolf_tools.dll +0 -0
- wolfhece/libs/get_infos.cp310-win_amd64.pyd +0 -0
- wolfhece/libs/verify_wolf.cp310-win_amd64.pyd +0 -0
- wolfhece/libs/wolfogl.cp310-win_amd64.pyd +0 -0
- wolfhece/tools2d_dll.py +359 -0
- wolfhece/wolf_array.py +27 -24
- wolfhece/wolfresults_2D.py +162 -33
- {wolfhece-2.1.129.dist-info → wolfhece-2.2.2.dist-info}/METADATA +14 -9
- {wolfhece-2.1.129.dist-info → wolfhece-2.2.2.dist-info}/RECORD +35 -33
- wolfhece/libs/wolfpy.cp310-win_amd64.pyd +0 -0
- {wolfhece-2.1.129.dist-info → wolfhece-2.2.2.dist-info}/WHEEL +0 -0
- {wolfhece-2.1.129.dist-info → wolfhece-2.2.2.dist-info}/entry_points.txt +0 -0
- {wolfhece-2.1.129.dist-info → wolfhece-2.2.2.dist-info}/top_level.txt +0 -0
wolfhece/hydrology/Comparison.py
CHANGED
@@ -12,8 +12,6 @@ import sys # module to stop the program when an err
|
|
12
12
|
import os
|
13
13
|
import matplotlib.pyplot as plt
|
14
14
|
import numpy as np
|
15
|
-
from numpy.__config__ import show
|
16
|
-
from numpy.core.arrayprint import set_string_function
|
17
15
|
from wx.core import DD_CHANGE_DIR
|
18
16
|
|
19
17
|
from ..PyTranslate import _
|
@@ -587,7 +585,7 @@ class Comparison:
|
|
587
585
|
# print("ERROR: the simulation time is not long enough for this subbasin to be taken into account")
|
588
586
|
# sys.exit()
|
589
587
|
|
590
|
-
cur_module:RetentionBasin = curCatch.retentionBasinDict["J18"]
|
588
|
+
cur_module:RetentionBasin = curCatch.retentionBasinDict["J18"]
|
591
589
|
tmpHydro = cur_module.get_direct_insideRB_inlets(unit='m3/s')
|
592
590
|
|
593
591
|
y1.append(tmpHydro[:])
|
@@ -604,7 +602,7 @@ class Comparison:
|
|
604
602
|
# else:
|
605
603
|
# print("ERROR: the simulation time is not long enough for this subbasin to be taken into account")
|
606
604
|
# sys.exit()
|
607
|
-
cur_module:RetentionBasin = curCatch.retentionBasinDict["J18"]
|
605
|
+
cur_module:RetentionBasin = curCatch.retentionBasinDict["J18"]
|
608
606
|
tmpHydro = cur_module.get_direct_insideRB_inlets(unit='m3/s')
|
609
607
|
|
610
608
|
y1.append(tmpHydro[:])
|
@@ -1412,13 +1410,13 @@ class Comparison:
|
|
1412
1410
|
# graph_title = curCatch.name + " :"
|
1413
1411
|
# cur_t, curVol = curCatch.get_all_cumulRain(selection_by_iD)
|
1414
1412
|
|
1415
|
-
# for
|
1413
|
+
# for
|
1416
1414
|
# plt.figure()
|
1417
1415
|
# plt.title(graph_title)
|
1418
1416
|
# for i in range(len(curVol)):
|
1419
1417
|
# plt.plot(cur_t, curVol[i])
|
1420
1418
|
# plt.savefig(os.path.join(writeDir, graph_title))
|
1421
|
-
|
1419
|
+
|
1422
1420
|
# if show : plt.show()
|
1423
1421
|
|
1424
1422
|
|
@@ -1582,34 +1580,34 @@ class Comparison:
|
|
1582
1580
|
del self.plotDict[stationKey]["Add Data"]
|
1583
1581
|
|
1584
1582
|
|
1585
|
-
|
1583
|
+
|
1586
1584
|
def plot_Nash_and_peak(self, stationKey:list[str, int], measures:list[SubBasin], intervals:list=[], toShow:bool=True):
|
1587
1585
|
assert len(stationKey) == len(measures)
|
1588
1586
|
|
1589
|
-
all_ns = {stationKey[i]: [ self.myCatchments[el]["Object"].get_sub_Nash(measures[i], stationKey[i], intervals)
|
1590
|
-
for el in self.myCatchments ]
|
1587
|
+
all_ns = {stationKey[i]: [ self.myCatchments[el]["Object"].get_sub_Nash(measures[i], stationKey[i], intervals)
|
1588
|
+
for el in self.myCatchments ]
|
1591
1589
|
for i in range(len(stationKey))
|
1592
1590
|
}
|
1593
1591
|
print(all_ns)
|
1594
1592
|
|
1595
|
-
all_peaks = [ [ self.myCatchments[el]["Object"].get_sub_peak(stationKey[i], intervals)
|
1596
|
-
for el in self.myCatchments ]
|
1597
|
-
for i in range(len(stationKey))
|
1593
|
+
all_peaks = [ [ self.myCatchments[el]["Object"].get_sub_peak(stationKey[i], intervals)
|
1594
|
+
for el in self.myCatchments ]
|
1595
|
+
for i in range(len(stationKey))
|
1598
1596
|
]
|
1599
|
-
|
1597
|
+
|
1600
1598
|
print(all_peaks)
|
1601
1599
|
|
1602
|
-
meas_peak = [ measures[i].get_peak(intervals)
|
1600
|
+
meas_peak = [ measures[i].get_peak(intervals)
|
1603
1601
|
for i in range(len(stationKey)) ]
|
1604
|
-
|
1602
|
+
|
1605
1603
|
# The following lines is take the peak difference between simulation and measurements -> Display 0.0 if the measurement is 0.0
|
1606
1604
|
isZero = np.array(meas_peak)==0
|
1607
1605
|
notZero = np.array(meas_peak)!=0
|
1608
|
-
peak_prop = {stationKey[i]: [ list( (np.array(el)-np.array(meas_peak[i]))/(np.array(meas_peak[i])+isZero[i]) *notZero[i] )
|
1609
|
-
for el in all_peaks[i] ]
|
1606
|
+
peak_prop = {stationKey[i]: [ list( (np.array(el)-np.array(meas_peak[i]))/(np.array(meas_peak[i])+isZero[i]) *notZero[i] )
|
1607
|
+
for el in all_peaks[i] ]
|
1610
1608
|
for i in range(len(stationKey))
|
1611
1609
|
}
|
1612
|
-
|
1610
|
+
|
1613
1611
|
print(meas_peak)
|
1614
1612
|
print(peak_prop)
|
1615
1613
|
|
@@ -1637,7 +1635,7 @@ class Comparison:
|
|
1637
1635
|
continue
|
1638
1636
|
else:
|
1639
1637
|
colors_Nash[key][i_model].append("g")
|
1640
|
-
|
1638
|
+
|
1641
1639
|
|
1642
1640
|
colors_peaks = {}
|
1643
1641
|
for key, value in peak_prop.items():
|
@@ -1660,15 +1658,15 @@ class Comparison:
|
|
1660
1658
|
all_names = ["\n - \n".join([cdate[0].strftime("%d/%m/%Y"), cdate[1].strftime("%d/%m/%Y")]) for cdate in intervals]
|
1661
1659
|
|
1662
1660
|
|
1663
|
-
## Plot
|
1661
|
+
## Plot
|
1664
1662
|
nb_stations = len(stationKey)
|
1665
1663
|
type_of_model = [self.myCatchments[el]["Title"] for el in self.myCatchments]
|
1666
1664
|
type_of_data = ["Nash", r"$ \frac{Q^{s}_{max}-Q^{m}_{max}}{Q^{m}_{max}} $ "]
|
1667
1665
|
type_of_data_names = ["Nash", "Exceedance"]
|
1668
1666
|
|
1669
|
-
# ph.bar_Nash_n_other(all_data, all_colors, nb_x=len(intervals), nb_data=len(type_of_model), nb_lines=nb_stations,
|
1667
|
+
# ph.bar_Nash_n_other(all_data, all_colors, nb_x=len(intervals), nb_data=len(type_of_model), nb_lines=nb_stations,
|
1670
1668
|
# y_titles=type_of_data, x_titles=all_names, nameModel=type_of_model, line_names=sorted_keys, toShow=False)
|
1671
|
-
|
1669
|
+
|
1672
1670
|
# =========
|
1673
1671
|
# =========
|
1674
1672
|
# Plot tables - 2nd version with the table instead of bars
|
@@ -1680,12 +1678,12 @@ class Comparison:
|
|
1680
1678
|
all_peaks = {cur_catch["Title"]: np.array([cur_catch["Object"].get_sub_peak(stationKey[i], intervals) for i in range(len(stationKey))])
|
1681
1679
|
for cur_catch in self.myCatchments.values()
|
1682
1680
|
}
|
1683
|
-
|
1681
|
+
|
1684
1682
|
print(all_peaks)
|
1685
1683
|
|
1686
|
-
meas_peak = np.array([ measures[i].get_peak(intervals)
|
1684
|
+
meas_peak = np.array([ measures[i].get_peak(intervals)
|
1687
1685
|
for i in range(len(stationKey)) ])
|
1688
|
-
|
1686
|
+
|
1689
1687
|
# The following lines is take the peak difference between simulation and measurements -> Display 0.0 if the measurement is 0.0
|
1690
1688
|
isZero = (meas_peak==0)
|
1691
1689
|
notZero = (meas_peak!=0)
|
@@ -1696,13 +1694,13 @@ class Comparison:
|
|
1696
1694
|
|
1697
1695
|
# Concatenate all data
|
1698
1696
|
all_data = [all_ns, peak_prop]
|
1699
|
-
|
1697
|
+
|
1700
1698
|
for data, name_of_data in zip(all_data, type_of_data_names):
|
1701
1699
|
for cur_model, cur_data in data.items():
|
1702
1700
|
file_name = os.path.join(self.workingDir, name_of_data+"_"+cur_model)+".png"
|
1703
1701
|
# cur_title = cur_model + ": " + name_of_data
|
1704
|
-
ph.table_Nash_n_other(cur_data, name_of_data,
|
1705
|
-
row_names=sorted_keys, column_names=all_names,
|
1702
|
+
ph.table_Nash_n_other(cur_data, name_of_data,
|
1703
|
+
row_names=sorted_keys, column_names=all_names,
|
1706
1704
|
writeFile=file_name, toShow=False)
|
1707
1705
|
if toShow:
|
1708
1706
|
plt.show()
|
@@ -17,9 +17,9 @@ import math
|
|
17
17
|
import datetime
|
18
18
|
import sys
|
19
19
|
import logging
|
20
|
-
from numpy.core.arrayprint import set_string_function
|
20
|
+
# from numpy.core.arrayprint import set_string_function
|
21
21
|
|
22
|
-
from numpy.core.defchararray import index
|
22
|
+
# from numpy.core.defchararray import index
|
23
23
|
|
24
24
|
from ..PyTranslate import _
|
25
25
|
|
@@ -397,7 +397,7 @@ class Particle_system_to_draw(Element_To_Draw):
|
|
397
397
|
self._ps.nbx, self._ps.nby = value.array.shape
|
398
398
|
self._ps.dx, self._ps.dy = value.dx, value.dy
|
399
399
|
else:
|
400
|
-
assert value.dtype == np.
|
400
|
+
assert value.dtype == np.bool, 'Domain must be boolean'
|
401
401
|
self._ps.domain = value
|
402
402
|
self._ps.nbx, self._ps.nby = value.shape
|
403
403
|
|
wolfhece/lagrangian/particles.py
CHANGED
@@ -38,7 +38,7 @@ class Particles():
|
|
38
38
|
|
39
39
|
self.start_position = [x0, y0]
|
40
40
|
self.end_position = [x0.copy(), y0.copy()] # copy to define new memory storage
|
41
|
-
self._is_alive = np.ones_like(x0, dtype=np.
|
41
|
+
self._is_alive = np.ones_like(x0, dtype=np.bool)
|
42
42
|
|
43
43
|
def copy_prop_from(self, other:'Particles') -> None:
|
44
44
|
"""
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
wolfhece/tools2d_dll.py
ADDED
@@ -0,0 +1,359 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
import numpy as np
|
3
|
+
import ctypes as ct
|
4
|
+
import logging
|
5
|
+
|
6
|
+
from .wolf_array import header_wolf, getkeyblock
|
7
|
+
|
8
|
+
try:
|
9
|
+
import pefile
|
10
|
+
except ImportError:
|
11
|
+
logging.warning("pefile module not found. Exported functions will not be listed.")
|
12
|
+
|
13
|
+
|
14
|
+
class Tools2DFortran:
|
15
|
+
"""
|
16
|
+
Fortran routines/functions available in "2d_cpu_tools.f90" in Wolf_OO
|
17
|
+
|
18
|
+
Ref : https://docs.python.org/3/library/ctypes.html et https://gcc.gnu.org/onlinedocs/gfortran/Interoperability-with-C.html
|
19
|
+
Ref : https://stackoverflow.com/questions/59330863/cant-import-dll-module-in-python
|
20
|
+
"""
|
21
|
+
|
22
|
+
def __init__(self, fn_simul:str | Path, debugmode:bool = False, path_to_dll:Path = None):
|
23
|
+
|
24
|
+
if debugmode:
|
25
|
+
if path_to_dll is None:
|
26
|
+
self.dll_file = Path(__file__).parent / "libs" / "Wolf_tools_debug.dll"
|
27
|
+
else:
|
28
|
+
self.dll_file = path_to_dll / "Wolf_tools_debug.dll"
|
29
|
+
else:
|
30
|
+
if path_to_dll is None:
|
31
|
+
self.dll_file = Path(__file__).parent / "libs" / "Wolf_tools.dll"
|
32
|
+
else:
|
33
|
+
self.dll_file = path_to_dll / "Wolf_tools.dll"
|
34
|
+
|
35
|
+
self.dll_file = self.dll_file.absolute()
|
36
|
+
|
37
|
+
if not Path(self.dll_file).exists():
|
38
|
+
logging.error(f"File {self.dll_file} does not exist.")
|
39
|
+
return
|
40
|
+
|
41
|
+
# Load the DLL
|
42
|
+
try:
|
43
|
+
self.lib = ct.CDLL(str(self.dll_file))
|
44
|
+
except OSError as e:
|
45
|
+
logging.error(f"Could not load the DLL: {e}")
|
46
|
+
return
|
47
|
+
|
48
|
+
fn_simul = Path(fn_simul).absolute()
|
49
|
+
|
50
|
+
self.fn_simul = str(fn_simul)
|
51
|
+
|
52
|
+
if not Path(self.fn_simul).exists():
|
53
|
+
logging.error(f"File {self.fn_simul} does not exist.")
|
54
|
+
return
|
55
|
+
|
56
|
+
# Convert to ANSI encoding - this is important for Fortran on Windows and Latin-1 encoding
|
57
|
+
self.fn_simul = self.fn_simul.encode('ansi')
|
58
|
+
|
59
|
+
# res2D_init
|
60
|
+
self.lib.r2D_init.restype = None
|
61
|
+
self.lib.r2D_init.argtypes = [ct.c_char_p, ct.c_int]
|
62
|
+
|
63
|
+
self.lib.r2D_nbblocks.restype = ct.c_int
|
64
|
+
self.lib.r2D_nbblocks.argtypes = []
|
65
|
+
|
66
|
+
self.lib.r2D_header_block.restype = ct.c_int
|
67
|
+
self.lib.r2D_header_block.argtypes = [
|
68
|
+
ct.POINTER(ct.c_int), # nbx
|
69
|
+
ct.POINTER(ct.c_int), # nby
|
70
|
+
ct.POINTER(ct.c_double), # ox
|
71
|
+
ct.POINTER(ct.c_double), # oy
|
72
|
+
ct.POINTER(ct.c_double), # tx
|
73
|
+
ct.POINTER(ct.c_double), # ty
|
74
|
+
ct.POINTER(ct.c_double), # dx
|
75
|
+
ct.POINTER(ct.c_double), # dy
|
76
|
+
ct.c_int # which_block
|
77
|
+
]
|
78
|
+
|
79
|
+
self.lib.r2D_getsizes.restype = None
|
80
|
+
self.lib.r2D_getsizes.argtypes = [
|
81
|
+
ct.POINTER(ct.c_int), # nbx
|
82
|
+
ct.POINTER(ct.c_int), # nby
|
83
|
+
ct.c_int # which_block
|
84
|
+
]
|
85
|
+
|
86
|
+
self.lib.r2D_getnbresults.restype = ct.c_int
|
87
|
+
self.lib.r2D_getnbresults.argtypes = []
|
88
|
+
|
89
|
+
self.lib.r2D_getresults.restype = None
|
90
|
+
self.lib.r2D_getresults.argtypes = [
|
91
|
+
ct.c_int, # which
|
92
|
+
ct.c_int, # nbx
|
93
|
+
ct.c_int, # nby
|
94
|
+
ct.POINTER(ct.c_float), # waterdepth
|
95
|
+
ct.POINTER(ct.c_float), # qx
|
96
|
+
ct.POINTER(ct.c_float), # qy
|
97
|
+
ct.c_int # which_block
|
98
|
+
]
|
99
|
+
|
100
|
+
self.lib.r2D_getturbresults.restype = None
|
101
|
+
self.lib.r2D_getturbresults.argtypes = [
|
102
|
+
ct.c_int, # which
|
103
|
+
ct.c_int, # nbx
|
104
|
+
ct.c_int, # nby
|
105
|
+
ct.POINTER(ct.c_float), # k
|
106
|
+
ct.POINTER(ct.c_float), # e
|
107
|
+
ct.c_int # which_block
|
108
|
+
]
|
109
|
+
|
110
|
+
self.lib.r2D_get_times_steps.restype = None
|
111
|
+
self.lib.r2D_get_times_steps.argtypes = [
|
112
|
+
ct.POINTER(ct.c_float), # times
|
113
|
+
ct.POINTER(ct.c_int), # steps
|
114
|
+
ct.c_int # nb
|
115
|
+
]
|
116
|
+
|
117
|
+
self.lib.r2D_get_conv_border.restype = None
|
118
|
+
self.lib.r2D_get_conv_border.argtypes = [
|
119
|
+
ct.c_char_p, # ptr_fnsim
|
120
|
+
ct.c_char_p, # ptr_fnvec
|
121
|
+
ct.c_int, # simul_type
|
122
|
+
ct.c_char_p, # ptr_fnres
|
123
|
+
ct.c_char_p, # ptr_fncut
|
124
|
+
ct.c_int, # len_fnsim
|
125
|
+
ct.c_int, # len_fnvec
|
126
|
+
ct.c_int, # len_fnres
|
127
|
+
ct.c_int # len_fncut
|
128
|
+
]
|
129
|
+
|
130
|
+
|
131
|
+
def _list_exported_functions(self):
|
132
|
+
"""
|
133
|
+
Fortran routines/functions available in
|
134
|
+
"""
|
135
|
+
|
136
|
+
pe = pefile.PE(self.dll_file)
|
137
|
+
|
138
|
+
if not hasattr(pe, 'DIRECTORY_ENTRY_EXPORT'):
|
139
|
+
print("No exported functions found.")
|
140
|
+
return
|
141
|
+
|
142
|
+
for exp in pe.DIRECTORY_ENTRY_EXPORT.symbols:
|
143
|
+
print(f"Function: {exp.name.decode('utf-8') if exp.name else 'None'}, Address: {hex(exp.address)}")
|
144
|
+
|
145
|
+
def _r2D_init(self):
|
146
|
+
"""
|
147
|
+
Alias for the Fortran function r2D_init.
|
148
|
+
|
149
|
+
subroutine r2D_init(ptr_path, len_path) bind(C, name="r2d_init")
|
150
|
+
!DEC$ ATTRIBUTES DLLEXPORT :: r2d_init
|
151
|
+
type(c_ptr), value, intent(in) :: ptr_path
|
152
|
+
integer(c_int), value, intent(in) :: len_path
|
153
|
+
|
154
|
+
end subroutine
|
155
|
+
"""
|
156
|
+
self.lib.r2D_init(self.fn_simul, ct.c_int(len(self.fn_simul)))
|
157
|
+
|
158
|
+
def r2D_get_number_of_blocks(self):
|
159
|
+
"""
|
160
|
+
Alias for the Fortran function r2D_nbblocks.
|
161
|
+
|
162
|
+
function r2D_nbblocks() result(nb_blocks) bind(C, name="r2D_nbblocks")
|
163
|
+
!DEC$ ATTRIBUTES DLLEXPORT :: r2D_nbblocks
|
164
|
+
integer(c_int) :: nb_blocks
|
165
|
+
|
166
|
+
end function
|
167
|
+
"""
|
168
|
+
self._r2D_init()
|
169
|
+
nb_blocks = self.lib.r2D_nbblocks()
|
170
|
+
return nb_blocks
|
171
|
+
|
172
|
+
def r2D_get_header_one_block(self, which_block:int):
|
173
|
+
"""
|
174
|
+
Alias for the Fortran function r2D_header_block.
|
175
|
+
|
176
|
+
function r2D_header_block(nbx, nby, dx,dy,ox,oy,tx,ty,which_block) result(ret) bind(C, name="r2D_header_block")
|
177
|
+
!DEC$ ATTRIBUTES DLLEXPORT :: r2D_header_block
|
178
|
+
!DEC$ attributes REFERENCE :: nbx, nby
|
179
|
+
!DEC$ attributes REFERENCE :: dx, dy, ox, oy, tx, ty
|
180
|
+
!DEC$ attributes VALUE :: which_block
|
181
|
+
integer(c_int) :: nbx,nby, ret
|
182
|
+
double precision :: ox,oy,tx,ty,dx,dy
|
183
|
+
integer(c_int), intent(in) :: which_block
|
184
|
+
|
185
|
+
end function
|
186
|
+
"""
|
187
|
+
|
188
|
+
self._r2D_init()
|
189
|
+
nbx = ct.c_int()
|
190
|
+
nby = ct.c_int()
|
191
|
+
ox = ct.c_double()
|
192
|
+
oy = ct.c_double()
|
193
|
+
tx = ct.c_double()
|
194
|
+
ty = ct.c_double()
|
195
|
+
dx = ct.c_double()
|
196
|
+
dy = ct.c_double()
|
197
|
+
self.lib.r2D_header_block(ct.byref(nbx), ct.byref(nby), ct.byref(dx), ct.byref(dy),
|
198
|
+
ct.byref(ox), ct.byref(oy), ct.byref(tx), ct.byref(ty), ct.c_int(which_block))
|
199
|
+
|
200
|
+
return (nbx.value, nby.value, dx.value, dy.value, ox.value, oy.value, tx.value, ty.value)
|
201
|
+
|
202
|
+
def _r2D_get_header_block_python(self, which_block:int) -> header_wolf:
|
203
|
+
""" Return a header_wolf object with the header of the block number which_block."""
|
204
|
+
nbx, nby, dx, dy, ox, oy, tx, ty = self.r2D_get_header_one_block(which_block)
|
205
|
+
newhead = header_wolf()
|
206
|
+
newhead.nbx = nbx
|
207
|
+
newhead.nby = nby
|
208
|
+
newhead.dx = dx
|
209
|
+
newhead.dy = dy
|
210
|
+
newhead.origin = ox, oy
|
211
|
+
newhead.translation = tx, ty
|
212
|
+
|
213
|
+
return newhead
|
214
|
+
|
215
|
+
def r2D_get_header_allblocks(self):
|
216
|
+
|
217
|
+
nbblocks = self.r2D_get_number_of_blocks()
|
218
|
+
blocks = {}
|
219
|
+
|
220
|
+
for i in range(1, nbblocks+1):
|
221
|
+
key = getkeyblock(i, addone=False)
|
222
|
+
blocks[key] = self._r2D_get_header_block_python(i)
|
223
|
+
|
224
|
+
return blocks
|
225
|
+
|
226
|
+
def r2D_get_shape(self, which_block:int):
|
227
|
+
"""
|
228
|
+
Alias for the Fortran function r2D_getsizes.
|
229
|
+
|
230
|
+
subroutine r2D_getsizes(nbx,nby,which_block) bind(C, name="r2D_getsizes")
|
231
|
+
!DEC$ ATTRIBUTES DLLEXPORT :: r2D_getsizes
|
232
|
+
integer(c_int), intent(out) :: nbx,nby
|
233
|
+
integer(c_int), intent(in) :: which_block
|
234
|
+
|
235
|
+
end subroutine
|
236
|
+
"""
|
237
|
+
|
238
|
+
self._r2D_init()
|
239
|
+
nbx = ct.c_int()
|
240
|
+
nby = ct.c_int()
|
241
|
+
self.lib.r2D_getsizes(ct.byref(nbx), ct.byref(nby), ct.c_int(which_block))
|
242
|
+
|
243
|
+
return nbx.value, nby.value
|
244
|
+
|
245
|
+
|
246
|
+
def r2D_get_number_of_results(self):
|
247
|
+
"""
|
248
|
+
Alias for the Fortran function r2D_getnbresults.
|
249
|
+
|
250
|
+
function r2D_getnbresults() result(nb) bind(C, name="r2D_getnbresults")
|
251
|
+
!DEC$ ATTRIBUTES DLLEXPORT :: r2D_getnbresults
|
252
|
+
integer(c_int) :: nb
|
253
|
+
|
254
|
+
end function
|
255
|
+
"""
|
256
|
+
|
257
|
+
self._r2D_init()
|
258
|
+
nb = self.lib.r2D_getnbresults()
|
259
|
+
return nb
|
260
|
+
|
261
|
+
def r2D_get_one_result(self, which:int, which_block:int):
|
262
|
+
"""
|
263
|
+
Alias for the Fortran function r2D_getresults.
|
264
|
+
|
265
|
+
subroutine r2D_getresults(which,nbx,nby,waterdepth,qx,qy,which_block) bind(C, name="r2D_getresults")
|
266
|
+
!DEC$ ATTRIBUTES DLLEXPORT :: r2D_getresults
|
267
|
+
integer(c_int), intent(in) :: nbx,nby,which
|
268
|
+
integer(c_int), intent(in) :: which_block
|
269
|
+
real, dimension(nbx,nby), intent(out) :: waterdepth,qx,qy
|
270
|
+
|
271
|
+
end subroutine
|
272
|
+
"""
|
273
|
+
|
274
|
+
self._r2D_init()
|
275
|
+
|
276
|
+
nbx, nby = self.r2D_get_shape(which_block)
|
277
|
+
waterdepth = np.zeros((nbx, nby), dtype=np.float32, order='F')
|
278
|
+
qx = np.zeros((nbx, nby), dtype=np.float32, order='F')
|
279
|
+
qy = np.zeros((nbx, nby), dtype=np.float32, order='F')
|
280
|
+
|
281
|
+
self.lib.r2D_getresults(ct.c_int(which), ct.c_int(nbx), ct.c_int(nby),
|
282
|
+
waterdepth.ctypes.data_as(ct.POINTER(ct.c_float)),
|
283
|
+
qx.ctypes.data_as(ct.POINTER(ct.c_float)),
|
284
|
+
qy.ctypes.data_as(ct.POINTER(ct.c_float)),
|
285
|
+
ct.c_int(which_block))
|
286
|
+
|
287
|
+
return waterdepth, qx, qy
|
288
|
+
|
289
|
+
def r2D_get_one_turbulent_result(self, which:int, which_block:int):
|
290
|
+
"""
|
291
|
+
Alias for the Fortran function r2D_getturbresults.
|
292
|
+
|
293
|
+
subroutine r2D_getturbresults(which,nbx,nby,k,e,which_block) bind(C, name="r2D_getturbresults")
|
294
|
+
!DEC$ ATTRIBUTES DLLEXPORT :: r2D_getturbresults
|
295
|
+
integer(c_int), intent(in) :: nbx,nby,which
|
296
|
+
integer(c_int), intent(in) :: which_block
|
297
|
+
real, dimension(nbx,nby), intent(out) :: k,e
|
298
|
+
|
299
|
+
end subroutine
|
300
|
+
"""
|
301
|
+
|
302
|
+
self._r2D_init()
|
303
|
+
|
304
|
+
nbx, nby = self.r2D_get_shape(which_block)
|
305
|
+
k = np.zeros((nbx, nby), dtype=np.float32, order='F')
|
306
|
+
e = np.zeros((nbx, nby), dtype=np.float32, order='F')
|
307
|
+
self.lib.r2D_getturbresults(ct.c_int(which), ct.c_int(nbx), ct.c_int(nby),
|
308
|
+
k.ctypes.data_as(ct.POINTER(ct.c_float)),
|
309
|
+
e.ctypes.data_as(ct.POINTER(ct.c_float)),
|
310
|
+
ct.c_int(which_block))
|
311
|
+
|
312
|
+
return k, e
|
313
|
+
|
314
|
+
def r2D_get_times_steps(self):
|
315
|
+
"""
|
316
|
+
Alias for the Fortran function get_times_steps.
|
317
|
+
|
318
|
+
subroutine get_times_steps(times, steps, nb) bind(C, name="get_times_steps")
|
319
|
+
!DEC$ ATTRIBUTES DLLEXPORT :: r2D_gettimes_steps
|
320
|
+
integer(c_int), intent(in) :: nb
|
321
|
+
real, dimension(nb), intent(out) :: times
|
322
|
+
integer, dimension(nb), intent(out) :: steps
|
323
|
+
|
324
|
+
end subroutine
|
325
|
+
"""
|
326
|
+
|
327
|
+
self._r2D_init()
|
328
|
+
nb = self.r2D_get_number_of_results()
|
329
|
+
times = np.zeros((nb), dtype=np.float32, order='F')
|
330
|
+
steps = np.zeros((nb), dtype=np.int32, order='F')
|
331
|
+
self.lib.r2D_get_times_steps(times.ctypes.data_as(ct.POINTER(ct.c_float)),
|
332
|
+
steps.ctypes.data_as(ct.POINTER(ct.c_int)),
|
333
|
+
ct.c_int(nb))
|
334
|
+
return times, steps
|
335
|
+
|
336
|
+
def r2D_create_convergence_border(self, vec:str='', simtype:int=0, res:str='', cutcell:str=''):
|
337
|
+
"""
|
338
|
+
Alias for the Fortran function get_conv_border.
|
339
|
+
|
340
|
+
subroutine get_conv_border(ptr_fnsim, ptr_fnvec, simul_type, ptr_fnres, ptr_fncut, len_fnsim, len_fnvec, len_fnres, len_fncut) bind(C, name="get_conv_border")
|
341
|
+
!DEC$ ATTRIBUTES DLLEXPORT :: r2D_get_conv_border
|
342
|
+
type(c_ptr), value, intent(in) :: ptr_fnsim, ptr_fnvec, ptr_fnres, ptr_fncut
|
343
|
+
integer(c_int), value, intent(in) :: len_fnsim, len_fnvec, len_fnres, len_fncut
|
344
|
+
|
345
|
+
end subroutine
|
346
|
+
"""
|
347
|
+
|
348
|
+
fn_vec = str(vec).encode('ansi')
|
349
|
+
fn_res = str(res).encode('ansi')
|
350
|
+
fn_cutcell = str(cutcell).encode('ansi')
|
351
|
+
|
352
|
+
self._r2D_init()
|
353
|
+
self.lib.r2D_get_conv_border(self.fn_simul, fn_vec, simtype, fn_res, fn_cutcell,
|
354
|
+
ct.c_int(len(self.fn_simul)),
|
355
|
+
ct.c_int(len(fn_vec)),
|
356
|
+
ct.c_int(len(fn_res)),
|
357
|
+
ct.c_int(len(fn_cutcell)))
|
358
|
+
|
359
|
+
return 0
|