Commit ffc5f207 authored by Markus Mirz's avatar Markus Mirz
Browse files

add freq shifting func to time series

parent 1316737c
from dataprocessing.readtools import *
from dataprocessing.timeseries import *
from dataprocessing.plottools import *
def get_node_voltage_phasors(dpsim_timeseries_list):
"""Calculate voltage phasors of all nodes
......@@ -24,7 +25,7 @@ def get_node_emt_voltages(timeseries_list, freq):
voltages_list = {}
for name, ts in timeseries_list.items():
ts_emt = ts.dynphasor_shift_to_emt(, freq)
ts_emt = ts.frequency_shift(, freq)
voltages_list[] = ts_emt
return voltages_list
......@@ -37,6 +37,31 @@ class TimeSeries:
ts_phase = TimeSeries(name, self.time, phase_values)
return ts_phase
def phasor(self, name):
"""Calculate phasor of complex time series and return dict with abs and phase.
ts_abs = ts.abs( + '_abs')
ts_phase = ts.phase( + '_phase')
ts_phasor = {}
ts_phasor['abs'] = ts_abs
ts_phasor['phase'] = ts_phase
return ts_phasor
def frequency_shift_list(timeseries_list, freq):
"""Calculate shifted frequency results of all time series
:param timeseries_list: timeseries list retrieved from dpsim results
:param freq: frequency by which the timeseries should be shifted
:return: list of shifted time series
result_list = {}
for name, ts in timeseries_list.items():
ts_emt = ts.frequency_shift(, freq)
result_list[] = ts_emt
return result_list
def rmse(ts1, ts2):
""" Calculate root mean square error between two time series
......@@ -69,7 +94,7 @@ class TimeSeries:
ts_diff = TimeSeries(name, time, (interp_vals_ts2 - interp_vals_ts1))
return ts_diff
def dynphasor_shift_to_emt(self, name, freq):
def frequency_shift(self, name, freq):
""" Shift dynamic phasor values to EMT by frequency freq.
Assumes the same time steps for both timeseries.
:param name: name of returned time series
Supports Markdown
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