[GRASS-SVN] r51281 - in grass/trunk/temporal: . t.rast.to.rast3

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Apr 5 17:19:50 EDT 2012


Author: huhabla
Date: 2012-04-05 14:19:49 -0700 (Thu, 05 Apr 2012)
New Revision: 51281

Added:
   grass/trunk/temporal/t.rast.to.rast3/
   grass/trunk/temporal/t.rast.to.rast3/t.rast.to.rast3.html
   grass/trunk/temporal/t.rast.to.rast3/t.rast.to.rast3.py
   grass/trunk/temporal/t.rast.to.rast3/test.t.rast.to.rast3.sh
Removed:
   grass/trunk/temporal/t.rast.to.rast3/test.tr.to.rast3.sh
   grass/trunk/temporal/t.rast.to.rast3/tr.to.rast3.html
   grass/trunk/temporal/t.rast.to.rast3/tr.to.rast3.py
Modified:
   grass/trunk/temporal/t.rast.to.rast3/Makefile
Log:
Using new naming scheme


Modified: grass/trunk/temporal/t.rast.to.rast3/Makefile
===================================================================
--- grass/trunk/temporal/tr.to.rast3/Makefile	2012-04-04 21:20:55 UTC (rev 51264)
+++ grass/trunk/temporal/t.rast.to.rast3/Makefile	2012-04-05 21:19:49 UTC (rev 51281)
@@ -1,6 +1,6 @@
 MODULE_TOPDIR = ../../
 
-PGM = tr.to.rast3
+PGM = t.rast.to.rast3
 
 include $(MODULE_TOPDIR)/include/Make/Script.make
 

Copied: grass/trunk/temporal/t.rast.to.rast3/t.rast.to.rast3.html (from rev 51264, grass/trunk/temporal/tr.to.rast3/tr.to.rast3.html)
===================================================================
Copied: grass/trunk/temporal/t.rast.to.rast3/t.rast.to.rast3.py (from rev 51264, grass/trunk/temporal/tr.to.rast3/tr.to.rast3.py)
===================================================================
--- grass/trunk/temporal/t.rast.to.rast3/t.rast.to.rast3.py	                        (rev 0)
+++ grass/trunk/temporal/t.rast.to.rast3/t.rast.to.rast3.py	2012-04-05 21:19:49 UTC (rev 51281)
@@ -0,0 +1,140 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+############################################################################
+#
+# MODULE:	t.rast.to.rast3
+# AUTHOR(S):	Soeren Gebbert
+#               
+# PURPOSE:	Convert a space time raster dataset into a rast3d map
+# COPYRIGHT:	(C) 2011 by the GRASS Development Team
+#
+#		This program is free software under the GNU General Public
+#		License (version 2). Read the file COPYING that comes with GRASS
+#		for details.
+#
+#############################################################################
+
+#%module
+#% description: Convert a space time raster dataset into a rast3d map
+#% keywords: temporal
+#% keywords: raster3d
+#% keywords: convert
+#%end
+
+#%option G_OPT_STRDS_INPUT
+#%end
+
+#%option G_OPT_R3_OUTPUT
+#%end
+
+import os
+import grass.script as grass
+import grass.temporal as tgis
+
+############################################################################
+
+def main():
+
+    # Get the options
+    input = options["input"]
+    output = options["output"]
+
+    # Make sure the temporal database exists
+    tgis.create_temporal_database()
+
+    mapset =  grass.gisenv()["MAPSET"]
+
+    if input.find("@") >= 0:
+        id = input
+    else:
+        id = input + "@" + mapset
+
+    sp = tgis.space_time_raster_dataset(id)
+
+    if sp.is_in_db() == False:
+        grass.fatal(_("Space time %s dataset <%s> not found") % (sp.get_new_map_instance(None).get_type(), id))
+
+    sp.select()
+
+    maps = sp.get_registered_maps_as_objects_by_granularity()
+
+    # Get the granularity and set bottom, top and top-bottom resolution
+    granularity = sp.get_granularity()
+
+    if sp.is_time_absolute():
+        unit = granularity.split(" ")[1] 
+        granularity = int(granularity.split(" ")[0])
+    else:
+        unit = sp.get_relative_time_unit()
+
+    num_maps = len(maps)
+    bottom = 0
+    top = granularity * num_maps
+
+    ret = grass.run_command("g.region", t=top, b=bottom, tbres=granularity)
+    
+    if ret != 0:
+        grass.fatal(_("Unable to set 3d region"))
+
+    # Create a NULL map to fill the gaps
+    null_map = "temporary_null_map_%i" % os.getpid()
+    grass.mapcalc("%s = null()" % (null_map))
+
+    if maps:
+    	count = 0
+	map_names = ""
+        for map in maps:
+	    # Use the first map
+            id = map[0].get_id()
+            # None ids will be replaced by NULL maps
+            if id == None:
+                id = null_map
+
+	    if count == 0:
+	        map_names = id
+            else:
+                map_names += ",%s" % id
+
+            count += 1
+
+        ret = grass.run_command("r.to.rast3", input=map_names, output=output, overwrite=grass.overwrite())
+     
+        if ret != 0:
+            grass.fatal(_("Unable to create raster3d map <%s>" % output))
+
+    grass.run_command("g.remove", rast=null_map)
+
+    title = _("Space time voxel cube")
+    descr = _("This space time voxel cube was created with t.rast.to.rast3")
+
+    # Set the unit
+    ret = grass.run_command("r3.support", map=output, vunit=unit, title=title, description=descr, overwrite=grass.overwrite())
+
+    # Register the space time voxel cube in the temporal GIS
+    if output.find("@") >= 0:
+        id = output
+    else:
+        id = output + "@" + mapset
+
+    start, end = sp.get_valid_time()
+    r3ds = tgis.raster3d_dataset(id)
+
+    if r3ds.is_in_db():
+        r3ds.select()
+        r3ds.delete()
+        r3ds = tgis.raster3d_dataset(id)
+
+    r3ds.load()
+
+    if sp.is_time_absolute():
+        r3ds.set_absolute_time(start, end)
+        r3ds.write_absolute_time_to_file()
+    else:
+        r3ds.set_relative_time(start, end, sp.get_relative_time_unit())
+        r3ds.write_relative_time_to_file()
+
+    r3ds.insert()
+
+if __name__ == "__main__":
+    options, flags = grass.parser()
+    main()

