mirror of https://gitlab.com/pamhyr/pamhyr2
Adists: LC: Update for scenario.
parent
4a0456cbce
commit
89a898410f
|
|
@ -46,7 +46,7 @@ class LateralContributionAdisTS(SQLSubModel):
|
|||
self._status = status
|
||||
|
||||
self._pollutant = pollutant
|
||||
self._edge = None
|
||||
self._reach = None
|
||||
self._begin_rk = 0.0
|
||||
self._end_rk = 0.0
|
||||
self._data = []
|
||||
|
|
@ -149,7 +149,7 @@ class LateralContributionAdisTS(SQLSubModel):
|
|||
@classmethod
|
||||
def _db_load(cls, execute, data=None):
|
||||
new = []
|
||||
|
||||
status = data['status']
|
||||
scenario = data["scenario"]
|
||||
loaded = data['loaded_pid']
|
||||
|
||||
|
|
@ -157,7 +157,8 @@ class LateralContributionAdisTS(SQLSubModel):
|
|||
return new
|
||||
|
||||
table = execute(
|
||||
"SELECT pamhyr_id, pollutant, reach, begin_rk, end_rk " +
|
||||
"SELECT pamhyr_id, pollutant, reach, " +
|
||||
"begin_rk, end_rk, scenario " +
|
||||
"FROM lateral_contribution_adists " +
|
||||
f"WHERE scenario = {scenario.id} " +
|
||||
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))}) "
|
||||
|
|
@ -165,15 +166,25 @@ class LateralContributionAdisTS(SQLSubModel):
|
|||
|
||||
if table is not None:
|
||||
for row in table:
|
||||
it = iter(row)
|
||||
|
||||
pid = next(it)
|
||||
pollutant = next(it)
|
||||
reach = next(it)
|
||||
brk = next(it)
|
||||
erk = next(it)
|
||||
owner_scenario = next(it)
|
||||
|
||||
lca = cls(
|
||||
id=row[0],
|
||||
pollutant=row[1],
|
||||
status=data['status']
|
||||
id=pid,
|
||||
pollutant=pollutant,
|
||||
status=status,
|
||||
owner_scenario=owner_scenario
|
||||
)
|
||||
|
||||
lca.edge = row[2]
|
||||
lca.begin_rk = row[3]
|
||||
lca.end_rk = row[4]
|
||||
lca.reach = reach
|
||||
lca.begin_rk = brk
|
||||
lca.end_rk = erk
|
||||
|
||||
values = execute(
|
||||
"SELECT data0, data1 " +
|
||||
|
|
@ -185,12 +196,13 @@ class LateralContributionAdisTS(SQLSubModel):
|
|||
|
||||
# Write data
|
||||
for v in values:
|
||||
data0 = lca._types[0](v[0])
|
||||
data1 = lca._types[1](v[1])
|
||||
data0 = lca._types[0](v[1])
|
||||
data1 = lca._types[1](v[2])
|
||||
# Replace data at pos ind
|
||||
lca._data.append((data0, data1))
|
||||
|
||||
new.append(lc)
|
||||
loaded.add(pid)
|
||||
new.append(lca)
|
||||
|
||||
data["scenario"] = scenario.parent
|
||||
new += cls._db_load(execute, data)
|
||||
|
|
@ -213,7 +225,7 @@ class LateralContributionAdisTS(SQLSubModel):
|
|||
f"AND scenario = {self._status.scenario_id}"
|
||||
)
|
||||
|
||||
sql = (
|
||||
execute(
|
||||
"INSERT INTO " +
|
||||
"lateral_contribution_adists(id, " +
|
||||
"pollutant, reach, begin_rk, end_rk, scenario) " +
|
||||
|
|
@ -223,7 +235,6 @@ class LateralContributionAdisTS(SQLSubModel):
|
|||
f"{self._status.scenario_id}" +
|
||||
")"
|
||||
)
|
||||
execute(sql)
|
||||
|
||||
for d in self._data:
|
||||
data0 = self._db_format(str(d[0]))
|
||||
|
|
|
|||
Loading…
Reference in New Issue