Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
ACS
P
Public
VILLASframework
Data Processing
Commits
a085ca78
Commit
a085ca78
authored
Feb 18, 2019
by
Steffen Vogel
🎅🏼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added support for reading VILLAS datasets to readtools
parent
80215f64
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
1 deletion
+55
-1
examples/readinresults/VILLAS/readin.py
examples/readinresults/VILLAS/readin.py
+14
-0
villas/dataprocessing/readtools.py
villas/dataprocessing/readtools.py
+41
-1
No files found.
examples/readinresults/VILLAS/readin.py
0 → 100644
View file @
a085ca78
#!/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/readtools.py
View file @
a085ca78
...
...
@@ -38,7 +38,6 @@ def read_timeseries_Modelica(filename, timeseries_names=None, is_regex=False):
return
timeseries
def
read_timeseries_csv
(
filename
,
timeseries_names
=
None
,
print_status
=
True
):
"""Reads complex time series data from DPsim log file. Real and
imaginary part are stored in one complex variable.
...
...
@@ -318,3 +317,44 @@ def read_timeseries_simulink_loadflow(filename, timeseries_names=None, is_regex=
del
timeseries
[
line_del
[
len
(
line_del
)
-
num_to_del
-
1
]]
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
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