Copied: grass/trunk/temporal/t.rast.to.rast3/test.t.rast.to.rast3.sh (from rev 51264, grass/trunk/temporal/tr.to.rast3/test.tr.to.rast3.sh)
===================================================================
--- grass/trunk/temporal/t.rast.to.rast3/test.t.rast.to.rast3.sh	                        (rev 0)
+++ grass/trunk/temporal/t.rast.to.rast3/test.t.rast.to.rast3.sh	2012-04-05 21:19:49 UTC (rev 51281)
@@ -0,0 +1,36 @@
+# We need to set a specific region in the
+# @preprocess step of this test. We generate
+# raster with r.mapcalc and create two space time raster inputs
+# with relative and absolute time
+# The region setting should work for UTM and LL test locations
+g.region s=0 n=80 w=0 e=120 b=0 t=1 res=10 res3=1 -p3
+
+r.mapcalc --o expr="prec_1 = 100"
+r.mapcalc --o expr="prec_2 = 200"
+r.mapcalc --o expr="prec_3 = 300"
+r.mapcalc --o expr="prec_4 = 400"
+r.mapcalc --o expr="prec_5 = 500"
+r.mapcalc --o expr="prec_6 = 600"
+
+# @test
+# We create the space time raster inputs and register the raster maps with absolute time interval
+
+t.create --o type=strds temporaltype=absolute output=precip_abs title="A test" descr="A test"
+t.create --o type=strds temporaltype=relative output=precip_rel title="A test" descr="A test"
+
+t.register --o --v -i type=rast input=precip_abs maps=prec_1,prec_2,prec_3 start="2001-01-01" increment="1 months"
+t.info type=strds input=precip_abs
+
+t.rast.to.rast3 --o input=precip_abs output=precipitation
+t.info type=rast3d input=precipitation
+r3.info precipitation
+
+t.register --o --v -i type=rast input=precip_rel maps=prec_4,prec_5,prec_6 start=0 increment=100 unit=years
+t.info type=strds input=precip_rel
+
+t.rast.to.rast3 --o input=precip_rel output=precipitation
+t.info type=rast3d input=precipitation
+r3.info precipitation
+
+t.unregister type=rast maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6
+t.remove type=strds input=precip_abs,precip_rel

Deleted: grass/trunk/temporal/t.rast.to.rast3/test.tr.to.rast3.sh
===================================================================
--- grass/trunk/temporal/tr.to.rast3/test.tr.to.rast3.sh	2012-04-04 21:20:55 UTC (rev 51264)
+++ grass/trunk/temporal/t.rast.to.rast3/test.tr.to.rast3.sh	2012-04-05 21:19:49 UTC (rev 51281)
@@ -1,36 +0,0 @@
-# We need to set a specific region in the
-# @preprocess step of this test. We generate
-# raster with r.mapcalc and create two space time raster inputs
-# with relative and absolute time
-# The region setting should work for UTM and LL test locations
-g.region s=0 n=80 w=0 e=120 b=0 t=1 res=10 res3=1 -p3
-
-r.mapcalc --o expr="prec_1 = 100"
-r.mapcalc --o expr="prec_2 = 200"
-r.mapcalc --o expr="prec_3 = 300"
-r.mapcalc --o expr="prec_4 = 400"
-r.mapcalc --o expr="prec_5 = 500"
-r.mapcalc --o expr="prec_6 = 600"
-
-# @test
-# We create the space time raster inputs and register the raster maps with absolute time interval
-
-t.create --o type=strds temporaltype=absolute output=precip_abs title="A test" descr="A test"
-t.create --o type=strds temporaltype=relative output=precip_rel title="A test" descr="A test"
-
-t.register --o --v -i type=rast input=precip_abs maps=prec_1,prec_2,prec_3 start="2001-01-01" increment="1 months"
-t.info type=strds input=precip_abs
-
-tr.to.rast3 --o input=precip_abs output=precipitation
-t.info type=rast3d input=precipitation
-r3.info precipitation
-
-t.register --o --v -i type=rast input=precip_rel maps=prec_4,prec_5,prec_6 start=0 increment=100 unit=years
-t.info type=strds input=precip_rel
-
-tr.to.rast3 --o input=precip_rel output=precipitation
-t.info type=rast3d input=precipitation
-r3.info precipitation
-
-t.unregister type=rast maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6
-t.remove type=strds input=precip_abs,precip_rel

