Profiles: disabled profiles now affects results for mage, AdisTS and AdisTT

mesh_tab
Dylan Jeannin 2026-08-21 17:30:38 +02:00
parent deb84ca331
commit 824fbe506e
7 changed files with 75 additions and 32 deletions

View File

@ -229,7 +229,11 @@ for each reach"
gls = [] gls = []
for edge in edges: for edge in edges:
comp, incomp = edge.reach.compute_guidelines() profiles = edge.reach.enabled_profiles
comp, incomp = edge.reach.compute_guidelines(
profiles=profiles,
update_cache=False
)
if len(incomp) != 0: if len(incomp) != 0:
self._status = STATUS.WARNING self._status = STATUS.WARNING
self._summary = "incomplete_guideline" self._summary = "incomplete_guideline"
@ -237,7 +241,6 @@ for each reach"
gls.append(comp) gls.append(comp)
profiles = edge.reach.profiles
for profile in profiles: for profile in profiles:
if not profile.has_standard_named_points(): if not profile.has_standard_named_points():
self._status = STATUS.WARNING self._status = STATUS.WARNING

View File

@ -87,7 +87,7 @@ class StudyGeometryChecker(AbstractModelChecker):
return False return False
for edge in edges: for edge in edges:
if len(edge.reach.profiles) < 2: if len(edge.reach.enabled_profiles) < 2:
summary = "no_geometry_defined" summary = "no_geometry_defined"
status = STATUS.ERROR status = STATUS.ERROR
ok = False ok = False
@ -132,8 +132,12 @@ class StudyInitialConditionsChecker(AbstractModelChecker):
return ok return ok
ic = river.initial_conditions[reach] ic = river.initial_conditions[reach]
len_ic = len(ic) enabled_profiles = set(reach.enabled_profiles)
len_reach = len(reach) len_ic = sum(
data["section"] in enabled_profiles
for data in ic.data
)
len_reach = len(enabled_profiles)
if len_ic < len_reach: if len_ic < len_reach:
self._summary = "initial_condition_missing_profile" self._summary = "initial_condition_missing_profile"

View File

