[GRASS-SVN] r70966 - in grass/trunk/temporal/t.rast.accdetect: . testsuite

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Apr 27 12:27:38 PDT 2017


Author: huhabla
Date: 2017-04-27 12:27:38 -0700 (Thu, 27 Apr 2017)
New Revision: 70966

Modified:
   grass/trunk/temporal/t.rast.accdetect/t.rast.accdetect.py
   grass/trunk/temporal/t.rast.accdetect/testsuite/test_simple.py
Log:
temporal modules: Fixed naming bug of indicator maps in t.rast.accdetect


Modified: grass/trunk/temporal/t.rast.accdetect/t.rast.accdetect.py
===================================================================
--- grass/trunk/temporal/t.rast.accdetect/t.rast.accdetect.py	2017-04-27 16:19:37 UTC (rev 70965)
+++ grass/trunk/temporal/t.rast.accdetect/t.rast.accdetect.py	2017-04-27 19:27:38 UTC (rev 70966)
@@ -330,12 +330,13 @@
                 if input_strds.get_temporal_type() == 'absolute' and time_suffix == 'gran':
                     suffix = tgis.create_suffix_from_datetime(map.temporal_extent.get_start_time(),
                                                               input_strds.get_granularity())
-                    indicator_map_name = "{ba}_{su}".format(ba=base, su=suffix)
+                    indicator_map_name = "{ba}_indicator_{su}".format(ba=base, su=suffix)
                 elif input_strds.get_temporal_type() == 'absolute' and time_suffix == 'time':
                     suffix = tgis.create_time_suffix(map)
-                    indicator_map_name = "{ba}_{su}".format(ba=base, su=suffix)
+                    indicator_map_name = "{ba}_indicator_{su}".format(ba=base, su=suffix)
                 else:
-                    indicator_map_name = tgis.create_numeric_suffic(base, indi_count, time_suffix)
+                    indicator_map_name = tgis.create_numeric_suffic(base + "_indicator",
+                                                                    indi_count, time_suffix)
                 indicator_map_id = dummy.build_id(indicator_map_name, mapset)
                 indicator_map = input_strds.get_new_map_instance(indicator_map_id)
 

Modified: grass/trunk/temporal/t.rast.accdetect/testsuite/test_simple.py
===================================================================
--- grass/trunk/temporal/t.rast.accdetect/testsuite/test_simple.py	2017-04-27 16:19:37 UTC (rev 70965)
+++ grass/trunk/temporal/t.rast.accdetect/testsuite/test_simple.py	2017-04-27 19:27:38 UTC (rev 70966)
@@ -47,11 +47,12 @@
     def tearDown(self):
         """Remove generated data"""
         self.runModule("t.remove", flags="rf", type="strds", inputs="B")
+        self.runModule("t.remove", flags="rf", type="strds", inputs="C")
         
     def test_simple(self):
         self.assertModule('t.rast.accdetect', input='A', occurrence='B',
-                          start="2001-01-01", cycle="12 months",
-                          basename='b_occu', range=(1,8))
+                          indicator="C", start="2001-01-01", cycle="12 months",
+                          basename='result', range=(1,8))
         tinfo_string="""semantic_type=mean
         start_time=2001-01-01 00:00:00
         end_time=2009-05-01 00:00:00
@@ -62,10 +63,20 @@
         self.assertModuleKeyValue(module=info, reference=tinfo_string,
                                   precision=2, sep="=")
 
+        tinfo_string="""semantic_type=mean
+        start_time=2001-01-01 00:00:00
+        end_time=2009-05-01 00:00:00
+        granularity=1 month
+        map_time=interval
+        number_of_maps=100"""
+        info = SimpleModule("t.info", flags="g", type="strds", input="C")
+        self.assertModuleKeyValue(module=info, reference=tinfo_string,
+                                  precision=2, sep="=")
+
     def test_stop(self):
         self.assertModule('t.rast.accdetect', input='A', occurrence='B',
-                          start="2001-01-01", stop='2008-12-31',
-                          cycle="12 months", basename='b_occu', range=(1,8))
+                          indicator="C", start="2001-01-01", stop='2008-12-31',
+                          cycle="12 months", basename='result', range=(1,8))
         tinfo_string="""semantic_type=mean
         start_time=2001-01-01 00:00:00
         end_time=2009-01-01 00:00:00
@@ -75,22 +86,38 @@
         info = SimpleModule("t.info", flags="g", type="strds", input="B")
         self.assertModuleKeyValue(module=info, reference=tinfo_string,
                                   precision=2, sep="=")
-      
+
+        tinfo_string="""semantic_type=mean
+        start_time=2001-01-01 00:00:00
+        end_time=2009-01-01 00:00:00
+        granularity=1 month
+        map_time=interval
+        number_of_maps=96"""
+        info = SimpleModule("t.info", flags="g", type="strds", input="C")
+        self.assertModuleKeyValue(module=info, reference=tinfo_string,
+                                  precision=2, sep="=")
+
     def test_time_suffix(self):
         self.assertModule('t.rast.accdetect', input='A', occurrence='B',
-                          start="2001-01-01", cycle="12 months", suffix='time',
-                          basename='b_occu', range=(1,8))
-        self.assertRasterDoesNotExist('b_occu_2001_01')
-        self.assertRasterExists('b_occu_2001_01_01T00_00_00')
+                          indicator="C", start="2001-01-01", cycle="12 months", suffix='time',
+                          basename='result', range=(1,8))
+        self.assertRasterDoesNotExist('result_2001_01')
+        self.assertRasterExists('result_2001_01_01T00_00_00')
+        self.assertRasterDoesNotExist('result_indicator_2001_01')
+        self.assertRasterExists('result_indicator_2001_01_01T00_00_00')
 
     def test_num_suffix(self):
         self.assertModule('t.rast.accdetect', input='A', occurrence='B',
-                          start="2001-01-01", cycle="12 months",
-                          suffix='count%03', basename='b_occu', range=(1,8))
-        self.assertRasterDoesNotExist('b_occu_2001_01')
-        self.assertRasterExists('b_occu_001')
-        self.assertRasterDoesNotExist('b_occu_00001')
+                          indicator="C", start="2001-01-01", cycle="12 months",
+                          suffix='count%03', basename='result', range=(1,8))
+        self.assertRasterDoesNotExist('result_2001_01')
+        self.assertRasterExists('result_001')
+        self.assertRasterDoesNotExist('result_00001')
 
+        self.assertRasterDoesNotExist('result_indicator_2001_01')
+        self.assertRasterExists('result_indicator_001')
+        self.assertRasterDoesNotExist('result_indicator_00001')
+
 if __name__ == '__main__':
     from grass.gunittest.main import test
     test()



More information about the grass-commit mailing list