Deleted: grass/trunk/temporal/t.rast.to.rast3/tr.to.rast3.html
===================================================================
Deleted: grass/trunk/temporal/t.rast.to.rast3/tr.to.rast3.py
===================================================================
--- grass/trunk/temporal/tr.to.rast3/tr.to.rast3.py	2012-04-04 21:20:55 UTC (rev 51264)
+++ grass/trunk/temporal/t.rast.to.rast3/tr.to.rast3.py	2012-04-05 21:19:49 UTC (rev 51281)
@@ -1,140 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-############################################################################
-#
-# MODULE:	tr.to.rast3
-# AUTHOR(S):	Soeren Gebbert
-#               
-# PURPOSE:	Convert a space time raster dataset into a rast3d map
-# COPYRIGHT:	(C) 2011 by the GRASS Development Team
-#
-#		This program is free software under the GNU General Public
-#		License (version 2). Read the file COPYING that comes with GRASS
-#		for details.
-#
-#############################################################################
-
-#%module
-#% description: Convert a space time raster dataset into a rast3d map
-#% keywords: temporal
-#% keywords: raster3d
-#% keywords: convert
-#%end
-
-#%option G_OPT_STRDS_INPUT
-#%end
-
-#%option G_OPT_R3_OUTPUT
-#%end
-
-import os
-import grass.script as grass
-import grass.temporal as tgis
-
-############################################################################
-
-def main():
-
-    # Get the options
-    input = options["input"]
-    output = options["output"]
-
-    # Make sure the temporal database exists
-    tgis.create_temporal_database()
-
-    mapset =  grass.gisenv()["MAPSET"]
-
-    if input.find("@") >= 0:
-        id = input
-    else:
-        id = input + "@" + mapset
-
-    sp = tgis.space_time_raster_dataset(id)
-
-    if sp.is_in_db() == False:
-        grass.fatal(_("Space time %s dataset <%s> not found") % (sp.get_new_map_instance(None).get_type(), id))
-
-    sp.select()
-
-    maps = sp.get_registered_maps_as_objects_by_granularity()
-
-    # Get the granularity and set bottom, top and top-bottom resolution
-    granularity = sp.get_granularity()
-
-    if sp.is_time_absolute():
-        unit = granularity.split(" ")[1] 
-        granularity = int(granularity.split(" ")[0])
-    else:
-        unit = sp.get_relative_time_unit()
-
-    num_maps = len(maps)
-    bottom = 0
-    top = granularity * num_maps
-
-    ret = grass.run_command("g.region", t=top, b=bottom, tbres=granularity)
-    
-    if ret != 0:
-        grass.fatal(_("Unable to set 3d region"))
-
-    # Create a NULL map to fill the gaps
-    null_map = "temporary_null_map_%i" % os.getpid()
-    grass.mapcalc("%s = null()" % (null_map))
-
-    if maps:
-    	count = 0
-	map_names = ""
-        for map in maps:
-	    # Use the first map
-            id = map[0].get_id()
-            # None ids will be replaced by NULL maps
-            if id == None:
-                id = null_map
-
-	    if count == 0:
-	        map_names = id
-            else:
-                map_names += ",%s" % id
-
-            count += 1
-
-        ret = grass.run_command("r.to.rast3", input=map_names, output=output, overwrite=grass.overwrite())
-     
-        if ret != 0:
-            grass.fatal(_("Unable to create raster3d map <%s>" % output))
-
-    grass.run_command("g.remove", rast=null_map)
-
-    title = _("Space time voxel cube")
-    descr = _("This space time voxel cube was created with tr.to.rast3")
-
-    # Set the unit
-    ret = grass.run_command("r3.support", map=output, vunit=unit, title=title, description=descr, overwrite=grass.overwrite())
-
-    # Register the space time voxel cube in the temporal GIS
-    if output.find("@") >= 0:
-        id = output
-    else:
-        id = output + "@" + mapset
-
-    start, end = sp.get_valid_time()
-    r3ds = tgis.raster3d_dataset(id)
-
-    if r3ds.is_in_db():
-        r3ds.select()
-        r3ds.delete()
-        r3ds = tgis.raster3d_dataset(id)
-
-    r3ds.load()
-
-    if sp.is_time_absolute():
-        r3ds.set_absolute_time(start, end)
-        r3ds.write_absolute_time_to_file()
-    else:
-        r3ds.set_relative_time(start, end, sp.get_relative_time_unit())
-        r3ds.write_relative_time_to_file()
-
-    r3ds.insert()
-
-if __name__ == "__main__":
-    options, flags = grass.parser()
-    main()



More information about the grass-commit mailing list