[GRASS-SVN] r71437 - in grass/trunk/temporal/t.rast.series: . testsuite
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Aug 25 13:39:57 PDT 2017
Author: huhabla
Date: 2017-08-25 13:39:57 -0700 (Fri, 25 Aug 2017)
New Revision: 71437
Modified:
grass/trunk/temporal/t.rast.series/t.rast.series.py
grass/trunk/temporal/t.rast.series/testsuite/test_series.py
Log:
temporal modules: Added quantile option to t.rast.series with test
Modified: grass/trunk/temporal/t.rast.series/t.rast.series.py
===================================================================
--- grass/trunk/temporal/t.rast.series/t.rast.series.py 2017-08-25 15:14:33 UTC (rev 71436)
+++ grass/trunk/temporal/t.rast.series/t.rast.series.py 2017-08-25 20:39:57 UTC (rev 71437)
@@ -38,6 +38,15 @@
#%end
#%option
+#% key: quantile
+#% type: double
+#% description: Quantile to calculate for method=quantile
+#% required: no
+#% multiple: no
+#% options: 0.0-1.0
+#%end
+
+#%option
#% key: order
#% type: string
#% description: Sort the maps by category
@@ -78,6 +87,7 @@
input = options["input"]
output = options["output"]
method = options["method"]
+ quantile = options["quantile"]
order = options["order"]
where = options["where"]
add_time = flags["t"]
@@ -111,7 +121,7 @@
try:
grass.run_command("r.series", flags=flag, file=filename,
output=output, overwrite=grass.overwrite(),
- method=method)
+ method=method, quantile=quantile)
except CalledModuleError:
grass.fatal(_("%s failed. Check above error messages.") % 'r.series')
Modified: grass/trunk/temporal/t.rast.series/testsuite/test_series.py
===================================================================
--- grass/trunk/temporal/t.rast.series/testsuite/test_series.py 2017-08-25 15:14:33 UTC (rev 71436)
+++ grass/trunk/temporal/t.rast.series/testsuite/test_series.py 2017-08-25 20:39:57 UTC (rev 71437)
@@ -23,64 +23,71 @@
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,
+ 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",
+ 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",
+ cls.runModule("t.register", type="raster", input="A",
maps="a1,a2,a3,a4",
- start="2001-01-01",
- increment="1 month",
+ start="2001-01-01",
+ increment="1 month",
overwrite=True)
@classmethod
def tearDownClass(cls):
"""Remove the temporary region
"""
- cls.del_temp_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")
-
+ cls.runModule("g.remove", flags="f", type="raster", name="series_quantile")
+
def test_average(self):
- self.assertModule("t.rast.series", input="A", method="average",
+ 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",
+ 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",
+ 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",
+ 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")
+ def test_quantile(self):
+ self.assertModule("t.rast.series", input="A", method="quantile", quantile=0.5,
+ output="series_quantile")
+ self.assertRasterMinMax(map="series_quantile", refmin=300, refmax=300,
+ msg="Minimum must be 300")
+
class TestSnapRelativeSTRDS(TestCase):
@classmethod
@@ -90,64 +97,64 @@
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,
+ 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",
+ 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",
+ cls.runModule("t.register", type="raster", input="A",
maps="a1,a2,a3,a4",
- start="0",
- increment="14", unit="days",
+ start="0",
+ increment="14", unit="days",
overwrite=True)
@classmethod
def tearDownClass(cls):
"""Remove the temporary region
"""
- cls.del_temp_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",
+ 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",
+ 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",
+ 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",
+ 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