[GRASS-SVN] r72499 - in grass/branches/releasebranch_7_2/temporal/t.rast.series: . testsuite
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Mar 22 08:46:50 PDT 2018
Author: veroandreo
Date: 2018-03-22 08:46:50 -0700 (Thu, 22 Mar 2018)
New Revision: 72499
Modified:
grass/branches/releasebranch_7_2/temporal/t.rast.series/t.rast.series.py
grass/branches/releasebranch_7_2/temporal/t.rast.series/testsuite/test_series.py
Log:
t.rast.series: Fixed bug #3223 wrong time stamp for raster map in case where condition was used (trunk, r72479)
Modified: grass/branches/releasebranch_7_2/temporal/t.rast.series/t.rast.series.py
===================================================================
--- grass/branches/releasebranch_7_2/temporal/t.rast.series/t.rast.series.py 2018-03-22 15:44:10 UTC (rev 72498)
+++ grass/branches/releasebranch_7_2/temporal/t.rast.series/t.rast.series.py 2018-03-22 15:46:50 UTC (rev 72499)
@@ -122,6 +122,7 @@
grass.fatal(_("%s failed. Check above error messages.") % 'r.series')
if not add_time:
+
# Create the time range for the output map
if output.find("@") >= 0:
id = output
@@ -131,8 +132,25 @@
map = sp.get_new_map_instance(id)
map.load()
- map.set_temporal_extent(sp.get_temporal_extent())
+ # We need to set the temporal extent from the subset of selected maps
+ maps = sp.get_registered_maps_as_objects(where=where, order=order, dbif=None)
+ first_map = maps[0]
+ last_map = maps[-1]
+ start_a, end_a = first_map.get_temporal_extent_as_tuple()
+ start_b, end_b = last_map.get_temporal_extent_as_tuple()
+
+ if end_b is None:
+ end_b = start_b
+
+ if first_map.is_time_absolute():
+ extent = tgis.AbsoluteTemporalExtent(start_time=start_a, end_time=end_b)
+ else:
+ extent = tgis.RelativeTemporalExtent(start_time=start_a, end_time=end_b,
+ unit=first_map.get_relative_time_unit())
+
+ map.set_temporal_extent(extent=extent)
+
# Register the map in the temporal database
if map.is_in_db():
map.update_all()
Modified: grass/branches/releasebranch_7_2/temporal/t.rast.series/testsuite/test_series.py
===================================================================
--- grass/branches/releasebranch_7_2/temporal/t.rast.series/testsuite/test_series.py 2018-03-22 15:44:10 UTC (rev 72498)
+++ grass/branches/releasebranch_7_2/temporal/t.rast.series/testsuite/test_series.py 2018-03-22 15:46:50 UTC (rev 72499)
@@ -45,11 +45,23 @@
"""
cls.del_temp_region()
cls.runModule("t.remove", flags="rf", type="strds", inputs="A")
+ cls.runModule("t.unregister", type="raster",
+ maps="series_average,series_maximum,series_minimum,series_minimum_2")
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_time_stamp(self):
+ self.assertModule("t.rast.series", input="A", method="average",
+ output="series_time_stamp", where="start_time > '2001-02-01'")
+
+ tinfo_string="""start_time=2001-02-01 00:00:00
+ end_time=2001-05-01 00:00:00"""
+
+ info = SimpleModule("t.info", flags="g", type="raster", input="series_time_stamp")
+ self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+
def test_average(self):
self.assertModule("t.rast.series", input="A", method="average",
output="series_average")
@@ -112,6 +124,8 @@
"""
cls.del_temp_region()
cls.runModule("t.remove", flags="rf", type="strds", inputs="A")
+ cls.runModule("t.unregister", type="raster",
+ maps="series_average,series_maximum,series_minimum,series_minimum_2")
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")
More information about the grass-commit
mailing list