mirror of https://gitlab.com/pamhyr/pamhyr2
Pamhyr2: Some fixes.
parent
19d9a29459
commit
0d33072a7e
|
|
@ -101,7 +101,8 @@ class Friction(SQLSubModel):
|
|||
cls._db_update_to_0_1_0_set_stricklers_pid(execute, table, stricklers)
|
||||
|
||||
@classmethod
|
||||
def _db_update_to_0_1_0_set_stricklers_pid(cls, execute, table, stricklers):
|
||||
def _db_update_to_0_1_0_set_stricklers_pid(cls, execute, table,
|
||||
stricklers):
|
||||
els = execute(
|
||||
f"SELECT pamhyr_id, begin_strickler, end_strickler FROM {table}"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -81,8 +81,8 @@ class PointXYZ(Point, SQLSubModel):
|
|||
@classmethod
|
||||
def _db_update_to_0_1_0(cls, execute, data):
|
||||
table = "geometry_pointXYZ"
|
||||
reachs = data['id2pid']['sedimentary_layer']
|
||||
profiles = data['id2pid']['geometry_profileXYZ']
|
||||
id2pid = data['id2pid']
|
||||
profiles = id2pid['geometry_profileXYZ']
|
||||
|
||||
cls.update_db_add_pamhyr_id(execute, table, data)
|
||||
Scenario.update_db_add_scenario(execute, table)
|
||||
|
|
@ -100,7 +100,10 @@ class PointXYZ(Point, SQLSubModel):
|
|||
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
||||
|
||||
cls._db_update_to_0_1_0_set_profile_pid(execute, table, profiles)
|
||||
cls._db_update_to_0_1_0_set_sl_pid(execute, table, sl)
|
||||
|
||||
if 'sedimentary_layer' in id2pid:
|
||||
sl = id2pid['sedimentary_layer']
|
||||
cls._db_update_to_0_1_0_set_sl_pid(execute, table, sl)
|
||||
|
||||
@classmethod
|
||||
def _db_update_to_0_1_0_set_profile_pid(cls, execute, table, profiles):
|
||||
|
|
|
|||
|
|
@ -123,8 +123,8 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||
@classmethod
|
||||
def _db_update_to_0_1_0(cls, execute, data):
|
||||
table = "geometry_profileXYZ"
|
||||
reachs = data['id2pid']['river_reach']
|
||||
sl = data['id2pid']['sedimentary_layer']
|
||||
id2pid = data['id2pid']
|
||||
reachs = id2pid['river_reach']
|
||||
|
||||
cls.update_db_add_pamhyr_id(execute, table, data)
|
||||
Scenario.update_db_add_scenario(execute, table)
|
||||
|
|
@ -144,7 +144,10 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
||||
|
||||
cls._db_update_to_0_1_0_set_reach_pid(execute, table, reachs)
|
||||
cls._db_update_to_0_1_0_set_sl_pid(execute, table, sl)
|
||||
|
||||
if 'sedimentary_layer' in id2pid:
|
||||
sl = id2pid['sedimentary_layer']
|
||||
cls._db_update_to_0_1_0_set_sl_pid(execute, table, sl)
|
||||
|
||||
@classmethod
|
||||
def _db_update_to_0_1_0_set_sl_pid(cls, execute, table, sl):
|
||||
|
|
|
|||
|
|
@ -72,8 +72,8 @@ class BasicHS(SQLSubModel):
|
|||
if major == minor == "0":
|
||||
if int(release) < 6:
|
||||
cls._db_create(execute)
|
||||
|
||||
cls._db_update_to_0_1_0(execute, data)
|
||||
else:
|
||||
cls._db_update_to_0_1_0(execute, data)
|
||||
|
||||
return cls._update_submodel(execute, version, data)
|
||||
|
||||
|
|
|
|||
|
|
@ -59,8 +59,8 @@ class BHSValue(SQLSubModel):
|
|||
if major == minor == "0":
|
||||
if int(release) < 6:
|
||||
cls._db_create(execute)
|
||||
|
||||
cls._db_update_to_0_1_0(execute, data)
|
||||
else:
|
||||
cls._db_update_to_0_1_0(execute, data)
|
||||
|
||||
return cls._update_submodel(execute, version, data)
|
||||
|
||||
|
|
|
|||
|
|
@ -84,20 +84,16 @@ class HydraulicStructure(SQLSubModel):
|
|||
cls._db_create(execute)
|
||||
|
||||
if rl < 11:
|
||||
execute(
|
||||
"""
|
||||
ALTER TABLE hydraulic_structures
|
||||
RENAME COLUMN input_kp TO input_rk
|
||||
"""
|
||||
)
|
||||
execute(
|
||||
"""
|
||||
ALTER TABLE hydraulic_structures
|
||||
RENAME COLUMN output_kp TO output_rk
|
||||
"""
|
||||
)
|
||||
for v in ["input", "output"]:
|
||||
execute(
|
||||
f"""
|
||||
ALTER TABLE hydraulic_structures
|
||||
RENAME COLUMN {v}_kp TO {v}_rk
|
||||
"""
|
||||
)
|
||||
|
||||
cls._db_update_to_0_1_0(execute, data)
|
||||
if 6 < rl:
|
||||
cls._db_update_to_0_1_0(execute, data)
|
||||
|
||||
return cls._update_submodel(execute, version, data)
|
||||
|
||||
|
|
|
|||
|
|
@ -16,10 +16,11 @@
|
|||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from Model.Tools.PamhyrDB import PamhyrID
|
||||
from Model.Network.Node import Node
|
||||
|
||||
|
||||
class Edge(object):
|
||||
class Edge(PamhyrID):
|
||||
def __init__(self, id: int, name: str,
|
||||
node1: Node = None,
|
||||
node2: Node = None,
|
||||
|
|
|
|||
|
|
@ -16,10 +16,11 @@
|
|||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from Model.Tools.PamhyrDB import PamhyrID
|
||||
from Model.Network.Point import Point
|
||||
|
||||
|
||||
class Node(object):
|
||||
class Node(PamhyrID):
|
||||
def __init__(self, id: int, name: str,
|
||||
x: float = 0.0, y: float = 0.0,
|
||||
status=None):
|
||||
|
|
|
|||
|
|
@ -56,14 +56,15 @@ class Data(SQLSubModel):
|
|||
major, minor, release = version.strip().split(".")
|
||||
|
||||
if major == minor == "0":
|
||||
cls._db_update_to_0_1_0(execute, data)
|
||||
if 5 < int(release):
|
||||
cls._db_update_to_0_1_0(execute, data)
|
||||
|
||||
return cls._update_submodel(execute, version, data)
|
||||
|
||||
@classmethod
|
||||
def _db_update_to_0_1_0(cls, execute, data):
|
||||
table = "reservoir_data"
|
||||
reservoirs = data['id2pid']['reservoir']
|
||||
id2pid = data['id2pid']
|
||||
|
||||
cls.update_db_add_pamhyr_id(
|
||||
execute, table,
|
||||
|
|
@ -82,7 +83,9 @@ class Data(SQLSubModel):
|
|||
execute(f"DROP TABLE {table}")
|
||||
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
||||
|
||||
cls._db_update_to_0_1_0_set_reservoir_pid(execute, table, reservoirs)
|
||||
if 'reservoir' in id2pid:
|
||||
reservoirs = id2pid['reservoir']
|
||||
cls._db_update_to_0_1_0_set_reservoir_pid(execute, table, reservoirs)
|
||||
|
||||
@classmethod
|
||||
def _db_update_to_0_1_0_set_reservoir_pid(cls, execute, table, reservoirs):
|
||||
|
|
@ -190,8 +193,8 @@ class Reservoir(SQLSubModel):
|
|||
if major == minor == "0":
|
||||
if int(release) < 5:
|
||||
cls._db_create(execute)
|
||||
|
||||
cls._db_update_to_0_1_0(execute, data)
|
||||
else:
|
||||
cls._db_update_to_0_1_0(execute, data)
|
||||
|
||||
return cls._update_submodel(execute, version, data)
|
||||
|
||||
|
|
|
|||
|
|
@ -308,12 +308,12 @@ class RiverReach(Edge, SQLSubModel):
|
|||
|
||||
class River(Graph, SQLSubModel):
|
||||
_sub_classes = [
|
||||
StricklersList,
|
||||
RiverNode,
|
||||
RiverReach,
|
||||
BoundaryConditionList,
|
||||
LateralContributionList,
|
||||
InitialConditionsDict,
|
||||
StricklersList,
|
||||
SolverParametersList,
|
||||
SedimentLayerList,
|
||||
ReservoirList,
|
||||
|
|
|
|||
|
|
@ -204,7 +204,6 @@ class SQLSubModel(PamhyrID):
|
|||
"""
|
||||
raise NotImplementedMethodeError(cls, cls._db_update)
|
||||
|
||||
|
||||
@classmethod
|
||||
def _db_update_to_0_1_0_set_node_pid(cls, execute, table, nodes):
|
||||
els = execute(
|
||||
|
|
|
|||
Loading…
Reference in New Issue