startRegex = re.compile("\s*CONTROL\s*FUNCTION\s*NUMBER\s*CURRENT\s*VALUE")
regex = re.compile("^\s*(?P<name>( ?([0-9a-zA-Z-]+))*)\s+([0-9]+)\s*(?P<value>((([0-9.-]+)E(\+|-)[0-9][0-9])|((T|F))))\s*.*$")
for time,listOfLines in timeBlock.items():
functionValues = {}
start = -1
for lineNumber, line in enumerate(listOfLines):
if re.search(startRegex, line):
start = lineNumber + 1
After Change
match = re.match(regex, line)
if match is not None:
if match.groupdict()["name"] not in functionValuesForEachTime:
functionValuesForEachTime[match.groupdict()["name"]] = []
functionValuesForEachTime[match.groupdict()["name"]].append(float(match.groupdict()["value"]))
elif start == -2:
for lineNumber, line in enumerate(listOfLines):
fcnName = re.match(timeOneRegex_name, line)
if fcnName is not None:
fcnValue = re.match(timeOneRegex_value, listOfLines[lineNumber+1])
if fcnValue is not None:
if fcnName.groupdict()["name"] not in functionValuesForEachTime:
functionValuesForEachTime[fcnName.groupdict()["name"]] = []
functionValuesForEachTime[fcnName.groupdict()["name"]].append(float(fcnValue.groupdict()["value"]))
for parameter in functionValuesForEachTime:
functionValuesForEachTime[parameter] = np.asarray(functionValuesForEachTime[parameter])
return functionValuesForEachTime
def returnVolumeHybro(self,timeBlock):