[GRASS-SVN] r66319 - in grass/trunk/temporal/t.rast.series: . testsuite
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Sep 24 00:22:57 PDT 2015
Author: huhabla
Date: 2015-09-24 00:22:57 -0700 (Thu, 24 Sep 2015)
New Revision: 66319
Added:
grass/trunk/temporal/t.rast.series/testsuite/
grass/trunk/temporal/t.rast.series/testsuite/test_series.py
Modified:
grass/trunk/temporal/t.rast.series/t.rast.series.py
Log:
temporal modules: Fixed usage of the "z" flag and added tests
Modified: grass/trunk/temporal/t.rast.series/t.rast.series.py
===================================================================
--- grass/trunk/temporal/t.rast.series/t.rast.series.py 2015-09-24 05:04:21 UTC (rev 66318)
+++ grass/trunk/temporal/t.rast.series/t.rast.series.py 2015-09-24 07:22:57 UTC (rev 66319)
@@ -98,7 +98,9 @@
file.close()
- flag = "z"
+ flag = ""
+ if len(rows) > 1000:
+ flag += "z"
if nulls:
flag += "n"
Added: grass/trunk/temporal/t.rast.series/testsuite/test_series.py
===================================================================
--- grass/trunk/temporal/t.rast.series/testsuite/test_series.py (rev 0)
+++ grass/trunk/temporal/t.rast.series/testsuite/test_series.py 2015-09-24 07:22:57 UTC (rev 66319)
@@ -0,0 +1,154 @@
+"""Test t.rast.series
+
+(C) 2015 by the GRASS Development Team
+This program is free software under the GNU General Public
+License (>=v2). Read the file COPYING that comes with GRASS
+for details.
+
+:authors: Soeren Gebbert
+"""
+import os
+import grass.pygrass.modules as pymod
+import grass.temporal as tgis
+from grass.gunittest.case import TestCase
+from grass.gunittest.gmodules import SimpleModule
+
+
+class TestSnapAbsoluteSTRDS(TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ """Initiate the temporal GIS and set the region
+ """
+ os.putenv("GRASS_OVERWRITE", "1")
+ tgis.init()
+ cls.use_temp_region()
+ cls.runModule("g.region", s=0, n=80, w=0, e=120, b=0,
+ t=50, res=10, res3=10)
+ cls.runModule("r.mapcalc", expression="a1 = 100", overwrite=True)
+ cls.runModule("r.mapcalc", expression="a2 = 200", overwrite=True)
+ cls.runModule("r.mapcalc", expression="a3 = 300", overwrite=True)
+ cls.runModule("r.mapcalc", expression="a4 = 400", overwrite=True)
+
+ cls.runModule("t.create", type="strds", temporaltype="absolute",
+ output="A", title="A test",
+ description="A test", overwrite=True)
+
+ cls.runModule("t.register", type="raster", input="A",
+ maps="a1,a2,a3,a4",
+ start="2001-01-01",
+ increment="1 month",
+ overwrite=True)
+ @classmethod
+ def tearDownClass(cls):
+ """Remove the temporary region
+ """
+ cls.del_temp_region()
+ cls.runModule("t.remove", flags="rf", type="strds", inputs="A")
+ cls.runModule("g.remove", flags="f", type="raster", name="series_average")
+ cls.runModule("g.remove", flags="f", type="raster", name="series_maximum")
+ cls.runModule("g.remove", flags="f", type="raster", name="series_minimum")
+ cls.runModule("g.remove", flags="f", type="raster", name="series_minimum_2")
+
+ def test_average(self):
+ self.assertModule("t.rast.series", input="A", method="average",
+ output="series_average")
+
+ self.assertRasterMinMax(map="series_average", refmin=250, refmax=250,
+ msg="Average must be 250")
+
+ def test_maximum(self):
+ self.assertModule("t.rast.series", input="A", method="maximum",
+ output="series_maximum")
+
+ self.assertRasterMinMax(map="series_maximum", refmin=400, refmax=400,
+ msg="Maximum must be 400")
+
+ def test_minimum(self):
+ self.assertModule("t.rast.series", input="A", method="minimum",
+ output="series_minimum")
+
+ self.assertRasterMinMax(map="series_minimum", refmin=100, refmax=100,
+ msg="Minimum must be 100")
+
+ def test_minimum_where(self):
+ self.assertModule("t.rast.series", input="A", method="minimum",
+ output="series_minimum_2",
+ where="start_time >= '2001-03-01'")
+
+ self.assertRasterMinMax(map="series_minimum_2", refmin=300, refmax=300,
+ msg="Minimum must be 300")
+
+
+
+class TestSnapRelativeSTRDS(TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ """Initiate the temporal GIS and set the region
+ """
+ os.putenv("GRASS_OVERWRITE", "1")
+ tgis.init()
+ cls.use_temp_region()
+ cls.runModule("g.region", s=0, n=80, w=0, e=120, b=0,
+ t=50, res=10, res3=10)
+ cls.runModule("r.mapcalc", expression="a1 = 100", overwrite=True)
+ cls.runModule("r.mapcalc", expression="a2 = 200", overwrite=True)
+ cls.runModule("r.mapcalc", expression="a3 = 300", overwrite=True)
+ cls.runModule("r.mapcalc", expression="a4 = 400", overwrite=True)
+
+ cls.runModule("t.create", type="strds", temporaltype="relative",
+ output="A", title="A test",
+ description="A test", overwrite=True)
+
+ cls.runModule("t.register", type="raster", input="A",
+ maps="a1,a2,a3,a4",
+ start="0",
+ increment="14", unit="days",
+ overwrite=True)
+ @classmethod
+ def tearDownClass(cls):
+ """Remove the temporary region
+ """
+ cls.del_temp_region()
+ cls.runModule("t.remove", flags="rf", type="strds", inputs="A")
+ cls.runModule("g.remove", flags="f", type="raster", name="series_average")
+ cls.runModule("g.remove", flags="f", type="raster", name="series_maximum")
+ cls.runModule("g.remove", flags="f", type="raster", name="series_minimum")
+ cls.runModule("g.remove", flags="f", type="raster", name="series_minimum_2")
+
+ def test_average(self):
+ self.assertModule("t.rast.series", input="A", method="average",
+ output="series_average")
+
+ self.assertRasterMinMax(map="series_average", refmin=250, refmax=250,
+ msg="Average must be 250")
+
+ def test_maximum(self):
+ self.assertModule("t.rast.series", input="A", method="maximum",
+ output="series_maximum")
+
+ self.assertRasterMinMax(map="series_maximum", refmin=400, refmax=400,
+ msg="Maximum must be 400")
+
+ def test_minimum(self):
+ self.assertModule("t.rast.series", input="A", method="minimum",
+ output="series_minimum")
+
+ self.assertRasterMinMax(map="series_minimum", refmin=100, refmax=100,
+ msg="Minimum must be 100")
+
+ def test_minimum_where(self):
+ self.assertModule("t.rast.series", input="A", method="minimum",
+ output="series_minimum_2",
+ where="start_time >= 28")
+
+ self.assertRasterMinMax(map="series_minimum_2", refmin=300, refmax=300,
+ msg="Minimum must be 300")
+
+
+
+if __name__ == '__main__':
+ from grass.gunittest.main import test
+ test()
+
More information about the grass-commit
mailing list