Merge branch 'master' of gitlab-ssh.irstea.fr:theophile.terraz/pamhyr

setup.py
Theophile Terraz 2023-11-29 14:34:11 +01:00
commit 0a63f16f62
6 changed files with 20 additions and 10 deletions

View File

@ -57,12 +57,14 @@ class FrictionList(PamhyrModelList):
return new
def _db_save(self, execute, data=None):
frictions = self.lst
reach = data["reach"]
execute(f"DELETE FROM friction WHERE reach = {reach.id}")
ok = True
ind = 0
for friction in self._lst:
for friction in frictions:
data["ind"] = ind
ok &= friction._db_save(execute, data=data)
ind += 1

View File

@ -173,11 +173,13 @@ class ProfileXYZ(Profile, SQLSubModel):
)
execute(sql)
points = self.points
data["profile"] = self
execute(f"DELETE FROM geometry_pointXYZ WHERE profile = {self.id}")
ind = 0
for point in self.points:
for point in points:
data["ind"] = ind
ok &= point._db_save(execute, data)
ind += 1

View File

@ -71,15 +71,16 @@ class Reach(SQLSubModel):
return new
def _db_save(self, execute, data=None):
profiles = self.profiles
# Delete old data
execute(f"DELETE FROM geometry_profileXYZ WHERE reach = {self.id}")
# execute(f"DELETE FROM geometry_pointXYZ")
if data is None:
data = {}
ind = 0
for profile in self.profiles:
for profile in profiles:
data["ind"] = ind
profile._db_save(execute, data)
ind += 1

View File

@ -55,14 +55,18 @@ class InitialConditionsDict(PamhyrModelDict):
if data is None:
data = {}
execute("DELETE FROM initial_conditions")
for reach in self._dict:
ics = self._dict
for reach in ics:
data["reach"] = reach
v = self._dict[reach]
if isinstance(v, types.GeneratorType):
self._dict[reach] = list(v)[0]
execute(
"DELETE FROM initial_conditions " +
f"WHERE reach = '{reach.id}'"
)
ok &= self._dict[reach]._db_save(execute, data)
return ok

View File

@ -200,9 +200,9 @@ class Mage(CommandLineSolver):
wfile.write(f"{num}{c1}{c2}{t} {kp} {pname} {sediment}\n")
def _export_ST_point_line(self, wfile, files, point):
x = f"{point.x:<12f}"[0:12]
y = f"{point.y:<12f}"[0:12]
z = f"{point.z:<12f}"[0:12]
x = f"{point.x:<12.4f}"[0:12]
y = f"{point.y:<12.4f}"[0:12]
z = f"{point.z:<12.4f}"[0:12]
n = f"{point.name:<3}"
# Generate sediment additional data if available

View File

@ -156,6 +156,7 @@ class SolverLogWindow(PamhyrWindow):
def new_process(self, parent):
new = QProcess(parent)
new.setWorkingDirectory(self._workdir)
new.setProcessChannelMode(QProcess.MergedChannels)
return new
def setup_action(self):