From c1bff26ce8af30e0c0f321ab28a75644cf324166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98ystein=20Bj=C3=B8rndal?= Date: Wed, 25 Jan 2017 13:24:08 +0100 Subject: [PATCH] user-friendly exception message when using polarization in rx and not passing in dxdy --- gprMax/input_cmd_funcs.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gprMax/input_cmd_funcs.py b/gprMax/input_cmd_funcs.py index 21f9aec8..c7419735 100644 --- a/gprMax/input_cmd_funcs.py +++ b/gprMax/input_cmd_funcs.py @@ -16,6 +16,7 @@ # You should have received a copy of the GNU General Public License # along with gprMax. If not, see . +import sys from collections import namedtuple """This module contains functional forms of some of the most commonly used gprMax commands. It can be useful to use these within Python scripting in an input file. @@ -613,11 +614,18 @@ def rx(x, y, z, identifier=None, to_save=None, polarisation=None, dxdy=None, rot if rotate90origin: if polarisation == 'x': - xf = x + dxdy[0] + try: + xf = x + dxdy[0] + except Exception as e: + raise ValueError('With polarization = x, a dxdy[0] float values is required, got dxdy=%s' % dxdy) from e yf = y elif polarisation == 'y': xf = x - yf = y + dxdy[1] + try: + yf = y + dxdy[1] + except Exception as e: + raise ValueError('With polarization = y, a dxdy[1] float values is required, got dxdy=%s' % dxdy) from e + x, y, xf, yf = rotate90_edge(x, y, xf, yf, polarisation, rotate90origin) c = Coordinate(x, y, z) @@ -659,3 +667,4 @@ def rx_steps(dx=0, dy=0, dz=0): c = Coordinate(dx, dy, dz) command('rx_steps', str(c)) return c +