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