@ -494,14 +494,22 @@ class Reach(SQLSubModel):
) )
@timer @timer
def compute_guidelines(self): def compute_guidelines(self, profiles=None, update_cache=True):
"""Compute reach guidelines """Compute reach guidelines
Args:
profiles: Profiles used to compute the guidelines. If omitted,
all non-deleted profiles of the reach are used.
update_cache: Whether to update the reach guidelines cache.
Returns: Returns:
Tuple of complete and incomplete guidelines name. Tuple of complete and incomplete guidelines name.
""" """
if profiles is None:
profiles = self.profiles
# Get all point contained into a guideline # Get all point contained into a guideline
named_points = [profile.named_points() for profile in self.profiles] named_points = [profile.named_points() for profile in profiles]
points_name = list( points_name = list(
map( map(
lambda lst: list(map(lambda p: p.name, lst)), lambda lst: list(map(lambda p: p.name, lst)),
@ -532,11 +540,13 @@ class Reach(SQLSubModel):
complete = guide_set - incomplete complete = guide_set - incomplete
if update_cache:
# Compute guideline and put data in cache # Compute guideline and put data in cache
self._compute_guidelines_cache(guide_set, named_points, self._compute_guidelines_cache(
complete, incomplete) guide_set, named_points, complete, incomplete
)
self.modified() self.modified()
return (complete, incomplete) return (complete, incomplete)
def _map_guidelines_points(self, func, full=False): def _map_guidelines_points(self, func, full=False):

View File

@ -276,7 +276,7 @@ class Profile(SQLSubModel):
class Reach(SQLSubModel): class Reach(SQLSubModel):
_sub_classes = [Profile] _sub_classes = [Profile]
def __init__(self, reach, study, parent, with_init=True): def __init__(self, reach, study, parent, with_init=True, profiles=None):
super(Reach, self).__init__( super(Reach, self).__init__(
id=-1, status=study.status, id=-1, status=study.status,
owner_scenario=study.status.scenario.id owner_scenario=study.status.scenario.id
@ -287,10 +287,12 @@ class Reach(SQLSubModel):
self._reach = reach # Source reach in the study self._reach = reach # Source reach in the study
self._profiles = [] self._profiles = []
if with_init: if with_init:
if profiles is None:
profiles = reach.profiles
self._profiles = list( self._profiles = list(
map( map(
lambda p: Profile(p, self._study, self._parent), lambda p: Profile(p, self._study, self._parent),
reach.profiles profiles
) )
) )
@ -379,7 +381,14 @@ class Reach(SQLSubModel):
for i, profile in enumerate(reach.profiles): for i, profile in enumerate(reach.profiles):
data["profile"] = profile data["profile"] = profile
new_reach._profiles += [Profile._db_load(execute, data)] result_profile = Profile._db_load(execute, data)
if len(result_profile) > 0:
new_reach._profiles.append(result_profile)
new_reach._profile_mask = [
profile.name[0:8] != 'interpol'
for profile in new_reach._profiles
]
return new_reach return new_reach
@ -418,10 +427,13 @@ class River(SQLSubModel):
def has_reach(self, id): def has_reach(self, id):
return 0 <= id < len(self._reachs) return 0 <= id < len(self._reachs)
def add(self, reach_id): def add(self, reach_id, profiles=None):
reachs = self._study.river.enable_edges() reachs = self._study.river.enable_edges()
new = Reach(reachs[reach_id].reach, self._study, self._parent) new = Reach(
reachs[reach_id].reach, self._study, self._parent,
profiles=profiles
)
self._reachs.append(new) self._reachs.append(new)
return new return new
@ -460,9 +472,9 @@ class River(SQLSubModel):
for reach in study.river.reachs(): for reach in study.river.reachs():
data["reach"] = reach.reach data["reach"] = reach.reach
new_river._reachs.append( result_reach = Reach._db_load(execute, data)
Reach._db_load(execute, data) if len(result_reach) > 0:
) new_river._reachs.append(result_reach)
return new_river return new_river

View File

@ -180,7 +180,7 @@ class AdisTS(CommandLineSolver):
files.append(str(os.path.join("net", f"{name}.ST"))) files.append(str(os.path.join("net", f"{name}.ST")))
cnt_num = 1 cnt_num = 1
for profile in edge.reach.profiles: for profile in edge.reach.enabled_profiles:
self._export_ST_profile_header( self._export_ST_profile_header(
f, files, profile, cnt_num f, files, profile, cnt_num
) )
@ -335,7 +335,7 @@ class AdisTS(CommandLineSolver):
return coeff.minor, coeff.medium return coeff.minor, coeff.medium
for j, profile in enumerate(edge.reach.profiles): for j, profile in enumerate(edge.reach.enabled_profiles):
coef_min, coef_moy = get_stricklers_from_rk(profile.rk, coef_min, coef_moy = get_stricklers_from_rk(profile.rk,
lst) lst)
f.write( f.write(
@ -861,7 +861,10 @@ class AdisTSwc(AdisTS):
for i in range(ibmax): for i in range(ibmax):
# Add results reach to reach list # Add results reach to reach list
r = results.river.add(i) geometry_reach = study.river.enable_edges()[i].reach
r = results.river.add(
i, profiles=geometry_reach.enabled_profiles
)
reachs.append(r) reachs.append(r)
is1[i] = data[2 * i] - 1 # first section of reach i is1[i] = data[2 * i] - 1 # first section of reach i

View File

@ -187,7 +187,7 @@ class AdisTT(CommandLineSolver):
files.append(str(os.path.join("net", f"{name}.ST"))) files.append(str(os.path.join("net", f"{name}.ST")))
cnt_num = 1 cnt_num = 1
for profile in edge.reach.profiles: for profile in edge.reach.enabled_profiles:
self._export_ST_profile_header( self._export_ST_profile_header(
f, files, profile, cnt_num f, files, profile, cnt_num
) )
@ -310,7 +310,7 @@ class AdisTT(CommandLineSolver):
return coeff.minor, coeff.medium return coeff.minor, coeff.medium
for j, profile in enumerate(edge.reach.profiles): for j, profile in enumerate(edge.reach.enabled_profiles):
coef_min, coef_moy = get_stricklers_from_rk(profile.rk, coef_min, coef_moy = get_stricklers_from_rk(profile.rk,
lst) lst)
f.write( f.write(
@ -647,7 +647,10 @@ class AdisTTwc(AdisTT):
for i in range(ibmax): for i in range(ibmax):
# Add results reach to reach list # Add results reach to reach list
r = results.river.add(i) geometry_reach = study.river.enable_edges()[i].reach
r = results.river.add(
i, profiles=geometry_reach.enabled_profiles
)
reachs.append(r) reachs.append(r)
is1[i] = data[2 * i] - 1 # first section of reach i is1[i] = data[2 * i] - 1 # first section of reach i

View File

@ -224,7 +224,7 @@ class Mage(CommandLineSolver):
files.append(str(os.path.join("net", f"{name}.ST"))) files.append(str(os.path.join("net", f"{name}.ST")))
cnt_num = 1 cnt_num = 1
for profile in edge.reach.profiles: for profile in edge.reach.enabled_profiles:
self._export_ST_profile_header( self._export_ST_profile_header(
f, files, profile, cnt_num f, files, profile, cnt_num
) )
@ -489,7 +489,12 @@ class Mage(CommandLineSolver):
if cond.is_deleted(): if cond.is_deleted():
continue continue
data = cond.data enabled_profiles = set(reach.reach.enabled_profiles)
data = [
item for item in cond.data
if not item.is_deleted()
and item["section"] in enabled_profiles
]
if len(data) == 0: if len(data) == 0:
continue continue
@ -497,9 +502,6 @@ class Mage(CommandLineSolver):
id_sec = 1 id_sec = 1
for d in data: for d in data:
if d.is_deleted():
continue
IR = f"{id}" IR = f"{id}"
IS = f"{id_sec}" IS = f"{id_sec}"
discharge = f"{d['discharge']:>10.5f}" discharge = f"{d['discharge']:>10.5f}"
@ -1097,7 +1099,10 @@ class Mage8(Mage):
for i in range(nb_reach): for i in range(nb_reach):
# Add results reach to reach list # Add results reach to reach list
r = results.river.add(i) geometry_reach = study.river.enable_edges()[i].reach
r = results.river.add(
i, profiles=geometry_reach.enabled_profiles
)
reachs.append(r) reachs.append(r)
# ID of first and last reach profiles # ID of first and last reach profiles
@ -1402,7 +1407,10 @@ class Mage8(Mage):
zfd_lst = [] zfd_lst = []
for r in reachs: for r in reachs:
z_min = r.geometry.get_z_min() z_min = [
profile.geometry.z_min()
for profile in r.profiles
]
sls = map( sls = map(
lambda p: p.get_ts_key(ts_list[0], "sl")[0], lambda p: p.get_ts_key(ts_list[0], "sl")[0],
r.profiles r.profiles