1
"""Test t.rast.aggregation
3
(C) 2014 by the GRASS Development Team
4
This program is free software under the GNU General Public
5
License (>=v2). Read the file COPYING that comes with GRASS
8
:authors: Soeren Gebbert
11
import grass.pygrass.modules as pymod
12
import grass.temporal as tgis
13
from grass.gunittest.case import TestCase
14
from grass.gunittest.gmodules import SimpleModule
15
from datetime import datetime
17
class TestAggregationAbsoluteParallel(TestCase):
21
"""Initiate the temporal GIS and set the region
23
os.putenv("GRASS_OVERWRITE", "1")
26
cls.runModule("g.region", s=0, n=80, w=0, e=120, b=0,
27
t=50, res=10, res3=10)
31
cls.runModule("r.mapcalc", expression="a%i = %i"%(i + 1, i + 1), overwrite=True)
32
name_list.append("a%i"%(i + 1))
34
cls.runModule("t.create", type="strds", temporaltype="absolute",
35
output="A", title="A test",
36
description="A test", overwrite=True)
38
cls.runModule("t.register", flags="i", type="raster", input="A",
45
def tearDownClass(cls):
46
"""Remove the temporary region
49
cls.runModule("t.remove", flags="rf", type="strds", inputs="A")
52
"""Remove generated data"""
53
self.runModule("t.remove", flags="rf", type="strds", inputs="B")
55
def test_aggregation_12hours(self):
56
"""Aggregation one month"""
57
self.assertModule("t.rast.aggregate", input="A", output="B",
58
basename="b", granularity="12 hours",
59
method="sum", sampling=["contains"],
62
tinfo_string="""start_time=2001-01-01 00:00:00
63
end_time=2001-04-01 00:00:00
73
info = SimpleModule("t.info", flags="g", input="B")
75
#print info.outputs.stdout
76
self.assertModuleKeyValue(module=info, reference=tinfo_string,
79
def test_aggregation_1day_4procs(self):
80
"""Aggregation one month"""
81
start = datetime.now()
82
self.assertModule("t.rast.aggregate", input="A", output="B",
83
basename="b", granularity="1 day",
84
method="sum", sampling=["contains"],
89
print "test_aggregation_1day_4procs:", delta.total_seconds()
91
tinfo_string="""start_time=2001-01-01 00:00:00
92
end_time=2001-04-01 00:00:00
98
info = SimpleModule("t.info", flags="g", input="B")
100
#print info.outputs.stdout
101
self.assertModuleKeyValue(module=info, reference=tinfo_string,
102
precision=2, sep="=")
104
def test_aggregation_1day_3procs(self):
105
"""Aggregation one month"""
106
start = datetime.now()
107
self.assertModule("t.rast.aggregate", input="A", output="B",
108
basename="b", granularity="1 day",
109
method="sum", sampling=["contains"],
114
print "test_aggregation_1day_3procs:", delta.total_seconds()
117
tinfo_string="""start_time=2001-01-01 00:00:00
118
end_time=2001-04-01 00:00:00
128
info = SimpleModule("t.info", flags="g", input="B")
130
#print info.outputs.stdout
131
self.assertModuleKeyValue(module=info, reference=tinfo_string,
132
precision=2, sep="=")
134
def test_aggregation_1day_2procs(self):
135
"""Aggregation one month"""
136
start = datetime.now()
137
self.assertModule("t.rast.aggregate", input="A", output="B",
138
basename="b", granularity="1 day",
139
method="sum", sampling=["contains"],
144
print "test_aggregation_1day_2procs:", delta.total_seconds()
147
tinfo_string="""start_time=2001-01-01 00:00:00
148
end_time=2001-04-01 00:00:00
158
info = SimpleModule("t.info", flags="g", input="B")
160
#print info.outputs.stdout
161
self.assertModuleKeyValue(module=info, reference=tinfo_string,
162
precision=2, sep="=")
163
if __name__ == '__main__':
164
from grass.gunittest.main import test