mirror of https://gitlab.com/pamhyr/pamhyr2
Disable profiles: results only take into account enabled profiles to display results for Mage
parent
824fbe506e
commit
f08d4b1a37
|
|
@ -375,6 +375,28 @@ class Reach(SQLSubModel):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def get_z_min_enabled_profiles(self):
|
||||||
|
return list(
|
||||||
|
map(
|
||||||
|
lambda profile: profile.z_min(),
|
||||||
|
filter(
|
||||||
|
lambda profile: len(profile) > 0 and profile.is_enabled,
|
||||||
|
self.profiles
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_z_max_enabled_profiles(self):
|
||||||
|
return list(
|
||||||
|
map(
|
||||||
|
lambda profile: profile.z_max(),
|
||||||
|
filter(
|
||||||
|
lambda profile: len(profile) > 0 and profile.is_enabled,
|
||||||
|
self.profiles
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def get_rk(self):
|
def get_rk(self):
|
||||||
"""List of profiles rk
|
"""List of profiles rk
|
||||||
|
|
||||||
|
|
@ -383,6 +405,17 @@ class Reach(SQLSubModel):
|
||||||
"""
|
"""
|
||||||
return [profile.rk for profile in self.profiles]
|
return [profile.rk for profile in self.profiles]
|
||||||
|
|
||||||
|
def get_rk_enabled_profiles(self):
|
||||||
|
return list(
|
||||||
|
map(
|
||||||
|
lambda profile: profile.rk,
|
||||||
|
filter(
|
||||||
|
lambda profile: len(profile) > 0 and profile.is_enabled,
|
||||||
|
self.profiles
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def get_rk_complete_profiles(self):
|
def get_rk_complete_profiles(self):
|
||||||
return list(
|
return list(
|
||||||
map(
|
map(
|
||||||
|
|
|
||||||
|
|
@ -527,7 +527,7 @@ class Results(SQLSubModel):
|
||||||
i = 0
|
i = 0
|
||||||
for reach in new_results._river.reachs:
|
for reach in new_results._river.reachs:
|
||||||
nb = len(reach.profiles)
|
nb = len(reach.profiles)
|
||||||
reach.set_global_index(range(i, i + nb + 1))
|
reach.set_global_index(range(i, i + nb))
|
||||||
i += nb
|
i += nb
|
||||||
|
|
||||||
if "Z" in table_data:
|
if "Z" in table_data:
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,7 @@ class Profile(SQLSubModel):
|
||||||
"len_data, data, scenario " +
|
"len_data, data, scenario " +
|
||||||
"FROM results_data " +
|
"FROM results_data " +
|
||||||
f"WHERE scenario = {scenario.id} " +
|
f"WHERE scenario = {scenario.id} " +
|
||||||
|
f"AND result = {data['result_pid']} " +
|
||||||
f"AND reach = {reach.pamhyr_id} " +
|
f"AND reach = {reach.pamhyr_id} " +
|
||||||
f"AND section = {profile.pamhyr_id}"
|
f"AND section = {profile.pamhyr_id}"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,8 @@ class PlotRKC(PamhyrPlot):
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = False
|
self._autoscale_update = False
|
||||||
|
|
||||||
|
self.profile = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def results(self):
|
def results(self):
|
||||||
return self.data
|
return self.data
|
||||||
|
|
@ -71,9 +73,19 @@ class PlotRKC(PamhyrPlot):
|
||||||
self.data = results
|
self.data = results
|
||||||
self._current_timestamp = max(self._timestamps)
|
self._current_timestamp = max(self._timestamps)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def reach_geometry(reach):
|
||||||
|
"""Return geometry values for profiles present in the results."""
|
||||||
|
return (
|
||||||
|
reach.geometry.get_rk_enabled_profiles(),
|
||||||
|
reach.geometry.get_z_min_enabled_profiles(),
|
||||||
|
reach.geometry.get_z_max_enabled_profiles()
|
||||||
|
)
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def draw(self, highlight=None):
|
def draw(self, highlight=None):
|
||||||
self.init_axes()
|
self.init_axes()
|
||||||
|
self.profile = None
|
||||||
|
|
||||||
if self.results is None:
|
if self.results is None:
|
||||||
return
|
return
|
||||||
|
|
@ -104,7 +116,7 @@ class PlotRKC(PamhyrPlot):
|
||||||
|
|
||||||
def draw_bottom_with_bedload(self, reach):
|
def draw_bottom_with_bedload(self, reach):
|
||||||
results = self.results[self._current_res_id]
|
results = self.results[self._current_res_id]
|
||||||
rk = reach.geometry.get_rk()
|
rk, _, _ = self.reach_geometry(reach)
|
||||||
|
|
||||||
table = results.get("table")["zfd"]
|
table = results.get("table")["zfd"]
|
||||||
ts = results.get_timestamp_id(self._current_timestamp)
|
ts = results.get_timestamp_id(self._current_timestamp)
|
||||||
|
|
@ -136,8 +148,7 @@ class PlotRKC(PamhyrPlot):
|
||||||
|
|
||||||
for hs in lhs:
|
for hs in lhs:
|
||||||
x = hs.input_section.rk
|
x = hs.input_section.rk
|
||||||
z_min = reach.geometry.get_z_min()
|
_, z_min, z_max = self.reach_geometry(reach)
|
||||||
z_max = reach.geometry.get_z_max()
|
|
||||||
|
|
||||||
self.canvas.axes.plot(
|
self.canvas.axes.plot(
|
||||||
[x, x],
|
[x, x],
|
||||||
|
|
@ -157,9 +168,7 @@ class PlotRKC(PamhyrPlot):
|
||||||
)
|
)
|
||||||
|
|
||||||
def draw_bottom_geometry(self, reach):
|
def draw_bottom_geometry(self, reach):
|
||||||
rk = reach.geometry.get_rk()
|
rk, z_min, _ = self.reach_geometry(reach)
|
||||||
z_min = reach.geometry.get_z_min()
|
|
||||||
z_max = reach.geometry.get_z_max()
|
|
||||||
|
|
||||||
self.line_rk_zmin = self.canvas.axes.plot(
|
self.line_rk_zmin = self.canvas.axes.plot(
|
||||||
rk, z_min,
|
rk, z_min,
|
||||||
|
|
@ -170,10 +179,9 @@ class PlotRKC(PamhyrPlot):
|
||||||
self._river_bottom = z_min
|
self._river_bottom = z_min
|
||||||
|
|
||||||
def draw_water_elevation(self, reach):
|
def draw_water_elevation(self, reach):
|
||||||
if len(reach.geometry.profiles) != 0:
|
if len(reach.profiles) != 0:
|
||||||
result = self.results[self._current_res_id]
|
result = self.results[self._current_res_id]
|
||||||
rk = reach.geometry.get_rk()
|
rk, _, _ = self.reach_geometry(reach)
|
||||||
z_min = reach.geometry.get_z_min()
|
|
||||||
|
|
||||||
table = result.get("table")["Z"]
|
table = result.get("table")["Z"]
|
||||||
ts = result.get_timestamp_id(self._current_timestamp)
|
ts = result.get_timestamp_id(self._current_timestamp)
|
||||||
|
|
@ -201,10 +209,9 @@ class PlotRKC(PamhyrPlot):
|
||||||
)
|
)
|
||||||
|
|
||||||
def draw_water_elevation_max(self, reach):
|
def draw_water_elevation_max(self, reach):
|
||||||
if len(reach.geometry.profiles) != 0:
|
if len(reach.profiles) != 0:
|
||||||
result = self.results[self._current_res_id]
|
result = self.results[self._current_res_id]
|
||||||
rk = reach.geometry.get_rk()
|
rk, _, _ = self.reach_geometry(reach)
|
||||||
z_min = reach.geometry.get_z_min()
|
|
||||||
|
|
||||||
table = result.get("table")["Z"]
|
table = result.get("table")["Z"]
|
||||||
ts = result.get_timestamp_id(self._current_timestamp)
|
ts = result.get_timestamp_id(self._current_timestamp)
|
||||||
|
|
@ -250,9 +257,7 @@ class PlotRKC(PamhyrPlot):
|
||||||
self.canvas.draw_idle()
|
self.canvas.draw_idle()
|
||||||
|
|
||||||
def draw_current(self, reach):
|
def draw_current(self, reach):
|
||||||
rk = reach.geometry.get_rk()
|
rk, z_min, z_max = self.reach_geometry(reach)
|
||||||
z_min = reach.geometry.get_z_min()
|
|
||||||
z_max = reach.geometry.get_z_max()
|
|
||||||
|
|
||||||
self.profile, = self.canvas.axes.plot(
|
self.profile, = self.canvas.axes.plot(
|
||||||
[
|
[
|
||||||
|
|
@ -349,8 +354,7 @@ class PlotRKC(PamhyrPlot):
|
||||||
def update_water_elevation(self):
|
def update_water_elevation(self):
|
||||||
result = self.results[self._current_res_id]
|
result = self.results[self._current_res_id]
|
||||||
reach = result.river.reach(self._current_reach_id)
|
reach = result.river.reach(self._current_reach_id)
|
||||||
rk = reach.geometry.get_rk()
|
rk, _, _ = self.reach_geometry(reach)
|
||||||
z_min = reach.geometry.get_z_min()
|
|
||||||
table = result.get("table")["Z"]
|
table = result.get("table")["Z"]
|
||||||
ts = result.get_timestamp_id(self._current_timestamp)
|
ts = result.get_timestamp_id(self._current_timestamp)
|
||||||
|
|
||||||
|
|
@ -380,11 +384,13 @@ class PlotRKC(PamhyrPlot):
|
||||||
self.update_idle()
|
self.update_idle()
|
||||||
|
|
||||||
def update_current(self):
|
def update_current(self):
|
||||||
|
if not self._init or self.profile is None:
|
||||||
|
self.draw()
|
||||||
|
return
|
||||||
|
|
||||||
results = self.results[self._current_res_id]
|
results = self.results[self._current_res_id]
|
||||||
reach = results.river.reach(self._current_reach_id)
|
reach = results.river.reach(self._current_reach_id)
|
||||||
rk = reach.geometry.get_rk()
|
rk, z_min, z_max = self.reach_geometry(reach)
|
||||||
z_min = reach.geometry.get_z_min()
|
|
||||||
z_max = reach.geometry.get_z_max()
|
|
||||||
cid = self._current_profile_id
|
cid = self._current_profile_id
|
||||||
|
|
||||||
self.profile.set_data(
|
self.profile.set_data(
|
||||||
|
|
@ -396,7 +402,7 @@ class PlotRKC(PamhyrPlot):
|
||||||
def update_bottom_with_bedload(self):
|
def update_bottom_with_bedload(self):
|
||||||
results = self.results[self._current_res_id]
|
results = self.results[self._current_res_id]
|
||||||
reach = results.river.reach(self._current_reach_id)
|
reach = results.river.reach(self._current_reach_id)
|
||||||
rk = reach.geometry.get_rk()
|
rk, _, _ = self.reach_geometry(reach)
|
||||||
# z = self.sl_compute_current_z(reach)
|
# z = self.sl_compute_current_z(reach)
|
||||||
|
|
||||||
table = results.get("table")["zfd"]
|
table = results.get("table")["zfd"]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue