Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
Data Processing
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
1
Merge Requests
1
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ACS
P
Public
VILLASframework
Data Processing
Commits
959526a3
Commit
959526a3
authored
Apr 17, 2019
by
Markus Mirz
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of git.rwth-aachen.de:acs/public/simulation/data-processing
parents
e1f08571
93b7f93a
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
155 additions
and
87 deletions
+155
-87
.editorconfig
.editorconfig
+3
-0
examples/compareresults/compare_neplan_dpsim.py
examples/compareresults/compare_neplan_dpsim.py
+1
-1
examples/readinresults/NEPLAN/read_NEPLAN_example.py
examples/readinresults/NEPLAN/read_NEPLAN_example.py
+64
-66
examples/readinresults/VILLAS/readin.py
examples/readinresults/VILLAS/readin.py
+14
-0
villas/dataprocessing/__init__.py
villas/dataprocessing/__init__.py
+1
-1
villas/dataprocessing/readtools.py
villas/dataprocessing/readtools.py
+50
-10
villas/dataprocessing/validationtools.py
villas/dataprocessing/validationtools.py
+22
-9
No files found.
.editorconfig
0 → 100644
View file @
959526a3
[*.py]
indent_style = space
indent_size = 4
examples/compareresults/compare_neplan_dpsim.py
View file @
959526a3
...
@@ -43,4 +43,4 @@ for i in range(len(ts_dpsimList)):
...
@@ -43,4 +43,4 @@ for i in range(len(ts_dpsimList)):
print
(
'************************ convert dpsim to modelica end ****************'
)
print
(
'************************ convert dpsim to modelica end ****************'
)
res_err
=
validationtools
.
compare_timeseries
(
res_ref
,
ts_dpsimList
)
res_err
=
validationtools
.
compare_timeseries
(
res_ref
,
ts_dpsimList
)
validationtools
.
assert_modelia_results
(
net_name
,
res_err
,
threshold
)
validationtools
.
assert_modelica_results
(
net_name
,
res_err
,
threshold
)
\ No newline at end of file
\ No newline at end of file
examples/readinresults/NEPLAN/read_NEPLAN_example.py
View file @
959526a3
...
@@ -3,10 +3,8 @@
...
@@ -3,10 +3,8 @@
import
re
import
re
from
dataprocessing.readtools
import
*
from
dataprocessing.readtools
import
*
file
=
r
"C:\Users\admin\Desktop\Load_read\Load_flow_WCSS.rlf"
file
=
r
"C:\Users\admin\Desktop\Load_read\Load_flow_WCSS.rlf"
# Example 1: Read in all variable
# Example 1: Read in all variable
print
(
'************************ Test for read in all variable start ****************'
)
print
(
'************************ Test for read in all variable start ****************'
)
result_ALL
=
read_timeseries_NEPLAN_loadflow
(
file
)
result_ALL
=
read_timeseries_NEPLAN_loadflow
(
file
)
...
...
examples/readinresults/VILLAS/readin.py
0 → 100644
View file @
959526a3
#!/usr/bin/python
import
sys
import
villas.dataprocessing.readtools
as
rt
import
villas.dataprocessing.plottools
as
pt
import
matplotlib.pyplot
as
plt
filename
=
sys
.
argv
[
1
]
timeseries
=
rt
.
read_timeseries_villas
(
filename
)
pt
.
plot_timeseries
(
1
,
timeseries
)
plt
.
show
()
villas/dataprocessing/__init__.py
View file @
959526a3
__all__
=
[
"readtools"
,
"plottools"
,
"timeseries"
]
__all__
=
[
"readtools"
,
"plottools"
,
"timeseries"
,
"validationtools"
]
\ No newline at end of file
\ No newline at end of file
villas/dataprocessing/readtools.py
View file @
959526a3
...
@@ -38,7 +38,6 @@ def read_timeseries_Modelica(filename, timeseries_names=None, is_regex=False):
...
@@ -38,7 +38,6 @@ def read_timeseries_Modelica(filename, timeseries_names=None, is_regex=False):
return
timeseries
return
timeseries
def
read_timeseries_csv
(
filename
,
timeseries_names
=
None
,
print_status
=
True
):
def
read_timeseries_csv
(
filename
,
timeseries_names
=
None
,
print_status
=
True
):
"""Reads complex time series data from DPsim log file. Real and
"""Reads complex time series data from DPsim log file. Real and
imaginary part are stored in one complex variable.
imaginary part are stored in one complex variable.
...
@@ -160,19 +159,19 @@ def read_timeseries_PLECS(filename, timeseries_names=None):
...
@@ -160,19 +159,19 @@ def read_timeseries_PLECS(filename, timeseries_names=None):
return
timeseries_list
return
timeseries_list
def
read_timeseries_NEPLAN_loadflow
(
file
_
name
,
timeseries_names
=
None
,
is_regex
=
False
):
def
read_timeseries_NEPLAN_loadflow
(
filename
,
timeseries_names
=
None
,
is_regex
=
False
):
"""
"""
Read in NEPLAN loadflow result from result file, the result is in angle notation, amplitude and angle are stored
Read in NEPLAN loadflow result from result file, the result is in angle notation, amplitude and angle are stored
separately
separately
To keep consistent with the names of voltage in most cases, the name of voltage variables are changed into '.V*'
To keep consistent with the names of voltage in most cases, the name of voltage variables are changed into '.V*'
instead of '.U*' as in the result file
instead of '.U*' as in the result file
:param file
_
name: name of the mat file for the loadflow result from neplan
:param filename: name of the mat file for the loadflow result from neplan
:param timeseries_names: column name to be read
:param timeseries_names: column name to be read
:param is_regex: flag for using regular expression
:param is_regex: flag for using regular expression
:return: list of Timeseries objects
:return: list of Timeseries objects
"""
"""
str_tmp
=
open
(
file
_
name
,
"r"
)
# Read in files
str_tmp
=
open
(
filename
,
"r"
)
# Read in files
low
=
0
# flag for the start of a new data in str_cmp
low
=
0
# flag for the start of a new data in str_cmp
high
=
0
# flag for the end of this new data in str_cmp
high
=
0
# flag for the end of this new data in str_cmp
flag
=
True
# To judge if this is the first line of the file, which will be the names for the data type
flag
=
True
# To judge if this is the first line of the file, which will be the names for the data type
...
@@ -254,7 +253,7 @@ def read_timeseries_NEPLAN_loadflow(file_name, timeseries_names=None, is_regex=F
...
@@ -254,7 +253,7 @@ def read_timeseries_NEPLAN_loadflow(file_name, timeseries_names=None, is_regex=F
return
timeseries
return
timeseries
def
read_timeseries_simulink_loadflow
(
file
_
name
,
timeseries_names
=
None
,
is_regex
=
False
):
def
read_timeseries_simulink_loadflow
(
filename
,
timeseries_names
=
None
,
is_regex
=
False
):
"""
"""
Read in simulink load-flow result from result file(.rep), the result is in angle notation, amplitude and angle are stored
Read in simulink load-flow result from result file(.rep), the result is in angle notation, amplitude and angle are stored
separately.
separately.
...
@@ -262,12 +261,12 @@ def read_timeseries_simulink_loadflow(file_name, timeseries_names=None, is_regex
...
@@ -262,12 +261,12 @@ def read_timeseries_simulink_loadflow(file_name, timeseries_names=None, is_regex
.Arms/.IDegree for current/current angle,
.Arms/.IDegree for current/current angle,
.Vrms/.VDegree for voltage/voltage angle.
.Vrms/.VDegree for voltage/voltage angle.
:param file
_
name:path of the .rep file for the loadflow result from simulink
:param filename:path of the .rep file for the loadflow result from simulink
:param timeseries_names: specific values to be read
:param timeseries_names: specific values to be read
:param is_regex: flag for using regular expression
:param is_regex: flag for using regular expression
:return: list of Timeseries objects
:return: list of Timeseries objects
"""
"""
str_tmp
=
open
(
file
_
name
,
'r'
,
encoding
=
'latin-1'
)
# Read in files, using latin-1 to decode /xb0
str_tmp
=
open
(
filename
,
'r'
,
encoding
=
'latin-1'
)
# Read in files, using latin-1 to decode /xb0
# Read in data from result file of neplan
# Read in data from result file of neplan
name
=
[]
# list for data type names
name
=
[]
# list for data type names
...
@@ -318,3 +317,44 @@ def read_timeseries_simulink_loadflow(file_name, timeseries_names=None, is_regex
...
@@ -318,3 +317,44 @@ def read_timeseries_simulink_loadflow(file_name, timeseries_names=None, is_regex
del
timeseries
[
line_del
[
len
(
line_del
)
-
num_to_del
-
1
]]
del
timeseries
[
line_del
[
len
(
line_del
)
-
num_to_del
-
1
]]
return
timeseries
return
timeseries
def
read_timeseries_villas
(
filename
):
"""
Read data in "villas.human" format.
See: https://villas.fein-aachen.org/doc/node-formats.html
Format: seconds.nanoseconds+offset(sequenceno) value0 value1 ... valueN
Example: 1438959964.162102394(6) 3.489760 -1.882725 0.860070
:param filename: name of the file that contains the data
"""
from
villas.node.sample
import
Sample
with
open
(
filename
,
'r'
)
as
fp
:
timeseries
=
[
]
times
=
[
]
fields
=
[
]
for
line
in
fp
.
readlines
():
if
line
[
0
]
==
'#'
:
continue
sample
=
Sample
.
parse
(
line
)
times
.
append
(
sample
.
ts
)
for
index
,
field
in
enumerate
(
sample
.
values
,
start
=
0
):
if
len
(
fields
)
<=
index
:
fields
.
append
([])
fields
[
index
].
append
(
field
)
for
index
,
field
in
enumerate
(
fields
):
name
=
'signal_{}'
.
format
(
index
)
series
=
TimeSeries
(
name
,
times
,
field
)
timeseries
.
append
(
series
)
return
timeseries
villas/dataprocessing/validationtools.py
View file @
959526a3
...
@@ -121,7 +121,7 @@ def compare_timeseries(ts1, ts2):
...
@@ -121,7 +121,7 @@ def compare_timeseries(ts1, ts2):
# Match the components in result files, and compare them
# Match the components in result files, and compare them
for
i
in
range
(
len_ts1
):
for
i
in
range
(
len_ts1
):
flag_
not_
found
=
False
flag_found
=
False
for
j
in
range
(
len_limit
):
for
j
in
range
(
len_limit
):
if
ts1
[
i
].
name
==
ts2
[
j
].
name
:
# Find the same variable
if
ts1
[
i
].
name
==
ts2
[
j
].
name
:
# Find the same variable
timeseries_names
.
append
(
ts1
[
i
].
name
)
timeseries_names
.
append
(
ts1
[
i
].
name
)
...
@@ -132,15 +132,16 @@ def compare_timeseries(ts1, ts2):
...
@@ -132,15 +132,16 @@ def compare_timeseries(ts1, ts2):
print
(
ts1
[
i
].
name
)
print
(
ts1
[
i
].
name
)
print
(
timeseries_error
[
len
(
timeseries_error
)
-
1
])
print
(
timeseries_error
[
len
(
timeseries_error
)
-
1
])
flag_
not_
found
=
True
flag_found
=
True
if
flag_
not_
found
is
False
:
if
flag_found
is
False
:
# No such variable in Modelica model, set the error to -1
# No such variable in Modelica model, set the error to -1
timeseries_names
.
append
(
ts1
[
i
].
name
)
print
(
"Warning: no matching variable found for "
+
ts1
[
i
].
name
+
"! Skipping error calculation and assertion for this variable..."
)
timeseries_error
.
append
(
-
1
)
# timeseries_names.append(ts1[i].name)
# timeseries_error.append(-1)
return
dict
(
zip
(
timeseries_names
,
timeseries_error
))
return
dict
(
zip
(
timeseries_names
,
timeseries_error
))
def
assert_modelia_results
(
net_name
,
error
,
threshold
):
def
assert_modeli
c
a_results
(
net_name
,
error
,
threshold
):
"""
"""
assert the result data of a net.
assert the result data of a net.
:param net_name: name of the network
:param net_name: name of the network
...
@@ -149,7 +150,6 @@ def assert_modelia_results(net_name, error, threshold):
...
@@ -149,7 +150,6 @@ def assert_modelia_results(net_name, error, threshold):
:return: outputs to command line which are the results of the assert
:return: outputs to command line which are the results of the assert
"""
"""
fail_list
=
[]
# List for all the failed test
fail_list
=
[]
# List for all the failed test
# the limitations are set to 0.5
for
name
in
error
.
keys
():
for
name
in
error
.
keys
():
if
abs
(
error
[
name
])
>
threshold
:
if
abs
(
error
[
name
])
>
threshold
:
fail_list
.
append
(
name
)
fail_list
.
append
(
name
)
...
@@ -173,11 +173,24 @@ def validate_modelica_res(net_name, modelica_res_path, reference_res_path, thres
...
@@ -173,11 +173,24 @@ def validate_modelica_res(net_name, modelica_res_path, reference_res_path, thres
:param threshold: the threshold of the assertion, a default value of 0.5 is introduced.
:param threshold: the threshold of the assertion, a default value of 0.5 is introduced.
:return: outputs to command line which are the results of the validation.
:return: outputs to command line which are the results of the validation.
"""
"""
print
(
'
\n
************************ Modelica Results ****************'
)
res_mod
=
read_timeseries_Modelica
(
modelica_res_path
)
res_mod
=
read_timeseries_Modelica
(
modelica_res_path
)
for
res
in
res_mod
:
print
(
res
.
name
)
print
(
res
.
values
[
0
])
# only show first value of time series
print
(
'
\n
************************ Reference Results ****************'
)
if
os
.
path
.
splitext
(
reference_res_path
)[
1
]
==
'.rep'
:
if
os
.
path
.
splitext
(
reference_res_path
)[
1
]
==
'.rep'
:
res_ref
=
convert_simulink_to_modelica_timeseries
(
read_timeseries_simulink_loadflow
(
reference_res_path
))
res_ref
=
convert_simulink_to_modelica_timeseries
(
read_timeseries_simulink_loadflow
(
reference_res_path
))
elif
os
.
path
.
splitext
(
reference_res_path
)[
1
]
==
'.rlf'
:
elif
os
.
path
.
splitext
(
reference_res_path
)[
1
]
==
'.rlf'
:
res_ref
=
convert_neplan_to_modelica_timeseries
(
read_timeseries_NEPLAN_loadflow
(
reference_res_path
))
res_ref
=
convert_neplan_to_modelica_timeseries
(
read_timeseries_NEPLAN_loadflow
(
reference_res_path
))
for
res
in
res_ref
:
print
(
res
.
name
)
print
(
res
.
values
)
print
(
'
\n
************************ Comparison ****************'
)
res_err
=
compare_timeseries
(
res_ref
,
res_mod
)
res_err
=
compare_timeseries
(
res_ref
,
res_mod
)
assert_modelia_results
(
net_name
,
res_err
,
threshold
)
print
(
'
\n
************************ Assertion ****************'
)
assert_modelica_results
(
net_name
,
res_err
,
threshold
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment