Commit 22131eef authored by Bichen Li's avatar Bichen Li

initial commit with neplan read in

parent 26ea09db
......@@ -4,6 +4,7 @@
# ignore symbolic links
*.egg-info
*.eggs
# ignore compiled python files
*.pyc
......
......@@ -3,7 +3,6 @@ import pandas as pd
from .timeseries import *
import re
def read_timeseries_Modelica(filename, timeseries_names=None, is_regex=False):
from modelicares import SimRes
sim = SimRes(filename)
......@@ -12,6 +11,7 @@ def read_timeseries_Modelica(filename, timeseries_names=None, is_regex=False):
timeseries = []
for name in sim.names():
timeseries.append(TimeSeries(name, sim(name).times(), sim(name).values()))
timeseries_names = sim.names()
elif is_regex is True:
# Read in variables which match with regex
timeseries = []
......@@ -30,7 +30,7 @@ def read_timeseries_Modelica(filename, timeseries_names=None, is_regex=False):
timeseries.append(TimeSeries(name, sim(name).times(), sim(name).values()))
print('Modelica results column names: ' + str(timeseries_names))
print('Modelica results number: ' + str(len(timeseries_list)))
print('Modelica results number: ' + str(len(timeseries_names)))
return timeseries
......
import re
def readsim(file_name,timeseries_names=None, is_regex=False):
str_tmp = open(file_name,"r")
low = 0
high = 0
flag = True
dic = {}
seq = []
value = []
i = 0
isfloat = re.compile(r'^[-+]?[0-9]+\.[0-9]+$')
for line in str_tmp.readlines():
line = line.replace(",",".")
high -= high
low -= low
del value[:]
for letter in line:
if letter == " " or letter == "\n": # different data or end
if low is not high: # not NONE
if flag: # seq
seq.append(line[low:high])
else: # value
if isfloat.match(line[low:high]):
value.append(float(line[low:high]))
else:
value.append(line[low:high])
else: # NONE
value.append(r'#')
low = high + 1
high += 1
flag = False
dic[i] = dict(zip(seq, value))
i += 1
str_tmp.close()
return dic
\ No newline at end of file
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import read_NEPLAN
import re
file = r"C:\Users\jdi-bli\Desktop\Test\Slack_Rxline_PQLoad.rlf"
# Example 1: Read in all variable
result = read_NEPLAN.readsim(file)
for i in range(6):
print(result[i]) # result as list of TimeSeries
# Example 2: Read in specific variable
# all_bus_voltages = readsim_Neplan.readsim(file, )
# all_comp_currents = ...
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment