|
@@ -22,42 +22,42 @@ class TestAggregationAbsolute(TestCase):
|
|
|
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("r.mapcalc", expression="a5 = 500", overwrite=True)
|
|
|
- cls.runModule("r.mapcalc", expression="a6 = 600", overwrite=True)
|
|
|
+ cls.runModule("r.mapcalc", expression="a1 = 100.0", overwrite=True)
|
|
|
+ cls.runModule("r.mapcalc", expression="a2 = 200.0", overwrite=True)
|
|
|
+ cls.runModule("r.mapcalc", expression="a3 = 300.0", overwrite=True)
|
|
|
+ cls.runModule("r.mapcalc", expression="a4 = 400.0", overwrite=True)
|
|
|
+ cls.runModule("r.mapcalc", expression="a5 = 500.0", overwrite=True)
|
|
|
+ cls.runModule("r.mapcalc", expression="a6 = 600.0", overwrite=True)
|
|
|
cls.runModule("r.mapcalc", expression="a7 = null()", 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", flags="i", type="raster", input="A",
|
|
|
+ cls.runModule("t.register", flags="i", type="raster", input="A",
|
|
|
maps="a1,a2,a3,a4,a5,a6,a7",
|
|
|
- start="2001-01-15 12:05:45",
|
|
|
- increment="14 days",
|
|
|
+ start="2001-01-15 12:05:45",
|
|
|
+ increment="14 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")
|
|
|
|
|
|
def tearDown(self):
|
|
|
- """Remove generated data"""
|
|
|
+ """Remove generated data"""
|
|
|
self.runModule("t.remove", flags="rf", type="strds", inputs="B")
|
|
|
-
|
|
|
+
|
|
|
def test_disaggregation(self):
|
|
|
"""Disaggregation with empty maps"""
|
|
|
self.assertModule("t.rast.aggregate", input="A", output="B",
|
|
|
- basename="b", granularity="2 days",
|
|
|
+ basename="b", granularity="2 days",
|
|
|
method="average",
|
|
|
- sampling=["overlaps","overlapped","during"],
|
|
|
+ sampling=["overlaps","overlapped","during"],
|
|
|
nprocs=2, flags="n")
|
|
|
|
|
|
tinfo_string="""start_time=2001-01-15 00:00:00
|
|
@@ -74,15 +74,15 @@ class TestAggregationAbsolute(TestCase):
|
|
|
info = SimpleModule("t.info", flags="g", input="B")
|
|
|
#info.run()
|
|
|
#print info.outputs.stdout
|
|
|
- self.assertModuleKeyValue(module=info, reference=tinfo_string,
|
|
|
+ self.assertModuleKeyValue(module=info, reference=tinfo_string,
|
|
|
precision=2, sep="=")
|
|
|
|
|
|
def test_aggregation_1month(self):
|
|
|
"""Aggregation one month"""
|
|
|
self.assertModule("t.rast.aggregate", input="A", output="B",
|
|
|
basename="b", granularity="1 months",
|
|
|
- method="maximum", sampling=["contains"],
|
|
|
- nprocs=3, flags="s")
|
|
|
+ method="maximum", sampling=["contains"],
|
|
|
+ file_limit=0, nprocs=3, flags="s")
|
|
|
|
|
|
tinfo_string="""start_time=2001-01-01 00:00:00
|
|
|
end_time=2001-04-01 00:00:00
|
|
@@ -98,23 +98,23 @@ class TestAggregationAbsolute(TestCase):
|
|
|
info = SimpleModule("t.info", flags="g", input="B")
|
|
|
#info.run()
|
|
|
#print info.outputs.stdout
|
|
|
- self.assertModuleKeyValue(module=info, reference=tinfo_string,
|
|
|
+ self.assertModuleKeyValue(module=info, reference=tinfo_string,
|
|
|
precision=2, sep="=")
|
|
|
|
|
|
# Check the map names are correct
|
|
|
- lister = SimpleModule("t.rast.list", input="B", columns="name",
|
|
|
+ lister = SimpleModule("t.rast.list", input="B", columns="name",
|
|
|
flags="s")
|
|
|
self.runModule(lister)
|
|
|
#print lister.outputs.stdout
|
|
|
maps="b_2001_01" + os.linesep + "b_2001_02" + os.linesep + \
|
|
|
"b_2001_03" + os.linesep
|
|
|
self.assertEqual(maps, lister.outputs.stdout)
|
|
|
-
|
|
|
+
|
|
|
def test_aggregation_2months(self):
|
|
|
"""Aggregation two month"""
|
|
|
self.assertModule("t.rast.aggregate", input="A", output="B",
|
|
|
basename="b", granularity="2 months",
|
|
|
- method="minimum", sampling=["contains"],
|
|
|
+ method="minimum", sampling=["contains"],
|
|
|
nprocs=4, offset=10)
|
|
|
|
|
|
tinfo_string="""start_time=2001-01-01 00:00:00
|
|
@@ -131,23 +131,23 @@ class TestAggregationAbsolute(TestCase):
|
|
|
info = SimpleModule("t.info", flags="g", input="B")
|
|
|
#info.run()
|
|
|
#print info.outputs.stdout
|
|
|
- self.assertModuleKeyValue(module=info, reference=tinfo_string,
|
|
|
+ self.assertModuleKeyValue(module=info, reference=tinfo_string,
|
|
|
precision=2, sep="=")
|
|
|
|
|
|
# Check the map names are correct
|
|
|
- lister = SimpleModule("t.rast.list", input="B", columns="name",
|
|
|
+ lister = SimpleModule("t.rast.list", input="B", columns="name",
|
|
|
flags="s")
|
|
|
self.runModule(lister)
|
|
|
#print lister.outputs.stdout
|
|
|
- maps="b_11" + os.linesep + "b_12" + os.linesep
|
|
|
+ maps="b_11" + os.linesep + "b_12" + os.linesep
|
|
|
self.assertEqual(maps, lister.outputs.stdout)
|
|
|
|
|
|
def test_aggregation_3months(self):
|
|
|
"""Aggregation three month"""
|
|
|
self.assertModule("t.rast.aggregate", input="A", output="B",
|
|
|
basename="b", granularity="3 months",
|
|
|
- method="sum", sampling=["contains"],
|
|
|
- nprocs=9, offset=100)
|
|
|
+ method="sum", sampling=["contains"],
|
|
|
+ file_limit=0, nprocs=9, offset=100)
|
|
|
|
|
|
tinfo_string="""start_time=2001-01-01 00:00:00
|
|
|
end_time=2001-04-01 00:00:00
|
|
@@ -163,15 +163,15 @@ class TestAggregationAbsolute(TestCase):
|
|
|
info = SimpleModule("t.info", flags="g", input="B")
|
|
|
#info.run()
|
|
|
#print info.outputs.stdout
|
|
|
- self.assertModuleKeyValue(module=info, reference=tinfo_string,
|
|
|
+ self.assertModuleKeyValue(module=info, reference=tinfo_string,
|
|
|
precision=2, sep="=")
|
|
|
|
|
|
# Check the map names are correct
|
|
|
- lister = SimpleModule("t.rast.list", input="B", columns="name",
|
|
|
+ lister = SimpleModule("t.rast.list", input="B", columns="name",
|
|
|
flags="s")
|
|
|
self.runModule(lister)
|
|
|
#print lister.outputs.stdout
|
|
|
- maps="b_101" + os.linesep
|
|
|
+ maps="b_101" + os.linesep
|
|
|
self.assertEqual(maps, lister.outputs.stdout)
|
|
|
|
|
|
if __name__ == '__main__':
|