Commit a085ca78 authored by Steffen Vogel's avatar Steffen Vogel 🎅🏼

added support for reading VILLAS datasets to readtools

parent 80215f64
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)
......@@ -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.
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] == '#':
sample = Sample.parse(line)
for index, field in enumerate(sample.values, start=0):
if len(fields) <= index:
for index, field in enumerate(fields):
name = 'signal_{}'.format(index)
series = TimeSeries(name, times, field)
return timeseries
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