mirror of https://gitlab.com/pamhyr/pamhyr2
generate discharge without height
parent
30b3b8800e
commit
a0f964e89e
|
|
@ -369,6 +369,7 @@ class InitialConditions(SQLSubModel):
|
|||
|
||||
def generate_growing_constante_height(self, height: float,
|
||||
compute_discharge: bool):
|
||||
|
||||
profiles = self._reach.reach.profiles.copy()
|
||||
self._sort_by_z_and_kp(profiles)
|
||||
|
||||
|
|
@ -376,8 +377,12 @@ class InitialConditions(SQLSubModel):
|
|||
|
||||
data_discharge = {}
|
||||
if not compute_discharge:
|
||||
for data in self._data:
|
||||
data_discharge[data["kp"]] = data["discharge"]
|
||||
if len(self._data) == 0:
|
||||
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()
|
||||
logger.debug(f"incline = {incline}")
|
||||
|
|
@ -411,39 +416,42 @@ class InitialConditions(SQLSubModel):
|
|||
new["discharge"] = discharge
|
||||
new["elevation"] = elevation
|
||||
|
||||
previous_elevation = elevation
|
||||
self._data.append(new)
|
||||
|
||||
self._generate_resort_data(profiles)
|
||||
|
||||
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()
|
||||
self._sort_by_z_and_kp(profiles)
|
||||
|
||||
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()
|
||||
logger.debug(f"incline = {incline}")
|
||||
|
||||
self._data = []
|
||||
for profile in profiles:
|
||||
width = profile.width_approximation()
|
||||
strickler = 25
|
||||
height = (
|
||||
discharge
|
||||
/
|
||||
((width * 0.8) * strickler * (abs(incline) ** (0.5)))
|
||||
) ** (0.6)
|
||||
|
||||
if not compute_height:
|
||||
height = data_height[profile.kp]
|
||||
else:
|
||||
height = (
|
||||
discharge
|
||||
/
|
||||
((width * 0.8) * strickler * (abs(incline) ** (0.5)))
|
||||
) ** (0.6)
|
||||
|
||||
elevation = max(
|
||||
profile.z_min() + height,
|
||||
|
|
|
|||
Loading…
Reference in New Issue