mirror of https://gitlab.com/pamhyr/pamhyr2
add d50/sigma in database + load/save data in UI
parent
e6d059bc19
commit
c498ed2d96
|
|
@ -232,6 +232,8 @@ class BoundaryCondition(SQLSubModel):
|
||||||
type TEXT NOT NULL,
|
type TEXT NOT NULL,
|
||||||
tab TEXT NOT NULL,
|
tab TEXT NOT NULL,
|
||||||
node INTEGER,
|
node INTEGER,
|
||||||
|
d50 REAL DEFAULT 0.002,
|
||||||
|
sigma REAL DEFAULT 1,
|
||||||
{Scenario.create_db_add_scenario()},
|
{Scenario.create_db_add_scenario()},
|
||||||
{Scenario.create_db_add_scenario_fk()},
|
{Scenario.create_db_add_scenario_fk()},
|
||||||
FOREIGN KEY(node) REFERENCES river_node(pamhyr_id),
|
FOREIGN KEY(node) REFERENCES river_node(pamhyr_id),
|
||||||
|
|
@ -258,6 +260,17 @@ class BoundaryCondition(SQLSubModel):
|
||||||
"ADD COLUMN deleted BOOLEAN NOT NULL DEFAULT FALSE"
|
"ADD COLUMN deleted BOOLEAN NOT NULL DEFAULT FALSE"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if major == "0" and int(minor) <= 2:
|
||||||
|
if int(release) < 4:
|
||||||
|
execute(
|
||||||
|
"ALTER TABLE boundary_condition " +
|
||||||
|
"ADD COLUMN d50 REAL DEFAULT 0.002"
|
||||||
|
)
|
||||||
|
execute(
|
||||||
|
"ALTER TABLE boundary_condition " +
|
||||||
|
"ADD COLUMN sigma REAL DEFAULT 1"
|
||||||
|
)
|
||||||
|
|
||||||
return cls._update_submodel(execute, version, data)
|
return cls._update_submodel(execute, version, data)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
@ -316,7 +329,7 @@ class BoundaryCondition(SQLSubModel):
|
||||||
return new
|
return new
|
||||||
|
|
||||||
table = execute(
|
table = execute(
|
||||||
"SELECT pamhyr_id, deleted, name, type, node, scenario " +
|
"SELECT pamhyr_id, deleted, name, type, node, d50, sigma, scenario " +
|
||||||
"FROM boundary_condition " +
|
"FROM boundary_condition " +
|
||||||
f"WHERE tab = '{tab}' " +
|
f"WHERE tab = '{tab}' " +
|
||||||
f"AND scenario = {scenario.id} " +
|
f"AND scenario = {scenario.id} " +
|
||||||
|
|
@ -331,6 +344,8 @@ class BoundaryCondition(SQLSubModel):
|
||||||
name = next(it)
|
name = next(it)
|
||||||
t = next(it)
|
t = next(it)
|
||||||
node = next(it)
|
node = next(it)
|
||||||
|
d50 = next(it)
|
||||||
|
sigma = next(it)
|
||||||
owner_scenario = next(it)
|
owner_scenario = next(it)
|
||||||
|
|
||||||
ctor = cls._get_ctor_from_type(t)
|
ctor = cls._get_ctor_from_type(t)
|
||||||
|
|
@ -342,7 +357,9 @@ class BoundaryCondition(SQLSubModel):
|
||||||
)
|
)
|
||||||
if deleted:
|
if deleted:
|
||||||
bc.set_as_deleted()
|
bc.set_as_deleted()
|
||||||
|
if t=="SL":
|
||||||
|
bc.d50 = d50
|
||||||
|
bc.sigma = sigma
|
||||||
bc.node = None
|
bc.node = None
|
||||||
if node != -1:
|
if node != -1:
|
||||||
bc.node = next(filter(lambda n: n.id == node, nodes), None)
|
bc.node = next(filter(lambda n: n.id == node, nodes), None)
|
||||||
|
|
@ -375,15 +392,22 @@ class BoundaryCondition(SQLSubModel):
|
||||||
if self._node is not None:
|
if self._node is not None:
|
||||||
node = self._node.id
|
node = self._node.id
|
||||||
|
|
||||||
|
d50 = 0.002
|
||||||
|
sigma = 1
|
||||||
|
if self._type == "SL":
|
||||||
|
d50 = self._d50
|
||||||
|
sigma = self._sigma
|
||||||
|
|
||||||
execute(
|
execute(
|
||||||
"INSERT INTO " +
|
"INSERT INTO " +
|
||||||
"boundary_condition(" +
|
"boundary_condition(" +
|
||||||
"pamhyr_id, deleted, name, type, tab, node, scenario" +
|
"pamhyr_id, deleted, name, type, tab, node, d50, sigma, scenario" +
|
||||||
") " +
|
") " +
|
||||||
"VALUES (" +
|
"VALUES (" +
|
||||||
f"{self._pamhyr_id}, {self._db_format(self.is_deleted())}, " +
|
f"{self._pamhyr_id}, {self._db_format(self.is_deleted())}, " +
|
||||||
f"'{self._db_format(self._name)}', " +
|
f"'{self._db_format(self._name)}', " +
|
||||||
f"'{self._db_format(self._type)}', '{tab}', {node}, " +
|
f"'{self._db_format(self._type)}', '{tab}', {node}, " +
|
||||||
|
f"{d50}, {sigma}, " +
|
||||||
f"{self._status.scenario_id}" +
|
f"{self._status.scenario_id}" +
|
||||||
")"
|
")"
|
||||||
)
|
)
|
||||||
|
|
@ -468,6 +492,24 @@ class BoundaryCondition(SQLSubModel):
|
||||||
def has_node(self):
|
def has_node(self):
|
||||||
return self._node is not None
|
return self._node is not None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def d50(self):
|
||||||
|
return self._d50
|
||||||
|
|
||||||
|
@d50.setter
|
||||||
|
def d50(self, value):
|
||||||
|
self._d50 = float(value)
|
||||||
|
self.modified()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def sigma(self):
|
||||||
|
return self._sigma
|
||||||
|
|
||||||
|
@sigma.setter
|
||||||
|
def sigma(self, value):
|
||||||
|
self._sigma = float(value)
|
||||||
|
self.modified()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def header(self):
|
def header(self):
|
||||||
return self._header.copy()
|
return self._header.copy()
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
class Study(SQLModel):
|
class Study(SQLModel):
|
||||||
_version = "0.2.3"
|
_version = "0.2.4"
|
||||||
|
|
||||||
_sub_classes = [
|
_sub_classes = [
|
||||||
Scenario,
|
Scenario,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue