[GRASS-SVN] r48904 - in grass/trunk/temporal: . t.list tr.aggregate tr.aggregate.ds tr.export tr.extract tr.list tr.register tr3.list tv.list

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Oct 21 14:35:17 EDT 2011


Author: huhabla
Date: 2011-10-21 11:35:17 -0700 (Fri, 21 Oct 2011)
New Revision: 48904

Added:
   grass/trunk/temporal/tr.aggregate.ds/
   grass/trunk/temporal/tr.aggregate.ds/Makefile
   grass/trunk/temporal/tr.aggregate.ds/test.tr.aggregate.ds.sh
   grass/trunk/temporal/tr.aggregate.ds/tr.aggregate.ds.html
   grass/trunk/temporal/tr.aggregate.ds/tr.aggregate.ds.py
   grass/trunk/temporal/tr3.list/
   grass/trunk/temporal/tr3.list/Makefile
   grass/trunk/temporal/tr3.list/test.tr3.list.sh
   grass/trunk/temporal/tr3.list/tr3.list.html
   grass/trunk/temporal/tr3.list/tr3.list.py
   grass/trunk/temporal/tv.list/
   grass/trunk/temporal/tv.list/Makefile
   grass/trunk/temporal/tv.list/test.tv.list.sh
   grass/trunk/temporal/tv.list/tv.list.html
   grass/trunk/temporal/tv.list/tv.list.py
Modified:
   grass/trunk/temporal/Makefile
   grass/trunk/temporal/t.list/t.list.py
   grass/trunk/temporal/tr.aggregate/tr.aggregate.py
   grass/trunk/temporal/tr.export/tr.export.py
   grass/trunk/temporal/tr.extract/tr.extract.py
   grass/trunk/temporal/tr.list/tr.list.py
   grass/trunk/temporal/tr.register/ECAD_climate_analysis_1995_2010.py
Log:
New list modules for space time vector and raater3d datasets. New
aggregation module to use the temporal topology of space time datasets
for aggregation.


Modified: grass/trunk/temporal/Makefile
===================================================================
--- grass/trunk/temporal/Makefile	2011-10-21 18:33:50 UTC (rev 48903)
+++ grass/trunk/temporal/Makefile	2011-10-21 18:35:17 UTC (rev 48904)
@@ -10,8 +10,11 @@
 	t.time.abs \
 	t.time.rel \
 	tr.aggregate \
+	tr.aggregate.ds \
 	tr.register \
 	tr.list \
+	tv.list \
+	tr3.list \
 	tr.series \
 	tr.export \
 	tr.import \

Modified: grass/trunk/temporal/t.list/t.list.py
===================================================================
--- grass/trunk/temporal/t.list/t.list.py	2011-10-21 18:33:50 UTC (rev 48903)
+++ grass/trunk/temporal/t.list/t.list.py	2011-10-21 18:35:17 UTC (rev 48904)
@@ -53,7 +53,7 @@
 #%option
 #% key: where
 #% type: string
-#% description: A where statement for selected listing e.g: start_time < "2001-01-01" and end_time > "2001-01-01"
+#% description: A where statement for selected listing without "WHERE" e.g: "start_time < '2001-01-01' AND end_time > '2001-01-01'"
 #% required: no
 #% multiple: no
 #%end

Modified: grass/trunk/temporal/tr.aggregate/tr.aggregate.py
===================================================================
--- grass/trunk/temporal/tr.aggregate/tr.aggregate.py	2011-10-21 18:33:50 UTC (rev 48903)
+++ grass/trunk/temporal/tr.aggregate/tr.aggregate.py	2011-10-21 18:35:17 UTC (rev 48904)
@@ -76,24 +76,6 @@
 
 ############################################################################
 
-def collect_map_names(sp, dbif, start, end):
-    
-    where = " start_time >= \'%s\' and start_time < \'%s\'" % (start, end)
-
-    print where
-    
-    rows = sp.get_registered_maps("id", where, "start_time", dbif)
-
-    if not rows:
-        return None
-
-    names = []
-    for row in rows:
-        names.append(row["id"])
-
-    return names    
-
-
 def main():
 
     # Get the options
@@ -165,66 +147,13 @@
             end = next_start_time + gran
         next_start_time = end
 
-        input_map_names = collect_map_names(sp, dbif, start, end)
+        input_map_names = tgis.collect_map_names(sp, dbif, start, end)
 
         if input_map_names:
-            grass.verbose(_("Aggregate %s raster maps") %(len(input_map_names)))
-            count += 1
-        
-            output_map_name = "%s_%i" % (base, count)
+            tgis.aggregate_raster_maps(new_sp, mapset, input_map_names, base, start, end, count, method, register_null, dbif)
 
-            map_id = output_map_name + "@" + mapset
+        count += 1
 
-            new_map = new_sp.get_new_map_instance(map_id)
-
-            # Check if new map is in the temporal database
-            if new_map.is_in_db(dbif):
-                if grass.overwrite() == True:
-                    # Remove the existing temporal database entry
-                    new_map.delete(dbif)
-                    new_map = sp.get_new_map_instance(map_id)
-                else:
-                    dbif.close()
-                    grass.error(_("Raster map <%s> is already in temporal database, use overwrite flag to overwrite"))
-                    continue
-
-            grass.verbose(_("Compute aggregation of maps between %s - %s" % (str(start), str(end))))
-
-            # Create the r.series input file
-            filename = grass.tempfile(True)
-            file = open(filename, 'w')
-
-            for name in input_map_names:
-                string = "%s\n" % (name)
-                file.write(string)
-
-            file.close()
-            # Run r.series
-            ret = grass.run_command("r.series", flags="z", file=filename, output=output_map_name, overwrite=grass.overwrite(), method=method)
-
-            if ret != 0:
-                dbif.close()
-                grass.fatal(_("Error while r.series computation"))
-
-            # Read the raster map data
-            new_map.load()
-            
-            # In case of a null map continue, do not register null maps
-            if new_map.metadata.get_min() == None and new_map.metadata.get_max() == None:
-                if not register_null:
-                    continue
-
-            # Set the time stamp
-            if new_sp.is_time_absolute():
-                new_map.set_absolute_time(start, end, None)
-            else:
-                new_map.set_relative_time(start, end)
-
-            # Insert map in temporal database
-            new_map.insert(dbif)
-
-            new_sp.register_map(new_map, dbif)
-
     # Update the spatio-temporal extent and the raster metadata table entries
     new_sp.update_from_registered_maps(dbif)
         

Added: grass/trunk/temporal/tr.aggregate.ds/Makefile
===================================================================
--- grass/trunk/temporal/tr.aggregate.ds/Makefile	                        (rev 0)
+++ grass/trunk/temporal/tr.aggregate.ds/Makefile	2011-10-21 18:35:17 UTC (rev 48904)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../../
+
+PGM = tr.aggregate.ds
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script $(TEST_DST)

Added: grass/trunk/temporal/tr.aggregate.ds/test.tr.aggregate.ds.sh
===================================================================
--- grass/trunk/temporal/tr.aggregate.ds/test.tr.aggregate.ds.sh	                        (rev 0)
+++ grass/trunk/temporal/tr.aggregate.ds/test.tr.aggregate.ds.sh	2011-10-21 18:35:17 UTC (rev 48904)
@@ -0,0 +1,46 @@
+# Test the extraction of a subset of a space time raster input
+
+# 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 = 100"
+r.mapcalc --o expr="prec_2 = 150"
+r.mapcalc --o expr="prec_3 = 250"
+r.mapcalc --o expr="prec_4 = 250"
+r.mapcalc --o expr="prec_5 = 150"
+r.mapcalc --o expr="prec_6 = 100"
+
+v.random --o -z output=soil_1 n=20 zmin=0 zmax=100 column=height
+v.random --o -z output=soil_2 n=20 zmin=0 zmax=100 column=height
+v.random --o -z output=soil_3 n=20 zmin=0 zmax=100 column=height
+
+n1=`g.tempfile pid=1 -d` 
+
+cat > $n1 << EOF
+soil_1|2001-01-01|2001-04-01
+soil_2|2001-05-01|2001-07-01
+soil_3|2001-08-01|2001-12-01
+EOF
+
+t.create --o type=stvds temporaltype=absolute output=soil_abs1 title="A test" descr="A test"
+tv.register input=soil_abs1 file=$n1 start=file end=file
+
+t.create --o type=strds temporaltype=absolute output=precip_abs1 title="A test" descr="A test"
+tr.register -i input=precip_abs1 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-03-01 00:00:00" increment="1 months"
+
+# The @test
+
+tr.aggregate.ds --o input=precip_abs1 output=precip_abs2 base=prec_sum type=stvds dataset=soil_abs1 method=sum
+t.info type=strds input=precip_abs2
+tr.list input=precip_abs2 method=deltagap
+
+# @postprocess
+t.remove type=vect input=soil_1,soil_2,soil_3
+t.remove type=stvds input=soil_abs1
+
+t.remove type=rast input=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6
+t.remove type=strds input=precip_abs1,precip_abs2

Added: grass/trunk/temporal/tr.aggregate.ds/tr.aggregate.ds.html
===================================================================
Added: grass/trunk/temporal/tr.aggregate.ds/tr.aggregate.ds.py
===================================================================
--- grass/trunk/temporal/tr.aggregate.ds/tr.aggregate.ds.py	                        (rev 0)
+++ grass/trunk/temporal/tr.aggregate.ds/tr.aggregate.ds.py	2011-10-21 18:35:17 UTC (rev 48904)
@@ -0,0 +1,189 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+############################################################################
+#
+# MODULE:	tr.aggregate.ds
+# AUTHOR(S):	Soeren Gebbert
+#
+# PURPOSE:	Aggregated data of an existing space time raster dataset using the temporal topology of a second 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: Aggregated data of an existing space time raster dataset using the temporal topology of a second space time dataset
+#% keywords: spacetime raster dataset
+#% keywords: raster
+#% keywords: aggregation
+#%end
+
+#%option
+#% key: input
+#% type: string
+#% description: Name of a space time raster dataset
+#% required: yes
+#% multiple: no
+#%end
+
+#%option
+#% key: dataset
+#% type: string
+#% description: The time intervals from this space time dataset (raster, vector or raster3d) are used for aggregation computation. 
+#% required: yes
+#% multiple: no
+#%end
+
+#%option
+#% key: type
+#% type: string
+#% description: Type of the aggregation space time dataset, default is strds
+#% required: no                                                 
+#% options: strds, str3ds, stvds
+#% answer: strds                                                
+#%end                                                           
+
+#%option
+#% key: output
+#% type: string
+#% description: Name of the output space time raster dataset
+#% required: yes
+#% multiple: no
+#%end
+
+#%option
+#% key: method
+#% type: string
+#% description: Aggregate operation to be peformed on the raster maps
+#% required: yes
+#% multiple: no
+#% options: average,count,median,mode,minimum,min_raster,maximum,max_raster,stddev,range,sum,variance,diversity,slope,offset,detcoeff,quart1,quart3,perc90,quantile,skewness,kurtosis
+#% answer: average
+#%end
+
+#%option
+#% key: base
+#% type: string
+#% description: Base name of the new created raster maps
+#% required: yes
+#% multiple: no
+#%end
+
+#%flag
+#% key: n
+#% description: Register Null maps
+#%end
+
+import grass.script as grass
+import grass.temporal as tgis
+
+############################################################################
+
+def main():
+
+    # Get the options
+    input = options["input"]
+    output = options["output"]
+    sampler = options["dataset"]
+    base = options["base"]
+    register_null = flags["n"]
+    method = options["method"]
+    type = options["type"]
+
+    # Make sure the temporal database exists
+    tgis.create_temporal_database()
+    # We need a database interface
+    dbif = tgis.sql_database_interface()
+    dbif.connect()
+   
+    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:
+        dbif.close()
+        grass.fatal(_("Dataset <%s> not found in temporal database") % (id))
+
+    sp.select(dbif)
+
+    if sampler.find("@") >= 0:
+        sampler_id = sampler
+    else:
+        sampler_id = sampler + "@" + mapset
+
+    sampler_sp = tgis.dataset_factory(type, sampler_id)
+    
+    if sampler_sp.is_in_db() == False:
+        dbif.close()
+        grass.fatal(_("Dataset <%s> not found in temporal database") % (id))
+
+    sampler_sp.select(dbif)
+
+    if sampler_sp.get_temporal_type() != sp.get_temporal_type():
+        dbif.close()
+        grass.fatal(_("Input and aggregation dataset must have the same temporal type"))
+
+    # Check if intervals are present
+    if sampler_sp.get_temporal_type() == "absolute":
+        map_time = sampler_sp.absolute_time.get_map_time()
+    else:
+        map_time = sampler_sp.relative_time.get_map_time()
+    
+    if map_time != "interval":
+        dbif.close()
+        grass.fatal(_("All registered maps of the aggregation dataset must have time intervals"))
+
+    if output.find("@") >= 0:
+        out_id = output
+    else:
+        out_id = output + "@" + mapset
+
+    # The new space time raster dataset
+    new_sp = tgis.space_time_raster_dataset(out_id)
+    if new_sp.is_in_db(dbif):
+        if grass.overwrite() == True:
+            new_sp.delete(dbif)
+            new_sp = tgis.space_time_raster_dataset(out_id)
+        else:
+            dbif.close()
+            grass.fatal(_("Space time raster dataset <%s> is already in database, use overwrite flag to overwrite") % out_id)
+
+    temporal_type, semantic_type, title, description = sp.get_initial_values()
+    new_sp.set_initial_values(temporal_type, semantic_type, title, description)
+    new_sp.insert(dbif)
+
+    rows = sampler_sp.get_registered_maps("id,start_time,end_time", None, "start_time", dbif)
+
+    if not rows:
+            dbif.close()
+            grass.fatal(_("Aggregation dataset <%s> is empty") % out_id)
+
+    count = 0
+    for row in rows:
+        count += 1
+        start = row["start_time"]
+        end = row["end_time"]
+
+        input_map_names = tgis.collect_map_names(sp, dbif, start, end)
+
+        if input_map_names:
+            tgis.aggregate_raster_maps(new_sp, mapset, input_map_names, base, start, end, count, method, register_null, dbif)
+        
+
+    # Update the spatio-temporal extent and the raster metadata table entries
+    new_sp.update_from_registered_maps(dbif)
+        
+    dbif.close()
+
+if __name__ == "__main__":
+    options, flags = grass.parser()
+    main()
+


Property changes on: grass/trunk/temporal/tr.aggregate.ds/tr.aggregate.ds.py
___________________________________________________________________
Added: svn:executable
   + *

Modified: grass/trunk/temporal/tr.export/tr.export.py
===================================================================
--- grass/trunk/temporal/tr.export/tr.export.py	2011-10-21 18:33:50 UTC (rev 48903)
+++ grass/trunk/temporal/tr.export/tr.export.py	2011-10-21 18:35:17 UTC (rev 48904)
@@ -144,7 +144,7 @@
             out_name = name + ".tif"
 
             # Export the raster map with r.out.gdal
-            ret = grass.run_command("r.out.gdal", input=name, output=out_name, format="GTiff")
+            ret = grass.run_command("r.out.gdal", flags="c", input=name, output=out_name, format="GTiff")
             if ret != 0:
                 shutil.rmtree(new_cwd)
                 tar.close()

Modified: grass/trunk/temporal/tr.extract/tr.extract.py
===================================================================
--- grass/trunk/temporal/tr.extract/tr.extract.py	2011-10-21 18:33:50 UTC (rev 48903)
+++ grass/trunk/temporal/tr.extract/tr.extract.py	2011-10-21 18:35:17 UTC (rev 48904)
@@ -29,7 +29,12 @@
 #% multiple: no
 #%end
 
-#%option G_OPT_DB_WHERE
+#%option
+#% key: where
+#% type: string
+#% description: A where statement for selected listing without "WHERE" e.g: "start_time < '2001-01-01' AND end_time > '2001-01-01'"
+#% required: no
+#% multiple: no
 #%end
 
 #%option

Modified: grass/trunk/temporal/tr.list/tr.list.py
===================================================================
--- grass/trunk/temporal/tr.list/tr.list.py	2011-10-21 18:33:50 UTC (rev 48903)
+++ grass/trunk/temporal/tr.list/tr.list.py	2011-10-21 18:35:17 UTC (rev 48904)
@@ -53,7 +53,7 @@
 #%option
 #% key: where
 #% type: string
-#% description: A where statement for selected listing e.g: start_time < "2001-01-01" and end_time > "2001-01-01"
+#% description: A where statement for selected listing without "WHERE" e.g: "start_time < '2001-01-01' AND end_time > '2001-01-01'"
 #% required: no
 #% multiple: no
 #%end
@@ -78,9 +78,11 @@
 #%flag
 #% key: h
 #% description: Print column names 
+#%end
 
 import grass.script as grass
 import grass.temporal as tgis
+
 ############################################################################
 
 def main():
@@ -97,112 +99,8 @@
     # Make sure the temporal database exists
     tgis.create_temporal_database()
 
-    mapset =  grass.gisenv()["MAPSET"]
+    tgis.list_maps_of_stds("strds", input, columns, order, where, separator, method, header)
 
-    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(_("Dataset <%s> not found in temporal database") % (id))
-
-    sp.select()
-
-    if separator == None or separator == "":
-        separator = "\t"
-           
-    # This method expects a list of objects for gap detection
-    if method == "delta" or method == "deltagaps":
-        columns = "id,start_time,end_time"
-        if method == "deltagaps":
-            maps = sp.get_registered_maps_as_objects_with_gaps(where, None)
-        else:
-            maps = sp.get_registered_maps_as_objects(where, "start_time", None)
-
-        if header:
-            string = ""
-            string += "%s%s" % ("id", separator)
-            string += "%s%s" % ("start_time", separator)
-            string += "%s%s" % ("end_time", separator)
-            string += "%s%s" % ("interval_length", separator)
-            string += "%s"   % ("distance_from_begin")
-            print string
-
-        if maps and len(maps) > 0:
-
-            first_time, dummy = maps[0].get_valid_time()
-
-            for map in maps:
-                start, end = map.get_valid_time()
-                if end:
-                    delta = end -start
-                else:
-                    delta = None
-                delta_first = start - first_time
-
-                if map.is_time_absolute():
-                    if end:
-                        delta = tgis.time_delta_to_relative_time(delta)
-                    delta_first = tgis.time_delta_to_relative_time(delta_first)
-
-                string = ""
-                string += "%s%s" % (map.get_id(), separator)
-                string += "%s%s" % (start, separator)
-                string += "%s%s" % (end, separator)
-                string += "%s%s" % (delta, separator)
-                string += "%s"   % (delta_first)
-                print string
-
-    else:
-        # In comma separated mode only map ids are needed
-        if method == "comma":
-            columns = "id"
-
-        rows = sp.get_registered_maps(columns, where, order, None)
-
-        if rows:
-            if method == "comma":
-                string = ""
-                count = 0
-                for row in rows:
-                    if count == 0:
-                        string += row["id"]
-                    else:
-                        string += ",%s" % row["id"]
-                    count += 1
-                print string
-
-            elif method == "cols":
-                # Print the column names if requested
-                if header:
-                    output = ""
-                    count = 0
-
-                    collist = columns.split(",")
-
-                    for key in collist:
-                        if count > 0:
-                            output += separator + str(key)
-                        else:
-                            output += str(key)
-                        count += 1
-                    print output
-
-                for row in rows:
-                    output = ""
-                    count = 0
-                    for col in row:
-                        if count > 0:
-                            output += separator + str(col)
-                        else:
-                            output += str(col)
-                        count += 1
-                        
-                    print output
-
 if __name__ == "__main__":
     options, flags = grass.parser()
     main()

Modified: grass/trunk/temporal/tr.register/ECAD_climate_analysis_1995_2010.py
===================================================================
--- grass/trunk/temporal/tr.register/ECAD_climate_analysis_1995_2010.py	2011-10-21 18:33:50 UTC (rev 48903)
+++ grass/trunk/temporal/tr.register/ECAD_climate_analysis_1995_2010.py	2011-10-21 18:35:17 UTC (rev 48904)
@@ -8,16 +8,16 @@
 # First import the ECA&D data into GRASS GIS 
 input = "tg_0.25deg_reg_1995-2010_v4.0.nc"
 output = "temp_mean"
-grass.run_command("r.in.gdal", flags="o", input=input, output=output, overwrite=True)
+grass.run_command("r.in.gdal", flags="e", input=input, output=output, overwrite=True)
 input = "tn_0.25deg_reg_1995-2010_v4.0.nc"
 output = "temp_min"
-grass.run_command("r.in.gdal", flags="o", input=input, output=output, overwrite=True)
+grass.run_command("r.in.gdal", flags="e", input=input, output=output, overwrite=True)
 input = "tx_0.25deg_reg_1995-2010_v4.0.nc"
 output = "temp_max"
-grass.run_command("r.in.gdal", flags="o", input=input, output=output, overwrite=True)
+grass.run_command("r.in.gdal", flags="e", input=input, output=output, overwrite=True)
 input = "rr_0.25deg_reg_1995-2010_v4.0.nc"
 output = "precip"
-grass.run_command("r.in.gdal", flags="o", input=input, output=output, overwrite=True)
+grass.run_command("r.in.gdal", flags="e", input=input, output=output, overwrite=True)
 
 
 # This should be the number of maps to register

Added: grass/trunk/temporal/tr3.list/Makefile
===================================================================
--- grass/trunk/temporal/tr3.list/Makefile	                        (rev 0)
+++ grass/trunk/temporal/tr3.list/Makefile	2011-10-21 18:35:17 UTC (rev 48904)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../../
+
+PGM = tr3.list
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script $(TEST_DST)

Added: grass/trunk/temporal/tr3.list/test.tr3.list.sh
===================================================================
--- grass/trunk/temporal/tr3.list/test.tr3.list.sh	                        (rev 0)
+++ grass/trunk/temporal/tr3.list/test.tr3.list.sh	2011-10-21 18:35:17 UTC (rev 48904)
@@ -0,0 +1,106 @@
+# This is a test to list raster maps of a space time raster dataset
+
+# We need to set a specific region in the
+# @preprocess step of this test. We generate
+# raster with r.mapcalc and create a space time raster datasets
+# 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="vol_1 = rand(0, 550)"
+r3.mapcalc --o expr="vol_2 = rand(0, 450)"
+r3.mapcalc --o expr="vol_3 = rand(0, 320)"
+r3.mapcalc --o expr="vol_4 = rand(0, 510)"
+r3.mapcalc --o expr="vol_5 = rand(0, 300)"
+r3.mapcalc --o expr="vol_6 = rand(0, 650)"
+
+n1=`g.tempfile pid=1 -d` 
+n2=`g.tempfile pid=2 -d`
+n3=`g.tempfile pid=3 -d`
+n4=`g.tempfile pid=4 -d`
+n5=`g.tempfile pid=5 -d`
+
+cat > $n1 << EOF
+vol_1
+vol_2
+vol_3
+vol_4
+vol_5
+vol_6
+EOF
+
+cat > $n2 << EOF
+vol_1|2001-01-01
+vol_2|2001-02-01
+vol_3|2001-03-01
+vol_4|2001-04-01
+vol_5|2001-05-01
+vol_6|2001-06-01
+EOF
+
+cat > $n3 << EOF
+vol_1|2001-01-01|2001-04-01
+vol_2|2001-05-01|2001-07-01
+vol_3|2001-08-01|2001-10-01
+vol_4|2001-11-01|2002-01-01
+vol_5|2002-02-01|2002-04-01
+vol_6|2002-05-01|2002-07-01
+EOF
+
+cat > $n4 << EOF
+vol_1|2001-01-01|2001-07-01
+vol_2|2001-02-01|2001-04-01
+vol_3|2001-03-01|2001-04-01
+vol_4|2001-04-01|2001-06-01
+vol_5|2001-05-01|2001-06-01
+vol_6|2001-06-01|2001-07-01
+EOF
+
+cat > $n5 << EOF
+vol_1|2001-01-01|2001-03-11
+vol_2|2001-02-01|2001-04-01
+vol_3|2001-03-01|2001-06-02
+vol_4|2001-04-01|2001-04-01
+vol_5|2001-05-01|2001-05-01
+vol_6|2001-06-01|2001-07-01
+EOF
+
+t.create --o type=str3ds temporaltype=absolute output=volume_abs1 title="A test with input files" descr="A test with input files"
+t.create --o type=str3ds temporaltype=absolute output=volume_abs2 title="A test with input files" descr="A test with input files"
+t.create --o type=str3ds temporaltype=absolute output=volume_abs3 title="A test with input files" descr="A test with input files"
+t.create --o type=str3ds temporaltype=absolute output=volume_abs4 title="A test with input files" descr="A test with input files"
+t.create --o type=str3ds temporaltype=absolute output=volume_abs5 title="A test with input files" descr="A test with input files"
+
+# The first @test
+tr3.register    input=volume_abs1 file=$n1 start="2001-01-01" increment="1 months"
+tr3.list    fs=" | " method=comma     input=volume_abs1
+tr3.list -h input=volume_abs1
+tr3.list -h fs=" | " method=cols      input=volume_abs1
+tr3.list -h fs=" | " method=delta     input=volume_abs1
+tr3.list -h fs=" | " method=deltagaps input=volume_abs1
+
+tr3.register -i input=volume_abs2 file=$n2 start=file
+tr3.list    fs=" | " method=comma     input=volume_abs2
+tr3.list -h input=volume_abs2
+tr3.list -h fs=" | " method=cols      input=volume_abs2
+tr3.list -h fs=" | " method=delta     input=volume_abs2
+tr3.list -h fs=" | " method=deltagaps input=volume_abs2
+
+tr3.register -i input=volume_abs3 file=$n3 start=file end=file
+tr3.list    fs=" | " method=comma     input=volume_abs3
+tr3.list -h fs=" | " method=delta     input=volume_abs3
+tr3.list -h fs=" | " method=deltagaps input=volume_abs3
+
+tr3.register -i input=volume_abs4 file=$n4 start=file end=file
+tr3.list    fs=" | " method=comma     input=volume_abs4
+tr3.list -h fs=" | " method=delta     input=volume_abs4
+tr3.list -h fs=" | " method=deltagaps input=volume_abs4
+
+tr3.register -i input=volume_abs5 file=$n5 start=file end=file
+tr3.list    fs=" | " method=comma     input=volume_abs5
+tr3.list -h input=volume_abs5
+tr3.list -h fs=" | " method=cols      input=volume_abs5
+tr3.list -h fs=" | " method=delta     input=volume_abs5
+tr3.list -h fs=" | " method=deltagaps input=volume_abs5
+
+t.remove type=rast3d input=vol_1,vol_2,vol_3,vol_4,vol_5,vol_6
+t.remove type=str3ds input=volume_abs1,volume_abs2,volume_abs3,volume_abs4,volume_abs5

Added: grass/trunk/temporal/tr3.list/tr3.list.html
===================================================================
Added: grass/trunk/temporal/tr3.list/tr3.list.py
===================================================================
--- grass/trunk/temporal/tr3.list/tr3.list.py	                        (rev 0)
+++ grass/trunk/temporal/tr3.list/tr3.list.py	2011-10-21 18:35:17 UTC (rev 48904)
@@ -0,0 +1,106 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+############################################################################
+#
+# MODULE:	tr3.list
+# AUTHOR(S):	Soeren Gebbert
+#               
+# PURPOSE:	List registered maps of a space time raster3d 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 registered maps of a space time raster3d dataset 
+#% keywords: dataset
+#% keywords: spacetime
+#% keywords: raster3d
+#% keywords: list
+#%end
+
+#%option
+#% key: input
+#% type: string
+#% description: Name of a space time raster3d dataset
+#% required: yes
+#% multiple: no
+#%end
+
+#%option
+#% key: order
+#% type: string
+#% description: Order the space time dataset by category. 
+#% required: no
+#% multiple: yes
+#% options: id,name,creator,mapset,temporal_type,creation_time,start_time,end_time,north,south,west,east,nsres,tbres,ewres,cols,rows,depths,number_of_cells,min,max 
+#% answer: start_time
+#%end
+
+#%option
+#% key: columns
+#% type: string
+#% description: Select columns to be printed to stdout 
+#% required: no
+#% multiple: yes
+#% options: id,name,creator,mapset,temporal_type,creation_time,start_time,end_time,north,south,west,east,nsres,tbres,ewres,cols,rows,depths,number_of_cells,min,max 
+#% answer: name,mapset,start_time,end_time
+#%end
+
+#%option
+#% key: where
+#% type: string
+#% description: A where statement for selected listing e.g: "start_time < '2001-01-01' and end_time > '2001-01-01'"
+#% required: no
+#% multiple: no
+#%end
+
+#%option
+#% key: method
+#% type: string
+#% description: Which method should be used fot data listing
+#% required: no
+#% multiple: no
+#% options: cols,comma,delta,deltagaps
+#% answer: cols
+#%end
+
+#%option
+#% key: fs
+#% type: string
+#% description: The field separator character between the columns, default is tabular "\t"
+#% required: no
+#%end
+
+#%flag
+#% key: h
+#% description: Print column names 
+#%end
+
+import grass.script as grass
+import grass.temporal as tgis
+
+############################################################################
+
+def main():
+
+    # Get the options
+    input = options["input"]
+    columns = options["columns"]
+    order = options["order"]
+    where = options["where"]
+    separator = options["fs"]
+    method = options["method"]
+    header = flags["h"]
+
+    # Make sure the temporal database exists
+    tgis.create_temporal_database()
+
+    tgis.list_maps_of_stds("str3ds", input, columns, order, where, separator, method, header)
+
+if __name__ == "__main__":
+    options, flags = grass.parser()
+    main()


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

Added: grass/trunk/temporal/tv.list/Makefile
===================================================================
--- grass/trunk/temporal/tv.list/Makefile	                        (rev 0)
+++ grass/trunk/temporal/tv.list/Makefile	2011-10-21 18:35:17 UTC (rev 48904)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../../
+
+PGM = tv.list
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script $(TEST_DST)

Added: grass/trunk/temporal/tv.list/test.tv.list.sh
===================================================================
--- grass/trunk/temporal/tv.list/test.tv.list.sh	                        (rev 0)
+++ grass/trunk/temporal/tv.list/test.tv.list.sh	2011-10-21 18:35:17 UTC (rev 48904)
@@ -0,0 +1,106 @@
+# This is a test to list vecter maps of a space time vecter dataset
+
+# We need to set a specific region in the
+# @preprocess step of this test. We generate
+# vecter with r.mapcalc and create a space time vecter datasets
+# 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_1 n=20 zmin=0 zmax=100 column=height
+v.random --o -z output=lidar_2 n=20 zmin=0 zmax=100 column=height
+v.random --o -z output=lidar_3 n=20 zmin=0 zmax=100 column=height
+v.random --o -z output=lidar_4 n=20 zmin=0 zmax=100 column=height
+v.random --o -z output=lidar_5 n=20 zmin=0 zmax=100 column=height
+v.random --o -z output=lidar_6 n=20 zmin=0 zmax=100 column=height
+
+n1=`g.tempfile pid=1 -d` 
+n2=`g.tempfile pid=2 -d`
+n3=`g.tempfile pid=3 -d`
+n4=`g.tempfile pid=4 -d`
+n5=`g.tempfile pid=5 -d`
+
+cat > $n1 << EOF
+lidar_1
+lidar_2
+lidar_3
+lidar_4
+lidar_5
+lidar_6
+EOF
+
+cat > $n2 << EOF
+lidar_1|2001-01-01
+lidar_2|2001-02-01
+lidar_3|2001-03-01
+lidar_4|2001-04-01
+lidar_5|2001-05-01
+lidar_6|2001-06-01
+EOF
+
+cat > $n3 << EOF
+lidar_1|2001-01-01|2001-04-01
+lidar_2|2001-05-01|2001-07-01
+lidar_3|2001-08-01|2001-10-01
+lidar_4|2001-11-01|2002-01-01
+lidar_5|2002-02-01|2002-04-01
+lidar_6|2002-05-01|2002-07-01
+EOF
+
+cat > $n4 << EOF
+lidar_1|2001-01-01|2001-07-01
+lidar_2|2001-02-01|2001-04-01
+lidar_3|2001-03-01|2001-04-01
+lidar_4|2001-04-01|2001-06-01
+lidar_5|2001-05-01|2001-06-01
+lidar_6|2001-06-01|2001-07-01
+EOF
+
+cat > $n5 << EOF
+lidar_1|2001-01-01|2001-03-11
+lidar_2|2001-02-01|2001-04-01
+lidar_3|2001-03-01|2001-06-02
+lidar_4|2001-04-01|2001-04-01
+lidar_5|2001-05-01|2001-05-01
+lidar_6|2001-06-01|2001-07-01
+EOF
+
+t.create --o type=stvds temporaltype=absolute output=lidar_abs1 title="A test with input files" descr="A test with input files"
+t.create --o type=stvds temporaltype=absolute output=lidar_abs2 title="A test with input files" descr="A test with input files"
+t.create --o type=stvds temporaltype=absolute output=lidar_abs3 title="A test with input files" descr="A test with input files"
+t.create --o type=stvds temporaltype=absolute output=lidar_abs4 title="A test with input files" descr="A test with input files"
+t.create --o type=stvds temporaltype=absolute output=lidar_abs5 title="A test with input files" descr="A test with input files"
+
+# The first @test
+tv.register    input=lidar_abs1 file=$n1 start="2001-01-01" increment="1 months"
+tv.list    fs=" | " method=comma     input=lidar_abs1
+tv.list -h input=lidar_abs1
+tv.list -h fs=" | " method=cols      input=lidar_abs1
+tv.list -h fs=" | " method=delta     input=lidar_abs1
+tv.list -h fs=" | " method=deltagaps input=lidar_abs1
+
+tv.register -i input=lidar_abs2 file=$n2 start=file
+tv.list    fs=" | " method=comma     input=lidar_abs2
+tv.list -h input=lidar_abs2
+tv.list -h fs=" | " method=cols      input=lidar_abs2
+tv.list -h fs=" | " method=delta     input=lidar_abs2
+tv.list -h fs=" | " method=deltagaps input=lidar_abs2
+
+tv.register -i input=lidar_abs3 file=$n3 start=file end=file
+tv.list    fs=" | " method=comma     input=lidar_abs3
+tv.list -h fs=" | " method=delta     input=lidar_abs3
+tv.list -h fs=" | " method=deltagaps input=lidar_abs3
+
+tv.register -i input=lidar_abs4 file=$n4 start=file end=file
+tv.list    fs=" | " method=comma     input=lidar_abs4
+tv.list -h fs=" | " method=delta     input=lidar_abs4
+tv.list -h fs=" | " method=deltagaps input=lidar_abs4
+
+tv.register -i input=lidar_abs5 file=$n5 start=file end=file
+tv.list    fs=" | " method=comma     input=lidar_abs5
+tv.list -h input=lidar_abs5
+tv.list -h fs=" | " method=cols      input=lidar_abs5
+tv.list -h fs=" | " method=delta     input=lidar_abs5
+tv.list -h fs=" | " method=deltagaps input=lidar_abs5
+
+t.remove type=vect input=lidar_1,lidar_2,lidar_3,lidar_4,lidar_5,lidar_6
+t.remove type=stvds input=lidar_abs1,lidar_abs2,lidar_abs3,lidar_abs4,lidar_abs5

Added: grass/trunk/temporal/tv.list/tv.list.html
===================================================================
Added: grass/trunk/temporal/tv.list/tv.list.py
===================================================================
--- grass/trunk/temporal/tv.list/tv.list.py	                        (rev 0)
+++ grass/trunk/temporal/tv.list/tv.list.py	2011-10-21 18:35:17 UTC (rev 48904)
@@ -0,0 +1,106 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+############################################################################
+#
+# MODULE:	tv.list
+# AUTHOR(S):	Soeren Gebbert
+#               
+# PURPOSE:	List registered maps of a space time vector 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 registered maps of a space time vector dataset 
+#% keywords: dataset
+#% keywords: spacetime
+#% keywords: vector
+#% keywords: list
+#%end
+
+#%option
+#% key: input
+#% type: string
+#% description: Name of a space time vector dataset
+#% required: yes
+#% multiple: no
+#%end
+
+#%option
+#% key: order
+#% type: string
+#% description: Order the space time dataset by category. 
+#% required: no
+#% multiple: yes
+#% options: id,name,creator,mapset,temporal_type,creation_time,start_time,end_time,north,south,west,east
+#% answer: start_time
+#%end
+
+#%option
+#% key: columns
+#% type: string
+#% description: Select columns to be printed to stdout 
+#% required: no
+#% multiple: yes
+#% options: id,name,creator,mapset,temporal_type,creation_time,start_time,end_time,north,south,west,east
+#% answer: name,mapset,start_time,end_time
+#%end
+
+#%option
+#% key: where
+#% type: string
+#% description: A where statement for selected listing without "WHERE" e.g: "start_time < '2001-01-01' AND end_time > '2001-01-01'"
+#% required: no
+#% multiple: no
+#%end
+
+#%option
+#% key: method
+#% type: string
+#% description: Which method should be used fot data listing
+#% required: no
+#% multiple: no
+#% options: cols,comma,delta,deltagaps
+#% answer: cols
+#%end
+
+#%option
+#% key: fs
+#% type: string
+#% description: The field separator character between the columns, default is tabular "\t"
+#% required: no
+#%end
+
+#%flag
+#% key: h
+#% description: Print column names 
+#%end
+
+import grass.script as grass
+import grass.temporal as tgis
+
+############################################################################
+
+def main():
+
+    # Get the options
+    input = options["input"]
+    columns = options["columns"]
+    order = options["order"]
+    where = options["where"]
+    separator = options["fs"]
+    method = options["method"]
+    header = flags["h"]
+
+    # Make sure the temporal database exists
+    tgis.create_temporal_database()
+
+    tgis.list_maps_of_stds("stvds", input, columns, order, where, separator, method, header)
+
+if __name__ == "__main__":
+    options, flags = grass.parser()
+    main()


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



More information about the grass-commit mailing list