[GRASS-SVN] r61553 - in grass-addons/grass7/raster3d/r3.gradient: . data testsuite
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Aug 6 12:15:24 PDT 2014
Author: annakrat
Date: 2014-08-06 12:15:24 -0700 (Wed, 06 Aug 2014)
New Revision: 61553
Added:
grass-addons/grass7/raster3d/r3.gradient/data/
grass-addons/grass7/raster3d/r3.gradient/data/test_map_1
grass-addons/grass7/raster3d/r3.gradient/testsuite/
grass-addons/grass7/raster3d/r3.gradient/testsuite/r3gradient_test.py
Modified:
grass-addons/grass7/raster3d/r3.gradient/main.c
Log:
r3.gradient: added testsuite
Added: grass-addons/grass7/raster3d/r3.gradient/data/test_map_1
===================================================================
--- grass-addons/grass7/raster3d/r3.gradient/data/test_map_1 (rev 0)
+++ grass-addons/grass7/raster3d/r3.gradient/data/test_map_1 2014-08-06 19:15:24 UTC (rev 61553)
@@ -0,0 +1,61 @@
+version: grass7
+order: nsbt
+north: 100.000000
+south: 0.000000
+east: 120.000000
+west: 0.000000
+top: 50.000000
+bottom: 0.000000
+rows: 10
+cols: 12
+levels: 5
+1.73205081 2.44948974 3.31662479 4.24264069 5.19615242 6.16441400 7.14142843 8.12403840 9.11043358 10.09950494 11.09053651 12.08304597
+2.44948974 3.00000000 3.74165739 4.58257569 5.47722558 6.40312424 7.34846923 8.30662386 9.27361850 10.24695077 11.22497216 12.20655562
+3.31662479 3.74165739 4.35889894 5.09901951 5.91607978 6.78232998 7.68114575 8.60232527 9.53939201 10.48808848 11.44552314 12.40967365
+4.24264069 4.58257569 5.09901951 5.74456265 6.48074070 7.28010989 8.12403840 9.00000000 9.89949494 10.81665383 11.74734012 12.68857754
+5.19615242 5.47722558 5.91607978 6.48074070 7.14142843 7.87400787 8.66025404 9.48683298 10.34408043 11.22497216 12.12435565 13.03840481
+6.16441400 6.40312424 6.78232998 7.28010989 7.87400787 8.54400375 9.27361850 10.04987562 10.86278049 11.70469991 12.56980509 13.45362405
+7.14142843 7.34846923 7.68114575 8.12403840 8.66025404 9.27361850 9.94987437 10.67707825 11.44552314 12.24744871 13.07669683 13.92838828
+8.12403840 8.30662386 8.60232527 9.00000000 9.48683298 10.04987562 10.67707825 11.35781669 12.08304597 12.84523258 13.63818170 14.45683229
+9.11043358 9.27361850 9.53939201 9.89949494 10.34408043 10.86278049 11.44552314 12.08304597 12.76714533 13.49073756 14.24780685 15.03329638
+10.09950494 10.24695077 10.48808848 10.81665383 11.22497216 11.70469991 12.24744871 12.84523258 13.49073756 14.17744688 14.89966443 15.65247584
+2.44948974 3.00000000 3.74165739 4.58257569 5.47722558 6.40312424 7.34846923 8.30662386 9.27361850 10.24695077 11.22497216 12.20655562
+3.00000000 3.46410162 4.12310563 4.89897949 5.74456265 6.63324958 7.54983444 8.48528137 9.43398113 10.39230485 11.35781669 12.32882801
+3.74165739 4.12310563 4.69041576 5.38516481 6.16441400 7.00000000 7.87400787 8.77496439 9.69535971 10.63014581 11.57583690 12.52996409
+4.58257569 4.89897949 5.38516481 6.00000000 6.70820393 7.48331477 8.30662386 9.16515139 10.04987562 10.95445115 11.87434209 12.80624847
+5.47722558 5.74456265 6.16441400 6.70820393 7.34846923 8.06225775 8.83176087 9.64365076 10.48808848 11.35781669 12.24744871 13.15294644
+6.40312424 6.63324958 7.00000000 7.48331477 8.06225775 8.71779789 9.43398113 10.19803903 11.00000000 11.83215957 12.68857754 13.56465997
+7.34846923 7.54983444 7.87400787 8.30662386 8.83176087 9.43398113 10.09950494 10.81665383 11.57583690 12.36931688 13.19090596 14.03566885
+8.30662386 8.48528137 8.77496439 9.16515139 9.64365076 10.19803903 10.81665383 11.48912529 12.20655562 12.96148140 13.74772708 14.56021978
+9.27361850 9.43398113 9.69535971 10.04987562 10.48808848 11.00000000 11.57583690 12.20655562 12.88409873 13.60147051 14.35270009 15.13274595
+10.24695077 10.39230485 10.63014581 10.95445115 11.35781669 11.83215957 12.36931688 12.96148140 13.60147051 14.28285686 15.00000000 15.74801575
+3.31662479 3.74165739 4.35889894 5.09901951 5.91607978 6.78232998 7.68114575 8.60232527 9.53939201 10.48808848 11.44552314 12.40967365
+3.74165739 4.12310563 4.69041576 5.38516481 6.16441400 7.00000000 7.87400787 8.77496439 9.69535971 10.63014581 11.57583690 12.52996409
+4.35889894 4.69041576 5.19615242 5.83095189 6.55743852 7.34846923 8.18535277 9.05538514 9.94987437 10.86278049 11.78982612 12.72792206
+5.09901951 5.38516481 5.83095189 6.40312424 7.07106781 7.81024968 8.60232527 9.43398113 10.29563014 11.18033989 12.08304597 13.00000000
+5.91607978 6.16441400 6.55743852 7.07106781 7.68114575 8.36660027 9.11043358 9.89949494 10.72380529 11.57583690 12.44989960 13.34166406
+6.78232998 7.00000000 7.34846923 7.81024968 8.36660027 9.00000000 9.69535971 10.44030651 11.22497216 12.04159458 12.88409873 13.74772708
+7.68114575 7.87400787 8.18535277 8.60232527 9.11043358 9.69535971 10.34408043 11.04536102 11.78982612 12.56980509 13.37908816 14.21267040
+8.60232527 8.77496439 9.05538514 9.43398113 9.89949494 10.44030651 11.04536102 11.70469991 12.40967365 13.15294644 13.92838828 14.73091986
+9.53939201 9.69535971 9.94987437 10.29563014 10.72380529 11.22497216 11.78982612 12.40967365 13.07669683 13.78404875 14.52583905 15.29705854
+10.48808848 10.63014581 10.86278049 11.18033989 11.57583690 12.04159458 12.56980509 13.15294644 13.78404875 14.45683229 15.16575089 15.90597372
+4.24264069 4.58257569 5.09901951 5.74456265 6.48074070 7.28010989 8.12403840 9.00000000 9.89949494 10.81665383 11.74734012 12.68857754
+4.58257569 4.89897949 5.38516481 6.00000000 6.70820393 7.48331477 8.30662386 9.16515139 10.04987562 10.95445115 11.87434209 12.80624847
+5.09901951 5.38516481 5.83095189 6.40312424 7.07106781 7.81024968 8.60232527 9.43398113 10.29563014 11.18033989 12.08304597 13.00000000
+5.74456265 6.00000000 6.40312424 6.92820323 7.54983444 8.24621125 9.00000000 9.79795897 10.63014581 11.48912529 12.36931688 13.26649916
+6.48074070 6.70820393 7.07106781 7.54983444 8.12403840 8.77496439 9.48683298 10.24695077 11.04536102 11.87434209 12.72792206 13.60147051
+7.28010989 7.48331477 7.81024968 8.24621125 8.77496439 9.38083152 10.04987562 10.77032961 11.53256259 12.32882801 13.15294644 14.00000000
+8.12403840 8.30662386 8.60232527 9.00000000 9.48683298 10.04987562 10.67707825 11.35781669 12.08304597 12.84523258 13.63818170 14.45683229
+9.00000000 9.16515139 9.43398113 9.79795897 10.24695077 10.77032961 11.35781669 12.00000000 12.68857754 13.41640786 14.17744688 14.96662955
+9.89949494 10.04987562 10.29563014 10.63014581 11.04536102 11.53256259 12.08304597 12.68857754 13.34166406 14.03566885 14.76482306 15.52417470
+10.81665383 10.95445115 11.18033989 11.48912529 11.87434209 12.32882801 12.84523258 13.41640786 14.03566885 14.69693846 15.39480432 16.12451550
+5.19615242 5.47722558 5.91607978 6.48074070 7.14142843 7.87400787 8.66025404 9.48683298 10.34408043 11.22497216 12.12435565 13.03840481
+5.47722558 5.74456265 6.16441400 6.70820393 7.34846923 8.06225775 8.83176087 9.64365076 10.48808848 11.35781669 12.24744871 13.15294644
+5.91607978 6.16441400 6.55743852 7.07106781 7.68114575 8.36660027 9.11043358 9.89949494 10.72380529 11.57583690 12.44989960 13.34166406
+6.48074070 6.70820393 7.07106781 7.54983444 8.12403840 8.77496439 9.48683298 10.24695077 11.04536102 11.87434209 12.72792206 13.60147051
+7.14142843 7.34846923 7.68114575 8.12403840 8.66025404 9.27361850 9.94987437 10.67707825 11.44552314 12.24744871 13.07669683 13.92838828
+7.87400787 8.06225775 8.36660027 8.77496439 9.27361850 9.84885780 10.48808848 11.18033989 11.91637529 12.68857754 13.49073756 14.31782106
+8.66025404 8.83176087 9.11043358 9.48683298 9.94987437 10.48808848 11.09053651 11.74734012 12.44989960 13.19090596 13.96424004 14.76482306
+9.48683298 9.64365076 9.89949494 10.24695077 10.67707825 11.18033989 11.74734012 12.36931688 13.03840481 13.74772708 14.49137675 15.26433752
+10.34408043 10.48808848 10.72380529 11.04536102 11.44552314 11.91637529 12.44989960 13.03840481 13.67479433 14.35270009 15.06651917 15.81138830
+11.22497216 11.35781669 11.57583690 11.87434209 12.24744871 12.68857754 13.19090596 13.74772708 14.35270009 15.00000000 15.68438714 16.40121947
Modified: grass-addons/grass7/raster3d/r3.gradient/main.c
===================================================================
--- grass-addons/grass7/raster3d/r3.gradient/main.c 2014-08-06 15:51:00 UTC (rev 61552)
+++ grass-addons/grass7/raster3d/r3.gradient/main.c 2014-08-06 19:15:24 UTC (rev 61553)
@@ -55,6 +55,7 @@
/* TODO: define G_OPT_R3_OUTPUTS or use separate options for each map? */
output_opt = G_define_standard_option(G_OPT_R3_OUTPUT);
output_opt->multiple = YES;
+ output_opt->key_desc = "grad_x,grad_y,grad_z";
output_opt->description = _("Name for output 3D raster map(s)");
block_opt = G_define_option();
Added: grass-addons/grass7/raster3d/r3.gradient/testsuite/r3gradient_test.py
===================================================================
--- grass-addons/grass7/raster3d/r3.gradient/testsuite/r3gradient_test.py (rev 0)
+++ grass-addons/grass7/raster3d/r3.gradient/testsuite/r3gradient_test.py 2014-08-06 19:15:24 UTC (rev 61553)
@@ -0,0 +1,102 @@
+# -*- coding: utf-8 -*-
+"""
+Test of r3.gradient
+
+ at author Anna Petrasova
+"""
+from grass.gunittest import TestCase, test
+
+
+r3univar_test_grad_x = """
+n=600
+null_cells=0
+cells=600
+min=0.00902566899999995
+max=0.0993248405000001
+range=0.0902991715000001
+mean=0.0641879624599999
+mean_of_abs=0.0641879624599999
+stddev=0.0243482677445681
+variance=0.000592838142161176
+coeff_var=37.9327631091908
+sum=38.512777476
+"""
+
+
+r3univar_test_grad_y = """
+n=600
+null_cells=0
+cells=600
+min=-0.0990409449999998
+max=-0.00774536350000012
+range=0.0912955814999997
+mean=-0.0563959154616667
+mean_of_abs=0.0563959154616667
+stddev=0.0244377519801364
+variance=0.000597203721842658
+coeff_var=-43.3324856597942
+sum=-33.837549277"""
+
+
+r3univar_test_grad_z = """
+n=600
+null_cells=0
+cells=600
+min=0.00643308800000026
+max=0.0967259644999999
+range=0.0902928764999997
+mean=0.0336457494116667
+mean_of_abs=0.0336457494116667
+stddev=0.0186882020765464
+variance=0.000349248896853835
+coeff_var=55.5440208743464
+sum=20.187449647
+"""
+
+
+class GradientTest(TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ """Use temporary region settings"""
+ cls.use_temp_region()
+ cls.runModule('g.region', res3=10, n=100, s=0, w=0, e=120, b=0, t=50)
+ cls.runModule('r3.in.ascii', input='data/test_map_1', output='test_map_1_ref', overwrite=True)
+
+ @classmethod
+ def tearDownClass(cls):
+ """!Remove the temporary region"""
+ cls.del_temp_region()
+ cls.runModule('g.remove', rast3d=['test_map_1_ref', 'test_grad_x',
+ 'test_grad_y', 'test_grad_z'])
+
+ def test_gradient_runs(self):
+ self.assertModuleFail('r3.gradient', input='test_map_1_ref',
+ output=['test_grad_x', 'test_grad_y'], overwrite=True)
+ self.assertModule('r3.gradient', input='test_map_1_ref',
+ output=['test_grad_x', 'test_grad_y', 'test_grad_z'], overwrite=True)
+
+ def test_gradient(self):
+ self.runModule('r3.gradient', input='test_map_1_ref',
+ output=['test_grad_x', 'test_grad_y', 'test_grad_z'], overwrite=True)
+ self.assertRaster3dFitsUnivar(raster='test_grad_x', reference=r3univar_test_grad_x, precision=1e-8)
+ self.assertRaster3dFitsUnivar(raster='test_grad_y', reference=r3univar_test_grad_y, precision=1e-8)
+ self.assertRaster3dFitsUnivar(raster='test_grad_z', reference=r3univar_test_grad_z, precision=1e-8)
+
+ def test_gradient_block(self):
+ self.assertModule('r3.gradient', input='test_map_1_ref', block_size=[200, 2, 50],
+ output=['test_grad_x', 'test_grad_y', 'test_grad_z'], overwrite=True)
+ self.assertRaster3dFitsUnivar(raster='test_grad_x', reference=r3univar_test_grad_x, precision=1e-8)
+ self.assertRaster3dFitsUnivar(raster='test_grad_y', reference=r3univar_test_grad_y, precision=1e-8)
+ self.assertRaster3dFitsUnivar(raster='test_grad_z', reference=r3univar_test_grad_z, precision=1e-8)
+
+ def test_gradient_procs(self):
+ self.assertModule('r3.gradient', input='test_map_1_ref', block_size=[200, 2, 50], nprocs=3,
+ output=['test_grad_x', 'test_grad_y', 'test_grad_z'], overwrite=True)
+ self.assertRaster3dFitsUnivar(raster='test_grad_x', reference=r3univar_test_grad_x, precision=1e-8)
+ self.assertRaster3dFitsUnivar(raster='test_grad_y', reference=r3univar_test_grad_y, precision=1e-8)
+ self.assertRaster3dFitsUnivar(raster='test_grad_z', reference=r3univar_test_grad_z, precision=1e-8)
+
+
+if __name__ == '__main__':
+ test()
Property changes on: grass-addons/grass7/raster3d/r3.gradient/testsuite/r3gradient_test.py
___________________________________________________________________
Added: svn:mime-type
+ text/x-python
Added: svn:eol-style
+ native
More information about the grass-commit
mailing list