Stricklers: Add base of code.

This commit is contained in:
Pierre-Antoine Rouby committed 2023-05-16 16:24:49 +02:00
1 parent 1179dd0b92
commit 113fafac50
11 files changed
+669 -12

No files matched your search

+3 -3
View File
@@ -202,10 +202,10 @@ class Reach:
return [profile.kp for profile in self.profiles]
def get_kp_min(self):
return min([profile.kp for profile in self.profiles])
return min(self.get_kp())
def get_kp_max(self):
return max([profile.kp for profile in self.profiles])
return max(self.get_kp())
# Guidelines
@@ -237,7 +237,7 @@ class Reach:
@timer
def compute_guidelines(self):
"""Compute reach guideline and check if is valid for all profiles
"""Compute reach guidelines
Returns:
Tuple of complete and incomplete guidelines name.
+6 -1
View File
@@ -9,7 +9,7 @@ from Model.Geometry.Reach import Reach
from Model.BoundaryCondition.BoundaryConditionList import BoundaryConditionList
from Model.LateralContribution.LateralContributionList import LateralContributionList
from Model.Stricklers.StricklersList import StricklersList
class RiverNode(Node):
def __init__(self, id:str, name:str,
@@ -61,6 +61,7 @@ class River(Graph):
self._current_reach = None
self._boundary_condition = BoundaryConditionList(status=self._status)
self._lateral_contribution = LateralContributionList(status=self._status)
self._stricklers = StricklersList(status=self._status)
@property
def boundary_condition(self):
@@ -70,6 +71,10 @@ class River(Graph):
def lateral_contribution(self):
return self._lateral_contribution
@property
def striklers(self):
return self._stricklers
def has_current_reach(self):
return self._current_reach is not None
+47
View File
@@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
from tools import trace, timer
class Stricklers(object):
def __init__(self, status = None):
super(Stricklers, self).__init__()
self._status = status
self._name = ""
self._comment = ""
self._minor = 35
self._medium = 15
@property
def name(self):
return self._name
@name.setter
def name(self, name):
self._name = name
@property
def comment(self):
return self._comment
@comment.setter
def comment(self, comment):
self._comment = comment
@property
def minor(self):
return self._minor
@minor.setter
def minor(self, minor):
self._minor = int(minor)
@property
def medium(self):
return self._medium
@medium.setter
def medium(self, medium):
self._medium = int(medium)
+62
View File
@@ -0,0 +1,62 @@
# -*- coding: utf-8 -*-
from tools import trace, timer
from Model.Stricklers.Stricklers import Stricklers
class StricklersList(object):
def __init__(self, status = None):
self._status = status
self._stricks = []
def __len__(self):
return len(self._stricks)
@property
def stricks(self):
return self._stricks.copy()
def get(self, index):
if 0 <= index < len(self._stricks):
return self._stricks[index]
return None
def insert(self, index, strick):
self._stricks.insert(index, strick)
self._status.modified()
def add(self, index):
s = Stricklers(status = self._status)
self.insert(index, s)
return s
def delete(self, stricks):
self._stricks = list(
filter(
lambda s: s not in stricks,
self._stricks
)
)
self._status.modified()
def delete_i(self, indexes):
stricks = set(
map(
lambda e: e[1],
filter(
lambda e: e[0] in indexes,
enumerate(self._stricks)
)
)
)
self.delete(stricks)
def sort(self, reverse:bool = False):
self._strick = sorted(
self._strick,
key = lambda st: st.name,
reverse = reverse,
)
self._status.modified()