[GRASS-SVN] r50777 - in grass/trunk/temporal: . t.register

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Feb 12 18:09:11 EST 2012


Author: huhabla
Date: 2012-02-12 15:09:11 -0800 (Sun, 12 Feb 2012)
New Revision: 50777

Added:
   grass/trunk/temporal/t.register/
   grass/trunk/temporal/t.register/Makefile
   grass/trunk/temporal/t.register/t.register.html
   grass/trunk/temporal/t.register/t.register.py
   grass/trunk/temporal/t.register/test.t.register.raster.file.reltime.sh
   grass/trunk/temporal/t.register/test.t.register.raster.file.sh
   grass/trunk/temporal/t.register/test.t.register.raster.sh
   grass/trunk/temporal/t.register/test.t.register.raster3d.sh
   grass/trunk/temporal/t.register/test.t.register.vector.sh
Log:
Replacement for t.time.rel, t.time.abs, tr.register, tv.register
and tr3.register to reduce the complexity of the temporal GIS framework
and to avoid redundant functionality


Added: grass/trunk/temporal/t.register/Makefile
===================================================================
--- grass/trunk/temporal/t.register/Makefile	                        (rev 0)
+++ grass/trunk/temporal/t.register/Makefile	2012-02-12 23:09:11 UTC (rev 50777)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../../
+
+PGM = t.register
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script $(TEST_DST)

Added: grass/trunk/temporal/t.register/t.register.html
===================================================================
Added: grass/trunk/temporal/t.register/t.register.py
===================================================================
--- grass/trunk/temporal/t.register/t.register.py	                        (rev 0)
+++ grass/trunk/temporal/t.register/t.register.py	2012-02-12 23:09:11 UTC (rev 50777)
@@ -0,0 +1,421 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+############################################################################
+#
+# MODULE:	t.register
+# AUTHOR(S):	Soeren Gebbert
+#
+# PURPOSE:	Register raster, vector and raster3d maps in a space time datasets
+# 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: Register raster, vector adn raster3d maps in a space time datasets
+#% keywords: temnporal
+#% keywords: raster
+#% keywords: vector
+#% keywords: raster3d
+#%end
+
+#%option
+#% key: input
+#% type: string
+#% description: Name of an existing space time dataset of type raster, vector or raster3d
+#% required: yes
+#% multiple: no
+#%end
+
+#%option
+#% key: maps
+#% type: string
+#% description: Name(s) of existing map(s) of type raster, vector or raster3d
+#% required: no
+#% multiple: yes
+#%end
+
+#%option
+#% key: type
+#% type: string
+#% description: Input space time dataset type
+#% required: no
+#% options: strds, stvds, str3ds
+#% answer: strds
+#%end
+
+#%option
+#% key: file
+#% type: string
+#% description: Input file with map names, one per line. Additionally the start time and the end time can be specified per line
+#% required: no
+#% multiple: no
+#%end
+
+#%option
+#% key: start
+#% type: string
+#% description: The valid start date and time of the first map. Format absolute time: "yyyy-mm-dd HH:MM:SS +HHMM", relative time is of type integer).
+#% required: no
+#% multiple: no
+#%end
+
+#%option
+#% key: end
+#% type: string
+#% description: The valid end date and time of all map. Format absolute time: "yyyy-mm-dd HH:MM:SS +HHMM", relative time is of type integer).
+#% required: no
+#% multiple: no
+#%end
+
+#%option
+#% key: unit
+#% type: string
+#% description: This unit must be set in case of relative time stamps
+#% required: no
+#% multiple: no
+#% options: years,months,days,hours,minutes,seconds
+#%end
+
+#%option
+#% key: increment
+#% type: string
+#% description: Time increment between maps for valid time interval creation (format absolute: NNN seconds, minutes, hours, days, weeks, months, years; format relative is integer: 5)
+#% required: no
+#% multiple: no
+#%end
+
+#%option
+#% key: fs
+#% type: string
+#% description: The field separator character of the input file
+#% required: no
+#% answer: |
+#%end
+
+#%flag
+#% key: i
+#% description: Create an interval (start and end time) in case an increment is provided
+#%end
+
+import grass.script as grass
+import grass.temporal as tgis
+
+############################################################################
+
+def main():
+
+    # Get the options
+    name = options["input"]
+    maps = options["maps"]
+    type = options["type"]
+    file = options["file"]
+    fs = options["fs"]
+    start = options["start"]
+    end = options["end"]
+    unit = options["unit"]
+    increment = options["increment"]
+    interval = flags["i"]
+
+    # Make sure the temporal database exists
+    tgis.create_temporal_database()
+    # Register maps
+    register_maps_in_space_time_dataset(type=type, name=name, maps=maps, file=file, start=start, end=end, \
+                                             unit=unit, increment=increment, dbif=None, interval=interval, fs=fs)
+    
+###############################################################################
+
+def register_maps_in_space_time_dataset(type, name, maps=None, file=None, start=None, \
+                                        end=None, unit=None, increment=None, dbif = None, \
+                                        interval=False, fs="|"):
+    """Use this method to register maps in space time datasets. This function is generic and
+
+       Additionally a start time string and an increment string can be specified
+       to assign a time interval automatically to the maps.
+
+       It takes care of the correct update of the space time datasets from all
+       registered maps.
+
+       @param type: The type of the maps raster, raster3d or vector
+       @param name: The name of the space time dataset
+       @param maps: A comma separated list of map names
+       @param file: Input file one map with start and optional end time, one per line
+       @param start: The start date and time of the first raster map (format absolute: "yyyy-mm-dd HH:MM:SS" or "yyyy-mm-dd", format relative is integer 5)
+       @param end: The end date and time of the first raster map (format absolute: "yyyy-mm-dd HH:MM:SS" or "yyyy-mm-dd", format relative is integer 5)
+       @param unit: The unit of the relative time: years, months, days, hours, minutes, seconds
+       @param increment: Time increment between maps for time stamp creation (format absolute: NNN seconds, minutes, hours, days, weeks, months, years; format relative: 1.0)
+       @param dbif: The database interface to be used
+       @param interval: If True, time intervals are created in case the start time and an increment is provided
+       @param fs: Field separator used in input file
+    """
+
+    start_time_in_file = False
+    end_time_in_file = False
+    if maps and file:
+        grass.fatal(_("%s= and %s= are mutually exclusive") % ("input","file"))
+
+    if end and increment:
+        grass.fatal(_("%s= and %s= are mutually exclusive") % ("end","increment"))
+
+    if end and not start:
+        grass.fatal(_("Please specify %s= and %s=") % ("start_time","end_time"))
+
+    if not maps and not file:
+        grass.fatal(_("Please specify %s= or %s=") % ("input","file"))
+
+    # We may need the mapset
+    mapset =  grass.gisenv()["MAPSET"]
+
+    # Check if the dataset name contains the mapset as well
+    if name.find("@") < 0:
+        id = name + "@" + mapset
+    else:
+        id = name
+
+    sp = tgis.dataset_factory(type, id)
+
+    connect = False
+
+    if dbif == None:
+        dbif = tgis.sql_database_interface()
+        dbif.connect()
+        connect = True
+
+    # Read content from temporal database
+    sp.select(dbif)
+
+    if sp.is_in_db(dbif) == False:
+        dbif.close()
+        grass.fatal(_("Space time %s dataset <%s> no found") % (sp.get_new_map_instance(None).get_type(), name))
+
+    if sp.is_time_relative() and not unit:
+        dbif.close()
+        grass.fatal(_("Space time %s dataset <%s> with relative time found, but no relative unit set for %s maps") % (sp.get_new_map_instance(None).get_type(), name, sp.get_new_map_instance(None).get_type()))
+
+    dummy = sp.get_new_map_instance(None)
+        
+    maplist = []
+    
+    # Map names as comma separated string
+    if maps:
+        if maps.find(",") < 0:
+            maplist = [maps,]
+        else:
+            maplist = maps.split(",")
+
+	# Build the maplist again with the ids
+	for count in range(len(maplist)):
+	    row = {}
+	    mapid = dummy.build_id(maplist[count], mapset, None)
+		
+	    row["id"] = mapid
+            maplist[count] = row
+            
+    # Read the map list from file
+    if file:
+        fd = open(file, "r")
+
+        line = True
+        while True:
+            line = fd.readline()
+            if not line:
+                break
+
+            line_list = line.split(fs)
+
+            # Detect start and end time
+            if len(line_list) == 2:
+                start_time_in_file = True
+                end_time_in_file = False
+            elif len(line_list) == 3:
+                start_time_in_file = True
+                end_time_in_file = True
+            else:
+                start_time_in_file = False
+                end_time_in_file = False
+
+            mapname = line_list[0].strip()
+            row = {}
+            
+	    if start_time_in_file and  end_time_in_file:
+	        row["start"] = line_list[1].strip()
+	        row["end"] = line_list[2].strip()
+
+	    if start_time_in_file and  not end_time_in_file:
+	        row["start"] = line_list[1].strip()
+	    
+	    row["id"] = dummy.build_id(mapname, mapset)
+
+            maplist.append(row)
+    
+    num_maps = len(maplist)
+    for count in range(len(maplist)):
+	grass.percent(count, num_maps, 1)
+
+        # Get a new instance of the space time dataset map type
+        map = sp.get_new_map_instance(maplist[count]["id"])
+
+        # Use the time data from file
+        if maplist[count].has_key("start"):
+            start = maplist[count]["start"]
+        if maplist[count].has_key("end"):
+            end = maplist[count]["end"]
+
+        # Put the map into the database
+        if map.is_in_db(dbif) == False:
+            # Break in case no valid time is provided
+            if start == "" or start == None:
+                dbif.close()
+                if map.get_layer():
+		    grass.fatal(_("Unable to register %s map <%s> with layer %s. The map has no valid time and the start time is not set.") % \
+				(map.get_type(), map.get_map_id(), map.get_layer() ))
+		else:
+		    grass.fatal(_("Unable to register %s map <%s>. The map has no valid time and the start time is not set.") % \
+				(map.get_type(), map.get_map_id() ))
+            # Load the data from the grass file database
+            map.load()
+	    
+            if sp.get_temporal_type() == "absolute":
+                map.set_time_to_absolute()
+            else:
+                map.set_time_to_relative()
+                
+            #  Put it into the temporal database
+            map.insert(dbif)
+        else:
+            map.select(dbif)
+            if map.get_temporal_type() != sp.get_temporal_type():
+                dbif.close()
+                if map.get_layer():
+		    grass.fatal(_("Unable to register %s map <%s> with layer. The temporal types are different.") %  \
+		                 (map.get_type(), map.get_map_id(), map.get_layer()))
+		    grass.fatal(_("Unable to register %s map <%s>. The temporal types are different.") %  \
+		                 (map.get_type(), map.get_map_id()))
+
+        # In case the time is in the input file we ignore the increment counter
+        if start_time_in_file:
+            count = 1
+
+        # Set the valid time
+        if start:
+            tgis.assign_valid_time_to_map(ttype=sp.get_temporal_type(), map=map, start=start, end=end, unit=unit, increment=increment, mult=count, dbif=dbif, interval=interval)
+
+        # Finally Register map in the space time dataset
+        sp.register_map(map, dbif)
+
+    # Update the space time tables
+    sp.update_from_registered_maps(dbif)
+
+    if connect == True:
+        dbif.close()
+
+    grass.percent(num_maps, num_maps, 1)
+        
+###############################################################################
+
+def unregister_maps_from_space_time_datasets(type, name, maps, file=None, dbif=None):
+    """Unregister maps from a single space time dataset or, in case no dataset name is provided,
+       unregister from all datasets within the maps are registered.
+
+       @param type: The type of the maps raster, vector or raster3d
+       @param name: Name of an existing space time raster dataset. If no name is provided the raster map(s) are unregistered from all space time datasets in which they are registered.
+       @param maps: A comma separated list of map names
+       @param file: Input file one map per line
+       @param dbif: The database interface to be used
+    """
+
+    if maps and file:
+        grass.fatal(_("%s= and %s= are mutually exclusive") % ("input","file"))
+
+    mapset =  grass.gisenv()["MAPSET"]
+
+    if dbif == None:
+        dbif = sql_database_interface()
+        dbif.connect()
+        connect = True
+
+    # In case a space time dataset is specified
+    if name:
+        # Check if the dataset name contains the mapset as well
+        if name.find("@") < 0:
+            id = name + "@" + mapset
+        else:
+            id = name
+
+        if type == "rast":
+            sp = dataset_factory("strds", id)
+        if type == "rast3d":
+            sp = dataset_factory("str3ds", id)
+        if type == "vect":
+            sp = dataset_factory("stvds", id)
+
+        if sp.is_in_db(dbif) == False:
+            dbif.close()
+            grass.fatal("Space time " + sp.get_new_map_instance(None).get_type() + " dataset <" + name + "> not found")
+
+    maplist = []
+
+    dummy = raster_dataset(None)
+
+    # Map names as comma separated string
+    if maps != None:
+	if maps.find(",") == -1:
+	    maplist = [maps,]
+	else:
+	    maplist = maps.split(",")
+	    
+	# Build the maplist
+	for count in range(len(maplist)):
+	    mapname = maplist[count]
+	    mapid = dummy.build_id(mapname, mapset)
+            maplist[count] = mapid
+            
+    # Read the map list from file
+    if file:
+        fd = open(file, "r")
+
+        line = True
+        while True:
+            line = fd.readline()
+            if not line:
+                break
+
+            line_list = line.split(fs)
+            mapname = line_list[0].strip()
+	    mapid = dummy.build_id(mapname, mapset)
+            maplist.append(mapid)
+            
+    num_maps = len(maplist)
+    count = 0
+    for mapid in maplist:
+	grass.percent(count, num_maps, 1)
+            
+        print mapid
+        map = dataset_factory(type, mapid)
+
+        # Unregister map if in database
+        if map.is_in_db(dbif) == True:
+            if name:
+                sp.select(dbif)
+                sp.unregister_map(map, dbif)
+            else:
+                map.select(dbif)
+                map.unregister(dbif)
+		
+	count += 1
+
+    if name:
+        sp.update_from_registered_maps(dbif)
+
+    if connect == True:
+        dbif.close()
+	
+    grass.percent(num_maps, num_maps, 1)
+
+
+if __name__ == "__main__":
+    options, flags = grass.parser()
+    main()


Property changes on: grass/trunk/temporal/t.register/t.register.py
___________________________________________________________________
Added: svn:executable
   + *

Added: grass/trunk/temporal/t.register/test.t.register.raster.file.reltime.sh
===================================================================
--- grass/trunk/temporal/t.register/test.t.register.raster.file.reltime.sh	                        (rev 0)
+++ grass/trunk/temporal/t.register/test.t.register.raster.file.reltime.sh	2012-02-12 23:09:11 UTC (rev 50777)
@@ -0,0 +1,96 @@
+# This is a test to register and unregister raster maps in
+# space time raster input.
+# The raster maps will be registered in different space time raster
+# inputs
+
+# 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=50 res=10 res3=10 -p3
+
+r.mapcalc --o expr="prec_1 = rand(0, 550)"
+r.mapcalc --o expr="prec_2 = rand(0, 450)"
+r.mapcalc --o expr="prec_3 = rand(0, 320)"
+r.mapcalc --o expr="prec_4 = rand(0, 510)"
+r.mapcalc --o expr="prec_5 = rand(0, 300)"
+r.mapcalc --o expr="prec_6 = rand(0, 650)"
+
+n1=`g.tempfile pid=1 -d` # Only map names
+n2=`g.tempfile pid=2 -d` # Map names and start time
+n3=`g.tempfile pid=3 -d` # Map names start time and increment
+
+cat > "${n1}" << EOF
+prec_1
+prec_2
+prec_3
+prec_4
+prec_5
+prec_6
+EOF
+cat "${n1}"
+
+cat > "${n2}" << EOF
+prec_1|1
+prec_2|2
+prec_3|3
+prec_4|4
+prec_5|5
+prec_6|6
+EOF
+cat "${n2}"
+
+cat > "${n3}" << EOF
+prec_1|1|4
+prec_2|4|7
+prec_3|7|10
+prec_4|10|11
+prec_5|11|14
+prec_6|14|17
+EOF
+cat "${n3}"
+
+# The first @test
+# We create the space time raster inputs and register the raster maps with absolute time interval
+t.create --o type=strds temporaltype=relative output=precip_abs8 title="A test with input files" descr="A test with input files"
+
+# Test with input files
+# File 1
+t.register -i input=precip_abs8 file="${n1}" start=0 increment=7 unit=days
+t.info type=strds input=precip_abs8
+tr.list input=precip_abs8
+# File 1
+t.remove --v type=rast file="${n1}"
+t.register input=precip_abs8 file="${n1}" start=20 unit=years
+t.info type=strds input=precip_abs8
+tr.list input=precip_abs8
+# File 2
+t.remove --v type=rast file="${n1}"
+t.register input=precip_abs8 file="${n2}" unit=minutes
+t.info type=strds input=precip_abs8
+tr.list input=precip_abs8
+# File 2 ERROR ERROR -- Increment computation needs to be fixed
+t.remove --v type=rast file="${n1}"
+t.register input=precip_abs8 file="${n2}" increment=14 unit=days
+t.info type=strds input=precip_abs8
+tr.list input=precip_abs8
+# File 2 ERROR ERROR -- Increment computation needs to be fixed
+t.remove --v type=rast file="${n1}"
+t.register -i input=precip_abs8 file="${n2}" increment=14 unit=days
+t.info type=strds input=precip_abs8
+tr.list input=precip_abs8
+
+# File 3
+t.remove --v type=rast file="${n1}"
+t.register -i input=precip_abs8 file="${n3}" unit=seconds
+t.info type=strds input=precip_abs8
+tr.list input=precip_abs8
+
+t.remove --v type=rast file="${n1}"
+
+# @test of correct @failure handling
+t.register -i input=precip_abs8 maps=preac_1,prec_2 file="${n3}" # Maps and file set
+t.register -i input=precip_abs8 file="${n3}" # No relative unit set
+
+t.remove --v type=strds input=precip_abs8

Added: grass/trunk/temporal/t.register/test.t.register.raster.file.sh
===================================================================
--- grass/trunk/temporal/t.register/test.t.register.raster.file.sh	                        (rev 0)
+++ grass/trunk/temporal/t.register/test.t.register.raster.file.sh	2012-02-12 23:09:11 UTC (rev 50777)
@@ -0,0 +1,81 @@
+# This is a test to register and unregister raster maps in
+# space time raster input.
+# The raster maps will be registered in different space time raster
+# inputs
+
+# 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=50 res=10 res3=10 -p3
+
+r.mapcalc --o expr="prec_1 = rand(0, 550)"
+r.mapcalc --o expr="prec_2 = rand(0, 450)"
+r.mapcalc --o expr="prec_3 = rand(0, 320)"
+r.mapcalc --o expr="prec_4 = rand(0, 510)"
+r.mapcalc --o expr="prec_5 = rand(0, 300)"
+r.mapcalc --o expr="prec_6 = rand(0, 650)"
+
+n1=`g.tempfile pid=1 -d` # Only map names
+n2=`g.tempfile pid=2 -d` # Map names and start time
+n3=`g.tempfile pid=3 -d` # Map names start time and increment
+
+cat > "${n1}" << EOF
+prec_1
+prec_2
+prec_3
+prec_4
+prec_5
+prec_6
+EOF
+cat "${n1}"
+
+cat > "${n2}" << EOF
+prec_1|2001-01-01
+prec_2|2001-02-01
+prec_3|2001-03-01
+prec_4|2001-04-01
+prec_5|2001-05-01
+prec_6|2001-06-01
+EOF
+cat "${n2}"
+
+cat > "${n3}" << EOF
+prec_1|2001-01-01|2001-04-01
+prec_2|2001-04-01|2001-07-01
+prec_3|2001-07-01|2001-10-01
+prec_4|2001-10-01|2002-01-01
+prec_5|2002-01-01|2002-04-01
+prec_6|2002-04-01|2002-07-01
+EOF
+cat "${n3}"
+
+# The first @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_abs8 title="A test with input files" descr="A test with input files"
+
+# Test with input files
+# File 1
+t.register -i input=precip_abs8 file="${n1}" start="2001-01-01" increment="1 months"
+t.info type=strds input=precip_abs8
+tr.list input=precip_abs8
+# File 1
+t.register input=precip_abs8 file="${n1}" start="2001-01-01" 
+t.info type=strds input=precip_abs8
+tr.list input=precip_abs8
+# File 2
+t.register input=precip_abs8 file="${n2}"
+t.info type=strds input=precip_abs8
+tr.list input=precip_abs8
+# File 2
+t.register input=precip_abs8 file="${n2}" increment="1 months"
+t.info type=strds input=precip_abs8
+tr.list input=precip_abs8
+# File 3
+t.register -i input=precip_abs8 file="${n3}"
+t.info type=strds input=precip_abs8
+tr.list input=precip_abs8
+
+t.remove --v type=strds input=precip_abs8
+t.remove --v type=rast file="${n1}"

Added: grass/trunk/temporal/t.register/test.t.register.raster.sh
===================================================================
--- grass/trunk/temporal/t.register/test.t.register.raster.sh	                        (rev 0)
+++ grass/trunk/temporal/t.register/test.t.register.raster.sh	2012-02-12 23:09:11 UTC (rev 50777)
@@ -0,0 +1,96 @@
+# This is a test to register and unregister raster maps in
+# space time raster input.
+# The raster maps will be registered in different space time raster
+# inputs
+
+# 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=50 res=10 res3=10 -p3
+
+r.mapcalc --o expr="prec_1 = rand(0, 550)"
+r.mapcalc --o expr="prec_2 = rand(0, 450)"
+r.mapcalc --o expr="prec_3 = rand(0, 320)"
+r.mapcalc --o expr="prec_4 = rand(0, 510)"
+r.mapcalc --o expr="prec_5 = rand(0, 300)"
+r.mapcalc --o expr="prec_6 = rand(0, 650)"
+
+# The first @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_abs1 title="A test" descr="A test"
+t.create --o type=strds temporaltype=absolute output=precip_abs2 title="A test" descr="A test"
+t.create --o type=strds temporaltype=absolute output=precip_abs3 title="A test" descr="A test"
+t.create --o type=strds temporaltype=absolute output=precip_abs4 title="A test" descr="A test"
+t.create --o type=strds temporaltype=absolute output=precip_abs5 title="A test" descr="A test"
+t.create --o type=strds temporaltype=absolute output=precip_abs6 title="A test" descr="A test"
+t.create --o type=strds temporaltype=absolute output=precip_abs7 title="A test" descr="A test"
+
+t.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
+t.info -g type=strds input=precip_abs1
+r.info map=prec_1
+tr.list input=precip_abs1
+t.topology input=precip_abs1
+
+t.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
+t.info -g type=strds input=precip_abs2
+r.info map=prec_1
+tr.list input=precip_abs2
+t.topology input=precip_abs2
+
+t.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 -g type=strds input=precip_abs3
+r.info map=prec_1
+tr.list input=precip_abs3
+t.topology input=precip_abs3
+
+t.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 -g type=strds input=precip_abs4
+r.info map=prec_1
+tr.list input=precip_abs4
+t.topology input=precip_abs4
+
+t.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 -g type=strds input=precip_abs5
+r.info map=prec_1
+tr.list input=precip_abs5
+t.topology input=precip_abs5
+
+t.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 -g type=strds input=precip_abs6
+r.info map=prec_1
+tr.list input=precip_abs6
+t.topology input=precip_abs6
+
+t.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 -g type=strds input=precip_abs7
+r.info map=prec_1
+tr.list input=precip_abs7
+t.topology input=precip_abs7
+# Register with different valid time again
+t.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 -g type=strds input=precip_abs7
+r.info map=prec_1
+tr.list input=precip_abs7
+t.topology input=precip_abs7
+# Register with different valid time again creating an interval
+t.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 -g type=strds input=precip_abs7
+r.info map=prec_1
+tr.list input=precip_abs7
+t.topology input=precip_abs7
+
+t.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 -g type=strds input=precip_abs7
+r.info map=prec_1
+tr.list input=precip_abs7
+t.topology input=precip_abs7
+
+t.remove type=rast input=prec_1,prec_2,prec_3
+t.remove type=strds input=precip_abs1,precip_abs2,precip_abs3,precip_abs4,precip_abs5,precip_abs6,precip_abs7
+t.remove type=rast input=prec_4,prec_5,prec_6
+r.info map=prec_1

Added: grass/trunk/temporal/t.register/test.t.register.raster3d.sh
===================================================================
--- grass/trunk/temporal/t.register/test.t.register.raster3d.sh	                        (rev 0)
+++ grass/trunk/temporal/t.register/test.t.register.raster3d.sh	2012-02-12 23:09:11 UTC (rev 50777)
@@ -0,0 +1,70 @@
+# This is a test to register and unregister raster3d maps in
+# space time raster3d datasets
+# The raster3d maps will be registered in different space time raster3d
+# 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 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
+
+r3.mapcalc --o expr="volume_1 = rand(0, 550)"
+r3.mapcalc --o expr="volume_2 = rand(0, 450)"
+r3.mapcalc --o expr="volume_3 = rand(0, 320)"
+r3.mapcalc --o expr="volume_4 = rand(0, 510)"
+r3.mapcalc --o expr="volume_5 = rand(0, 300)"
+r3.mapcalc --o expr="volume_6 = rand(0, 650)"
+
+# The first @test
+# 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 title="A test" descr="A test"
+t.create --v --o type=str3ds temporaltype=absolute output=volume_abs2 title="A test" descr="A test"
+t.create --v --o type=str3ds temporaltype=absolute output=volume_abs3 title="A test" descr="A test"
+t.create --v --o type=str3ds temporaltype=absolute output=volume_abs4 title="A test" descr="A test"
+t.create --v --o type=str3ds temporaltype=absolute output=volume_abs5 title="A test" descr="A test"
+t.create --v --o type=str3ds temporaltype=absolute output=volume_abs6 title="A test" descr="A test"
+t.create --v --o type=str3ds temporaltype=absolute output=volume_abs7 title="A test" descr="A test"
+
+t.register type=str3ds --v -i input=volume_abs1 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6 start="2001-01-01" increment="1 seconds"
+t.info type=str3ds input=volume_abs1
+tr3.unregister --v input=volume_abs1 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6
+t.info type=str3ds input=volume_abs1
+
+t.register type=str3ds --v -i input=volume_abs2 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6 start="2001-01-01" increment="20 seconds, 5 minutes"
+t.info type=str3ds input=volume_abs2
+r3.info volume_1
+r3.info volume_2
+r3.info volume_3
+r3.info volume_4
+r3.info volume_5
+r3.info volume_6
+
+t.register type=str3ds --v -i input=volume_abs3 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6 start="2001-01-01" increment="8 hours"
+t.info type=str3ds input=volume_abs3
+tr3.unregister --v maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6
+t.info type=str3ds input=volume_abs3
+
+t.register type=str3ds input=volume_abs4 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6 start="2001-01-01" increment="3 days"
+t.info type=str3ds input=volume_abs4
+
+t.register type=str3ds input=volume_abs5 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6 start="2001-01-01" increment="4 weeks"
+t.info type=str3ds input=volume_abs5
+
+t.register type=str3ds input=volume_abs6 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6 start="2001-08-01" increment="2 months"
+t.info type=str3ds input=volume_abs6
+
+t.register type=str3ds input=volume_abs7 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6 start="2001-01-01" increment="20 years, 3 months, 1 days, 4 hours"
+t.info type=str3ds input=volume_abs7
+# Register with different valid time again
+t.register type=str3ds input=volume_abs7 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6 start="2001-01-01" increment="99 years, 9 months, 9 days, 9 hours"
+t.info type=str3ds input=volume_abs7
+# Register with different valid time again creating intervals
+t.register type=str3ds -i input=volume_abs7 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6 start="2001-01-01" increment="99 years, 9 months, 9 days, 9 hours"
+t.info type=str3ds input=volume_abs7
+
+t.remove --v type=rast3d input=volume_1,volume_2,volume_3
+t.remove --v type=str3ds input=volume_abs1,volume_abs2,volume_abs3,volume_abs4,volume_abs5,volume_abs6,volume_abs7
+t.remove --v type=rast3d input=volume_4,volume_5,volume_6

Added: grass/trunk/temporal/t.register/test.t.register.vector.sh
===================================================================
--- grass/trunk/temporal/t.register/test.t.register.vector.sh	                        (rev 0)
+++ grass/trunk/temporal/t.register/test.t.register.vector.sh	2012-02-12 23:09:11 UTC (rev 50777)
@@ -0,0 +1,64 @@
+# This is a test to register and unregister vector maps in
+# space time vector input.
+# The vector maps will be registered in different space time vector
+# inputs
+
+# We need to set a specific region in the
+# @preprocess step of this test. We generate
+# vector with v.random and create several space time vector inputs
+# with 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
+
+v.random --o -z output=lidar_abs_1 n=20 zmin=0 zmax=100 column=height
+v.random --o -z output=lidar_abs_2 n=20 zmin=0 zmax=100 column=height
+v.random --o -z output=lidar_abs_3 n=20 zmin=0 zmax=100 column=height
+v.random --o -z output=lidar_abs_4 n=20 zmin=0 zmax=100 column=height
+v.random --o -z output=lidar_abs_5 n=20 zmin=0 zmax=100 column=height
+v.random --o -z output=lidar_abs_6 n=20 zmin=0 zmax=100 column=height
+
+# The first @test
+# We create the space time vector inputs and register the vector maps with absolute time interval
+
+t.create --v --o type=stvds temporaltype=absolute output=lidar_abs_ds1 title="A test" descr="A test"
+t.create --v --o type=stvds temporaltype=absolute output=lidar_abs_ds2 title="A test" descr="A test"
+t.create --v --o type=stvds temporaltype=absolute output=lidar_abs_ds3 title="A test" descr="A test"
+t.create --v --o type=stvds temporaltype=absolute output=lidar_abs_ds4 title="A test" descr="A test"
+t.create --v --o type=stvds temporaltype=absolute output=lidar_abs_ds5 title="A test" descr="A test"
+t.create --v --o type=stvds temporaltype=absolute output=lidar_abs_ds6 title="A test" descr="A test"
+t.create --v --o type=stvds temporaltype=absolute output=lidar_abs_ds7 title="A test" descr="A test"
+
+t.register type=stvds --v -i input=lidar_abs_ds1 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-01-01" increment="1 seconds"
+t.info type=stvds input=lidar_abs_ds1
+tv.unregister --v input=lidar_abs_ds1 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6
+t.info type=stvds input=lidar_abs_ds1
+
+t.register type=stvds --v -i input=lidar_abs_ds2 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-01-01" increment="20 seconds, 5 minutes"
+t.info type=stvds input=lidar_abs_ds2
+
+t.register type=stvds --v -i input=lidar_abs_ds3 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-01-01" increment="8 hours"
+t.info type=stvds input=lidar_abs_ds3
+tv.unregister --v maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6
+t.info type=stvds input=lidar_abs_ds3
+
+t.register type=stvds input=lidar_abs_ds4 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-01-01" increment="3 days"
+t.info type=stvds input=lidar_abs_ds4
+
+t.register type=stvds input=lidar_abs_ds5 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-01-01" increment="4 weeks"
+t.info type=stvds input=lidar_abs_ds5
+
+t.register type=stvds input=lidar_abs_ds6 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-08-01" increment="2 months"
+t.info type=stvds input=lidar_abs_ds6
+
+t.register type=stvds input=lidar_abs_ds7 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-01-01" increment="20 years, 3 months, 1 days, 4 hours"
+t.info type=stvds input=lidar_abs_ds7
+# Register with different valid time again
+t.register type=stvds input=lidar_abs_ds7 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-01-01" increment="99 years, 9 months, 9 days, 9 hours"
+t.info type=stvds input=lidar_abs_ds7
+# Register with different valid time again creating an interval
+t.register type=stvds -i input=lidar_abs_ds7 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-01-01" increment="99 years, 9 months, 9 days, 9 hours"
+t.info type=stvds input=lidar_abs_ds7
+
+t.remove --v type=vect input=lidar_abs_1,lidar_abs_2,lidar_abs_3
+t.remove --v type=stvds input=lidar_abs_ds1,lidar_abs_ds2,lidar_abs_ds3,lidar_abs_ds4,lidar_abs_ds5,lidar_abs_ds6,lidar_abs_ds7
+t.remove --v type=vect input=lidar_abs_4,lidar_abs_5,lidar_abs_6



More information about the grass-commit mailing list