From 502dd2351ec036259b712ab47d3920bcc98e11df Mon Sep 17 00:00:00 2001 From: craig-warren Date: Mon, 18 Jan 2016 21:32:18 +0000 Subject: [PATCH] Corrected regression in plotting of a B-scan module, and in corresponding docs. --- docs/source/examples_simple_2D.rst | 10 +++++----- tools/plot_Bscan.py | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/source/examples_simple_2D.rst b/docs/source/examples_simple_2D.rst index af58f4f4..d5305a8f 100644 --- a/docs/source/examples_simple_2D.rst +++ b/docs/source/examples_simple_2D.rst @@ -110,7 +110,7 @@ You can now run the model: .. code-block:: none - python -m gprMax cylinder_Ascan_2D.in + python -m gprMax user_models/cylinder_Ascan_2D.in View the results ---------------- @@ -119,7 +119,7 @@ You should have produced an output file ``cylinder_Ascan_2D.out``. You can view .. code-block:: none - python -m tools.plot_Ascan cylinder_Ascan_2D.out + python -m tools.plot_Ascan user_models/cylinder_Ascan_2D.out :numref:`cylinder_Ascan_results` shows the time history of the electric and magnetic field components and currents at the receiver location. The :math:`E_z` field component can be converted to voltage which represents the A-scan (trace). The initial part of the signal (<1.5 ns) represents the direct wave from transmitter to receiver. Then comes the reflected wavelet from the metal cylinder. @@ -148,7 +148,7 @@ To run the model for a B-scan is slightly different than for a single A-scan. Yo .. code-block:: none - python -m gprMax cylinder_Bscan_2D.in -n 60 + python -m gprMax user_models/cylinder_Bscan_2D.in -n 60 Results @@ -158,7 +158,7 @@ You should have produced 60 output files, one for each A-scan, with names ``cyli .. code-block:: none - python -m tools.outputfiles_merge cylinder_Bscan_2D 60 + python -m tools.outputfiles_merge user_models/cylinder_Bscan_2D 60 You should see a combined output file ``cylinder_Bscan_2D_all.out``. The tool will ask you if you want to delete the original single A-scan output files or keep them. @@ -166,7 +166,7 @@ You can now view an image of the B-scan using the command: .. code-block:: none - python -m tools.plot_Bscan cylinder_Bscan_2D_all.out --field Ez + python -m tools.plot_Bscan user_models/cylinder_Bscan_2D_all.out Ez :numref:`cylinder_Bscan_results` shows the B-scan (image of the :math:`E_z` field component). As expected a hyperbolic response is present from the metal cylinder. diff --git a/tools/plot_Bscan.py b/tools/plot_Bscan.py index 82db3440..b3f8bc42 100644 --- a/tools/plot_Bscan.py +++ b/tools/plot_Bscan.py @@ -26,22 +26,21 @@ from gprMax.exceptions import CmdInputError """Plots a B-scan image.""" # Parse command line arguments -parser = argparse.ArgumentParser(description='Plots a B-scan image.', usage='cd gprMax; python -m tools.plot_Bscan outputfile --field fieldcomponent') +parser = argparse.ArgumentParser(description='Plots a B-scan image.', usage='cd gprMax; python -m tools.plot_Bscan outputfile output') parser.add_argument('outputfile', help='name of output file including path') -parser.add_argument('--output', help='name of output to be plotted, i.e. Ex Ey Ez') +parser.add_argument('output', help='name of output to be plotted, i.e. Ex Ey Ez') args = parser.parse_args() # Open output file and read some attributes f = h5py.File(args.outputfile, 'r') path = '/rxs/rx1' availablecomponents = list(f[path].keys()) - + # Check if requested output is in file -if args.output[0] not in availablecomponents: - raise CmdInputError('{} output requested to plot, but the available output for receiver 1 is {}'.format(args.outputs[0], ', '.join(availablecomponents))) +if args.output not in availablecomponents: + raise CmdInputError('{} output requested to plot, but the available output for receiver 1 is {}'.format(args.output, ', '.join(availablecomponents))) outputdata = f[path + '/' + args.output] -f.close() # Check that there is more than one A-scan present if outputdata.shape[1] == 1: @@ -61,9 +60,10 @@ elif 'H' in args.output: elif 'I' in args.output: cb.set_label('Current [A]') -plt.show() - # Save a PDF/PNG of the figure #fig.savefig(os.path.splitext(os.path.abspath(file))[0] + '.pdf', dpi=None, format='pdf', bbox_inches='tight', pad_inches=0.1) #fig.savefig(os.path.splitext(os.path.abspath(file))[0] + '.png', dpi=150, format='png', bbox_inches='tight', pad_inches=0.1) +plt.show() +f.close() +