From d2febd4222903761094d58edc023c9c1b55e195d Mon Sep 17 00:00:00 2001 From: Anne Philipp <anne.philipp@univie.ac.at> Date: Fri, 7 Dec 2018 16:28:01 +0100 Subject: [PATCH] fixed grid area check for negative values --- source/python/mods/checks.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/source/python/mods/checks.py b/source/python/mods/checks.py index d0f9498..787047d 100644 --- a/source/python/mods/checks.py +++ b/source/python/mods/checks.py @@ -68,19 +68,19 @@ def check_area(grid, area, upper, lower, left , right): upper, left, lower, right = components # determine area format - if (float(upper) / 1000. >= 0.05 and - float(lower) / 1000. >= 0.05 and - float(left) / 1000. >= 0.05 and - float(right) / 1000. >= 0.05): + if (abs(float(upper) / 1000.) >= 0.05 and + abs(float(lower) / 1000.) >= 0.05 and + abs(float(left) / 1000.) >= 0.05 and + abs(float(right) / 1000.) >= 0.05): # area is defined in 1/1000 degrees; old format area = '{}/{}/{}/{}'.format(float(upper) / 1000., float(left) / 1000., float(lower) / 1000., float(right) / 1000.) - elif (float(upper) / 1000. < 0.05 and - float(lower) / 1000. < 0.05 and - float(left) / 1000. < 0.05 and - float(right) / 1000. < 0.05): + elif (abs(float(upper) / 1000.) < 0.05 and + abs(float(lower) / 1000.) < 0.05 and + abs(float(left) / 1000.) < 0.05 and + abs(float(right) / 1000.) < 0.05): # area is already in new format area = '{}/{}/{}/{}'.format(float(upper), float(left), @@ -88,7 +88,9 @@ def check_area(grid, area, upper, lower, left , right): float(right)) else: raise ValueError('The area components have different ' - 'formats: %s ' (area)) + 'formats (upper, lower, left, right): ' + '{}/{}/{}/{}'.format(str(upper), str(lower), + str(left) , str(right))) return area @@ -152,7 +154,6 @@ def check_ppid(c, ppid): return - def check_(): ''' -- GitLab