Commit 2743eece authored by Markus Mirz's avatar Markus Mirz

update

parent 8e077c15
......@@ -9,6 +9,13 @@ def diff(name, ts1, ts2):
ts_diff = TimeSeries(name, ts1.time, (ts1.values - ts2.values))
return ts_diff
def scale_ts(name, ts, factor):
""" Scale timeseries.
Assumes the same time steps for both timeseries.
"""
ts_scaled = TimeSeries(name, ts.time, ts.values * factor)
return ts_scaled
def complex_abs(name, real, imag):
""" Calculate absolute value of complex variable.
Assumes the same time steps for both timeseries.
......
......@@ -22,22 +22,27 @@ def plot_dpsim_abs_diff(filename1, node1, filename2, node2):
# this assumes same timestep for both simulations
ts_abs1 = complex_abs('node ' + str(node1) + 'abs', ts_dpsim1[node1], ts_dpsim1[node1 + im_offset1])
ts_abs1 = scale_ts(ts_abs1.name, ts_abs1, 0.001)
ts_abs1.label = 'reference'
ts_abs2 = complex_abs('node ' + str(node2) + 'abs', ts_dpsim2[node1], ts_dpsim2[node1 + im_offset2])
ts_abs2 = scale_ts(ts_abs2.name, ts_abs2, 0.001)
ts_abs2.label = 'local co-sim'
ts_diff = diff('diff', ts_abs1, ts_abs2)
ts_diff.label = 'difference'
figure_id = 1
plt.figure(figure_id)
#plt.figure(figure_id)
plt.figure(figure_id, figsize=(12 / 2.54, 6 / 2.54), facecolor='w', edgecolor='k')
plot_single_ts(figure_id, ts_abs1)
plot_single_ts(figure_id, ts_abs2)
plot_single_ts(figure_id, ts_diff)
plt.xlabel('Time [s]')
plt.ylabel('Voltage [V]')
plt.ylabel('Voltage [kV]')
plt.grid(True)
plt.tight_layout()
plt.show()
def plot_dpsim_abs_single(filename, node):
ts_dpsim = read_time_series_DPsim(filename)
......
......@@ -17,15 +17,6 @@ def plot_in_subplots(figure_id, time_series, plt_linestyle='-'):
plt.gca().autoscale(axis='x', tight=True)
plt.legend()
def plot_in_oneplot(figure_id, time_series, plt_linestyle='-'):
plt.figure(figure_id)
for ts in time_series:
plt.subplot(len(time_series), 1, time_series.index(ts) + 1)
plt.plot(ts.time, ts.values, linestyle=plt_linestyle, label=ts.label)
plt.gca().autoscale(axis='x', tight=True)
plt.legend()
def set_time_series_labels(time_series, time_series_labels):
for ts in time_series:
ts.label = time_series_labels[time_series.index(ts)]
\ No newline at end of file
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