[GRASS-SVN] r68693 - in grass-addons/grass7/raster/r.forestfrag: . testsuite
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jun 14 18:22:11 PDT 2016
Author: wenzeslaus
Date: 2016-06-14 18:22:11 -0700 (Tue, 14 Jun 2016)
New Revision: 68693
Added:
grass-addons/grass7/raster/r.forestfrag/testsuite/
grass-addons/grass7/raster/r.forestfrag/testsuite/r_forestfrag_ncspm.py
grass-addons/grass7/raster/r.forestfrag/testsuite/r_forestfrag_xy.py
Log:
r.forestfrag: test suite for NC SPM and XY locations
Added: grass-addons/grass7/raster/r.forestfrag/testsuite/r_forestfrag_ncspm.py
===================================================================
--- grass-addons/grass7/raster/r.forestfrag/testsuite/r_forestfrag_ncspm.py (rev 0)
+++ grass-addons/grass7/raster/r.forestfrag/testsuite/r_forestfrag_ncspm.py 2016-06-15 01:22:11 UTC (rev 68693)
@@ -0,0 +1,47 @@
+from grass.gunittest.case import TestCase
+from grass.gunittest.main import test
+import grass.script.raster as gr
+
+
+class TestForestFrag(TestCase):
+ # TODO: replace by unified handing of maps
+ to_remove = []
+ landclass = 'landclass96' # in full NC SPM
+ forest = 'rff_test_forest'
+ forest_frag = 'rff_test_forest_frag'
+
+ def setUp(self):
+ self.use_temp_region()
+ self.runModule('g.region', raster=self.landclass)
+ gr.mapcalc("{f} = if({c} == 5, 1, 0)".format(c=self.landclass,
+ f=self.forest))
+ self.to_remove.append(self.forest)
+
+ def tearDown(self):
+ self.del_temp_region()
+ if self.to_remove:
+ self.runModule('g.remove', flags='f', type='raster',
+ name=','.join(self.to_remove), verbose=True)
+
+ def test_3x3(self):
+ self.assertModule('r.forestfrag', input=self.forest,
+ output=self.forest_frag, window=3)
+ self.assertRasterExists(self.forest_frag)
+ self.to_remove.append(self.forest_frag)
+ self.assertRasterMinMax(self.forest_frag, refmin=0, refmax=6)
+ # we don't have a check sum test for raster, so we just test all
+ ref = dict(north=228527.25, south=215018.25,
+ east=644971, west=629980,
+ nsres=28.5, ewres=28.5, rows=474, cols=526,
+ cells=249324, datatype='CELL', ncats=6)
+ self.assertRasterFitsInfo(raster=self.forest_frag,
+ reference=ref, precision=0.0006)
+ ref = dict(n=249323, null_cells=1, cells=249324, min=0, max=5,
+ range=5, mean=2.2925, mean_of_abs=2.2925,
+ stddev=2.3564, variance=5.5526, coeff_var=102.7886,
+ sum=571564)
+ self.assertRasterFitsUnivar(raster=self.forest_frag,
+ reference=ref, precision=0.0006)
+
+if __name__ == '__main__':
+ test()
Added: grass-addons/grass7/raster/r.forestfrag/testsuite/r_forestfrag_xy.py
===================================================================
--- grass-addons/grass7/raster/r.forestfrag/testsuite/r_forestfrag_xy.py (rev 0)
+++ grass-addons/grass7/raster/r.forestfrag/testsuite/r_forestfrag_xy.py 2016-06-15 01:22:11 UTC (rev 68693)
@@ -0,0 +1,244 @@
+from grass.gunittest.case import TestCase
+from grass.gunittest.main import test
+
+# this is in fact taken from the NC SPM Location landclass96 raster map
+
+FOREST = """\
+north: 220105.5
+south: 219478.5
+east: 634609.5
+west: 633612
+rows: 22
+cols: 35
+0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1
+0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0
+0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 0 0 0 0
+1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 0 1 1 1 1 1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0 1 0
+"""
+
+
+class TestForestFragXY(TestCase):
+ # TODO: replace by unified handing of maps
+ to_remove = []
+ forest = 'rff_test_forest'
+ forest_frag = 'rff_test_forest_frag'
+ forest_frag_ref = 'rff_test_forest_frag_ref'
+
+ def setUp(self):
+ self.use_temp_region()
+ self.runModule('r.in.ascii', input='-', stdin_=FOREST,
+ output=self.forest)
+ self.runModule('g.region', raster=self.forest)
+ self.to_remove.append(self.forest)
+
+ def tearDown(self):
+ self.del_temp_region()
+ if self.to_remove:
+ self.runModule('g.remove', flags='f', type='raster',
+ name=','.join(self.to_remove), verbose=True)
+
+ def forest_frag_general(self, window, reference):
+ self.runModule('r.in.ascii', input='-', stdin_=reference,
+ output=self.forest_frag_ref)
+ self.to_remove.append(self.forest_frag_ref)
+ self.assertRasterMinMax(self.forest_frag_ref, refmin=0, refmax=6)
+ self.assertModule('r.forestfrag', input=self.forest,
+ output=self.forest_frag, window=window)
+ self.assertRasterExists(self.forest_frag)
+ self.to_remove.append(self.forest_frag)
+ self.assertRasterMinMax(self.forest_frag, refmin=0, refmax=6)
+ self.assertRastersNoDifference(actual=self.forest_frag,
+ reference=self.forest_frag_ref,
+ precision=0) # it's CELL type
+
+ def test_3(self):
+ self.forest_frag_general(3, FRAG_3)
+
+ def test_5(self):
+ self.forest_frag_general(5, FRAG_5)
+
+ def test_7(self):
+ self.forest_frag_general(7, FRAG_7)
+
+ def test_9(self):
+ self.forest_frag_general(9, FRAG_9)
+
+ def test_13(self):
+ self.forest_frag_general(13, FRAG_13)
+
+
+if __name__ == '__main__':
+ test()
More information about the grass-commit
mailing list