diff --git a/src/Model/InitialConditions/InitialConditions.py b/src/Model/InitialConditions/InitialConditions.py index a49cfcef9fcf5166e72746b9b2757b95268c5c70..8d47178aed8cd6df65fcf1dbf89783418131b4f2 100644 --- a/src/Model/InitialConditions/InitialConditions.py +++ b/src/Model/InitialConditions/InitialConditions.py @@ -367,53 +367,52 @@ 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: - 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 - discharge = ( - ((width * 0.8) - * strickler - * (height ** (5/3)) - * (abs(incline) ** (0.5))) - ) + data_discharge = {} + if not compute_discharge: + for data in self._data: + data_discharge[data["kp"]] = data["discharge"] - elevation = max( - profile.z_min() + height, - previous_elevation - ) + 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 - logger.debug(f"({profile.kp}):") - logger.debug(f" width = {width}") - logger.debug(f" strickler = {strickler}") - logger.debug(f" discharge = {discharge}") + if not compute_discharge: + discharge = data_discharge[profile.kp] + else: + discharge = ( + ((width * 0.8) + * strickler + * (height ** (5/3)) + * (abs(incline) ** (0.5))) + ) - new = Data(reach=self._reach, status=self._status) - new["kp"] = profile.kp - new["discharge"] = discharge + elevation = max( + profile.z_min() + height, + previous_elevation + ) - new["elevation"] = elevation + logger.debug(f"({profile.kp}):") + logger.debug(f" width = {width}") + logger.debug(f" strickler = {strickler}") + logger.debug(f" discharge = {discharge}") - self._data.append(new) - else: - for data, profile in zip(self._data, profiles): + new = Data(reach=self._reach, status=self._status) + new["kp"] = profile.kp + new["discharge"] = discharge - elevation = max( - profile.z_min() + height, - previous_elevation - ) - data["elevation"] = elevation - previous_elevation = elevation + new["elevation"] = elevation + + self._data.append(new) self._generate_resort_data(profiles)