mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Compare commits
2
Commits
97867080d9
...
f93e6a7d7c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f93e6a7d7c | ||
|
|
5d46401b85 |
No files matched your search
@@ -826,6 +826,13 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
|
||||
return n_zones
|
||||
|
||||
def froude(self, z, v):
|
||||
return v / np.sqrt(
|
||||
9.81 * (
|
||||
self.wet_area(z) / self.wet_width(z)
|
||||
)
|
||||
)
|
||||
|
||||
@timer
|
||||
def get_all_water_limits_ac(self, z):
|
||||
"""
|
||||
|
||||
+245
-366
@@ -876,266 +876,174 @@ class ResultsWindow(PamhyrWindow):
|
||||
dict_x = self._trad.get_dict("values_x")
|
||||
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:
|
||||
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")
|
||||
id_ts = results.get_timestamp_id(timestamp)
|
||||
|
||||
z = table["Z"]
|
||||
q = table["Q"]
|
||||
v = table["V"]
|
||||
zfd = table["zfd"]
|
||||
ind = reach.global_index
|
||||
|
||||
if "bed_elevation" in y:
|
||||
if reach.has_bedload():
|
||||
zmin = list(map(
|
||||
lambda p: zfd[id_ts, p.global_index],
|
||||
reach.profiles
|
||||
))
|
||||
else:
|
||||
zmin = reach.geometry.get_z_min()
|
||||
my_dict[dict_y["bed_elevation"]] = zmin
|
||||
# if envelop and reach.has_sediment():
|
||||
if "discharge" in y:
|
||||
my_dict[dict_y["discharge"]] = list(
|
||||
map(
|
||||
lambda p: q[id_ts, p.global_index],
|
||||
reach.profiles
|
||||
)
|
||||
my_dict = {}
|
||||
data = {
|
||||
"z": table["Z"][:, ind[0]:ind[1]+1],
|
||||
"q": table["Q"][:, ind[0]:ind[1]+1],
|
||||
"v": table["V"][:, ind[0]:ind[1]+1],
|
||||
"zfd": table["zfd"][:, ind[0]:ind[1]+1],
|
||||
|
||||
"reach": reach,
|
||||
"id_ts": id_ts, "envelop": envelop,
|
||||
"my_dict": my_dict,
|
||||
}
|
||||
|
||||
func = {
|
||||
"bed_elevation": self._export_rk_compute_elevation,
|
||||
"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(
|
||||
lambda p: np.min(q[:, p.global_index]),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
my_dict[dict_y["max_discharge"]] = list(
|
||||
map(
|
||||
lambda p: np.max(q[:, p.global_index]),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
if "water_elevation" in y:
|
||||
my_dict[dict_y["water_elevation"]] = list(
|
||||
map(
|
||||
lambda p: z[id_ts, p.global_index],
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
|
||||
if envelop:
|
||||
z_min = reach.geometry.get_z_min()
|
||||
|
||||
my_dict["min_depth"] = np.min(z, axis=0) - z_min
|
||||
my_dict["max_depth"] = np.max(z, axis=0) - z_min
|
||||
|
||||
def _export_rk_compute_mean_depth(self, data):
|
||||
my_dict = data["my_dict"]
|
||||
reach = data["reach"]
|
||||
id_ts = data["id_ts"]
|
||||
|
||||
z = data["z"]
|
||||
|
||||
my_dict["mean_depth"] = list(
|
||||
map(
|
||||
lambda p: p.geometry.mean_water_depth(
|
||||
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:
|
||||
my_dict[dict_y["velocity"]] = list(
|
||||
map(
|
||||
lambda p: v[id_ts, p.global_index],
|
||||
reach.profiles
|
||||
)
|
||||
def _export_rk_compute_froude(self, data):
|
||||
my_dict = data["my_dict"]
|
||||
reach = data["reach"]
|
||||
id_ts = data["id_ts"]
|
||||
|
||||
z = data["z"]
|
||||
v = data["v"]
|
||||
|
||||
my_dict["froude"] = list(
|
||||
map(
|
||||
lambda p: p.geometry.froude(
|
||||
z[id_ts, p.global_index],
|
||||
v[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:
|
||||
if self._current_results != 2:
|
||||
d = my_dict[dict_y["depth"]] = list(
|
||||
map(
|
||||
lambda p: p.geometry.max_water_depth(
|
||||
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()
|
||||
)
|
||||
)
|
||||
def _export_rk_compute_wet_area(self, data):
|
||||
my_dict = data["my_dict"]
|
||||
reach = data["reach"]
|
||||
id_ts = data["id_ts"]
|
||||
|
||||
if "mean_depth" in y:
|
||||
if self._current_results != 2:
|
||||
d = list(
|
||||
map(
|
||||
lambda p: p.geometry.mean_water_depth(
|
||||
z[id_ts, p.global_index]
|
||||
),
|
||||
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
|
||||
))
|
||||
z = data["z"]
|
||||
|
||||
my_dict[dict_y["wet_area"]] = wa
|
||||
|
||||
return my_dict
|
||||
my_dict["wet_area"] = list(
|
||||
map(
|
||||
lambda p: p.geometry.wet_area(
|
||||
z[id_ts, p.global_index]
|
||||
),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
|
||||
def _export_time(self, profile, y, solver_id):
|
||||
results = self._results[solver_id]
|
||||
@@ -1144,134 +1052,105 @@ class ResultsWindow(PamhyrWindow):
|
||||
dict_x = self._trad.get_dict("values_x")
|
||||
dict_y = self._trad.get_dict("values_y")
|
||||
|
||||
my_dict = {}
|
||||
my_dict[dict_x["time"]] = self._timestamps
|
||||
|
||||
table = results.get("table")
|
||||
ind = profile.global_index
|
||||
|
||||
z = table["Z"][:, profile.global_index]
|
||||
q = table["Q"][:, profile.global_index]
|
||||
v = table["V"][:, profile.global_index]
|
||||
zfd = table["zfd"][:, profile.global_index]
|
||||
my_dict = {}
|
||||
data = {
|
||||
"z": table["Z"][:, ind],
|
||||
"q": table["Q"][:, ind],
|
||||
"v": table["V"][:, ind],
|
||||
"zfd": table["zfd"][:, ind],
|
||||
|
||||
if self._current_results == 2:
|
||||
reach1 = self._results[0].river.reach(self._reach)
|
||||
reach2 = self._results[1].river.reach(self._reach)
|
||||
reach3 = self._results[2].river.reach(self._reach)
|
||||
profile1 = reach1.profile(self._profile)
|
||||
profile2 = reach2.profile(self._profile)
|
||||
# profile3 = reach3.profile(self._profile)
|
||||
"reach": reach,
|
||||
"profile": profile,
|
||||
"my_dict": my_dict,
|
||||
}
|
||||
|
||||
z1 = table["Z"][:, profile1.global_index]
|
||||
q1 = table["Q"][:, profile1.global_index]
|
||||
v1 = table["V"][:, profile1.global_index]
|
||||
def set_dict(k, v):
|
||||
my_dict[k] = v
|
||||
|
||||
z2 = table["Z"][:, profile2.global_index]
|
||||
q2 = table["Q"][:, profile2.global_index]
|
||||
v2 = table["V"][:, profile2.global_index]
|
||||
func = {
|
||||
"bed_elevation": self._export_time_compute_elevation,
|
||||
"discharge": lambda d: set_dict("discharge", d["q"]),
|
||||
"water_elevation": lambda d: set_dict("water_elevation", d["z"]),
|
||||
"velocity": lambda d: set_dict("velocity", d["v"]),
|
||||
"depth": self._export_time_compute_depth,
|
||||
"mean_depth": self._export_time_compute_mean_depth,
|
||||
"froude": self._export_time_compute_froude,
|
||||
"wet_area": self._export_time_compute_wet_area,
|
||||
}
|
||||
|
||||
if "bed_elevation" in y:
|
||||
if reach.has_bedload():
|
||||
z_min = zfd
|
||||
else:
|
||||
z_min = [profile.geometry.z_min()] * len(self._timestamps)
|
||||
# Compute values
|
||||
for key in y:
|
||||
func[key](data)
|
||||
|
||||
my_dict[dict_y["bed_elevation"]] = z_min
|
||||
if "discharge" in y:
|
||||
my_dict[dict_y["discharge"]] = q
|
||||
if "water_elevation" in y:
|
||||
my_dict[dict_y["water_elevation"]] = z
|
||||
if "velocity" in y:
|
||||
my_dict[dict_y["velocity"]] = v
|
||||
if "depth" in y:
|
||||
if self._current_results != 2:
|
||||
d = list(
|
||||
map(lambda x: profile.geometry.max_water_depth(x), z)
|
||||
)
|
||||
else:
|
||||
d1 = list(
|
||||
map(lambda x: profile1.geometry.max_water_depth(x), z1)
|
||||
)
|
||||
d2 = list(
|
||||
map(lambda x: profile2.geometry.max_water_depth(x), z2)
|
||||
)
|
||||
d = list(
|
||||
map(
|
||||
lambda x, y: x - y,
|
||||
d1, d2
|
||||
)
|
||||
)
|
||||
my_dict[dict_y["depth"]] = d
|
||||
if "mean_depth" in y:
|
||||
if self._current_results != 2:
|
||||
d = list(
|
||||
map(lambda x: profile.geometry.mean_water_depth(x), z)
|
||||
)
|
||||
else:
|
||||
d1 = list(
|
||||
map(lambda x: profile1.geometry.mean_water_depth(x), z1)
|
||||
)
|
||||
d2 = list(
|
||||
map(lambda x: profile2.geometry.mean_water_depth(x), z2)
|
||||
)
|
||||
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 z, v:
|
||||
v / sqrt(9.81 * (
|
||||
profile.geometry.wet_area(z) /
|
||||
profile.geometry.wet_width(z))
|
||||
),
|
||||
z, v)
|
||||
)
|
||||
else:
|
||||
fr1 = list(
|
||||
map(lambda z, v:
|
||||
v /
|
||||
sqrt(9.81 * (
|
||||
profile1.geometry.wet_area(z) /
|
||||
profile1.geometry.wet_width(z))
|
||||
),
|
||||
z1, v1)
|
||||
)
|
||||
fr2 = list(
|
||||
map(lambda z, v:
|
||||
v /
|
||||
sqrt(9.81 * (
|
||||
profile2.geometry.wet_area(z) /
|
||||
profile2.geometry.wet_width(z))
|
||||
),
|
||||
z2, v2)
|
||||
)
|
||||
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 x: profile.geometry.wet_area(x), z)
|
||||
)
|
||||
else:
|
||||
wa1 = list(
|
||||
map(lambda x: profile1.geometry.wet_area(x), z1)
|
||||
)
|
||||
wa2 = list(
|
||||
map(lambda x: profile2.geometry.wet_area(x), z2)
|
||||
)
|
||||
wa = list(map(
|
||||
lambda x, y: x - y,
|
||||
wa1, wa2
|
||||
))
|
||||
my_dict[dict_y["wet_area"]] = wa
|
||||
# Translate dictionary keys
|
||||
translated_dict = {}
|
||||
for key in my_dict:
|
||||
translated_dict[dict_y[key]] = my_dict[key]
|
||||
|
||||
return my_dict
|
||||
translated_dict[dict_x["time"]] = self._timestamps
|
||||
|
||||
return translated_dict
|
||||
|
||||
def _export_time_compute_elevation(self, data):
|
||||
my_dict = data["my_dict"]
|
||||
reach = data["reach"]
|
||||
|
||||
if reach.has_bedload():
|
||||
z_min = data["zfd"]
|
||||
else:
|
||||
z_min = [profile.geometry.z_min()] * len(self._timestamps)
|
||||
|
||||
my_dict["bed_elevation"] = z_min
|
||||
|
||||
def _export_time_compute_depth(self, data):
|
||||
my_dict = data["my_dict"]
|
||||
profile = data["profile"]
|
||||
|
||||
z = data["z"]
|
||||
|
||||
my_dict["depth"] = list(
|
||||
map(lambda x: profile.geometry.max_water_depth(x), z)
|
||||
)
|
||||
|
||||
def _export_time_compute_mean_depth(self, data):
|
||||
my_dict = data["my_dict"]
|
||||
profile = data["profile"]
|
||||
|
||||
z = data["z"]
|
||||
|
||||
my_dict["mean_depth"] = list(
|
||||
map(lambda x: profile.geometry.mean_water_depth(x), z)
|
||||
)
|
||||
|
||||
def _export_time_compute_froude(self, data):
|
||||
my_dict = data["my_dict"]
|
||||
profile = data["profile"]
|
||||
|
||||
z = data["z"]
|
||||
v = data["v"]
|
||||
|
||||
my_dict["froude"] = list(
|
||||
map(
|
||||
lambda z, v: profile.geometry.froude(z, v),
|
||||
z, v
|
||||
)
|
||||
)
|
||||
|
||||
def _export_time_compute_wet_area(self, data):
|
||||
my_dict = data["my_dict"]
|
||||
profile = data["profile"]
|
||||
|
||||
z = data["z"]
|
||||
|
||||
my_dict["wet_area"] = list(
|
||||
map(
|
||||
lambda x: profile.geometry.wet_area(x),
|
||||
z
|
||||
)
|
||||
)
|
||||
|
||||
def get_timestamps(self):
|
||||
self._timestamps = sorted(list(self._results[0].get("timestamps")))
|
||||
|
||||
Reference in new issue
Block a user