|
@@ -3,6 +3,7 @@ Created on Sun Jun 07 21:57:07 2018
|
|
|
|
|
|
@author: Sanjeet Bhatti
|
|
|
"""
|
|
|
+import os
|
|
|
|
|
|
from grass.gunittest.case import TestCase
|
|
|
from grass.gunittest.main import test
|
|
@@ -13,36 +14,42 @@ from grass.script.core import run_command
|
|
|
class TestRFillNulls(TestCase):
|
|
|
"""Test r.fillnulls script"""
|
|
|
|
|
|
- mapName = 'elev_srtm_30m'
|
|
|
- expression = 'elev_srtm_30m_filt = if(elev_srtm_30m < 50.0, \
|
|
|
- null(), elev_srtm_30m)'
|
|
|
- mapNameCalc = 'elev_srtm_30m_filt'
|
|
|
- mapComplete = 'elev_srtm_30m_complete'
|
|
|
+ module_dir = os.path.dirname(os.path.dirname(__file__))
|
|
|
+ module = os.path.join(module_dir, 'r.fillnulls.py')
|
|
|
+ mapName = 'elevation'
|
|
|
+ expression = 'elevation_filt = if(elevation > 130, \
|
|
|
+ null(), elevation)'
|
|
|
+ mapNameCalc = 'elevation_filt'
|
|
|
+ mapComplete = 'elevation_complete'
|
|
|
values = 'null_cells=0'
|
|
|
|
|
|
- @classmethod
|
|
|
- def setUpClass(cls):
|
|
|
+ def setUp(self):
|
|
|
"""Create maps in a small region."""
|
|
|
- cls.use_temp_region()
|
|
|
- cls.runModule('g.region', raster=cls.mapName, flags='p')
|
|
|
-
|
|
|
- @classmethod
|
|
|
- def tearDownClass(cls):
|
|
|
- """Remove temporary region"""
|
|
|
- cls.runModule('g.remove', flags='f', type='raster',
|
|
|
- name=(cls.mapNameCalc, cls.mapComplete))
|
|
|
- cls.del_temp_region()
|
|
|
-
|
|
|
- def test_fill_nulls(self):
|
|
|
- """Fill nulls test"""
|
|
|
+ self.use_temp_region()
|
|
|
+ self.runModule('g.region', res=200, raster=self.mapName, flags='ap')
|
|
|
run_command('r.mapcalc', expression=self.expression)
|
|
|
|
|
|
- module = SimpleModule('r.fillnulls', input=self.mapNameCalc,
|
|
|
- output=self.mapComplete, tension=20)
|
|
|
+ def tearDown(self):
|
|
|
+ """Remove temporary region"""
|
|
|
+ self.runModule('g.remove', flags='f', type='raster',
|
|
|
+ name=(self.mapNameCalc, self.mapComplete))
|
|
|
+ self.del_temp_region()
|
|
|
+
|
|
|
+ def test_rst(self):
|
|
|
+ module = SimpleModule(self.module, input=self.mapNameCalc,
|
|
|
+ output=self.mapComplete, segmax=1200,
|
|
|
+ npmin=100, tension=150)
|
|
|
self.assertModule(module)
|
|
|
+ self.assertRasterFitsUnivar(raster=self.mapComplete,
|
|
|
+ reference=self.values)
|
|
|
|
|
|
+ def test_bspline(self):
|
|
|
+ module = SimpleModule(self.module, input=self.mapNameCalc,
|
|
|
+ output=self.mapComplete, method='bicubic')
|
|
|
+ self.assertModule(module)
|
|
|
self.assertRasterFitsUnivar(raster=self.mapComplete,
|
|
|
reference=self.values)
|
|
|
|
|
|
+
|
|
|
if __name__ == '__main__':
|
|
|
test()
|