Changed default default for saving and plotting of receiver output components to only electric and magnetic fields, i.e. no longer current.

这个提交包含在:
Craig Warren
2016-10-14 15:03:47 +01:00
父节点 f947cc941e
当前提交 000cb46c4c
共有 8 个文件被更改,包括 125 次插入107 次删除

查看文件

@@ -794,7 +794,7 @@ Allows you to introduce output points into the model. These are locations where
.. note::
* When the optional parameters ``str1`` and ``str2`` are not given all the electric and magnetic field components and currents will be output with the receiver point.
* When the optional parameters ``str1`` and ``str2`` are not given all the electric and magnetic field components will be output with the receiver point.
#rx_array:
----------

查看文件

@@ -21,7 +21,7 @@ where ``outputfile`` is the name of output file including the path.
There are optional command line arguments:
* ``--outputs`` to specify a subset of the default output components (``Ex``, ``Ey``, ``Ez``, ``Hx``, ``Hy``, ``Hz``, ``Ix``, ``Iy`` or ``Iz``) to plot. By default all components are plotted.
* ``--outputs`` to specify a subset of the default output components (``Ex``, ``Ey``, ``Ez``, ``Hx``, ``Hy``, ``Hz``, ``Ix``, ``Iy`` or ``Iz``) to plot. By default all electric and magnetic field components are plotted.
* ``-fft`` to plot the Fast Fourier Transform (FFT) of a single output component
For example to plot the ``Ez`` output component with it's FFT:

查看文件

@@ -343,7 +343,7 @@ def process_multicmds(multicmds, G):
# If no ID or outputs are specified, use default i.e Ex, Ey, Ez, Hx, Hy, Hz, Ix, Iy, Iz
if len(tmp) == 3:
r.ID = r.__class__.__name__ + '(' + str(r.xcoord) + ',' + str(r.ycoord) + ',' + str(r.zcoord) + ')'
for key in Rx.availableoutputs:
for key in Rx.defaultoutputs:
r.outputs[key] = np.zeros(G.iterations, dtype=floattype)
else:
r.ID = tmp[3]
@@ -418,7 +418,7 @@ def process_multicmds(multicmds, G):
r.ycoordorigin = y
r.zcoordorigin = z
r.ID = r.__class__.__name__ + '(' + str(x) + ',' + str(y) + ',' + str(z) + ')'
for key in Rx.availableoutputs:
for key in Rx.defaultoutputs:
r.outputs[key] = np.zeros(G.iterations, dtype=floattype)
if G.messages:
print(' Receiver at {:g}m, {:g}m, {:g}m with output component(s) {} created.'.format(r.xcoord * G.dx, r.ycoord * G.dy, r.zcoord * G.dz, ', '.join(r.outputs)))

查看文件

@@ -25,6 +25,7 @@ class Rx(object):
"""Receiver output points."""
availableoutputs = ['Ex', 'Ey', 'Ez', 'Hx', 'Hy', 'Hz', 'Ix', 'Iy', 'Iz']
defaultoutputs = availableoutputs[:-3]
def __init__(self):

文件差异因一行或多行过长而隐藏

文件差异因一行或多行过长而隐藏

查看文件

