IC: Fix `generate_growing_constante_height` method.

InitialConditions
Pierre-Antoine Rouby 2024-07-05 11:30:07 +02:00
parent 453a2084e7
commit 366baa737a
1 changed files with 35 additions and 36 deletions

View File

@ -367,20 +367,28 @@ class InitialConditions(SQLSubModel):
key=lambda p: p.kp
)
def generate_growing_constante_height(self, height: float, compute_discharge: bool):
def generate_growing_constante_height(self, height: float,
compute_discharge: bool):
profiles = self._reach.reach.profiles.copy()
self._sort_by_z_and_kp(profiles)
previous_elevation = -99999.99
if compute_discharge:
data_discharge = {}
if not compute_discharge:
for data in self._data:
data_discharge[data["kp"]] = data["discharge"]
incline = self._reach.reach.get_incline_median_mean()
logger.debug(f"incline = {incline}")
self._data = []
for profile in profiles:
width = profile.width_approximation()
strickler = 25
if not compute_discharge:
discharge = data_discharge[profile.kp]
else:
discharge = (
((width * 0.8)
* strickler
@ -405,15 +413,6 @@ class InitialConditions(SQLSubModel):
new["elevation"] = elevation
self._data.append(new)
else:
for data, profile in zip(self._data, profiles):
elevation = max(
profile.z_min() + height,
previous_elevation
)
data["elevation"] = elevation
previous_elevation = elevation
self._generate_resort_data(profiles)