Allow to read EPANET3 pattern
This commit is contained in:
@@ -94,14 +94,22 @@ def delete_pattern(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# [EPANET2][IN][OUT]
|
||||
# [EPA2][IN][OUT]
|
||||
# ;desc
|
||||
# id mult1 mult2 .....
|
||||
#--------------------------------------------------------------
|
||||
# [EPA3][IN][OUT]
|
||||
# id FIXED (interval)
|
||||
# id factor1 factor2 ...
|
||||
# id VARIABLE
|
||||
# id time1 factor1 time2 factor2 ...
|
||||
#--------------------------------------------------------------
|
||||
def inp_in_pattern(section: list[str]) -> ChangeSet:
|
||||
descs = {}
|
||||
patterns: dict[str, list[float]] = {}
|
||||
|
||||
variable_patterns: list[str] = []
|
||||
|
||||
count = len(section)
|
||||
for i in range(0, count):
|
||||
if section[i].startswith(';'):
|
||||
@@ -113,10 +121,22 @@ def inp_in_pattern(section: list[str]) -> ChangeSet:
|
||||
continue
|
||||
|
||||
tokens = section[i].split()
|
||||
|
||||
# for EPA3, ignore time of variable pattern...
|
||||
if tokens[1] == 'VARIABLE':
|
||||
variable_patterns.append(tokens[0])
|
||||
continue
|
||||
elif tokens[1] == 'FIXED':
|
||||
continue
|
||||
|
||||
if tokens[0] not in patterns:
|
||||
patterns[tokens[0]] = []
|
||||
for token in tokens[1:]:
|
||||
patterns[tokens[0]].append(float(token))
|
||||
if tokens[0] not in variable_patterns:
|
||||
for token in tokens[1:]:
|
||||
patterns[tokens[0]].append(float(token))
|
||||
else:
|
||||
for token in tokens[1::2]:
|
||||
patterns[tokens[0]].append(float(token))
|
||||
|
||||
cs = ChangeSet()
|
||||
for id, factors in patterns.items():
|
||||
|
||||
Reference in New Issue
Block a user