From 543ca1ba3b6846777b9877a0d76effb4206bcde8 Mon Sep 17 00:00:00 2001 From: Craig Warren Date: Mon, 30 Jan 2017 16:54:25 +0000 Subject: [PATCH] Added ability to plot current outputs if specified. --- tools/plot_Ascan.py | 49 ++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/tools/plot_Ascan.py b/tools/plot_Ascan.py index d2ab2979..fcaff27b 100644 --- a/tools/plot_Ascan.py +++ b/tools/plot_Ascan.py @@ -121,12 +121,12 @@ def mpl_plot(filename, outputs=Rx.defaultoutputs, fft=False): plt.setp(ax1, ylabel=outputtext + ' field strength [A/m]') plt.setp(stemlines, 'color', 'g') plt.setp(markerline, 'markerfacecolor', 'g', 'markeredgecolor', 'g') -# elif 'I' in outputs[0]: -# plt.setp(line1, color='b') -# plt.setp(line2, color='b') -# plt.setp(ax1, ylabel=outputtext + ' current [A]') -# plt.setp(stemlines, 'color', 'b') -# plt.setp(markerline, 'markerfacecolor', 'b', 'markeredgecolor', 'b') + elif 'I' in outputs[0]: + plt.setp(line1, color='b') + plt.setp(line2, color='b') + plt.setp(ax1, ylabel=outputtext + ' current [A]') + plt.setp(stemlines, 'color', 'b') + plt.setp(markerline, 'markerfacecolor', 'b', 'markeredgecolor', 'b') plt.show() @@ -141,16 +141,19 @@ def mpl_plot(filename, outputs=Rx.defaultoutputs, fft=False): if 'H' in output: plt.setp(line, color='g') plt.setp(ax, ylabel=outputtext + ', field strength [A/m]') -# elif 'I' in output: -# plt.setp(line, color='b') -# plt.setp(ax, ylabel=outputtext + ', current [A]') + elif 'I' in output: + plt.setp(line, color='b') + plt.setp(ax, ylabel=outputtext + ', current [A]') # If multiple outputs required, create all nine subplots and populate only the specified ones else: fig, ax = plt.subplots(subplot_kw=dict(xlabel='Time [s]'), num='rx' + str(rx), figsize=(20, 10), facecolor='w', edgecolor='w') - gs = gridspec.GridSpec(3, 2, hspace=0.3, wspace=0.3) + if len(outputs) == 9: + gs = gridspec.GridSpec(3, 3, hspace=0.3, wspace=0.3) + else: + gs = gridspec.GridSpec(3, 2, hspace=0.3, wspace=0.3) + for output in outputs: - # Check for polarity of output and if requested output is in file if output[-1] == 'm': polarity = -1 @@ -196,18 +199,18 @@ def mpl_plot(filename, outputs=Rx.defaultoutputs, fft=False): ax.plot(time, outputdata, 'g', lw=2, label=outputtext) ax.set_ylabel(outputtext + ', field strength [A/m]') #ax.set_ylim([-0.03, 0.03]) -# elif output == 'Ix': -# ax = plt.subplot(gs[0, 2]) -# ax.plot(time, outputdata,'b', lw=2, label=outputtext) -# ax.set_ylabel(outputtext + ', current [A]') -# elif output == 'Iy': -# ax = plt.subplot(gs[1, 2]) -# ax.plot(time, outputdata,'b', lw=2, label=outputtext) -# ax.set_ylabel(outputtext + ', current [A]') -# elif output == 'Iz': -# ax = plt.subplot(gs[2, 2]) -# ax.plot(time, outputdata,'b', lw=2, label=outputtext) -# ax.set_ylabel(outputtext + ', current [A]') + elif output == 'Ix': + ax = plt.subplot(gs[0, 2]) + ax.plot(time, outputdata,'b', lw=2, label=outputtext) + ax.set_ylabel(outputtext + ', current [A]') + elif output == 'Iy': + ax = plt.subplot(gs[1, 2]) + ax.plot(time, outputdata,'b', lw=2, label=outputtext) + ax.set_ylabel(outputtext + ', current [A]') + elif output == 'Iz': + ax = plt.subplot(gs[2, 2]) + ax.plot(time, outputdata,'b', lw=2, label=outputtext) + ax.set_ylabel(outputtext + ', current [A]') for ax in fig.axes: ax.set_xlim([0, np.amax(time)]) ax.grid()