mirror of https://gitlab.com/pamhyr/pamhyr2
Adists: BC, IC, LC: Fix pollutant pamhyr_id update.
parent
0df813b0d2
commit
f13ab03192
|
|
@ -126,6 +126,29 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
||||||
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
||||||
|
|
||||||
cls._db_update_to_0_2_0_set_node_pid(execute, table, nodes)
|
cls._db_update_to_0_2_0_set_node_pid(execute, table, nodes)
|
||||||
|
cls._db_update_to_0_2_0_set_pollutants_pid(execute, data)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _db_update_to_0_2_0_set_pollutants_pid(cls, execute, data):
|
||||||
|
pid_pol = data["id2pid"]["Pollutants"]
|
||||||
|
els = execute(
|
||||||
|
f"SELECT pamhyr_id, pollutant " +
|
||||||
|
"FROM boundary_condition_adists"
|
||||||
|
)
|
||||||
|
|
||||||
|
for row in els:
|
||||||
|
it = iter(row)
|
||||||
|
pid = next(it)
|
||||||
|
pol_id = next(it)
|
||||||
|
|
||||||
|
if pol_id == -1:
|
||||||
|
continue
|
||||||
|
|
||||||
|
execute(
|
||||||
|
f"UPDATE boundary_condition_adists " +
|
||||||
|
f"SET pollutant = {pid_pol[pol_id]} " +
|
||||||
|
f"WHERE pamhyr_id = {pid}"
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_update_to_0_2_0_data(cls, execute, data):
|
def _db_update_to_0_2_0_data(cls, execute, data):
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,6 @@ class InitialConditionsAdisTS(SQLSubModel):
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_update_to_0_2_0(cls, execute, data):
|
def _db_update_to_0_2_0(cls, execute, data):
|
||||||
table = "initial_conditions_adists"
|
table = "initial_conditions_adists"
|
||||||
reachs = data['id2pid']['river_reach']
|
|
||||||
|
|
||||||
cls.update_db_add_pamhyr_id(execute, table, data)
|
cls.update_db_add_pamhyr_id(execute, table, data)
|
||||||
Scenario.update_db_add_scenario(execute, table)
|
Scenario.update_db_add_scenario(execute, table)
|
||||||
|
|
@ -113,6 +112,30 @@ class InitialConditionsAdisTS(SQLSubModel):
|
||||||
execute(f"DROP TABLE {table}")
|
execute(f"DROP TABLE {table}")
|
||||||
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
||||||
|
|
||||||
|
cls._db_update_to_0_2_0_set_pollutants_pid(execute, data)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _db_update_to_0_2_0_set_pollutants_pid(cls, execute, data):
|
||||||
|
pid_pol = data["id2pid"]["Pollutants"]
|
||||||
|
els = execute(
|
||||||
|
f"SELECT pamhyr_id, pollutant " +
|
||||||
|
"FROM initial_conditions_adists"
|
||||||
|
)
|
||||||
|
|
||||||
|
for row in els:
|
||||||
|
it = iter(row)
|
||||||
|
pid = next(it)
|
||||||
|
pol_id = next(it)
|
||||||
|
|
||||||
|
if pol_id == -1:
|
||||||
|
continue
|
||||||
|
|
||||||
|
execute(
|
||||||
|
f"UPDATE initial_conditions_adists " +
|
||||||
|
f"SET pollutant = {pid_pol[pol_id]} " +
|
||||||
|
f"WHERE pamhyr_id = {pid}"
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_load(cls, execute, data=None):
|
def _db_load(cls, execute, data=None):
|
||||||
new = []
|
new = []
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,29 @@ class LateralContributionAdisTS(SQLSubModel):
|
||||||
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
||||||
|
|
||||||
cls._db_update_to_0_2_0_set_reach_pid(execute, table, reachs)
|
cls._db_update_to_0_2_0_set_reach_pid(execute, table, reachs)
|
||||||
|
cls._db_update_to_0_2_0_set_pollutants_pid(execute, data)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _db_update_to_0_2_0_set_pollutants_pid(cls, execute, data):
|
||||||
|
pid_pol = data["id2pid"]["Pollutants"]
|
||||||
|
els = execute(
|
||||||
|
f"SELECT pamhyr_id, pollutant " +
|
||||||
|
"FROM lateral_contribution_adists"
|
||||||
|
)
|
||||||
|
|
||||||
|
for row in els:
|
||||||
|
it = iter(row)
|
||||||
|
pid = next(it)
|
||||||
|
pol_id = next(it)
|
||||||
|
|
||||||
|
if pol_id == -1:
|
||||||
|
continue
|
||||||
|
|
||||||
|
execute(
|
||||||
|
f"UPDATE lateral_contribution_adists " +
|
||||||
|
f"SET pollutant = {pid_pol[pol_id]} " +
|
||||||
|
f"WHERE pamhyr_id = {pid}"
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_update_to_0_2_0_data(cls, execute, data):
|
def _db_update_to_0_2_0_data(cls, execute, data):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue