[GRASS-SVN] r61204 - in grass/trunk/raster/r.slope.aspect: . testsuite testsuite/data

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jul 8 20:01:47 PDT 2014


Author: wenzeslaus
Date: 2014-07-08 20:01:47 -0700 (Tue, 08 Jul 2014)
New Revision: 61204

Added:
   grass/trunk/raster/r.slope.aspect/testsuite/
   grass/trunk/raster/r.slope.aspect/testsuite/data/
   grass/trunk/raster/r.slope.aspect/testsuite/data/fractal_surf.ascii
   grass/trunk/raster/r.slope.aspect/testsuite/data/gdal_aspect.grd
   grass/trunk/raster/r.slope.aspect/testsuite/data/gdal_aspect.grd.aux.xml
   grass/trunk/raster/r.slope.aspect/testsuite/data/gdal_slope.grd
   grass/trunk/raster/r.slope.aspect/testsuite/data/gdal_slope.grd.aux.xml
   grass/trunk/raster/r.slope.aspect/testsuite/test_r_slope_aspect.py
Log:
testing: add tests of slope and aspect to r.slope.aspect

Added: grass/trunk/raster/r.slope.aspect/testsuite/data/fractal_surf.ascii
===================================================================
--- grass/trunk/raster/r.slope.aspect/testsuite/data/fractal_surf.ascii	                        (rev 0)
+++ grass/trunk/raster/r.slope.aspect/testsuite/data/fractal_surf.ascii	2014-07-09 03:01:47 UTC (rev 61204)
@@ -0,0 +1,16 @@
+north: 20
+south: 10
+east: 25
+west: 15
+rows: 10
+cols: 10
+18042.0449657581812062 25383.8864299957058392 14054.8876733628094371 9718.6028777712708688 6811.412182415643656 2930.9162473829337614 -2117.0534472693707357 -3110.9860095434078175 4306.5996776199253873 987.4507122526649709 
+10168.7073320247400261 9977.3079539500449755 5446.1555224152061783 4481.6517453232163462 1848.8039189165833704 -1700.797216407640235 -1544.4356998912949166 5619.2167452912372028 166.5044979636321045 2281.682802785037893 
+3177.1414551946154461 -1491.910636019688809 -522.2980383497083494 -7733.1639587946547181 -9407.8445629291018122 -5840.1778570036331075 736.7154505421329986 6800.3416513099646181 -931.3345534823686194 -5463.0700545775525825 
+10109.0777441430691397 913.7987579666439615 -2463.2252033934960309 -14508.6051479571506206 -20888.966440910462552 -14497.8998969001877413 -10522.8316460882324463 -816.1074612102775063 3359.0009318826023446 1090.6260443768023833 
+8603.3056905043868028 4831.7340326208714032 -3556.3140177522709564 -8175.5341846188184718 -18357.2730383907437499 -18661.3149188292372855 -14409.728317302373398 -7102.8287566742747003 1779.425264984356545 3837.2560983032271906 
+3627.8840285699184278 -133.8571474710850566 -3452.0622719314178539 -8000.7487283949603807 -16672.8438014870589541 -18038.9599507521306805 -17202.0380336391281162 -8919.2834336959240318 -5346.6450827091866813 -1954.214336749309723 
+873.3209737757239282 -3346.9982385845969475 -11470.5463756023364112 -13199.9832339778495225 -14721.2637378373001411 -16224.3487699516826979 -19522.6366976581812196 -13069.7222692795330659 -9759.9528482313853601 -9054.4029620675919432 
+292.2682278056205973 -3794.3364980614819615 -11426.0054321001316566 -16664.9545810654999514 -23409.7229947478008398 -27173.6223750138269679 -21000.9338307948601141 -8467.5305864940492029 -3463.9662640234532773 -4937.8907319630416168 
+-5159.7969122775912183 -5883.0143716484344623 -4182.0455386342391648 -9149.4519877815255313 -28860.9848558809571841 -24850.2964268596515467 -18894.4634812169642828 -7910.7308709206999993 -2709.5147474691702882 1055.4081442089825487 
+-1721.3017714211916882 -3815.394704173491391 721.3503318535069866 -4283.5534905015056211 -19226.051844524248736 -18363.9268685237584577 -12999.7725237885060778 -12001.7549241148735746 -4098.3666298110829302 5166.4987688895371321

Added: grass/trunk/raster/r.slope.aspect/testsuite/data/gdal_aspect.grd
===================================================================
--- grass/trunk/raster/r.slope.aspect/testsuite/data/gdal_aspect.grd	                        (rev 0)
+++ grass/trunk/raster/r.slope.aspect/testsuite/data/gdal_aspect.grd	2014-07-09 03:01:47 UTC (rev 61204)
@@ -0,0 +1,25 @@
+DSAA
+10 10
+15.5 24.5
+10.5 19.5
+1.3795901536942 359.78637695312
+1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 
+
+1.70141E+38 54.044281005859 61.536731719971 26.817855834961 27.830316543579 133.78686523438 160.15232849121 179.70936584473 172.18589782715 1.70141E+38 
+
+1.70141E+38 353.74163818359 22.493587493896 1.3795901536942 320.41970825195 252.02178955078 182.20143127441 163.56805419922 124.30812072754 1.70141E+38 
+
+1.70141E+38 336.80844116211 325.04400634766 314.70040893555 310.37930297852 285.00897216797 205.49880981445 181.18598937988 176.19082641602 1.70141E+38 
+
+1.70141E+38 320.38543701172 323.04837036133 342.1510925293 7.9401998519897 60.624557495117 202.65769958496 209.92497253418 235.44174194336 1.70141E+38 
+
+1.70141E+38 347.72735595703 4.0403199195862 14.852857589722 20.189586639404 208.29371643066 208.56834411621 208.52819824219 222.8828125 1.70141E+38 
+
+1.70141E+38 20.142166137695 359.78637695312 347.99960327148 285.37921142578 235.00204467773 227.87588500977 223.58207702637 161.80085754395 1.70141E+38 
+
+1.70141E+38 313.41848754883 307.28234863281 300.10757446289 271.76864624023 244.55999755859 218.78259277344 236.69653320312 357.2619934082 1.70141E+38 
+
+1.70141E+38 281.6360168457 294.11804199219 289.54504394531 286.39514160156 280.21655273438 162.12962341309 115.12343597412 334.69934082031 1.70141E+38 
+
+1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 
+

Added: grass/trunk/raster/r.slope.aspect/testsuite/data/gdal_aspect.grd.aux.xml
===================================================================
--- grass/trunk/raster/r.slope.aspect/testsuite/data/gdal_aspect.grd.aux.xml	                        (rev 0)
+++ grass/trunk/raster/r.slope.aspect/testsuite/data/gdal_aspect.grd.aux.xml	2014-07-09 03:01:47 UTC (rev 61204)
@@ -0,0 +1,5 @@
+<PAMDataset>
+  <PAMRasterBand band="1">
+    <NoDataValue>-9.99900000000000E+03</NoDataValue>
+  </PAMRasterBand>
+</PAMDataset>


Property changes on: grass/trunk/raster/r.slope.aspect/testsuite/data/gdal_aspect.grd.aux.xml
___________________________________________________________________
Added: svn:mime-type
   + text/xml
Added: svn:eol-style
   + native

Added: grass/trunk/raster/r.slope.aspect/testsuite/data/gdal_slope.grd
===================================================================
--- grass/trunk/raster/r.slope.aspect/testsuite/data/gdal_slope.grd	                        (rev 0)
+++ grass/trunk/raster/r.slope.aspect/testsuite/data/gdal_slope.grd	2014-07-09 03:01:47 UTC (rev 61204)
@@ -0,0 +1,25 @@
+DSAA
+10 10
+15.5 24.5
+10.5 19.5
+89.825134277344 89.994964599609
+1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 
+
+1.70141E+38 89.963233947754 89.98900604248 89.994964599609 89.99275970459 89.988899230957 89.992683410645 89.992202758789 89.988243103027 1.70141E+38 
+
+1.70141E+38 89.986907958984 89.989105224609 89.991172790527 89.991111755371 89.985824584961 89.992034912109 89.992797851562 89.987106323242 1.70141E+38 
+
+1.70141E+38 89.990310668945 89.990707397461 89.98983001709 89.988838195801 89.98462677002 89.98787689209 89.990631103516 89.975311279297 1.70141E+38 
+
+1.70141E+38 89.990867614746 89.990509033203 89.990196228027 89.986480712891 89.882415771484 89.987167358398 89.992004394531 89.990997314453 1.70141E+38 
+
+1.70141E+38 89.989814758301 89.99072265625 89.992767333984 89.986122131348 89.977241516113 89.991233825684 89.993072509766 89.989074707031 1.70141E+38 
+
+1.70141E+38 89.989501953125 89.990852355957 89.99259185791 89.985816955566 89.992454528809 89.994033813477 89.992149353027 89.825134277344 1.70141E+38 
+
+1.70141E+38 89.987243652344 89.991683959961 89.99422454834 89.994071960449 89.992774963379 89.992279052734 89.979469299316 89.982360839844 1.70141E+38 
+
+1.70141E+38 89.994606018066 89.99430847168 89.993423461914 89.992500305176 89.985404968262 89.979461669922 89.976203918457 89.972076416016 1.70141E+38 
+
+1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 1.70141E+38 
+

Added: grass/trunk/raster/r.slope.aspect/testsuite/data/gdal_slope.grd.aux.xml
===================================================================
--- grass/trunk/raster/r.slope.aspect/testsuite/data/gdal_slope.grd.aux.xml	                        (rev 0)
+++ grass/trunk/raster/r.slope.aspect/testsuite/data/gdal_slope.grd.aux.xml	2014-07-09 03:01:47 UTC (rev 61204)
@@ -0,0 +1,5 @@
+<PAMDataset>
+  <PAMRasterBand band="1">
+    <NoDataValue>-9.99900000000000E+03</NoDataValue>
+  </PAMRasterBand>
+</PAMDataset>


Property changes on: grass/trunk/raster/r.slope.aspect/testsuite/data/gdal_slope.grd.aux.xml
___________________________________________________________________
Added: svn:mime-type
   + text/xml
Added: svn:eol-style
   + native

Added: grass/trunk/raster/r.slope.aspect/testsuite/test_r_slope_aspect.py
===================================================================
--- grass/trunk/raster/r.slope.aspect/testsuite/test_r_slope_aspect.py	                        (rev 0)
+++ grass/trunk/raster/r.slope.aspect/testsuite/test_r_slope_aspect.py	2014-07-09 03:01:47 UTC (rev 61204)
@@ -0,0 +1,163 @@
+import gunittest
+from gunittest.gmodules import call_module
+
+SMALL_MAP = """\
+north:   15
+south:   10
+east:    25
+west:    20
+rows:    5
+cols:    5
+
+100.0 150.0 150.0 100.0 100.0
+100.0 150.0 150.0 100.0 100.0
+100.0 150.0 150.0 150.0 150.0
+100.0 150.0 150.0 100.0 100.0
+100.0 150.0 150.0 100.0 100.0
+"""
+
+class TestSlopeAspect(gunittest.TestCase):
+
+    def test_limits(self):
+        slope = 'limits_slope'
+        aspect = 'limits_aspect'
+        self.assertModule('r.slope.aspect', elevation='elevation',
+                          slope=slope, aspect=aspect)
+        self.assertRasterMinMax(map=slope, refmin=0, refmax=90,
+                                msg="Slope in degrees must be between 0 and 90")
+        self.assertRasterMinMax(map=aspect, refmin=0, refmax=360,
+                                msg="Aspect in degrees must be between 0 and 360")
+
+    def test_limits_precent(self):
+        slope = 'limits_percent_slope'
+        aspect = 'limits_percent_aspect'
+        self.assertModule('r.slope.aspect', elevation='elevation',
+                          slope=slope, aspect=aspect, format='percent')
+        self.assertRasterMinMax(map=slope, refmin=0, refmax=100,
+                                msg="Slope in percent must be between 0 and 100")
+        self.assertRasterMinMax(map=aspect, refmin=0, refmax=360,
+                                msg="Aspect in degrees must be between 0 and 360")
+
+
+class TestSlopeAspectAgainstReference(gunittest.TestCase):
+    """
+
+    Data created using::
+
+        g.region n=20 s=10 e=25 w=15 res=1
+        r.surf.fractal output=fractal_surf
+        r.out.ascii input=fractal_surf output=data/fractal_surf.ascii
+        gdaldem slope .../fractal_surf.ascii .../gdal_slope.grd -of GSAG
+        gdaldem aspect .../fractal_surf.ascii .../gdal_aspect.grd -of GSAG -trigonometric
+
+    GDAL version 1.11.0 was used. GDAL implementation is originally based on
+    GRASS GIS 4.1.
+    """
+
+    # precision for comparisons
+    precision = 0.0001
+
+    @classmethod
+    def setUpClass(cls):
+        cls.use_temp_region()
+        call_module('g.region', n=20, s=10, e=25, w=15, res=1)
+        cls.elevation = 'fractal_surf'
+        cls.runModule('r.in.ascii', input='data/fractal_surf.ascii',
+                       output=cls.elevation)
+
+    @classmethod
+    def tearDownClass(cls):
+        cls.del_temp_region()
+        cls.runModule('g.remove', rast=cls.elevation)
+
+    def test_slope(self):
+        ref_slope = 'referece_slope'
+        slope = 'fractal_slope'
+
+        # TODO: using gdal instead of ascii because of cannot seek error
+        self.runModule('r.in.gdal', flags='o',
+                       input='data/gdal_slope.grd', output=ref_slope)
+        self.assertModule('r.slope.aspect', elevation=self.elevation,
+                          slope=slope)
+        # check we have expected values
+        self.assertRasterMinMax(map=slope, refmin=0, refmax=90,
+                                msg="Slope in degrees must be between 0 and 90")
+        # check against reference data
+        self.assertRastersNoDifference(actual=slope, reference=ref_slope,
+                                       precision=self.precision)
+
+    def test_aspect(self):
+        ref_aspect = 'reference_aspect'
+        aspect = 'fractal_aspect'
+        # TODO: using gdal instead of ascii because of cannot seek error
+        self.runModule('r.in.gdal', flags='o',
+                       input='data/gdal_aspect.grd', output=ref_aspect)
+        self.assertModule('r.slope.aspect', elevation=self.elevation,
+                          aspect=aspect)
+        # check we have expected values
+        self.assertRasterMinMax(map=aspect, refmin=0, refmax=360,
+                                msg="Aspect in degrees must be between 0 and 360")
+        # check against reference data
+        self.assertRastersNoDifference(actual=aspect, reference=ref_aspect,
+                                       precision=self.precision)
+
+
+class TestSlopeAspectAgainstItself(gunittest.TestCase):
+
+    precision = 0.0000001
+
+    @classmethod
+    def setUpClass(cls):
+        cls.use_temp_region()
+        call_module('g.region', rast='elevation')
+
+    @classmethod
+    def tearDownClass(cls):
+        cls.del_temp_region()
+
+    def test_slope_aspect_together(self):
+        """Slope and aspect computed sepeately and together should be the same
+        """
+        elevation = 'elevation'
+        t_aspect = 'sa_together_aspect'
+        t_slope = 'sa_together_slope'
+        s_aspect = 'sa_seperately_aspect'
+        s_slope = 'sa_seperately_slope'
+        self.assertModule('r.slope.aspect', elevation=elevation,
+                          aspect=s_aspect)
+        self.assertModule('r.slope.aspect', elevation=elevation,
+                          slope=s_slope)
+        self.assertModule('r.slope.aspect', elevation=elevation,
+                          slope=t_slope, aspect=t_aspect)
+        self.assertRastersNoDifference(actual=t_aspect, reference=s_aspect,
+                                       precision=self.precision)
+        self.assertRastersNoDifference(actual=t_slope, reference=s_slope,
+                                       precision=self.precision)
+
+
+# TODO: implement this class
+class TestExtremes(gunittest.TestCase):
+
+    def setUp(self):
+        self.use_temp_region()
+
+    def tearDown(self):
+        self.del_temp_region()
+
+    def test_small(self):
+        elevation = 'small_elevation'
+        slope = 'small_slope'
+        aspect = 'small_aspect'
+        self.runModule('r.in.ascii', input='-', output=elevation,
+                       stdin_=SMALL_MAP)
+        call_module('g.region', rast=elevation)
+        self.assertModule('r.slope.aspect', elevation=elevation,
+                          slope=slope, aspect=aspect)
+        self.assertRasterMinMax(map=slope, refmin=0, refmax=90,
+                                msg="Slope in degrees must be between 0 and 90")
+        self.assertRasterMinMax(map=aspect, refmin=0, refmax=360,
+                                msg="Aspect in degrees must be between 0 and 360")
+
+
+if __name__ == '__main__':
+    gunittest.test()


Property changes on: grass/trunk/raster/r.slope.aspect/testsuite/test_r_slope_aspect.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native



More information about the grass-commit mailing list