diff --git a/dataprocessing/plotdpsim.py b/dataprocessing/plotdpsim.py index 39014e98a2f0853734b300288f7bf121075bbaec..a0eb07adfa78c1f8d337e0eb331e99f3becc27c7 100644 --- a/dataprocessing/plotdpsim.py +++ b/dataprocessing/plotdpsim.py @@ -34,8 +34,8 @@ def plot_dpsim_abs_diff(filename1, label1, node1, filename2, label2, node2): figure_id = 1 #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_abs1) + #plot_single_ts(figure_id, ts_abs2) plot_single_ts(figure_id, ts_diff) plt.xlabel('Time [s]') plt.ylabel('Voltage [kV]') @@ -43,6 +43,41 @@ def plot_dpsim_abs_diff(filename1, label1, node1, filename2, label2, node2): plt.tight_layout() plt.show() +def plot_dpsim_abs(filename1, label1, node1, filename2, label2, node2): + ts_dpsim1 = read_time_series_DPsim(filename1) + ts_dpsim2 = read_time_series_DPsim(filename2) + + ts_dpsim1_length = len(ts_dpsim1) + im_offset1 = int(ts_dpsim1_length / 2) + if im_offset1 <= node1 or node1 < 0: + print('Node 1 not available') + exit() + + ts_dpsim2_length = len(ts_dpsim2) + im_offset2 = int(ts_dpsim2_length / 2) + if im_offset2 <= node1 or node1 < 0: + print('Node 2 not available') + exit() + + # 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 = label1 + 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 = label2 + + figure_id = 1 + # 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) + plt.xlabel('Time [s]') + 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/examples/plot_absolute_example.py b/examples/plot_absolute_example.py new file mode 100644 index 0000000000000000000000000000000000000000..98d3bdcb24fbf4840ef5c6d42fed25642e007bdc --- /dev/null +++ b/examples/plot_absolute_example.py @@ -0,0 +1,11 @@ +from dataprocessing.plotdpsim import * + +path = 'C:\\Users\\mmi\\git\\PowerSystemSimulation\\gre\\step-dist-init\\' +plot_dpsim_abs(path + 'lvector-ref.csv', 'reference', 2, + path + 'lvector0-local_rm-first-row.csv', 'local', 2) + +plot_dpsim_abs(path + 'lvector-ref.csv', 'reference', 2, + path + 'lvector0-netem.csv', 'netem', 2) + +plot_dpsim_abs(path + 'lvector-ref.csv', 'reference', 2, + path + 'lvector0-dist.csv', 'dist', 2) \ No newline at end of file