@@ -29,9 +29,6 @@ if filename ~= 0
fields.hx = zeros(header.iterations, header.nrx);
fields.hy = zeros(header.iterations, header.nrx);
fields.hz = zeros(header.iterations, header.nrx);
fields.ix = zeros(header.iterations, header.nrx);
fields.iy = zeros(header.iterations, header.nrx);
fields.iz = zeros(header.iterations, header.nrx);
% Save and plot fields from each receiver
for n=1:header.nrx
@@ -47,29 +44,15 @@ if filename ~= 0
fields.hx(:,n) = h5read(fullfilename, strcat(path, 'Hx'));
fields.hy(:,n) = h5read(fullfilename, strcat(path, 'Hy'));
fields.hz(:,n) = h5read(fullfilename, strcat(path, 'Hz'));
fields.ix(:,n) = h5read(fullfilename, strcat(path, 'Ix'));
fields.iy(:,n) = h5read(fullfilename, strcat(path, 'Iy'));
fields.iz(:,n) = h5read(fullfilename, strcat(path, 'Iz'));
fh1=figure('Name', strcat('rx', num2str(n)));
ax1 = subplot(3,3,1); plot(time, fields.ex(:,n), 'r', 'LineWidth', 2), grid on, xlabel('Time [ns]'), ylabel('Field strength [V/m]'), title('E_x')
ax2 = subplot(3,3,4); plot(time, fields.ey(:,n), 'r', 'LineWidth', 2), grid on, xlabel('Time [ns]'), ylabel('Field strength [V/m]'), title('E_y')
ax3 = subplot(3,3,7); plot(time, fields.ez(:,n), 'r', 'LineWidth', 2), grid on, xlabel('Time [ns]'), ylabel('Field strength [V/m]'), title('E_z')
ax4 = subplot(3,3,2); plot(time, fields.hx(:,n), 'b', 'LineWidth', 2), grid on, xlabel('Time [ns]'), ylabel('Field strength [A/m]'), title('H_x')
ax5 = subplot(3,3,5); plot(time, fields.hy(:,n), 'b', 'LineWidth', 2), grid on, xlabel('Time [ns]'), ylabel('Field strength [A/m]'), title('H_y')
ax6 = subplot(3,3,8); plot(time, fields.hz(:,n), 'b', 'LineWidth', 2), grid on, xlabel('Time [ns]'), ylabel('Field strength [A/m]'), title('H_z')
ax7 = subplot(3,3,3); plot(time, fields.ix(:,n), 'g', 'LineWidth', 2), grid on, xlabel('Time [ns]'), ylabel('Current [A]'), title('I_x')
ax8 = subplot(3,3,6); plot(time, fields.iy(:,n), 'g', 'LineWidth', 2), grid on, xlabel('Time [ns]'), ylabel('Current [A]'), title('I_y')
ax9 = subplot(3,3,9); plot(time, fields.iz(:,n), 'g', 'LineWidth', 2), grid on, xlabel('Time [ns]'), ylabel('Current [A]'), title('I_z')
ax1.FontSize = 16;
ax2.FontSize = ax1.FontSize;
ax3.FontSize = ax1.FontSize;
ax4.FontSize = ax1.FontSize;
ax5.FontSize = ax1.FontSize;
ax6.FontSize = ax1.FontSize;
ax7.FontSize = ax1.FontSize;
ax8.FontSize = ax1.FontSize;
ax9.FontSize = ax1.FontSize;
ax(1) = subplot(3,2,1); plot(time, fields.ex(:,n), 'r', 'LineWidth', 2), grid on, xlabel('Time [ns]'), ylabel('Field strength [V/m]'), title('E_x')
ax(2) = subplot(3,2,3); plot(time, fields.ey(:,n), 'r', 'LineWidth', 2), grid on, xlabel('Time [ns]'), ylabel('Field strength [V/m]'), title('E_y')
ax(3) = subplot(3,2,5); plot(time, fields.ez(:,n), 'r', 'LineWidth', 2), grid on, xlabel('Time [ns]'), ylabel('Field strength [V/m]'), title('E_z')
ax(4) = subplot(3,2,2); plot(time, fields.hx(:,n), 'b', 'LineWidth', 2), grid on, xlabel('Time [ns]'), ylabel('Field strength [A/m]'), title('H_x')
ax(5) = subplot(3,2,4); plot(time, fields.hy(:,n), 'b', 'LineWidth', 2), grid on, xlabel('Time [ns]'), ylabel('Field strength [A/m]'), title('H_y')
ax(6) = subplot(3,2,6); plot(time, fields.hz(:,n), 'b', 'LineWidth', 2), grid on, xlabel('Time [ns]'), ylabel('Field strength [A/m]'), title('H_z')
set(ax,'FontSize', 16, 'xlim', [0 time(end)]);
% Options to create a nice looking figure for display and printing
set(fh1,'Color','white','Menubar','none');

查看文件

@@ -29,7 +29,7 @@ from gprMax.exceptions import CmdInputError
from gprMax.receivers import Rx
def mpl_plot(filename, outputs=Rx.availableoutputs, fft=False):
def mpl_plot(filename, outputs=Rx.defaultoutputs, fft=False):
"""Plots electric and magnetic fields and currents from all receiver points in the given output file. Each receiver point is plotted in a new figure window.
Args:
@@ -121,12 +121,12 @@ def mpl_plot(filename, outputs=Rx.availableoutputs, 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,14 +141,14 @@ def mpl_plot(filename, outputs=Rx.availableoutputs, 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, 3, hspace=0.3, wspace=0.3)
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
@@ -196,25 +196,25 @@ def mpl_plot(filename, outputs=Rx.availableoutputs, 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()
# Save a PDF/PNG of the figure
#fig.savefig(os.path.splitext(os.path.abspath(filename))[0] + '_rx' + str(rx) + '.pdf', dpi=None, format='pdf', bbox_inches='tight', pad_inches=0.1)
#fig.savefig(os.path.splitext(os.path.abspath(filename))[0] + '_rx' + str(rx) + '.png', dpi=150, format='png', bbox_inches='tight', pad_inches=0.1)
# fig.savefig(os.path.splitext(os.path.abspath(filename))[0] + '_rx' + str(rx) + '.pdf', dpi=None, format='pdf', bbox_inches='tight', pad_inches=0.1)
# fig.savefig(os.path.splitext(os.path.abspath(filename))[0] + '_rx' + str(rx) + '.png', dpi=150, format='png', bbox_inches='tight', pad_inches=0.1)
return plt