mirror of https://gitlab.com/pamhyr/pamhyr2
Results: CustomPlot: Use np table.
parent
762e4d70a0
commit
3e094af325
|
|
@ -20,6 +20,9 @@ import logging
|
||||||
|
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
from numpy import sqrt
|
from numpy import sqrt
|
||||||
from numpy import asarray
|
from numpy import asarray
|
||||||
|
|
||||||
|
|
@ -119,21 +122,24 @@ class CustomPlot(PamhyrPlot):
|
||||||
else:
|
else:
|
||||||
z_min = reach.geometry.get_z_min()
|
z_min = reach.geometry.get_z_min()
|
||||||
|
|
||||||
|
table = results.get("table")
|
||||||
|
id_ts = results.get_timestamp_id(self._current_timestamp)
|
||||||
|
|
||||||
q = list(
|
q = list(
|
||||||
map(
|
map(
|
||||||
lambda p: p.get_ts_key(self._current_timestamp, "Q"),
|
lambda p: table["Q"][id_ts, p.global_index],
|
||||||
reach.profiles
|
reach.profiles
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
z = list(
|
z = list(
|
||||||
map(
|
map(
|
||||||
lambda p: p.get_ts_key(self._current_timestamp, "Z"),
|
lambda p: table["Z"][id_ts, p.global_index],
|
||||||
reach.profiles
|
reach.profiles
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
v = list(
|
v = list(
|
||||||
map(
|
map(
|
||||||
lambda p: p.get_ts_key(self._current_timestamp, "V"),
|
lambda p: table["V"][id_ts, p.global_index],
|
||||||
reach.profiles
|
reach.profiles
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -150,14 +156,15 @@ class CustomPlot(PamhyrPlot):
|
||||||
|
|
||||||
if len(self.lines) != 0:
|
if len(self.lines) != 0:
|
||||||
self.lines = {}
|
self.lines = {}
|
||||||
if "bed_elevation" in self._y:
|
|
||||||
|
|
||||||
|
if "bed_elevation" in self._y:
|
||||||
ax = self._axes[unit["bed_elevation"]]
|
ax = self._axes[unit["bed_elevation"]]
|
||||||
if self._current_res_id < 2:
|
if self._current_res_id < 2:
|
||||||
if reach.has_bedload():
|
if reach.has_bedload():
|
||||||
dz = self.draw_bottom_with_bedload(reach)
|
dz = self.draw_bottom_with_bedload(reach)
|
||||||
else:
|
else:
|
||||||
dz = z_min
|
dz = z_min
|
||||||
|
|
||||||
line = ax.plot(
|
line = ax.plot(
|
||||||
rk, dz,
|
rk, dz,
|
||||||
color='grey', lw=1.,
|
color='grey', lw=1.,
|
||||||
|
|
@ -199,7 +206,6 @@ class CustomPlot(PamhyrPlot):
|
||||||
if (self._envelop and
|
if (self._envelop and
|
||||||
reach.has_bedload() and
|
reach.has_bedload() and
|
||||||
self._current_res_id < 2):
|
self._current_res_id < 2):
|
||||||
|
|
||||||
ax = self._axes[unit["bed_elevation_envelop"]]
|
ax = self._axes[unit["bed_elevation_envelop"]]
|
||||||
|
|
||||||
e = list(
|
e = list(
|
||||||
|
|
@ -231,7 +237,6 @@ class CustomPlot(PamhyrPlot):
|
||||||
# self.lines["bed_elevation_envelop"] = line2
|
# self.lines["bed_elevation_envelop"] = line2
|
||||||
|
|
||||||
if "water_elevation" in self._y:
|
if "water_elevation" in self._y:
|
||||||
|
|
||||||
ax = self._axes[unit["water_elevation"]]
|
ax = self._axes[unit["water_elevation"]]
|
||||||
line = ax.plot(
|
line = ax.plot(
|
||||||
rk, z, lw=1.,
|
rk, z, lw=1.,
|
||||||
|
|
@ -246,12 +251,11 @@ class CustomPlot(PamhyrPlot):
|
||||||
)
|
)
|
||||||
|
|
||||||
if self._envelop:
|
if self._envelop:
|
||||||
|
|
||||||
ax = self._axes[unit["water_elevation_envelop"]]
|
ax = self._axes[unit["water_elevation_envelop"]]
|
||||||
|
|
||||||
d = list(
|
d = list(
|
||||||
map(
|
map(
|
||||||
lambda p: max(p.get_key("Z")),
|
lambda p: np.max(table["Z"][:, p.global_index]),
|
||||||
reach.profiles
|
reach.profiles
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -265,7 +269,7 @@ class CustomPlot(PamhyrPlot):
|
||||||
|
|
||||||
d = list(
|
d = list(
|
||||||
map(
|
map(
|
||||||
lambda p: min(p.get_key("Z")),
|
lambda p: np.min(table["Z"][:, p.global_index]),
|
||||||
reach.profiles
|
reach.profiles
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -278,7 +282,6 @@ class CustomPlot(PamhyrPlot):
|
||||||
# self.lines["water_elevation_envelop2"] = line2
|
# self.lines["water_elevation_envelop2"] = line2
|
||||||
|
|
||||||
if "discharge" in self._y:
|
if "discharge" in self._y:
|
||||||
|
|
||||||
ax = self._axes[unit["discharge"]]
|
ax = self._axes[unit["discharge"]]
|
||||||
line = ax.plot(
|
line = ax.plot(
|
||||||
rk, q, lw=1.,
|
rk, q, lw=1.,
|
||||||
|
|
@ -287,12 +290,11 @@ class CustomPlot(PamhyrPlot):
|
||||||
self.lines["discharge"] = line
|
self.lines["discharge"] = line
|
||||||
|
|
||||||
if self._envelop:
|
if self._envelop:
|
||||||
|
|
||||||
ax = self._axes[unit["discharge_envelop"]]
|
ax = self._axes[unit["discharge_envelop"]]
|
||||||
|
|
||||||
q1 = list(
|
q1 = list(
|
||||||
map(
|
map(
|
||||||
lambda p: max(p.get_key("Q")),
|
lambda p: np.max(table["Q"][:, p.global_index]),
|
||||||
reach.profiles
|
reach.profiles
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -305,7 +307,7 @@ class CustomPlot(PamhyrPlot):
|
||||||
|
|
||||||
q2 = list(
|
q2 = list(
|
||||||
map(
|
map(
|
||||||
lambda p: min(p.get_key("Q")),
|
lambda p: np.min(table["Q"][:, p.global_index]),
|
||||||
reach.profiles
|
reach.profiles
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -317,7 +319,6 @@ class CustomPlot(PamhyrPlot):
|
||||||
# self.lines["discharge_envelop2"] = line2
|
# self.lines["discharge_envelop2"] = line2
|
||||||
|
|
||||||
if "velocity" in self._y:
|
if "velocity" in self._y:
|
||||||
|
|
||||||
ax = self._axes[unit["velocity"]]
|
ax = self._axes[unit["velocity"]]
|
||||||
|
|
||||||
line = ax.plot(
|
line = ax.plot(
|
||||||
|
|
@ -330,7 +331,7 @@ class CustomPlot(PamhyrPlot):
|
||||||
|
|
||||||
velocities = list(
|
velocities = list(
|
||||||
map(
|
map(
|
||||||
lambda p: p.get_key("V"),
|
lambda p: table["V"][:, p.global_index],
|
||||||
reach.profiles
|
reach.profiles
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -354,13 +355,13 @@ class CustomPlot(PamhyrPlot):
|
||||||
# self.lines["velocity_envelop2"] = line2
|
# self.lines["velocity_envelop2"] = line2
|
||||||
|
|
||||||
if "depth" in self._y:
|
if "depth" in self._y:
|
||||||
|
|
||||||
ax = self._axes[unit["depth"]]
|
ax = self._axes[unit["depth"]]
|
||||||
if self._current_res_id < 2:
|
if self._current_res_id < 2:
|
||||||
d = list(
|
d = list(
|
||||||
map(
|
map(
|
||||||
lambda p: p.geometry.max_water_depth(
|
lambda p: p.geometry.max_water_depth(
|
||||||
p.get_ts_key(self._current_timestamp, "Z")),
|
table["Z"][id_ts, p.global_index]
|
||||||
|
),
|
||||||
reach.profiles
|
reach.profiles
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -368,23 +369,22 @@ class CustomPlot(PamhyrPlot):
|
||||||
d1 = list(
|
d1 = list(
|
||||||
map(
|
map(
|
||||||
lambda p: p.geometry.max_water_depth(
|
lambda p: p.geometry.max_water_depth(
|
||||||
p.get_ts_key(self._current_timestamp, "Z")),
|
table["Z"][id_ts, p.global_index]
|
||||||
|
),
|
||||||
reach1.profiles
|
reach1.profiles
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
d2 = list(
|
d2 = list(
|
||||||
map(
|
map(
|
||||||
lambda p: p.geometry.max_water_depth(
|
lambda p: p.geometry.max_water_depth(
|
||||||
p.get_ts_key(self._current_timestamp, "Z")),
|
table["Z"][id_ts, p.global_index]),
|
||||||
reach2.profiles
|
reach2.profiles
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
d = list(
|
d = list(map(
|
||||||
map(
|
|
||||||
lambda x, y: x - y,
|
lambda x, y: x - y,
|
||||||
d1, d2
|
d1, d2
|
||||||
)
|
))
|
||||||
)
|
|
||||||
|
|
||||||
line = ax.plot(
|
line = ax.plot(
|
||||||
rk, d,
|
rk, d,
|
||||||
|
|
@ -393,7 +393,6 @@ class CustomPlot(PamhyrPlot):
|
||||||
self.lines["depth"] = line
|
self.lines["depth"] = line
|
||||||
|
|
||||||
if self._envelop and self._current_res_id < 2:
|
if self._envelop and self._current_res_id < 2:
|
||||||
|
|
||||||
ax = self._axes[unit["depth_envelop"]]
|
ax = self._axes[unit["depth_envelop"]]
|
||||||
|
|
||||||
d = list(map(
|
d = list(map(
|
||||||
|
|
@ -411,7 +410,7 @@ class CustomPlot(PamhyrPlot):
|
||||||
|
|
||||||
d = list(map(
|
d = list(map(
|
||||||
lambda p1, p2: p1 - p2, map(
|
lambda p1, p2: p1 - p2, map(
|
||||||
lambda p: min(p.get_key("Z")),
|
lambda p: np.min(table["Z"][:, p.global_index]),
|
||||||
reach.profiles
|
reach.profiles
|
||||||
), z_min)
|
), z_min)
|
||||||
)
|
)
|
||||||
|
|
@ -423,13 +422,13 @@ class CustomPlot(PamhyrPlot):
|
||||||
# self.lines["depth_envelop2"] = line2
|
# self.lines["depth_envelop2"] = line2
|
||||||
|
|
||||||
if "mean_depth" in self._y:
|
if "mean_depth" in self._y:
|
||||||
|
|
||||||
ax = self._axes[unit["mean_depth"]]
|
ax = self._axes[unit["mean_depth"]]
|
||||||
if self._current_res_id < 2:
|
if self._current_res_id < 2:
|
||||||
d = list(
|
d = list(
|
||||||
map(
|
map(
|
||||||
lambda p: p.geometry.mean_water_depth(
|
lambda p: p.geometry.mean_water_depth(
|
||||||
p.get_ts_key(self._current_timestamp, "Z")),
|
table["Z"][id_ts, p.global_index]
|
||||||
|
),
|
||||||
reach.profiles
|
reach.profiles
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -437,23 +436,23 @@ class CustomPlot(PamhyrPlot):
|
||||||
d1 = list(
|
d1 = list(
|
||||||
map(
|
map(
|
||||||
lambda p: p.geometry.mean_water_depth(
|
lambda p: p.geometry.mean_water_depth(
|
||||||
p.get_ts_key(self._current_timestamp, "Z")),
|
table["Z"][id_ts, p.global_index]
|
||||||
|
),
|
||||||
reach1.profiles
|
reach1.profiles
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
d2 = list(
|
d2 = list(
|
||||||
map(
|
map(
|
||||||
lambda p: p.geometry.mean_water_depth(
|
lambda p: p.geometry.mean_water_depth(
|
||||||
p.get_ts_key(self._current_timestamp, "Z")),
|
table["Z"][id_ts, p.global_index]
|
||||||
|
),
|
||||||
reach2.profiles
|
reach2.profiles
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
d = list(
|
d = list(map(
|
||||||
map(
|
|
||||||
lambda x, y: x - y,
|
lambda x, y: x - y,
|
||||||
d1, d2
|
d1, d2
|
||||||
)
|
))
|
||||||
)
|
|
||||||
|
|
||||||
line = ax.plot(
|
line = ax.plot(
|
||||||
rk, d,
|
rk, d,
|
||||||
|
|
@ -462,18 +461,20 @@ class CustomPlot(PamhyrPlot):
|
||||||
self.lines["mean_depth"] = line
|
self.lines["mean_depth"] = line
|
||||||
|
|
||||||
if "froude" in self._y:
|
if "froude" in self._y:
|
||||||
|
|
||||||
ax = self._axes[unit["froude"]]
|
ax = self._axes[unit["froude"]]
|
||||||
|
|
||||||
if self._current_res_id < 2:
|
if self._current_res_id < 2:
|
||||||
fr = list(
|
fr = list(
|
||||||
map(
|
map(
|
||||||
lambda p:
|
lambda p:
|
||||||
p.get_ts_key(self._current_timestamp, "V") /
|
table["V"][id_ts, p.global_index] /
|
||||||
sqrt(9.81 * (
|
sqrt(9.81 * (
|
||||||
p.geometry.wet_area(p.get_ts_key(
|
p.geometry.wet_area(
|
||||||
self._current_timestamp, "Z")) /
|
table["Z"][id_ts, p.global_index]
|
||||||
p.geometry.wet_width(p.get_ts_key(
|
) /
|
||||||
self._current_timestamp, "Z"))
|
p.geometry.wet_width(
|
||||||
|
table["Z"][id_ts, p.global_index]
|
||||||
|
)
|
||||||
)),
|
)),
|
||||||
reach.profiles
|
reach.profiles
|
||||||
)
|
)
|
||||||
|
|
@ -482,12 +483,14 @@ class CustomPlot(PamhyrPlot):
|
||||||
fr1 = list(
|
fr1 = list(
|
||||||
map(
|
map(
|
||||||
lambda p:
|
lambda p:
|
||||||
p.get_ts_key(self._current_timestamp, "V") /
|
table["V"][id_ts, p.global_index] /
|
||||||
sqrt(9.81 * (
|
sqrt(9.81 * (
|
||||||
p.geometry.wet_area(p.get_ts_key(
|
p.geometry.wet_area(
|
||||||
self._current_timestamp, "Z")) /
|
table["Z"][id_ts, p.global_index]
|
||||||
p.geometry.wet_width(p.get_ts_key(
|
) /
|
||||||
self._current_timestamp, "Z"))
|
p.geometry.wet_width(
|
||||||
|
table["Z"][id_ts, p.global_index]
|
||||||
|
)
|
||||||
)),
|
)),
|
||||||
reach1.profiles
|
reach1.profiles
|
||||||
)
|
)
|
||||||
|
|
@ -495,12 +498,14 @@ class CustomPlot(PamhyrPlot):
|
||||||
fr2 = list(
|
fr2 = list(
|
||||||
map(
|
map(
|
||||||
lambda p:
|
lambda p:
|
||||||
p.get_ts_key(self._current_timestamp, "V") /
|
table["V"][id_ts, p.global_index] /
|
||||||
sqrt(9.81 * (
|
sqrt(9.81 * (
|
||||||
p.geometry.wet_area(p.get_ts_key(
|
p.geometry.wet_area(
|
||||||
self._current_timestamp, "Z")) /
|
table["Z"][id_ts, p.global_index]
|
||||||
p.geometry.wet_width(p.get_ts_key(
|
) /
|
||||||
self._current_timestamp, "Z"))
|
p.geometry.wet_width(
|
||||||
|
table["Z"][id_ts, p.global_index]
|
||||||
|
)
|
||||||
)),
|
)),
|
||||||
reach2.profiles
|
reach2.profiles
|
||||||
)
|
)
|
||||||
|
|
@ -524,7 +529,8 @@ class CustomPlot(PamhyrPlot):
|
||||||
d = list(
|
d = list(
|
||||||
map(
|
map(
|
||||||
lambda p: p.geometry.wet_area(
|
lambda p: p.geometry.wet_area(
|
||||||
p.get_ts_key(self._current_timestamp, "Z")),
|
table["Z"][id_ts, p.global_index]
|
||||||
|
),
|
||||||
reach.profiles
|
reach.profiles
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -532,14 +538,16 @@ class CustomPlot(PamhyrPlot):
|
||||||
d1 = list(
|
d1 = list(
|
||||||
map(
|
map(
|
||||||
lambda p: p.geometry.wet_area(
|
lambda p: p.geometry.wet_area(
|
||||||
p.get_ts_key(self._current_timestamp, "Z")),
|
table["Z"][id_ts, p.global_index]
|
||||||
|
),
|
||||||
reach1.profiles
|
reach1.profiles
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
d2 = list(
|
d2 = list(
|
||||||
map(
|
map(
|
||||||
lambda p: p.geometry.wet_area(
|
lambda p: p.geometry.wet_area(
|
||||||
p.get_ts_key(self._current_timestamp, "Z")),
|
table["Z"][id_ts, p.global_index]
|
||||||
|
),
|
||||||
reach2.profiles
|
reach2.profiles
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue