[GRASS-SVN] r48779 - in grass/trunk/temporal: . t.info t.support
t.topology tr.register tr3.register
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Oct 13 08:44:10 EDT 2011
Author: huhabla
Date: 2011-10-13 05:44:09 -0700 (Thu, 13 Oct 2011)
New Revision: 48779
Added:
grass/trunk/temporal/t.support/
grass/trunk/temporal/t.support/Makefile
grass/trunk/temporal/t.support/t.support.html
grass/trunk/temporal/t.support/t.support.py
grass/trunk/temporal/t.support/test.t.support.sh
grass/trunk/temporal/t.topology/
grass/trunk/temporal/t.topology/Makefile
grass/trunk/temporal/t.topology/t.topology.html
grass/trunk/temporal/t.topology/t.topology.py
Modified:
grass/trunk/temporal/Makefile
grass/trunk/temporal/t.info/t.info.py
grass/trunk/temporal/tr.register/test.tr.register.sh
grass/trunk/temporal/tr3.register/test.tr3.register.sh
Log:
New simple temporal support and topology modules
Modified: grass/trunk/temporal/Makefile
===================================================================
--- grass/trunk/temporal/Makefile 2011-10-13 12:42:15 UTC (rev 48778)
+++ grass/trunk/temporal/Makefile 2011-10-13 12:44:09 UTC (rev 48779)
@@ -2,6 +2,8 @@
SUBDIRS = \
t.create \
+ t.support \
+ t.topology \
t.list \
t.info \
t.remove \
Modified: grass/trunk/temporal/t.info/t.info.py
===================================================================
--- grass/trunk/temporal/t.info/t.info.py 2011-10-13 12:42:15 UTC (rev 48778)
+++ grass/trunk/temporal/t.info/t.info.py 2011-10-13 12:44:09 UTC (rev 48779)
@@ -43,11 +43,6 @@
#%end
#%flag
-#% key: t
-#% description: Print temporal relation matrix for space time datasets
-#%end
-
-#%flag
#% key: s
#% description: Print information about the temporal DBMI interface and exit
#%end
@@ -64,7 +59,6 @@
name = options["input"]
type = options["type"]
shellstyle = flags['g']
- tmatrix = flags['t']
system = flags['s']
# Make sure the temporal database exists
@@ -112,15 +106,6 @@
# Insert content from db
sp.select()
- if tmatrix:
- matrix = sp.get_temporal_relation_matrix()
-
- for row in matrix:
- for col in row:
- print col,
- print " "
- print " "
-
if shellstyle == True:
sp.print_shell_info()
else:
Added: grass/trunk/temporal/t.support/Makefile
===================================================================
--- grass/trunk/temporal/t.support/Makefile (rev 0)
+++ grass/trunk/temporal/t.support/Makefile 2011-10-13 12:44:09 UTC (rev 48779)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../../
+
+PGM = t.support
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script $(TEST_DST)
Added: grass/trunk/temporal/t.support/t.support.html
===================================================================
Added: grass/trunk/temporal/t.support/t.support.py
===================================================================
--- grass/trunk/temporal/t.support/t.support.py (rev 0)
+++ grass/trunk/temporal/t.support/t.support.py 2011-10-13 12:44:09 UTC (rev 48779)
@@ -0,0 +1,126 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+############################################################################
+#
+# MODULE: t.support
+# AUTHOR(S): Soeren Gebbert
+#
+# PURPOSE: Modify the metadata of a space time dataset
+# 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: Modify the metadata of a space time dataset
+#% keywords: spacetime
+#% keywords: dataset
+#% keywords: create
+#%end
+
+#%option
+#% key: input
+#% type: string
+#% description: Name of the space time dataset
+#% required: yes
+#% multiple: no
+#%end
+
+#%option
+#% key: granularity
+#% type: string
+#% description: The granularity of the space time dataset (NNN day, NNN week, NNN month)
+#% required: yes
+#% multiple: no
+#%end
+
+#%option
+#% key: semantictype
+#% type: string
+#% description: The semantic type of the space time dataset
+#% required: yes
+#% multiple: no
+#% options: event, const, continuous
+#% answer: event
+#%end
+
+#%option
+#% key: type
+#% type: string
+#% description: Type of the space time dataset, default is strds
+#% required: no
+#% options: strds, str3ds, stvds
+#% answer: strds
+#%end
+
+#%option
+#% key: title
+#% type: string
+#% description: Title of the space time dataset
+#% required: yes
+#% multiple: no
+#%end
+
+#%option
+#% key: description
+#% type: string
+#% description: Description of the space time dataset
+#% required: yes
+#% multiple: no
+#%end
+
+#%flag
+#% key: u
+#% description: Update metadata information, temporal and spatial extent from registered maps
+#%end
+
+import grass.temporal as tgis
+import grass.script as grass
+
+############################################################################
+
+def main():
+
+ # Get the options
+ name = options["input"]
+ type = options["type"]
+ title = options["title"]
+ descr = options["description"]
+ semantic = options["semantictype"]
+ gran = options["granularity"]
+ update = flags["u"]
+
+ # Make sure the temporal database exists
+ tgis.create_temporal_database()
+
+ #Get the current mapset to create the id of the space time dataset
+ mapset = grass.gisenv()["MAPSET"]
+ id = name + "@" + mapset
+
+ if type == "strds":
+ sp = tgis.space_time_raster_dataset(id)
+ if type == "str3ds":
+ sp = tgis.space_time_raster3d_dataset(id)
+ if type == "stvds":
+ sp = tgis.space_time_vector_dataset(id)
+
+ if sp.is_in_db() == False:
+ grass.fatal(_("%s dataset <%s> not found in temporal database") % (ds.get_type(), name))
+
+ sp.select()
+ # Temporal type can not be changed
+ ttype= sp.get_temporal_type()
+ sp.set_initial_values(granularity=gran, temporal_type=ttype, semantic_type=semantic, title=title, description=descr)
+ # Update only non-null entries
+ sp.update()
+
+ if update:
+ sp.update_from_registered_maps()
+
+if __name__ == "__main__":
+ options, flags = grass.parser()
+ main()
+
Property changes on: grass/trunk/temporal/t.support/t.support.py
___________________________________________________________________
Added: svn:executable
+ *
Added: grass/trunk/temporal/t.support/test.t.support.sh
===================================================================
--- grass/trunk/temporal/t.support/test.t.support.sh (rev 0)
+++ grass/trunk/temporal/t.support/test.t.support.sh 2011-10-13 12:44:09 UTC (rev 48779)
@@ -0,0 +1,15 @@
+# We create several space time raster datasets
+
+# A simple space ime raster datasets creation and unpdate @test with absolute time
+t.create --v --o type=strds temporaltype=absolute output=precip_abs1 gran="5 senconds" title="Test" descr="This is the 1 test strds" semantictype=event
+t.info type=strds input=precip_abs1
+t.support --v type=strds input=precip_abs1 gran="5 hours" title="Test support" descr="This is the support test strds" semantictype=const
+t.info type=strds input=precip_abs1
+
+# A simple space ime raster datasets creation and update @test with relative time
+t.create --v --o type=strds temporaltype=relative output=precip_rel1 gran=5 title="Test" descr="This is the 1 test strds" semantictype=event
+t.info type=strds input=precip_rel1
+t.support --v type=strds input=precip_rel1 gran=3 title="Test support" descr="This is the support test strds" semantictype=continuous
+t.info type=strds input=precip_rel1
+
+t.remove --v type=strds input=precip_abs1,precip_rel1
Added: grass/trunk/temporal/t.topology/Makefile
===================================================================
--- grass/trunk/temporal/t.topology/Makefile (rev 0)
+++ grass/trunk/temporal/t.topology/Makefile 2011-10-13 12:44:09 UTC (rev 48779)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../../
+
+PGM = t.topology
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script $(TEST_DST)
Added: grass/trunk/temporal/t.topology/t.topology.html
===================================================================
Added: grass/trunk/temporal/t.topology/t.topology.py
===================================================================
--- grass/trunk/temporal/t.topology/t.topology.py (rev 0)
+++ grass/trunk/temporal/t.topology/t.topology.py 2011-10-13 12:44:09 UTC (rev 48779)
@@ -0,0 +1,101 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+############################################################################
+#
+# MODULE: t.topology
+# AUTHOR(S): Soeren Gebbert
+#
+# PURPOSE: List and modify temporal topology of a space time dataset
+# 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: List and modify temporal topology of a space time dataset
+#% keywords: spacetime dataset
+#% keywords: remove
+#%end
+
+#%option
+#% key: input
+#% type: string
+#% description: Name of an existing space time dataset
+#% required: yes
+#% multiple: no
+#%end
+
+#%option
+#% key: type
+#% type: string
+#% description: Type of the space time dataset, default is strds (space time raster dataset)
+#% required: no
+#% options: strds, str3ds, stvds
+#% answer: strds
+#%end
+
+#%flag
+#% key: t
+#% description: Print temporal relation matrix for space time datasets
+#%end
+
+import grass.script as grass
+import grass.temporal as tgis
+
+############################################################################
+
+def main():
+
+ # Get the options
+ name = options["input"]
+ type = options["type"]
+ tmatrix = flags['t']
+
+ # Make sure the temporal database exists
+ tgis.create_temporal_database()
+
+ #Get the current mapset to create the id of the space time dataset
+ if name.find("@") >= 0:
+ id = name
+ else:
+ mapset = grass.gisenv()["MAPSET"]
+ id = name + "@" + mapset
+
+ if type == "strds":
+ sp = tgis.space_time_raster_dataset(id)
+ if type == "str3ds":
+ sp = tgis.space_time_raster3d_dataset(id)
+ if type == "stvds":
+ sp = tgis.space_time_vector_dataset(id)
+ if type == "rast":
+ sp = tgis.raster_dataset(id)
+ tmatrix = False
+ if type == "rast3d":
+ sp = tgis.raster3d_dataset(id)
+ tmatrix = False
+ if type == "vect":
+ sp = tgis.vector_dataset(id)
+ tmatrix = False
+
+ if sp.is_in_db() == False:
+ grass.fatal("Dataset <" + name + "> not found in temporal database")
+
+ # Insert content from db
+ sp.select()
+
+ if tmatrix:
+ matrix = sp.get_temporal_relation_matrix()
+
+ for row in matrix:
+ for col in row:
+ print col,
+ print " "
+ print " "
+
+if __name__ == "__main__":
+ options, flags = grass.parser()
+ main()
+
Property changes on: grass/trunk/temporal/t.topology/t.topology.py
___________________________________________________________________
Added: svn:executable
+ *
Modified: grass/trunk/temporal/tr.register/test.tr.register.sh
===================================================================
--- grass/trunk/temporal/tr.register/test.tr.register.sh 2011-10-13 12:42:15 UTC (rev 48778)
+++ grass/trunk/temporal/tr.register/test.tr.register.sh 2011-10-13 12:44:09 UTC (rev 48779)
@@ -31,43 +31,53 @@
tr.register -i input=precip_abs1 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="1 seconds"
t.info type=strds input=precip_abs1
tr.list input=precip_abs1
+t.topology -t input=precip_abs1
tr.register -i input=precip_abs2 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="20 seconds, 5 minutes"
t.info type=strds input=precip_abs2
tr.list input=precip_abs2
+t.topology -t input=precip_abs2
tr.register -i input=precip_abs3 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="8 hours"
t.info type=strds input=precip_abs3
tr.list input=precip_abs3
+t.topology -t input=precip_abs3
tr.register input=precip_abs4 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="3 days"
t.info type=strds input=precip_abs4
tr.list input=precip_abs4
+t.topology -t input=precip_abs4
tr.register input=precip_abs5 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="4 weeks"
t.info type=strds input=precip_abs5
tr.list input=precip_abs5
+t.topology -t input=precip_abs5
tr.register input=precip_abs6 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-08-01" increment="2 months"
t.info type=strds input=precip_abs6
tr.list input=precip_abs6
+t.topology -t input=precip_abs6
tr.register input=precip_abs7 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="20 years, 3 months, 1 days, 4 hours"
t.info type=strds input=precip_abs7
tr.list input=precip_abs7
+t.topology -t input=precip_abs7
# Register with different valid time again
tr.register input=precip_abs7 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="99 years, 9 months, 9 days, 9 hours"
t.info type=strds input=precip_abs7
tr.list input=precip_abs7
+t.topology -t input=precip_abs7
# Register with different valid time again creating an interval
tr.register -i input=precip_abs7 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="99 years, 9 months, 9 days, 9 hours"
t.info type=strds input=precip_abs7
tr.list input=precip_abs7
+t.topology -t input=precip_abs7
tr.register input=precip_abs7 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" end="2002-01-01"
t.info type=strds input=precip_abs7
tr.list input=precip_abs7
+t.topology -t input=precip_abs7
-t.remove --v type=raster input=prec_1,prec_2,prec_3
+t.remove --v type=rast input=prec_1,prec_2,prec_3
t.remove --v type=strds input=precip_abs1,precip_abs2,precip_abs3,precip_abs4,precip_abs5,precip_abs6,precip_abs7,precip_abs7
-t.remove --v type=raster input=prec_4,prec_5,prec_6
+t.remove --v type=rast input=prec_4,prec_5,prec_6
Modified: grass/trunk/temporal/tr3.register/test.tr3.register.sh
===================================================================
--- grass/trunk/temporal/tr3.register/test.tr3.register.sh 2011-10-13 12:42:15 UTC (rev 48778)
+++ grass/trunk/temporal/tr3.register/test.tr3.register.sh 2011-10-13 12:44:09 UTC (rev 48779)
@@ -1,11 +1,11 @@
# This is a test to register and unregister raster3d maps in
-# space time raster3d input.
+# space time raster3d datasets
# The raster3d maps will be registered in different space time raster3d
-# inputs
+# datasets
# We need to set a specific region in the
# @preprocess step of this test. We generate
-# 3d raster with r3.mapcalc and create two space time raster3d inputs
+# 3d raster with r3.mapcalc and create two space time raster3d datasets
# 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=50 res=10 res3=10 -p3
@@ -18,7 +18,7 @@
r3.mapcalc --o expr="volume_6 = rand(0, 650)"
# The first @test
-# We create the space time raster3d inputs and register the raster3d maps with absolute time interval
+# We create the space time raster3d dataset and register the raster3d maps with absolute time interval
t.create --v --o type=str3ds temporaltype=absolute output=volume_abs1 gran="1 senconds" title="A test" descr="A test"
t.create --v --o type=str3ds temporaltype=absolute output=volume_abs2 gran="1 minutes" title="A test" descr="A test"
More information about the grass-commit
mailing list