Commit a0f964e8 authored by Theophile Terraz's avatar Theophile Terraz
Browse files

generate discharge without height

No related merge requests found
Pipeline #56432 passed with stages
in 3 minutes and 23 seconds
Showing with 27 additions and 19 deletions
+27 -19
...@@ -369,6 +369,7 @@ class InitialConditions(SQLSubModel): ...@@ -369,6 +369,7 @@ class InitialConditions(SQLSubModel):
def generate_growing_constante_height(self, height: float, def generate_growing_constante_height(self, height: float,
compute_discharge: bool): compute_discharge: bool):
profiles = self._reach.reach.profiles.copy() profiles = self._reach.reach.profiles.copy()
self._sort_by_z_and_kp(profiles) self._sort_by_z_and_kp(profiles)
...@@ -376,8 +377,12 @@ class InitialConditions(SQLSubModel): ...@@ -376,8 +377,12 @@ class InitialConditions(SQLSubModel):
data_discharge = {} data_discharge = {}
if not compute_discharge: if not compute_discharge:
for data in self._data: if len(self._data) == 0:
data_discharge[data["kp"]] = data["discharge"] for profile in profiles:
data_discharge[profile.kp] = 0.0
else:
for data in self._data:
data_discharge[data["kp"]] = data["discharge"]
incline = self._reach.reach.get_incline_median_mean() incline = self._reach.reach.get_incline_median_mean()
logger.debug(f"incline = {incline}") logger.debug(f"incline = {incline}")
...@@ -411,39 +416,42 @@ class InitialConditions(SQLSubModel): ...@@ -411,39 +416,42 @@ class InitialConditions(SQLSubModel):
new["discharge"] = discharge new["discharge"] = discharge
new["elevation"] = elevation new["elevation"] = elevation
previous_elevation = elevation
self._data.append(new) self._data.append(new)
self._generate_resort_data(profiles) self._generate_resort_data(profiles)
def generate_discharge(self, discharge: float, compute_height: bool): def generate_discharge(self, discharge: float, compute_height: bool):
if compute_height:
self._data = []
self._generate_height_estimation_from_discharge(
discharge
)
else:
for data in self._data:
data["discharge"] = discharge
def _generate_height_estimation_from_discharge(self, discharge: float):
profiles = self._reach.reach.profiles.copy() profiles = self._reach.reach.profiles.copy()
self._sort_by_z_and_kp(profiles) self._sort_by_z_and_kp(profiles)
previous_elevation = -99999.99 previous_elevation = -99999.99
data_height = {}
if not compute_height:
if len(self._data) == 0:
for profile in profiles:
data_height[profile.kp] = 0.0
else:
for data in self._data:
data_height[data["kp"]] = data["height"]
incline = self._reach.reach.get_incline_median_mean() incline = self._reach.reach.get_incline_median_mean()
logger.debug(f"incline = {incline}") logger.debug(f"incline = {incline}")
self._data = []
for profile in profiles: for profile in profiles:
width = profile.width_approximation() width = profile.width_approximation()
strickler = 25 strickler = 25
height = (
discharge if not compute_height:
/ height = data_height[profile.kp]
((width * 0.8) * strickler * (abs(incline) ** (0.5))) else:
) ** (0.6) height = (
discharge
/
((width * 0.8) * strickler * (abs(incline) ** (0.5)))
) ** (0.6)
elevation = max( elevation = max(
profile.z_min() + height, profile.z_min() + height,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment