From f7c1019a43e99c32df595ccb44a29e602908243f Mon Sep 17 00:00:00 2001
From: Junjie Zhang <junjie.zhang@eonerc.rwth-aachen.de>
Date: Sun, 4 Nov 2018 14:36:58 +0100
Subject: [PATCH] add converting dpsim ts to modelica ts

---
 .vscode/settings.json                    |  3 +++
 villas/dataprocessing/validationtools.py | 16 +++++++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 .vscode/settings.json

diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..f7c1a80
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,3 @@
+{
+    "python.pythonPath": "D:\\Anaconda3\\python.exe"
+}
\ No newline at end of file
diff --git a/villas/dataprocessing/validationtools.py b/villas/dataprocessing/validationtools.py
index f8a5b27..43f3d94 100644
--- a/villas/dataprocessing/validationtools.py
+++ b/villas/dataprocessing/validationtools.py
@@ -3,7 +3,7 @@
 
 import os
 
-from readtools import *
+from .readtools import *
 
 """
 The validationtools are used to validate the simulate results from the model.
@@ -83,6 +83,20 @@ def convert_simulink_to_modelica_timeseries(simseri):
             res.append(simseri[check])
     return res
 
+def convert_dpsim_to_modelica_timeseries(dpsim_timeseries):
+    """
+    Convert the steady-state results timeseries from dpsim to modelica timeseries
+    :param dpsim_timeseries: dict of dpsim timeseries, generated by the csv result file from dpsim
+    :return: a list of dpsim timeseries
+    """
+    ts_dpsimList=[]
+    for ts,values in dpsim_timeseries.items():
+        ts_abs = values.abs(ts + '.Vpp')
+        ts_phase = values.phase(ts + '.Vangle')
+        ts_phase.values*=np.pi/180
+        ts_dpsimList.append(ts_abs)
+        ts_dpsimList.append(ts_phase)
+    return ts_dpsimList
 
 def compare_timeseries(ts1, ts2):
     """
-- 
GitLab