From 09154edcbf46f2c68f0f68482b2d7613193fa0dc Mon Sep 17 00:00:00 2001 From: Craig Warren Date: Mon, 22 Feb 2016 10:49:10 +0000 Subject: [PATCH] Corrected bug with looking for excitation file in same directory as input file. --- docs/source/input.rst | 2 +- gprMax/input_cmds_singleuse.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/source/input.rst b/docs/source/input.rst index 3d6d613d..3b3a0524 100644 --- a/docs/source/input.rst +++ b/docs/source/input.rst @@ -666,7 +666,7 @@ If there are less amplitude values than the number of iterations that are going #excitation_file: file1 -``str1`` is the name of the ASCII file containing the specified waveform. It should be located in the same directory as the input file. +``str1`` is the name (and optionally full path) of the ASCII file containing the specified waveform. ``str1`` will first be tested as the full path to the file, and if it does not exist it will look for ``str1`` in the same directory as the input file. For example, to specify the file ``my_waves.txt``, which contains two custom waveform shapes, use: ``#excitation_file: my_waves.txt``. The contents of the file ``my_waves.txt`` would take the form: diff --git a/gprMax/input_cmds_singleuse.py b/gprMax/input_cmds_singleuse.py index 250a6932..01e5d373 100644 --- a/gprMax/input_cmds_singleuse.py +++ b/gprMax/input_cmds_singleuse.py @@ -221,7 +221,11 @@ def process_singlecmds(singlecmds, multicmds, G): raise CmdInputError(cmd + ' requires exactly one parameter') excitationfile = tmp[0] - # Open file and get waveform names + # See if file exists at specified path and if not try input file directory + if not os.path.isfile(excitationfile): + excitationfile = os.path.join(G.inputdirectory, excitationfile) + + # Get waveform names with open(excitationfile, 'r') as f: waveformIDs = f.readline().split()