IC, BC: Some fixes.

scenarios
Pierre-Antoine 2025-09-02 10:47:50 +02:00
parent 420d766ae5
commit 4bf0ad40b1
4 changed files with 18 additions and 9 deletions

View File

@ -498,7 +498,7 @@ class InitialConditions(SQLSubModel):
data_discharge[profile.rk] = 0.0 data_discharge[profile.rk] = 0.0
else: else:
for data in self._data: for data in self._data:
data_discharge[data["rk"]] = data["discharge"] data_discharge[data["rk"].rk] = 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}")
@ -562,7 +562,9 @@ class InitialConditions(SQLSubModel):
data_height[profile.rk] = 0.0 data_height[profile.rk] = 0.0
else: else:
for data in self._data: for data in self._data:
data_height[data["rk"]] = data["height"] data_height[data["rk"].rk] = data["height"]
print(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}")
@ -571,11 +573,13 @@ class InitialConditions(SQLSubModel):
width = profile.width_approximation() width = profile.width_approximation()
frictions = self._reach.frictions.frictions frictions = self._reach.frictions.frictions
strickler = None strickler = None
if frictions is not None: if frictions is not None:
if len(frictions) >= 1: if len(frictions) >= 1:
for f in frictions: for f in frictions:
if f.contains_rk(profile.rk): if f.contains_rk(profile.rk):
strickler = f.get_friction(profile.rk)[0] strickler = f.get_friction(profile.rk)[0]
if strickler is None: if strickler is None:
strickler = 25.0 strickler = 25.0
@ -587,8 +591,9 @@ class InitialConditions(SQLSubModel):
else: else:
height = ( height = (
discharge discharge
/ / ((width * 0.8)
((width * 0.8) * strickler * (abs(incline) ** (0.5))) * strickler
* (abs(incline) ** (0.5)))
) ** (0.6) ) ** (0.6)
elevation = max( elevation = max(
@ -624,7 +629,7 @@ class InitialConditions(SQLSubModel):
data_discharge[profile.rk] = 0.0 data_discharge[profile.rk] = 0.0
else: else:
for data in self._data: for data in self._data:
data_discharge[data["rk"]] = data["discharge"] data_discharge[data["rk"].rk] = data["discharge"]
self._data = [] self._data = []
for profile in profiles: for profile in profiles:
@ -637,7 +642,7 @@ class InitialConditions(SQLSubModel):
[upstream_rk, downstream_rk], [upstream_rk, downstream_rk],
[elevation1, elevation2]) [elevation1, elevation2])
new = Data(reach=self._reach, status=self._status) new = Data(reach=self._reach, status=self._status)
new["rk"] = profile.rk new["rk"] = profile
new["discharge"] = d new["discharge"] = d
new["elevation"] = elevation new["elevation"] = elevation
self._data.append(new) self._data.append(new)

View File

@ -72,7 +72,9 @@ class TableModel(PamhyrTableModel):
if 0 <= column < 2: if 0 <= column < 2:
v = self._data.get_i(row)[column] v = self._data.get_i(row)[column]
if self._data.get_type_column(column) == float: if self._data.get_type_column(column) == float:
value = f"{v:.4f}" if type(v) == str:
v = v.replace(',', '.')
value = f"{float(v):.4f}"
elif self._data.header[column] == "time": elif self._data.header[column] == "time":
if self._opt_data == "time": if self._opt_data == "time":
value = timestamp_to_old_pamhyr_date(int(v)) value = timestamp_to_old_pamhyr_date(int(v))

View File

@ -94,7 +94,9 @@ class AddCommand(QUndoCommand):
self._bcs = bcs self._bcs = bcs
self._tab = tab self._tab = tab
self._index = index self._index = index
self._old = self._bcs.get(self._tab, self._index) self._old = None
if len(self._bcs.get_tab(self._tab)) > self._index:
self._bcs.get(self._tab, self._index)
self._new = None self._new = None
def undo(self): def undo(self):

View File

@ -113,7 +113,7 @@ class SortCommand(QUndoCommand):
def redo(self): def redo(self):
self._ics.sort( self._ics.sort(
reverse=self._reverse, reverse=self._reverse,
key=lambda x: x["rk"] key=lambda x: x["rk"].rk
) )
if self._indexes is None: if self._indexes is None:
self._indexes = list( self._indexes = list(