|
@@ -7,56 +7,21 @@ year = "1995"
|
|
|
|
|
|
@author Soeren Gebbert
|
|
@author Soeren Gebbert
|
|
"""
|
|
"""
|
|
-
|
|
|
|
import grass.script as grass
|
|
import grass.script as grass
|
|
-import grass.pygrass.modules as pymod
|
|
|
|
from gunittest.case import TestCase
|
|
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):
|
|
class Validation7x7Grid(TestCase):
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
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.use_temp_region()
|
|
- grass.run_command("g.region", res=100, n=700, s=0, w=0, e=700)
|
|
|
|
|
|
|
|
def setUp(self):
|
|
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="phead=50")
|
|
self.assertModule("r.mapcalc", expression="status=if(col() == 1 || col() == 7 , 2, 1)")
|
|
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)")
|
|
self.assertModule("r.mapcalc", expression="well=if((row() == 4 && col() == 4), -0.1, 0)")
|
|
@@ -69,20 +34,48 @@ class Validation7x7Grid(TestCase):
|
|
|
|
|
|
def test_transient(self):
|
|
def test_transient(self):
|
|
#First compute the groundwater flow
|
|
#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",\
|
|
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)
|
|
recharge="recharge", output="gwresult_conf", dt=500, type="confined", budget="water_budget", overwrite=True)
|
|
|
|
|
|
# loop over the timesteps
|
|
# loop over the timesteps
|
|
for i in range(20):
|
|
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",\
|
|
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)
|
|
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"""
|
|
|
|
+
|
|
|
|
+ # 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"""
|
|
|
|
|
|
- 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)
|
|
|
|
|
|
+ self.assertRasterFitsUnivar(raster="gwresult_conf", reference=univar_string, precision=3)
|
|
|
|
+ self.assertRasterFitsInfo(raster="gwresult_conf", reference=info_string, precision=3)
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|
|
def tearDownClass(cls):
|
|
def tearDownClass(cls):
|