[GRASS-SVN] r61186 - grass/trunk/raster/r.gwflow/testsuite
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jul 8 03:58:50 PDT 2014
Author: huhabla
Date: 2014-07-08 03:58:50 -0700 (Tue, 08 Jul 2014)
New Revision: 61186
Modified:
grass/trunk/raster/r.gwflow/testsuite/validation_7x7_grid.py
grass/trunk/raster/r.gwflow/testsuite/validation_excavation.py
Log:
Test update to use the latest improvements in PyGRASS
Modified: grass/trunk/raster/r.gwflow/testsuite/validation_7x7_grid.py
===================================================================
--- grass/trunk/raster/r.gwflow/testsuite/validation_7x7_grid.py 2014-07-08 10:29:48 UTC (rev 61185)
+++ grass/trunk/raster/r.gwflow/testsuite/validation_7x7_grid.py 2014-07-08 10:58:50 UTC (rev 61186)
@@ -7,56 +7,21 @@
@author Soeren Gebbert
"""
-
import grass.script as grass
-import grass.pygrass.modules as pymod
from gunittest.case import TestCase
-# Output of r.univar
-UNIVAR_OUTPUT="""n=49
-null_cells=0
-cells=49
-min=45.1219899394172
-max=50
-range=4.8780100605828
-mean=49.081632669812
-mean_of_abs=49.081632669812
-stddev=0.908558909200636
-variance=0.825479291487849
-coeff_var=1.85111794326975
-sum=2405.00000082079
-"""
-
-# Output of r.info, only a subset of the output is needed
-INFO_OUTPUT="""north=700
-south=0
-east=700
-west=0
-nsres=100
-ewres=100
-rows=7
-cols=7
-cells=49
-datatype=DCELL
-ncats=0
-min=45.1219899394172
-max=50
-map=gwresult_conf
-"""
-
class Validation7x7Grid(TestCase):
@classmethod
def setUpClass(cls):
- """!Initiate the temporal GIS and set the region
- """
- # Use always the current mapset as temporal database
+ """Use temporary region settings"""
grass.use_temp_region()
- grass.run_command("g.region", res=100, n=700, s=0, w=0, e=700)
def setUp(self):
- """Create input data for transient groundwater flow computation
+ """Set region and create input data for transient groundwater flow computation
"""
+ self.assertModule("g.region", res=100, n=700, s=0, w=0, e=700)
+
self.assertModule("r.mapcalc", expression="phead=50")
self.assertModule("r.mapcalc", expression="status=if(col() == 1 || col() == 7 , 2, 1)")
self.assertModule("r.mapcalc", expression="well=if((row() == 4 && col() == 4), -0.1, 0)")
@@ -69,20 +34,48 @@
def test_transient(self):
#First compute the groundwater flow
- grass.run_command("r.gwflow", "f", solver="cholesky", top="top_conf", bottom="bottom", phead="phead",\
+ self.assertModule("r.gwflow", flags="f", solver="cholesky", top="top_conf", bottom="bottom", phead="phead",\
status="status", hc_x="hydcond", hc_y="hydcond", q="well", s="s",\
recharge="recharge", output="gwresult_conf", dt=500, type="confined", budget="water_budget", overwrite=True)
# loop over the timesteps
for i in range(20):
- grass.run_command("r.gwflow", "f", solver="cholesky", top="top_conf", bottom="bottom", phead="gwresult_conf",\
+ self.assertModule("r.gwflow", flags="f", solver="cholesky", top="top_conf", bottom="bottom", phead="gwresult_conf",\
status="status", hc_x="hydcond", hc_y="hydcond", q="well", s="s",\
recharge="recharge", output="gwresult_conf", dt=500, type="confined", budget="water_budget", overwrite=True)
+
+ # Output of r.univar
+ univar_string="""n=49
+ null_cells=0
+ cells=49
+ min=45.1219899394172
+ max=50
+ range=4.8780100605828
+ mean=49.081632669812
+ mean_of_abs=49.081632669812
+ stddev=0.908558909200636
+ variance=0.825479291487849
+ coeff_var=1.85111794326975
+ sum=2405.00000082079"""
- global UNIVAR_OUTPUT
- self.assertRasterFitsUnivar(raster="gwresult_conf", reference=UNIVAR_OUTPUT, precision=3)
- global INFO_OUTPUT
- self.assertRasterFitsInfo(raster="gwresult_conf", reference=INFO_OUTPUT, precision=3)
+ # Output of r.info, only a subset of the output is needed
+ info_string="""north=700
+ south=0
+ east=700
+ west=0
+ nsres=100
+ ewres=100
+ rows=7
+ cols=7
+ cells=49
+ datatype=DCELL
+ ncats=0
+ min=45.1219899394172
+ max=50
+ map=gwresult_conf"""
+
+ self.assertRasterFitsUnivar(raster="gwresult_conf", reference=univar_string, precision=3)
+ self.assertRasterFitsInfo(raster="gwresult_conf", reference=info_string, precision=3)
@classmethod
def tearDownClass(cls):
Modified: grass/trunk/raster/r.gwflow/testsuite/validation_excavation.py
===================================================================
--- grass/trunk/raster/r.gwflow/testsuite/validation_excavation.py 2014-07-08 10:29:48 UTC (rev 61185)
+++ grass/trunk/raster/r.gwflow/testsuite/validation_excavation.py 2014-07-08 10:58:50 UTC (rev 61186)
@@ -9,55 +9,21 @@
"""
import grass.script as grass
-import grass.pygrass.modules as pymod
from gunittest.case import TestCase
-# Output of r.univar -g
-UNIVAR_OUTPUT="""n=760
-null_cells=0
-cells=760
-min=3
-max=5.39762629189687
-range=2.39762629189687
-mean=5.02846950820457
-mean_of_abs=5.02846950820457
-stddev=0.333565013446849
-variance=0.111265618195797
-coeff_var=6.63352960384062
-sum=3821.63682623547
-"""
-
-# Output of r.info -gre, only a subset of the output is needed
-INFO_OUTPUT="""north=950
-south=0
-east=2000
-west=0
-nsres=50
-ewres=50
-rows=19
-cols=40
-cells=760
-datatype=DCELL
-ncats=0
-min=3
-max=5.3976262918968
-map=gwresult
-"""
-
class ValidationExcavation(TestCase):
@classmethod
def setUpClass(cls):
- """!Initiate the temporal GIS and set the region
- """
- # Use always the current mapset as temporal database
+ """Use temporary region settings"""
grass.use_temp_region()
- grass.run_command("g.region", flags="p", res=50, n=950, s=0, w=0, e=2000)
def setUp(self):
- """Create input data for steady state groundwater flow computation
+ """Set region and create input data for steady state groundwater flow computation
"""
+ self.assertModule("g.region", flags="p", res=50, n=950, s=0, w=0, e=2000)
+
self.assertModule("r.mapcalc", expression="phead= if(row() == 19, 5, 3)")
self.assertModule("r.mapcalc", expression="status=if((col() == 1 && row() == 13) ||\
(col() == 1 && row() == 14) ||\
@@ -74,15 +40,43 @@
def test_steady_state(self):
#compute a steady state groundwater flow
- grass.run_command("r.gwflow", flags="f", solver="cholesky", top="top", bottom="bottom", phead="phead", \
+ self.assertModule("r.gwflow", flags="f", solver="cholesky", top="top", bottom="bottom", phead="phead", \
status="status", hc_x="hydcond", hc_y="hydcond", s="poros", \
recharge="recharge", output="gwresult", dt=864000000000, type="unconfined", budget="water_budget")
- global UNIVAR_OUTPUT
- self.assertRasterFitsUnivar(raster="gwresult", reference=UNIVAR_OUTPUT, precision=3)
- global INFO_OUTPUT
- self.assertRasterFitsInfo(raster="gwresult", reference=INFO_OUTPUT, precision=3)
+ # Output of r.univar -g
+ univar_string="""n=760
+ null_cells=0
+ cells=760
+ min=3
+ max=5.39762629189687
+ range=2.39762629189687
+ mean=5.02846950820457
+ mean_of_abs=5.02846950820457
+ stddev=0.333565013446849
+ variance=0.111265618195797
+ coeff_var=6.63352960384062
+ sum=3821.63682623547"""
+ # Output of r.info -gre, only a subset of the output is needed
+ info_string="""north=950
+ south=0
+ east=2000
+ west=0
+ nsres=50
+ ewres=50
+ rows=19
+ cols=40
+ cells=760
+ datatype=DCELL
+ ncats=0
+ min=3
+ max=5.3976262918968
+ map=gwresult"""
+
+ self.assertRasterFitsUnivar(raster="gwresult", reference=univar_string, precision=3)
+ self.assertRasterFitsInfo(raster="gwresult", reference=info_string, precision=3)
+
@classmethod
def tearDownClass(cls):
"""!Remove the temporary region
More information about the grass-commit
mailing list