mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-29 19:10:42 +01:00
Results: Refactoring '_export_rk' methode.
This commit is contained in:
1 parent
97867080d9
commit
5d46401b85
2 files changed
+155
-247
No files matched your search
@@ -826,6 +826,13 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||||||
|
|
||||||
return n_zones
|
return n_zones
|
||||||
|
|
||||||
|
def froude(self, v, z):
|
||||||
|
return v / np.sqrt(
|
||||||
|
9.81 * (
|
||||||
|
self.wet_area(z) / self.wet_width(z)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def get_all_water_limits_ac(self, z):
|
def get_all_water_limits_ac(self, z):
|
||||||
"""
|
"""
|
||||||
|
|||||||
+148
-247
@@ -876,266 +876,167 @@ class ResultsWindow(PamhyrWindow):
|
|||||||
dict_x = self._trad.get_dict("values_x")
|
dict_x = self._trad.get_dict("values_x")
|
||||||
dict_y = self._trad.get_dict("values_y")
|
dict_y = self._trad.get_dict("values_y")
|
||||||
|
|
||||||
if self._current_results == 2:
|
|
||||||
envelop = False
|
|
||||||
reach1 = results[0].river.reachs[self._get_current_reach()]
|
|
||||||
reach2 = results[1].river.reachs[self._get_current_reach()]
|
|
||||||
|
|
||||||
if envelop:
|
if envelop:
|
||||||
dict_y.update(self._trad.get_dict("values_y_envelop"))
|
dict_y.update(self._trad.get_dict("values_y_envelop"))
|
||||||
|
|
||||||
my_dict = {}
|
|
||||||
my_dict[dict_x["rk"]] = reach.geometry.get_rk()
|
|
||||||
|
|
||||||
table = results.get("table")
|
table = results.get("table")
|
||||||
id_ts = results.get_timestamp_id(timestamp)
|
id_ts = results.get_timestamp_id(timestamp)
|
||||||
|
|
||||||
z = table["Z"]
|
ind = reach.global_index
|
||||||
q = table["Q"]
|
|
||||||
v = table["V"]
|
|
||||||
zfd = table["zfd"]
|
|
||||||
|
|
||||||
if "bed_elevation" in y:
|
my_dict = {}
|
||||||
if reach.has_bedload():
|
data = {
|
||||||
zmin = list(map(
|
"z": table["Z"][:, ind[0]:ind[1]+1],
|
||||||
lambda p: zfd[id_ts, p.global_index],
|
"q": table["Q"][:, ind[0]:ind[1]+1],
|
||||||
reach.profiles
|
"v": table["V"][:, ind[0]:ind[1]+1],
|
||||||
))
|
"zfd": table["zfd"][:, ind[0]:ind[1]+1],
|
||||||
else:
|
|
||||||
zmin = reach.geometry.get_z_min()
|
"reach": reach,
|
||||||
my_dict[dict_y["bed_elevation"]] = zmin
|
"id_ts": id_ts, "envelop": envelop,
|
||||||
# if envelop and reach.has_sediment():
|
"my_dict": my_dict,
|
||||||
if "discharge" in y:
|
}
|
||||||
my_dict[dict_y["discharge"]] = list(
|
|
||||||
map(
|
func = {
|
||||||
lambda p: q[id_ts, p.global_index],
|
"bed_elevation": self._export_rk_compute_elevation,
|
||||||
reach.profiles
|
"discharge": self._export_rk_compute_discharge,
|
||||||
)
|
"water_elevation": self._export_rk_compute_water_elevation,
|
||||||
|
"velocity": self._export_rk_compute_velocity,
|
||||||
|
"depth": self._export_rk_compute_depth,
|
||||||
|
"mean_depth": self._export_rk_compute_mean_depth,
|
||||||
|
"froude": self._export_rk_compute_froude,
|
||||||
|
"wet_area": self._export_rk_compute_wet_area,
|
||||||
|
}
|
||||||
|
|
||||||
|
# Compute values
|
||||||
|
for key in y:
|
||||||
|
func[key](data)
|
||||||
|
|
||||||
|
# Translate dictionary keys
|
||||||
|
translated_dict = {}
|
||||||
|
for key in my_dict:
|
||||||
|
translated_dict[dict_y[key]] = my_dict[key]
|
||||||
|
|
||||||
|
translated_dict[dict_x["rk"]] = reach.geometry.get_rk()
|
||||||
|
|
||||||
|
return translated_dict
|
||||||
|
|
||||||
|
def _export_rk_compute_elevation(self, data):
|
||||||
|
my_dict = data["my_dict"]
|
||||||
|
reach = data["reach"]
|
||||||
|
id_ts = data["id_ts"]
|
||||||
|
|
||||||
|
if reach.has_bedload():
|
||||||
|
zfd = data["zfd"]
|
||||||
|
zmin = zfd[id_ts, :]
|
||||||
|
else:
|
||||||
|
zmin = reach.geometry.get_z_min()
|
||||||
|
|
||||||
|
my_dict["bed_elevation"] = zmin
|
||||||
|
|
||||||
|
def _export_rk_compute_discharge(self, data):
|
||||||
|
my_dict = data["my_dict"]
|
||||||
|
envelop = data["envelop"]
|
||||||
|
id_ts = data["id_ts"]
|
||||||
|
q = data["q"]
|
||||||
|
|
||||||
|
my_dict["discharge"] = q[id_ts, :]
|
||||||
|
|
||||||
|
if envelop:
|
||||||
|
my_dict["min_discharge"] = np.min(q, axis=0)
|
||||||
|
my_dict["max_discharge"] = np.max(q, axis=0)
|
||||||
|
|
||||||
|
def _export_rk_compute_water_elevation(self, data):
|
||||||
|
my_dict = data["my_dict"]
|
||||||
|
envelop = data["envelop"]
|
||||||
|
id_ts = data["id_ts"]
|
||||||
|
z = data["z"]
|
||||||
|
|
||||||
|
my_dict["water_elevation"] = z[id_ts, :]
|
||||||
|
|
||||||
|
if envelop:
|
||||||
|
my_dict["min_water_elevation"] = np.min(z, axis=0)
|
||||||
|
my_dict["max_water_elevation"] = np.max(z, axis=0)
|
||||||
|
|
||||||
|
def _export_rk_compute_velocity(self, data):
|
||||||
|
my_dict = data["my_dict"]
|
||||||
|
envelop = data["envelop"]
|
||||||
|
id_ts = data["id_ts"]
|
||||||
|
v = data["v"]
|
||||||
|
|
||||||
|
my_dict["velocity"] = v[id_ts, :]
|
||||||
|
|
||||||
|
if envelop:
|
||||||
|
my_dict["min_velocity"] = np.min(v, axis=0)
|
||||||
|
my_dict["max_velocity"] = np.max(v, axis=0)
|
||||||
|
|
||||||
|
def _export_rk_compute_depth(self, data):
|
||||||
|
my_dict = data["my_dict"]
|
||||||
|
envelop = data["envelop"]
|
||||||
|
reach = data["reach"]
|
||||||
|
id_ts = data["id_ts"]
|
||||||
|
z = data["z"]
|
||||||
|
|
||||||
|
my_dict["depth"] = list(
|
||||||
|
map(
|
||||||
|
lambda p: p.geometry.max_water_depth(
|
||||||
|
z[id_ts, p.global_index]
|
||||||
|
),
|
||||||
|
reach.profiles
|
||||||
)
|
)
|
||||||
if envelop:
|
)
|
||||||
my_dict[dict_y["min_discharge"]] = list(
|
|
||||||
map(
|
if envelop:
|
||||||
lambda p: np.min(q[:, p.global_index]),
|
z_min = reach.geometry.get_z_min()
|
||||||
reach.profiles
|
|
||||||
)
|
my_dict["min_depth"] = np.min(z, axis=0) - z_min
|
||||||
)
|
my_dict["max_depth"] = np.max(z, axis=0) - z_min
|
||||||
my_dict[dict_y["max_discharge"]] = list(
|
|
||||||
map(
|
def _export_rk_compute_mean_depth(self, data):
|
||||||
lambda p: np.max(q[:, p.global_index]),
|
my_dict = data["my_dict"]
|
||||||
reach.profiles
|
reach = data["reach"]
|
||||||
)
|
id_ts = data["id_ts"]
|
||||||
)
|
z = data["z"]
|
||||||
if "water_elevation" in y:
|
|
||||||
my_dict[dict_y["water_elevation"]] = list(
|
my_dict["mean_depth"] = list(
|
||||||
map(
|
map(
|
||||||
lambda p: z[id_ts, p.global_index],
|
lambda p: p.geometry.mean_water_depth(
|
||||||
reach.profiles
|
z[id_ts, p.global_index]
|
||||||
)
|
),
|
||||||
|
reach.profiles
|
||||||
)
|
)
|
||||||
if envelop:
|
)
|
||||||
my_dict[dict_y["min_water_elevation"]] = list(
|
|
||||||
map(
|
|
||||||
lambda p: np.min(z[:, p.global_index]),
|
|
||||||
reach.profiles
|
|
||||||
)
|
|
||||||
)
|
|
||||||
my_dict[dict_y["max_water_elevation"]] = list(
|
|
||||||
map(
|
|
||||||
lambda p: np.max(z[:, p.global_index]),
|
|
||||||
reach.profiles
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if "velocity" in y:
|
def _export_rk_compute_froude(self, data):
|
||||||
my_dict[dict_y["velocity"]] = list(
|
my_dict = data["my_dict"]
|
||||||
map(
|
reach = data["reach"]
|
||||||
lambda p: v[id_ts, p.global_index],
|
id_ts = data["id_ts"]
|
||||||
reach.profiles
|
z = data["z"]
|
||||||
)
|
v = data["v"]
|
||||||
|
|
||||||
|
my_dict["froude"] = list(
|
||||||
|
map(
|
||||||
|
lambda p: p.geometry.froude(
|
||||||
|
v[id_ts, p.global_index],
|
||||||
|
z[id_ts, p.global_index]
|
||||||
|
),
|
||||||
|
reach.profiles
|
||||||
)
|
)
|
||||||
if envelop:
|
)
|
||||||
velocities = list(map(
|
|
||||||
lambda p: v[:, p.global_index],
|
|
||||||
reach.profiles
|
|
||||||
))
|
|
||||||
my_dict[dict_y["min_velocity"]] = [min(v) for v in velocities]
|
|
||||||
my_dict[dict_y["max_velocity"]] = [max(v) for v in velocities]
|
|
||||||
|
|
||||||
if "depth" in y:
|
def _export_rk_compute_wet_area(self, data):
|
||||||
if self._current_results != 2:
|
my_dict = data["my_dict"]
|
||||||
d = my_dict[dict_y["depth"]] = list(
|
reach = data["reach"]
|
||||||
map(
|
id_ts = data["id_ts"]
|
||||||
lambda p: p.geometry.max_water_depth(
|
z = data["z"]
|
||||||
z[id_ts, p.global_index]
|
|
||||||
),
|
|
||||||
reach.profiles
|
|
||||||
)
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
d1 = list(
|
|
||||||
map(
|
|
||||||
lambda p: p.geometry.max_water_depth(
|
|
||||||
z[id_ts, p.global_index]
|
|
||||||
),
|
|
||||||
reach1.profiles
|
|
||||||
)
|
|
||||||
)
|
|
||||||
d2 = list(
|
|
||||||
map(
|
|
||||||
lambda p: p.geometry.max_water_depth(
|
|
||||||
z[id_ts, p.global_index]
|
|
||||||
),
|
|
||||||
reach2.profiles
|
|
||||||
)
|
|
||||||
)
|
|
||||||
d = list(
|
|
||||||
map(
|
|
||||||
lambda x, y: x - y,
|
|
||||||
d1, d2
|
|
||||||
)
|
|
||||||
)
|
|
||||||
my_dict[dict_y["depth"]] = d
|
|
||||||
if envelop:
|
|
||||||
my_dict[dict_y["min_depth"]] = list(map(
|
|
||||||
lambda p1, p2: p1 - p2, map(
|
|
||||||
lambda p: np.min(z[:, p.global_index]),
|
|
||||||
reach.profiles
|
|
||||||
), reach.geometry.get_z_min()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
my_dict[dict_y["max_depth"]] = list(map(
|
|
||||||
lambda p1, p2: p1 - p2, map(
|
|
||||||
lambda p: np.max(z[:, p.global_index]),
|
|
||||||
reach.profiles
|
|
||||||
), reach.geometry.get_z_min()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if "mean_depth" in y:
|
my_dict["wet_area"] = list(
|
||||||
if self._current_results != 2:
|
map(
|
||||||
d = list(
|
lambda p: p.geometry.wet_area(
|
||||||
map(
|
z[id_ts, p.global_index]
|
||||||
lambda p: p.geometry.mean_water_depth(
|
),
|
||||||
z[id_ts, p.global_index]
|
reach.profiles
|
||||||
),
|
)
|
||||||
reach.profiles
|
)
|
||||||
)
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
d1 = list(
|
|
||||||
map(
|
|
||||||
lambda p: p.geometry.mean_water_depth(
|
|
||||||
z[id_ts, p.global_index]
|
|
||||||
),
|
|
||||||
reach1.profiles
|
|
||||||
)
|
|
||||||
)
|
|
||||||
d2 = list(
|
|
||||||
map(
|
|
||||||
lambda p: p.geometry.mean_water_depth(
|
|
||||||
z[id_ts, p.global_index]
|
|
||||||
),
|
|
||||||
reach2.profiles
|
|
||||||
)
|
|
||||||
)
|
|
||||||
d = list(
|
|
||||||
map(
|
|
||||||
lambda x, y: x - y,
|
|
||||||
d1, d2
|
|
||||||
)
|
|
||||||
)
|
|
||||||
my_dict[dict_y["mean_depth"]] = d
|
|
||||||
if "froude" in y:
|
|
||||||
if self._current_results != 2:
|
|
||||||
fr = my_dict[dict_y["froude"]] = list(
|
|
||||||
map(
|
|
||||||
lambda p: (
|
|
||||||
v[id_ts, p.global_index] /
|
|
||||||
sqrt(9.81 * (
|
|
||||||
p.geometry.wet_area(
|
|
||||||
z[id_ts, p.global_index]
|
|
||||||
) /
|
|
||||||
p.geometry.wet_width(
|
|
||||||
z[id_ts, p.global_index]
|
|
||||||
)
|
|
||||||
))
|
|
||||||
),
|
|
||||||
reach.profiles
|
|
||||||
)
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
fr1 = list(
|
|
||||||
map(
|
|
||||||
lambda p: (
|
|
||||||
v[id_ts, p.global_index] /
|
|
||||||
sqrt(9.81 * (
|
|
||||||
p.geometry.wet_area(
|
|
||||||
z[id_ts, p.global_index]
|
|
||||||
) /
|
|
||||||
p.geometry.wet_width(
|
|
||||||
z[id_ts, p.global_index]
|
|
||||||
)
|
|
||||||
))
|
|
||||||
),
|
|
||||||
reach1.profiles
|
|
||||||
)
|
|
||||||
)
|
|
||||||
fr2 = list(
|
|
||||||
map(
|
|
||||||
lambda p: (
|
|
||||||
v[id_ts, p.global_index] /
|
|
||||||
sqrt(9.81 * (
|
|
||||||
p.geometry.wet_area(
|
|
||||||
z[id_ts, p.global_index]
|
|
||||||
) /
|
|
||||||
p.geometry.wet_width(
|
|
||||||
z[id_ts, p.global_index]
|
|
||||||
)
|
|
||||||
))
|
|
||||||
),
|
|
||||||
reach2.profiles
|
|
||||||
)
|
|
||||||
)
|
|
||||||
fr = list(map(
|
|
||||||
lambda x, y: x - y,
|
|
||||||
fr1, fr2
|
|
||||||
))
|
|
||||||
my_dict[dict_y["froude"]] = fr
|
|
||||||
if "wet_area" in y:
|
|
||||||
if self._current_results != 2:
|
|
||||||
wa = list(
|
|
||||||
map(
|
|
||||||
lambda p: p.geometry.wet_area(
|
|
||||||
z[id_ts, p.global_index]
|
|
||||||
),
|
|
||||||
reach.profiles
|
|
||||||
)
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
wa1 = list(
|
|
||||||
map(
|
|
||||||
lambda p: p.geometry.wet_area(
|
|
||||||
z[id_ts, p.global_index]
|
|
||||||
),
|
|
||||||
reach1.profiles
|
|
||||||
)
|
|
||||||
)
|
|
||||||
wa2 = list(
|
|
||||||
map(
|
|
||||||
lambda p: p.geometry.wet_area(
|
|
||||||
z[id_ts, p.global_index]
|
|
||||||
),
|
|
||||||
reach2.profiles
|
|
||||||
)
|
|
||||||
)
|
|
||||||
wa = list(map(
|
|
||||||
lambda x, y: x - y,
|
|
||||||
wa1, wa2
|
|
||||||
))
|
|
||||||
|
|
||||||
my_dict[dict_y["wet_area"]] = wa
|
|
||||||
|
|
||||||
return my_dict
|
|
||||||
|
|
||||||
def _export_time(self, profile, y, solver_id):
|
def _export_time(self, profile, y, solver_id):
|
||||||
results = self._results[solver_id]
|
results = self._results[solver_id]
|
||||||
|
|||||||
Reference in new issue
Block a user