diff --git a/dataprocessing/calc.py b/dataprocessing/calc.py index be6ca96d913e83655d711f21133db214a7d74298..29d89b805cd218849b24c232b3069bafff03371a 100644 --- a/dataprocessing/calc.py +++ b/dataprocessing/calc.py @@ -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. diff --git a/dataprocessing/plotdpsim.py b/dataprocessing/plotdpsim.py index 178fed138697272d9e90491ed9cd3dd519783091..e44615bee17944a77a425b6b38a451ff27abe383 100644 --- a/dataprocessing/plotdpsim.py +++ b/dataprocessing/plotdpsim.py @@ -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) diff --git a/dataprocessing/plottools.py b/dataprocessing/plottools.py index 3e1fa38c3e84616acf3611e0b864b937d8b9c39b..5f2ae4a2ac98a9f5fd1b9c49522aefbff756b322 100644 --- a/dataprocessing/plottools.py +++ b/dataprocessing/plottools.py @@ -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