Browse Source

PEP8 compliance. Using the new class naming scheme.

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@52647 15284696-431f-4ddb-bdfa-cd5b030d7da7
Soeren Gebbert 12 years ago
parent
commit
d0682feb0a
36 changed files with 779 additions and 638 deletions
  1. 13 7
      temporal/t.create/t.create.py
  2. 8 6
      temporal/t.info/t.info.py
  3. 4 4
      temporal/t.list/t.list.py
  4. 30 21
      temporal/t.rast.aggregate.ds/t.rast.aggregate.ds.py
  5. 32 26
      temporal/t.rast.aggregate/t.rast.aggregate.py
  6. 22 21
      temporal/t.rast.export/t.rast.export.py
  7. 6 5
      temporal/t.rast.extract/t.rast.extract.py
  8. 83 75
      temporal/t.rast.gapfill/t.rast.gapfill.py
  9. 16 15
      temporal/t.rast.import/t.rast.import.py
  10. 8 6
      temporal/t.rast.list/t.rast.list.py
  11. 7 6
      temporal/t.rast.mapcalc/t.rast.mapcalc.py
  12. 39 27
      temporal/t.rast.out.vtk/t.rast.out.vtk.py
  13. 11 8
      temporal/t.rast.series/t.rast.series.py
  14. 66 57
      temporal/t.rast.to.rast3/t.rast.to.rast3.py
  15. 5 4
      temporal/t.rast.univar/t.rast.univar.py
  16. 4 3
      temporal/t.rast3d.extract/t.rast3d.extract.py
  17. 8 6
      temporal/t.rast3d.list/t.rast3d.list.py
  18. 7 6
      temporal/t.rast3d.mapcalc/t.rast3d.mapcalc.py
  19. 6 5
      temporal/t.rast3d.univar/t.rast3d.univar.py
  20. 4 2
      temporal/t.register/t.register.py
  21. 9 8
      temporal/t.remove/t.remove.py
  22. 7 5
      temporal/t.sample/t.sample.py
  23. 49 49
      temporal/t.support/t.support.py
  24. 12 10
      temporal/t.topology/t.topology.py
  25. 41 36
      temporal/t.unregister/t.unregister.py
  26. 51 42
      temporal/t.vect.db.select/t.vect.db.select.py
  27. 2 2
      temporal/t.vect.db.select/test.t.vect.db.select.sh
  28. 22 21
      temporal/t.vect.export/t.vect.export.py
  29. 5 4
      temporal/t.vect.extract/t.vect.extract.py
  30. 1 1
      temporal/t.vect.extract/test.t.vect.extract.layer.sh
  31. 15 15
      temporal/t.vect.import/t.vect.import.py
  32. 7 5
      temporal/t.vect.list/t.vect.list.py
  33. 97 73
      temporal/t.vect.observe.strds/t.vect.observe.strds.py
  34. 1 1
      temporal/t.vect.observe.strds/test.t.vect.observe.strds.sh
  35. 5 4
      temporal/t.vect.univar/t.vect.univar.py
  36. 76 52
      temporal/t.vect.what.strds/t.vect.what.strds.py

+ 13 - 7
temporal/t.create/t.create.py

@@ -4,7 +4,7 @@
 #
 # MODULE:	t.create
 # AUTHOR(S):	Soeren Gebbert
-#               
+#
 # PURPOSE:	Create a space time dataset
 # COPYRIGHT:	(C) 2011 by the GRASS Development Team
 #
@@ -60,6 +60,7 @@ import grass.script as grass
 
 ############################################################################
 
+
 def main():
 
     # Get the options
@@ -75,7 +76,7 @@ def main():
 
     #Get the current mapset to create the id of the space time dataset
 
-    mapset =  grass.gisenv()["MAPSET"]
+    mapset = grass.gisenv()["MAPSET"]
     id = name + "@" + mapset
 
     sp = tgis.dataset_factory(type, id)
@@ -85,16 +86,22 @@ def main():
 
     if sp.is_in_db(dbif) and grass.overwrite() == False:
         dbif.close()
-        grass.fatal(_("Space time %s dataset <%s> is already in the database. Use the overwrite flag.") % (sp.get_new_map_instance(None).get_type(), name))
+        grass.fatal(_("Space time %s dataset <%s> is already in the database. "
+                      "Use the overwrite flag.") %
+                    (sp.get_new_map_instance(None).get_type(), name))
 
     if sp.is_in_db(dbif) and grass.overwrite() == True:
-        grass.info(_("Overwrite space time %s dataset <%s> and unregister all maps.") % (sp.get_new_map_instance(None).get_type(), name))
+        grass.info(_("Overwrite space time %s dataset <%s> "
+                     "and unregister all maps.") %
+                   (sp.get_new_map_instance(None).get_type(), name))
         sp.delete(dbif)
         sp = sp.get_new_instance(id)
 
-    grass.verbose(_("Create space time %s dataset.") % sp.get_new_map_instance(None).get_type())
+    grass.verbose(_("Create space time %s dataset.") %
+                  sp.get_new_map_instance(None).get_type())
 
-    sp.set_initial_values(temporal_type=temporaltype, semantic_type=semantic, title=title, description=descr)
+    sp.set_initial_values(temporal_type=temporaltype, semantic_type=semantic,
+                          title=title, description=descr)
     sp.insert(dbif)
 
     dbif.close()
@@ -102,4 +109,3 @@ def main():
 if __name__ == "__main__":
     options, flags = grass.parser()
     main()
-

+ 8 - 6
temporal/t.info/t.info.py

@@ -4,7 +4,7 @@
 #
 # MODULE:	t.info
 # AUTHOR(S):	Soeren Gebbert
-#               
+#
 # PURPOSE:	Print information about a space-time dataset
 # COPYRIGHT:	(C) 2011 by the GRASS Development Team
 #
@@ -53,6 +53,7 @@ import grass.temporal as tgis
 
 ############################################################################
 
+
 def main():
 
     name = options["input"]
@@ -67,8 +68,10 @@ def main():
         #      0123456789012345678901234567890
         print " +------------------- Temporal DBMI backend information ----------------------+"
         print " | DBMI Python interface:...... " + str(tgis.dbmi.__name__)
-        print " | DBMI init string:........... " + str(tgis.get_temporal_dbmi_init_string())
-        print " | SQL template path:.......... " + str(tgis.get_sql_template_path())
+        print " | DBMI init string:........... " + str(
+            tgis.get_temporal_dbmi_init_string())
+        print " | SQL template path:.......... " + str(
+            tgis.get_sql_template_path())
         print " +----------------------------------------------------------------------------+"
         return
 
@@ -78,14 +81,14 @@ def main():
     if name.find("@") >= 0:
         id = name
     else:
-        mapset =  grass.gisenv()["MAPSET"]
+        mapset = grass.gisenv()["MAPSET"]
         id = name + "@" + mapset
 
     ds = tgis.dataset_factory(type, id)
 
     if ds.is_in_db() == False:
         grass.fatal(_("Dataset <%s> not found") % (id))
-        
+
     ds.select()
 
     if shellstyle == True:
@@ -96,4 +99,3 @@ def main():
 if __name__ == "__main__":
     options, flags = grass.parser()
     main()
-

+ 4 - 4
temporal/t.list/t.list.py

@@ -4,7 +4,7 @@
 #
 # MODULE:	t.list
 # AUTHOR(S):	Soeren Gebbert
-#               
+#
 # PURPOSE:	List space time datasets and maps registered in the temporal database
 # COPYRIGHT:	(C) 2011 by the GRASS Development Team
 #
@@ -72,6 +72,7 @@ import grass.temporal as tgis
 
 ############################################################################
 
+
 def main():
 
     # Get the options
@@ -110,14 +111,13 @@ def main():
     if order:
         sql += " ORDER BY " + order
 
-
     dbif.cursor.execute(sql)
     rows = dbif.cursor.fetchall()
     dbif.close()
 
     # Print the query result to stout
     if rows:
-        if separator == None or separator == "":
+        if separator is None or separator == "":
             separator = "\t"
 
         # Print the column names if requested
@@ -141,7 +141,7 @@ def main():
                 else:
                     output += str(col)
                 count += 1
-                
+
             print output
 
 if __name__ == "__main__":

+ 30 - 21
temporal/t.rast.aggregate.ds/t.rast.aggregate.ds.py

@@ -30,7 +30,7 @@
 
 #%option G_OPT_STDS_TYPE
 #% description: Type of the aggregation space time dataset, default is strds
-#%end                                                           
+#%end
 
 #%option
 #% key: output
@@ -54,7 +54,7 @@
 #%end
 
 #%option G_OPT_R_BASE
-#% gisprompt: 
+#% gisprompt:
 #%end
 
 #%flag
@@ -67,6 +67,7 @@ import grass.temporal as tgis
 
 ############################################################################
 
+
 def main():
 
     # Get the options
@@ -84,19 +85,20 @@ def main():
     # We need a database interface
     dbif = tgis.SQLDatabaseInterfaceConnection()
     dbif.connect()
-   
-    mapset =  grass.gisenv()["MAPSET"]
+
+    mapset = grass.gisenv()["MAPSET"]
 
     if input.find("@") >= 0:
         id = input
     else:
         id = input + "@" + mapset
 
-    sp = tgis.space_time_raster_dataset(id)
-    
+    sp = tgis.SpaceTimeRasterDataset(id)
+
     if sp.is_in_db() == False:
         dbif.close()
-        grass.fatal(_("Space time %s dataset <%s> not found") % (sp.get_new_map_instance(None).get_type(), id))
+        grass.fatal(_("Space time %s dataset <%s> not found") % (
+            sp.get_new_map_instance(None).get_type(), id))
 
     sp.select(dbif)
 
@@ -106,7 +108,7 @@ def main():
         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))
@@ -115,17 +117,19 @@ def main():
 
     if sampler_sp.get_temporal_type() != sp.get_temporal_type():
         dbif.close()
-        grass.fatal(_("Input and aggregation dataset must have the same temporal type"))
+        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"))
+        grass.fatal(_("All registered maps of the aggregation dataset "
+                      "must have time intervals"))
 
     if output.find("@") >= 0:
         out_id = output
@@ -133,20 +137,22 @@ def main():
         out_id = output + "@" + mapset
 
     # The new space time raster dataset
-    new_sp = tgis.space_time_raster_dataset(out_id)
+    new_sp = tgis.SpaceTimeRasterDataset(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)
+            new_sp = tgis.SpaceTimeRasterDataset(out_id)
         else:
             dbif.close()
-            grass.fatal(_("Space time raster dataset <%s> is already in database, use overwrite flag to overwrite") % out_id)
+            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)
+    rows = sampler_sp.get_registered_maps(
+        "id,start_time,end_time", None, "start_time", dbif)
 
     if not rows:
             dbif.close()
@@ -158,28 +164,31 @@ def main():
         start = row["start_time"]
         end = row["end_time"]
 
-        input_map_names = tgis.collect_map_names(sp, dbif, start, end, sampling)
+        input_map_names = tgis.collect_map_names(
+            sp, dbif, start, end, sampling)
 
         if input_map_names:
-            new_map = tgis.aggregate_raster_maps(input_map_names, base, start, end, count, method, register_null, dbif)
+            new_map = tgis.aggregate_raster_maps(input_map_names, base,
+                                                 start, end, count, method, 
+                                                 register_null, dbif)
 
             if new_map:
                 # Set the time stamp and write it to the raster map
                 if sp.is_time_absolute():
                     new_map.set_absolute_time(start, end, None)
                 else:
-                    new_map.set_relative_time(start, end, sp.get_relative_time_unit())
+                    new_map.set_relative_time(start,
+                                              end, sp.get_relative_time_unit())
 
                 # 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)
-        
+
     dbif.close()
 
 if __name__ == "__main__":
     options, flags = grass.parser()
     main()
-

+ 32 - 26
temporal/t.rast.aggregate/t.rast.aggregate.py

@@ -2,15 +2,15 @@
 # -*- coding: utf-8 -*-
 ############################################################################
 #
-# MODULE:	tr.aggregate
-# AUTHOR(S):	Soeren Gebbert
+# MODULE:       tr.aggregate
+# AUTHOR(S):    Soeren Gebbert
 #
-# PURPOSE:	Temporally aggregates the maps of a space time raster dataset by a user defined granularity.
-# COPYRIGHT:	(C) 2011 by the GRASS Development Team
+# PURPOSE:      Temporally aggregates the maps of a space time raster dataset by a user defined granularity.
+# 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.
+#               This program is free software under the GNU General Public
+#               License (version 2). Read the file COPYING that comes with GRASS
+#               for details.
 #
 #############################################################################
 
@@ -56,7 +56,7 @@
 #%end
 
 #%option G_OPT_R_BASE
-#% gisprompt: 
+#% gisprompt:
 #%end
 
 #%flag
@@ -70,6 +70,7 @@ import grass.temporal as tgis
 
 ############################################################################
 
+
 def main():
 
     # Get the options
@@ -87,19 +88,20 @@ def main():
     # We need a database interface
     dbif = tgis.SQLDatabaseInterfaceConnection()
     dbif.connect()
-   
-    mapset =  grass.gisenv()["MAPSET"]
+
+    mapset = grass.gisenv()["MAPSET"]
 
     if input.find("@") >= 0:
         id = input
     else:
         id = input + "@" + mapset
 
-    sp = tgis.space_time_raster_dataset(id)
-    
+    sp = tgis.SpaceTimeRasterDataset(id)
+
     if sp.is_in_db() == False:
         dbif.close()
-        grass.fatal(_("Space time %s dataset <%s> not found") % (sp.get_new_map_instance(None).get_type(), id))
+        grass.fatal(_("Space time %s dataset <%s> not found") % (
+            sp.get_new_map_instance(None).get_type(), id))
 
     sp.select(dbif)
 
@@ -109,14 +111,15 @@ def main():
         out_id = output + "@" + mapset
 
     # The new space time raster dataset
-    new_sp = tgis.space_time_raster_dataset(out_id)
+    new_sp = tgis.SpaceTimeRasterDataset(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)
+            new_sp = tgis.SpaceTimeRasterDataset(out_id)
         else:
             dbif.close()
-            grass.fatal(_("Space time raster dataset <%s> is already in the database, use overwrite flag to overwrite") % out_id)
+            grass.fatal(_("Space time raster dataset <%s> is already in the "
+                          "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)
@@ -125,13 +128,14 @@ def main():
     rows = sp.get_registered_maps("id,start_time", where, "start_time", dbif)
 
     if not rows:
-            dbif.close()
-            grass.fatal(_("Space time raster dataset <%s> is empty") % out_id)
+        dbif.close()
+        grass.fatal(_("Space time raster dataset <%s> is empty") % out_id)
 
     # Modify the start time to fit the granularity
 
     if sp.is_time_absolute():
-        first_start_time = tgis.adjust_datetime_to_granularity( rows[0]["start_time"], gran)
+        first_start_time = tgis.adjust_datetime_to_granularity(
+            rows[0]["start_time"], gran)
     else:
         first_start_time = rows[0]["start_time"]
 
@@ -139,7 +143,7 @@ def main():
     next_start_time = first_start_time
 
     count = 0
-    
+
     while next_start_time <= last_start_time:
         start = next_start_time
         if sp.is_time_absolute():
@@ -148,18 +152,21 @@ def main():
             end = next_start_time + int(gran)
         next_start_time = end
 
-        input_map_names = tgis.collect_map_names(sp, dbif, start, end, sampling)
+        input_map_names = tgis.collect_map_names(
+            sp, dbif, start, end, sampling)
 
         if input_map_names:
-            new_map = tgis.aggregate_raster_maps(input_map_names, base, start, end, 
-						count, method, register_null, dbif)
+            new_map = tgis.aggregate_raster_maps(
+                input_map_names, base, start, end,
+                count, method, register_null, dbif)
 
             if new_map:
                 # Set the time stamp and write it to the raster map
                 if sp.is_time_absolute():
                     new_map.set_absolute_time(start, end, None)
                 else:
-                    new_map.set_relative_time(start, end, sp.get_relative_time_unit())
+                    new_map.set_relative_time(start,
+                                              end, sp.get_relative_time_unit())
 
                 # Insert map in temporal database
                 new_map.insert(dbif)
@@ -169,10 +176,9 @@ def main():
 
     # 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()
-

+ 22 - 21
temporal/t.rast.export/t.rast.export.py

@@ -2,15 +2,15 @@
 # -*- coding: utf-8 -*-
 ############################################################################
 #
-# MODULE:	t.rast.export
-# AUTHOR(S):	Soeren Gebbert
-#               
-# PURPOSE:	Export a space time raster dataset
-# COPYRIGHT:	(C) 2011 by the GRASS Development Team
+# MODULE:       t.rast.export
+# AUTHOR(S):    Soeren Gebbert
 #
-#		This program is free software under the GNU General Public
-#		License (version 2). Read the file COPYING that comes with GRASS
-#		for details.
+# PURPOSE:      Export a space time raster 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.
 #
 #############################################################################
 
@@ -60,23 +60,24 @@
 import grass.script as grass
 import grass.temporal as tgis
 
-    
+
 ############################################################################
 def main():
 
-	# Get the options
-	_input = options["input"]
-	output = options["output"]
-	compression = options["compression"]
-	workdir = options["workdir"]
-	where = options["where"]
-	_format = options["format"]
+    # Get the options
+    _input = options["input"]
+    output = options["output"]
+    compression = options["compression"]
+    workdir = options["workdir"]
+    where = options["where"]
+    _format = options["format"]
+
+    # Make sure the temporal database exists
+    tgis.create_temporal_database()
+    # Export the space time raster dataset
+    tgis.export_stds(
+        _input, output, compression, workdir, where, _format, "strds")
 
-	# Make sure the temporal database exists
-	tgis.create_temporal_database()
-	# Export the space time raster dataset
-	tgis.export_stds(_input, output, compression, workdir, where, _format, "strds")
-     
 ############################################################################
 if __name__ == "__main__":
     options, flags = grass.parser()

+ 6 - 5
temporal/t.rast.extract/t.rast.extract.py

@@ -43,7 +43,7 @@
 #% description: The base name of the new created raster maps. This name will be extended with a numerical prefix
 #% required: no
 #% multiple: no
-#% gisprompt: 
+#% gisprompt:
 #%end
 
 #%option
@@ -66,6 +66,7 @@ from multiprocessing import Process
 
 ############################################################################
 
+
 def main():
 
     # Get the options
@@ -79,12 +80,12 @@ def main():
 
     # Make sure the temporal database exists
     tgis.create_temporal_database()
-    
-    tgis.extract_dataset(input, output, "raster", where, expression, base, nprocs, register_null)
-    
+
+    tgis.extract_dataset(input, output, "raster", where, expression,
+                         base, nprocs, register_null)
+
 ###############################################################################
 
 if __name__ == "__main__":
     options, flags = grass.parser()
     main()
-

+ 83 - 75
temporal/t.rast.gapfill/t.rast.gapfill.py

@@ -2,15 +2,15 @@
 # -*- coding: utf-8 -*-
 ############################################################################
 #
-# MODULE:	t.rast.gapfill
-# AUTHOR(S):	Soeren Gebbert
+# MODULE:       t.rast.gapfill
+# AUTHOR(S):    Soeren Gebbert
 #
-# PURPOSE:	Replace gaps in a space time raster dataset with interpolated raster maps.
-# COPYRIGHT:	(C) 2012 by the GRASS Development Team
+# PURPOSE:      Replace gaps in a space time raster dataset with interpolated raster maps.
+# COPYRIGHT:    (C) 2012 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.
+#               This program is free software under the GNU General Public
+#               License (version 2). Read the file COPYING that comes with GRASS
+#               for details.
 #
 #############################################################################
 
@@ -54,7 +54,7 @@ import grass.temporal as tgis
 
 ############################################################################
 
-    
+
 def main():
 
     # Get the options
@@ -69,108 +69,116 @@ def main():
     if input.find("@") >= 0:
         id = input
     else:
-        mapset =  grass.gisenv()["MAPSET"]
+        mapset = grass.gisenv()["MAPSET"]
         id = input + "@" + mapset
 
     # We need a database interface
     dbif = tgis.SQLDatabaseInterfaceConnection()
     dbif.connect()
-    
-    sp = tgis.space_time_raster_dataset(id)
+
+    sp = tgis.SpaceTimeRasterDataset(id)
 
     if sp.is_in_db(dbif) == False:
-        grass.fatal(_("Space time %s dataset <%s> not found") % (sp.get_new_map_instance(None).get_type(), id))
+        grass.fatal(_("Space time %s dataset <%s> not found") %
+                    (sp.get_new_map_instance(None).get_type(), id))
 
     sp.select(dbif)
-    
+
     maps = sp.get_registered_maps_as_objects_with_gaps(where, dbif)
 
     num = len(maps)
-    
+
     gap_list = []
-    
+
     # Identify all gaps and create new names
     count = 0
     for _map in maps:
-	if _map.get_id() == None:
-	    count += 1
-	    _id = "%s_%d@%s"%(base, num + count, mapset)
-	    print _id
-	    _map.set_id(_id)
-	    if _map.map_exists() or _map.is_in_db(dbif):
-		grass.fatal(_("Map with name <%s> already exists. Please use another base name."%(_id)))
-	    
-	    gap_list.append(_map)
-	    
+        if _map.get_id() is None:
+            count += 1
+            _id = "%s_%d@%s" % (base, num + count, mapset)
+            print _id
+            _map.set_id(_id)
+            if _map.map_exists() or _map.is_in_db(dbif):
+                grass.fatal(_("Map with name <%s> already exists. "
+                              "Please use another base name." % (_id)))
+
+            gap_list.append(_map)
+
     if len(gap_list) == 0:
-	grass.message(_("No gaps found"))
-	return
+        grass.message(_("No gaps found"))
+        return
 
     # Build the temporal topology
     tb = tgis.temporal_topology_builder()
     tb.build(maps)
-    
+
     # Do some checks before computation
-    for _map in gap_list:	
-	if not _map.get_precedes() or not _map.get_follows():
-	    grass.fatal(_("Unable to determine successor and predecessor of a gap."))
-	
-	if len(_map.get_precedes()) > 1:
-	    grass.warning(_("More than one successor of the gap found. Using the first found."))
-	    
-	if len(_map.get_follows()) > 1:
-	    grass.warning(_("More than one predecessor of the gap found. Using the first found."))
-
-    # Interpolate the maps using parallel processing   
+    for _map in gap_list:
+        if not _map.get_precedes() or not _map.get_follows():
+            grass.fatal(_("Unable to determine successor "
+                          "and predecessor of a gap."))
+
+        if len(_map.get_precedes()) > 1:
+            grass.warning(_("More than one successor of the gap found. "
+                            "Using the first found."))
+
+        if len(_map.get_follows()) > 1:
+            grass.warning(_("More than one predecessor of the gap found. "
+                            "Using the first found."))
+
+    # Interpolate the maps using parallel processing
     proc_list = []
     proc_count = 0
     num = len(gap_list)
-        
-    for _map in gap_list:	
-	predecessor = _map.get_follows()[0]
-	successor = _map.get_precedes()[0]
-	
-	# Build the module inputs strings
-	inputs = "%s,%s"%(predecessor.get_map_id(), successor.get_map_id())
-	dpos = "0,1"
-	output = "%s"%(_map.get_name())
-	outpos = "0.5"
-	
-	# Start several processes in parallel
-	proc_list.append(Process(target=run_interp, args=(inputs,dpos,output,outpos)))
-	proc_list[proc_count].start()
-	proc_count += 1
-	
-	if proc_count == nprocs or proc_count == num:
-	    proc_count = 0
-	    exitcodes = 0
-	    for proc in proc_list:
-		proc.join()
-		exitcodes += proc.exitcode
-		
-	    if exitcodes != 0:
-		dbif.close()
-		grass.fatal(_("Error while interpolation computation"))
-		
-	    # Empty process list
-	    proc_list = []
+
+    for _map in gap_list:
+        predecessor = _map.get_follows()[0]
+        successor = _map.get_precedes()[0]
+
+        # Build the module inputs strings
+        inputs = "%s,%s" % (predecessor.get_map_id(), successor.get_map_id())
+        dpos = "0,1"
+        output = "%s" % (_map.get_name())
+        outpos = "0.5"
+
+        # Start several processes in parallel
+        proc_list.append(Process(
+            target=run_interp, args=(inputs, dpos, output, outpos)))
+        proc_list[proc_count].start()
+        proc_count += 1
+
+        if proc_count == nprocs or proc_count == num:
+            proc_count = 0
+            exitcodes = 0
+            for proc in proc_list:
+                proc.join()
+                exitcodes += proc.exitcode
+
+            if exitcodes != 0:
+                dbif.close()
+                grass.fatal(_("Error while interpolation computation"))
+
+            # Empty process list
+            proc_list = []
 
     # Insert new interpolated maps in temporal database and dataset
     for _map in gap_list:
-	_map.load()
-	_map.insert(dbif)
-	sp.register_map(_map, dbif)
-	
+        _map.load()
+        _map.insert(dbif)
+        sp.register_map(_map, dbif)
+
     sp.update_from_registered_maps(dbif)
     dbif.close()
-	
+
 ###############################################################################
 
+
 def run_interp(inputs, dpos, output, outpos):
     """Helper function to run r.series.interp in parallel"""
-    return grass.run_command("r.series.interp", input=inputs, datapos=dpos, output=output, samplingpos=outpos, overwrite=grass.overwrite(), quiet=True)
+    return grass.run_command("r.series.interp", input=inputs, datapos=dpos,
+                             output=output, samplingpos=outpos,
+                             overwrite=grass.overwrite(), quiet=True)
 
 if __name__ == "__main__":
     options, flags = grass.parser()
     main()
-

+ 16 - 15
temporal/t.rast.import/t.rast.import.py

@@ -4,7 +4,7 @@
 #
 # MODULE:        t.rast.import
 # AUTHOR(S):     Soeren Gebbert
-#               
+#
 # PURPOSE:        Import a space time raster dataset
 # COPYRIGHT:        (C) 2011 by the GRASS Development Team
 #
@@ -78,22 +78,23 @@
 import grass.script as grass
 import grass.temporal as tgis
 
+
 def main():
 
-	# Get the options
-	input = options["input"]
-	output = options["output"]
-	extrdir = options["extrdir"]
-	title = options["title"]
-	descr = options["description"]
-	location = options["location"]
-	link = flags["l"]
-	exp = flags["e"]
-	overr = flags["o"]
-	create = flags["c"]
-	
-	tgis.import_stds(input, output, extrdir, title, descr, location, 
-                link, exp, overr, create, "strds")
+    # Get the options
+    input = options["input"]
+    output = options["output"]
+    extrdir = options["extrdir"]
+    title = options["title"]
+    descr = options["description"]
+    location = options["location"]
+    link = flags["l"]
+    exp = flags["e"]
+    overr = flags["o"]
+    create = flags["c"]
+
+    tgis.import_stds(input, output, extrdir, title, descr, location,
+                     link, exp, overr, create, "strds")
 
 if __name__ == "__main__":
     options, flags = grass.parser()

+ 8 - 6
temporal/t.rast.list/t.rast.list.py

@@ -4,8 +4,8 @@
 #
 # MODULE:	t.rast.list
 # AUTHOR(S):	Soeren Gebbert
-#               
-# PURPOSE:	List registered maps of a space time raster dataset 
+#
+# PURPOSE:	List registered maps of a space time raster dataset
 # COPYRIGHT:	(C) 2011 by the GRASS Development Team
 #
 #		This program is free software under the GNU General Public
@@ -30,7 +30,7 @@
 #% 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,ewres,cols,rows,number_of_cells,min,max 
+#% options: id,name,creator,mapset,temporal_type,creation_time,start_time,end_time,north,south,west,east,nsres,ewres,cols,rows,number_of_cells,min,max
 #% answer: start_time
 #%end
 
@@ -40,7 +40,7 @@
 #% 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,ewres,cols,rows,number_of_cells,min,max 
+#% options: id,name,creator,mapset,temporal_type,creation_time,start_time,end_time,north,south,west,east,nsres,ewres,cols,rows,number_of_cells,min,max
 #% answer: name,mapset,start_time,end_time
 #%end
 
@@ -66,7 +66,7 @@
 
 #%flag
 #% key: h
-#% description: Print column names 
+#% description: Print column names
 #%end
 
 import grass.script as grass
@@ -74,6 +74,7 @@ import grass.temporal as tgis
 
 ############################################################################
 
+
 def main():
 
     # Get the options
@@ -88,7 +89,8 @@ def main():
     # Make sure the temporal database exists
     tgis.create_temporal_database()
 
-    tgis.list_maps_of_stds("strds", input, columns, order, where, separator, method, header)
+    tgis.list_maps_of_stds(
+        "strds", input, columns, order, where, separator, method, header)
 
 if __name__ == "__main__":
     options, flags = grass.parser()

+ 7 - 6
temporal/t.rast.mapcalc/t.rast.mapcalc.py

@@ -74,6 +74,7 @@ import grass.temporal as tgis
 
 ############################################################################
 
+
 def main():
 
     # Get the options
@@ -85,18 +86,18 @@ def main():
     nprocs = int(options["nprocs"])
     register_null = flags["n"]
     spatial = flags["s"]
-    
+
     # Create the method list
     method = method.split(",")
-        
+
     # Make sure the temporal database exists
     tgis.create_temporal_database()
-    
-    tgis.dataset_mapcalculator(inputs, output, "raster", expression, base, method, nprocs, register_null, spatial)
-    
+
+    tgis.dataset_mapcalculator(inputs, output, "raster", expression,
+                               base, method, nprocs, register_null, spatial)
+
 ###############################################################################
 
 if __name__ == "__main__":
     options, flags = grass.parser()
     main()
-

+ 39 - 27
temporal/t.rast.out.vtk/t.rast.out.vtk.py

@@ -2,15 +2,15 @@
 # -*- coding: utf-8 -*-
 ############################################################################
 #
-# MODULE:	t.rast.out.vtk
-# AUTHOR(S):	Soeren Gebbert
-#               
-# PURPOSE:	Export space time raster dataset as VTK time series
-# COPYRIGHT:	(C) 2011 by the GRASS Development Team
+# MODULE:       t.rast.out.vtk
+# AUTHOR(S):    Soeren Gebbert
 #
-#		This program is free software under the GNU General Public
-#		License (version 2). Read the file COPYING that comes with GRASS
-#		for details.
+# PURPOSE:      Export space time raster dataset as VTK time series
+# 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.
 #
 #############################################################################
 
@@ -71,6 +71,7 @@ import grass.temporal as tgis
 
 ############################################################################
 
+
 def main():
 
     # Get the options
@@ -86,27 +87,28 @@ def main():
     # Make sure the temporal database exists
     tgis.create_temporal_database()
 
-    if not os.path.exists(expdir): 
+    if not os.path.exists(expdir):
         grass.fatal(_("Export directory <%s> not found.") % expdir)
 
     os.chdir(expdir)
 
-    mapset =  grass.gisenv()["MAPSET"]
+    mapset = grass.gisenv()["MAPSET"]
 
     if input.find("@") >= 0:
         id = input
     else:
         id = input + "@" + mapset
 
-    sp = tgis.space_time_raster_dataset(id)
-    
+    sp = tgis.SpaceTimeRasterDataset(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))
+        grass.fatal(_("Space time %s dataset <%s> not found") % (
+            sp.get_new_map_instance(None).get_type(), id))
 
     sp.select()
 
     if use_granularity:
-	# Attention: A list of lists of maps will be returned
+        # Attention: A list of lists of maps will be returned
         maps = sp.get_registered_maps_as_objects_by_granularity()
         # Create a NULL map in case of granularity support
         null_map = "temporary_null_map_%i" % os.getpid()
@@ -114,24 +116,29 @@ def main():
     else:
         maps = sp.get_registered_maps_as_objects(where, "start_time", None)
 
-    # To have scalar values with the same name, we need to copy the raster maps using a single name
+    # To have scalar values with the same name, we need to copy the 
+    # raster maps using a single name
     map_name = "%s_%i" % (sp.base.get_name(), os.getpid())
 
     count = 0
-    if maps:
+    if maps is not None:
         for map in maps:
-	    if use_granularity:
-		id = map[0].get_map_id()
-	    else:
-		id = map.get_map_id()
+            if use_granularity:
+                if len(map[0]) > 0:
+                    id = map[0].get_map_id()
+                else:
+                    continue
+            else:
+                id = map.get_map_id()
             # None ids will be replaced by NULL maps
-            if id == None:
+            if id is None:
                 id = null_map
-            
-            grass.run_command("g.copy", rast="%s,%s" % (id, map_name), overwrite=True)
-            out_name = "%6.6i_%s.vtk" % (count, sp.base.get_name()) 
 
-            mflags=""
+            grass.run_command("g.copy", rast="%s,%s" % (id, map_name), 
+                              overwrite=True)
+            out_name = "%6.6i_%s.vtk" % (count, sp.base.get_name())
+
+            mflags = ""
             if use_pdata:
                 mflags += "p"
             if coorcorr:
@@ -139,9 +146,14 @@ def main():
 
             # Export the raster map with r.out.vtk
             if elevation:
-                ret = grass.run_command("r.out.vtk", flags=mflags, null=null, input=map_name, elevation=elevation, output=out_name, overwrite=grass.overwrite())
+                ret = grass.run_command("r.out.vtk", flags=mflags, null=null, 
+                                        input=map_name, elevation=elevation, 
+                                        output=out_name, 
+                                        overwrite=grass.overwrite())
             else:
-                ret = grass.run_command("r.out.vtk", flags=mflags, null=null, input=map_name, output=out_name, overwrite=grass.overwrite())
+                ret = grass.run_command("r.out.vtk", flags=mflags, null=null, 
+                                        input=map_name, output=out_name, 
+                                        overwrite=grass.overwrite())
 
             if ret != 0:
                 grass.fatal(_("Unable to export raster map <%s>" % name))

+ 11 - 8
temporal/t.rast.series/t.rast.series.py

@@ -59,6 +59,7 @@ import grass.temporal as tgis
 
 ############################################################################
 
+
 def main():
 
     # Get the options
@@ -75,13 +76,14 @@ def main():
     if input.find("@") >= 0:
         id = input
     else:
-        mapset =  grass.gisenv()["MAPSET"]
+        mapset = grass.gisenv()["MAPSET"]
         id = input + "@" + mapset
 
-    sp = tgis.space_time_raster_dataset(id)
+    sp = tgis.SpaceTimeRasterDataset(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))
+        grass.fatal(_("Space time %s dataset <%s> not found") % (
+            sp.get_new_map_instance(None).get_type(), id))
 
     sp.select()
 
@@ -95,22 +97,24 @@ def main():
         for row in rows:
             string = "%s\n" % (row["id"])
             file.write(string)
-        
+
         file.close()
 
-        ret = grass.run_command("r.series", flags="z", file=filename, output=output, overwrite=grass.overwrite(), method=method)
+        ret = grass.run_command("r.series", flags="z", file=filename,
+                                output=output, overwrite=grass.overwrite(), 
+                                method=method)
 
         if ret == 0 and not add_time:
             if sp.is_time_absolute():
                 start_time, end_time, tz = sp.get_absolute_time()
             else:
                 start_time, end_time = sp.get_relative_time()
-                
+
             # Create the time range for the output map
             if output.find("@") >= 0:
                 id = output
             else:
-                mapset =  grass.gisenv()["MAPSET"]
+                mapset = grass.gisenv()["MAPSET"]
                 id = output + "@" + mapset
 
             map = sp.get_new_map_instance(id)
@@ -130,4 +134,3 @@ def main():
 if __name__ == "__main__":
     options, flags = grass.parser()
     main()
-

+ 66 - 57
temporal/t.rast.to.rast3/t.rast.to.rast3.py

@@ -2,15 +2,15 @@
 # -*- 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
+# MODULE:       t.rast.to.rast3
+# AUTHOR(S):    Soeren Gebbert
 #
-#		This program is free software under the GNU General Public
-#		License (version 2). Read the file COPYING that comes with GRASS
-#		for details.
+# 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.
 #
 #############################################################################
 
@@ -34,6 +34,7 @@ from datetime import datetime
 
 ############################################################################
 
+
 def main():
 
     # Get the options
@@ -43,74 +44,79 @@ def main():
     # Make sure the temporal database exists
     tgis.create_temporal_database()
 
-    mapset =  grass.gisenv()["MAPSET"]
+    mapset = grass.gisenv()["MAPSET"]
 
     if input.find("@") >= 0:
         id = input
     else:
         id = input + "@" + mapset
 
-    sp = tgis.space_time_raster_dataset(id)
+    sp = tgis.SpaceTimeRasterDataset(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))
+        grass.fatal(_("Space time %s dataset <%s> not found") % (
+            sp.get_new_map_instance(None).get_type(), id))
 
     sp.select()
-    
+
     grass.use_temp_region()
 
     maps = sp.get_registered_maps_as_objects_by_granularity()
     num_maps = len(maps)
-    
+
     # Get the granularity and set bottom, top and top-bottom resolution
     granularity = sp.get_granularity()
-    
+
     # This is the reference time to scale the z coordinate
     reftime = datetime(1900, 1, 1)
 
-    # We set top and bottom according to the start time in relation to the date 1900-01-01 00:00:00
-    # In case of days, hours, minutes and seconds, a double number is used to represent days and fracs of a day
-    
-    # Space time voxel cubes with montly or yearly granularity can not be mixed with other temporal units
-    
+    # We set top and bottom according to the start time in relation 
+    # to the date 1900-01-01 00:00:00
+    # In case of days, hours, minutes and seconds, a double number 
+    # is used to represent days and fracs of a day
+
+    # Space time voxel cubes with montly or yearly granularity can not be 
+    # mixed with other temporal units
+
     # Compatible temporal units are : days, hours, minutes and seconds
     # Incompatible are years and moths
     start, end = sp.get_valid_time()
-        
+
     if sp.is_time_absolute():
-        unit = granularity.split(" ")[1] 
+        unit = granularity.split(" ")[1]
         granularity = int(granularity.split(" ")[0])
-        
+
         if unit == "years":
-	    bottom = start.year - 1900
-	    top = granularity * num_maps
-	elif unit == "months":
-	    bottom = (start.year - 1900) * 12 + start.month
-	    top = granularity * num_maps
-	else:
-	    bottom = tgis.time_delta_to_relative_time(start - reftime)
-	    days = 0
-	    hours = 0
-	    minutes = 0
-	    seconds = 0
-	    if unit == "days":
-		days = granularity
-	    if unit == "hours":
-		hours = granularity
-	    if unit == "minutes":
-		minutes = granularity
-	    if unit == "seconds":
-		seconds = granularity
-		
-	    granularity = days + hours/24.0 + minutes/1440.0 + seconds/86400.0 
+            bottom = start.year - 1900
+            top = granularity * num_maps
+        elif unit == "months":
+            bottom = (start.year - 1900) * 12 + start.month
+            top = granularity * num_maps
+        else:
+            bottom = tgis.time_delta_to_relative_time(start - reftime)
+            days = 0
+            hours = 0
+            minutes = 0
+            seconds = 0
+            if unit == "days":
+                days = granularity
+            if unit == "hours":
+                hours = granularity
+            if unit == "minutes":
+                minutes = granularity
+            if unit == "seconds":
+                seconds = granularity
+
+            granularity = days + hours / 24.0 + minutes / \
+                1440.0 + seconds / 86400.0
     else:
         unit = sp.get_relative_time_unit()
-	bottom = start
+        bottom = start
 
     top = bottom + 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"))
 
@@ -119,24 +125,25 @@ def main():
     grass.mapcalc("%s = null()" % (null_map))
 
     if maps:
-    	count = 0
-	map_names = ""
+        count = 0
+        map_names = ""
         for map in maps:
-	    # Use the first map
+            # Use the first map
             id = map[0].get_id()
             # None ids will be replaced by NULL maps
-            if id == None:
+            if id is None:
                 id = null_map
 
-	    if count == 0:
-	        map_names = id
+            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())
-     
+        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))
 
@@ -146,7 +153,9 @@ def main():
     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())
+    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:
@@ -155,12 +164,12 @@ def main():
         id = output + "@" + mapset
 
     start, end = sp.get_valid_time()
-    r3ds = tgis.raster3d_dataset(id)
+    r3ds = tgis.Raster3DDataset(id)
 
     if r3ds.is_in_db():
         r3ds.select()
         r3ds.delete()
-        r3ds = tgis.raster3d_dataset(id)
+        r3ds = tgis.Raster3DDataset(id)
 
     r3ds.load()
 

+ 5 - 4
temporal/t.rast.univar/t.rast.univar.py

@@ -42,7 +42,7 @@
 
 #%flag
 #% key: h
-#% description: Print column names 
+#% description: Print column names
 #%end
 
 import grass.script as grass
@@ -50,6 +50,7 @@ import grass.temporal as tgis
 
 ############################################################################
 
+
 def main():
 
     # Get the options
@@ -61,10 +62,10 @@ def main():
 
     # Make sure the temporal database exists
     tgis.create_temporal_database()
-    
-    tgis.print_gridded_dataset_univar_statistics("strds", input, where, extended, header, fs)
+
+    tgis.print_gridded_dataset_univar_statistics(
+        "strds", input, where, extended, header, fs)
 
 if __name__ == "__main__":
     options, flags = grass.parser()
     main()
-

+ 4 - 3
temporal/t.rast3d.extract/t.rast3d.extract.py

@@ -64,6 +64,7 @@ import grass.temporal as tgis
 
 ############################################################################
 
+
 def main():
 
     # Get the options
@@ -77,10 +78,10 @@ def main():
 
     # Make sure the temporal database exists
     tgis.create_temporal_database()
-    
-    tgis.extract_dataset(input, output, "raster3d", where, expression, base, nprocs, register_null)
+
+    tgis.extract_dataset(input, output, "raster3d", where, expression,
+                         base, nprocs, register_null)
 
 if __name__ == "__main__":
     options, flags = grass.parser()
     main()
-

+ 8 - 6
temporal/t.rast3d.list/t.rast3d.list.py

@@ -4,8 +4,8 @@
 #
 # MODULE:	t.rast3d.list
 # AUTHOR(S):	Soeren Gebbert
-#               
-# PURPOSE:	List registered maps of a space time raster3d dataset 
+#
+# 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
@@ -31,7 +31,7 @@
 #% 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 
+#% 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
 
@@ -41,7 +41,7 @@
 #% description: 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 
+#% 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
 
@@ -67,7 +67,7 @@
 
 #%flag
 #% key: h
-#% description: Print column names 
+#% description: Print column names
 #%end
 
 import grass.script as grass
@@ -75,6 +75,7 @@ import grass.temporal as tgis
 
 ############################################################################
 
+
 def main():
 
     # Get the options
@@ -89,7 +90,8 @@ def main():
     # Make sure the temporal database exists
     tgis.create_temporal_database()
 
-    tgis.list_maps_of_stds("str3ds", input, columns, order, where, separator, method, header)
+    tgis.list_maps_of_stds(
+        "str3ds", input, columns, order, where, separator, method, header)
 
 if __name__ == "__main__":
     options, flags = grass.parser()

+ 7 - 6
temporal/t.rast3d.mapcalc/t.rast3d.mapcalc.py

@@ -73,6 +73,7 @@ import grass.temporal as tgis
 
 ############################################################################
 
+
 def main():
 
     # Get the options
@@ -84,18 +85,18 @@ def main():
     nprocs = int(options["nprocs"])
     register_null = flags["n"]
     spatial = flags["s"]
-    
+
     # Create the method list
     method = method.split(",")
-        
+
     # Make sure the temporal database exists
     tgis.create_temporal_database()
-    
-    tgis.dataset_mapcalculator(inputs, output, "raster3d", expression, base, method, nprocs, register_null, spatial)
-    
+
+    tgis.dataset_mapcalculator(inputs, output, "raster3d", expression,
+                               base, method, nprocs, register_null, spatial)
+
 ###############################################################################
 
 if __name__ == "__main__":
     options, flags = grass.parser()
     main()
-

+ 6 - 5
temporal/t.rast3d.univar/t.rast3d.univar.py

@@ -42,7 +42,7 @@
 
 #%flag
 #% key: h
-#% description: Print column names 
+#% description: Print column names
 #%end
 
 import grass.script as grass
@@ -50,6 +50,7 @@ import grass.temporal as tgis
 
 ############################################################################
 
+
 def main():
 
     # Get the options
@@ -61,10 +62,10 @@ def main():
 
     # Make sure the temporal database exists
     tgis.create_temporal_database()
-    
-    tgis.print_gridded_dataset_univar_statistics("str3ds", input, where, extended, header, fs)
- 
+
+    tgis.print_gridded_dataset_univar_statistics(
+        "str3ds", input, where, extended, header, fs)
+
 if __name__ == "__main__":
     options, flags = grass.parser()
     main()
-

+ 4 - 2
temporal/t.register/t.register.py

@@ -87,6 +87,7 @@ import grass.temporal as tgis
 
 ############################################################################
 
+
 def main():
 
     # Get the options
@@ -104,8 +105,9 @@ def main():
     # Make sure the temporal database exists
     tgis.create_temporal_database()
     # Register maps
-    tgis.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)
+    tgis.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)
 
 ###############################################################################
 

+ 9 - 8
temporal/t.remove/t.remove.py

@@ -4,7 +4,7 @@
 #
 # MODULE:	t.remove
 # AUTHOR(S):	Soeren Gebbert
-#               
+#
 # PURPOSE:	Remove space time datasets from the temporal database
 # COPYRIGHT:	(C) 2011 by the GRASS Development Team
 #
@@ -46,15 +46,16 @@ import grass.temporal as tgis
 
 ############################################################################
 
+
 def main():
-    
+
     # Get the options
     datasets = options["input"]
     file = options["file"]
     type = options["type"]
 
     if datasets and file:
-        core.fata(_("%s= and %s= are mutually exclusive") % ("input","file"))
+        core.fata(_("%s= and %s= are mutually exclusive") % ("input", "file"))
 
     # Make sure the temporal database exists
     tgis.create_temporal_database()
@@ -84,9 +85,9 @@ def main():
             line_list = line.split("\n")
             dataset_name = line_list[0]
             dataset_list.append(dataset_name)
-    
-    mapset =  grass.gisenv()["MAPSET"]
-    
+
+    mapset = grass.gisenv()["MAPSET"]
+
     statement = ""
 
     for name in dataset_list:
@@ -101,7 +102,8 @@ def main():
 
         if sp.is_in_db(dbif) == False:
             dbif.close()
-            grass.fatal(_("Space time %s dataset <%s> not found") % (sp.get_new_map_instance(None).get_type(), id))
+            grass.fatal(_("Space time %s dataset <%s> not found")
+                        % (sp.get_new_map_instance(None).get_type(), id))
 
         statement += sp.delete(dbif=dbif, execute=False)
 
@@ -113,4 +115,3 @@ def main():
 if __name__ == "__main__":
     options, flags = grass.parser()
     main()
-

+ 7 - 5
temporal/t.sample/t.sample.py

@@ -4,7 +4,7 @@
 #
 # MODULE:	t.sample
 # AUTHOR(S):	Soeren Gebbert
-#               
+#
 # PURPOSE:	Sample the input space time dataset(s) with a sample space time dataset and print the result to stdout
 # COPYRIGHT:	(C) 2011 by the GRASS Development Team
 #
@@ -25,7 +25,7 @@
 
 #%option G_OPT_STDS_INPUT
 #% key: sample
-#% description: Name of the sample space time dataset 
+#% description: Name of the sample space time dataset
 #%end
 
 #%option G_OPT_STDS_TYPE
@@ -51,12 +51,12 @@
 
 #%flag
 #% key: c
-#% description: Print column names 
+#% description: Print column names
 #%end
 
 #%flag
 #% key: s
-#% description: Check spatial overlap to perform spatio-temporal sampling 
+#% description: Check spatial overlap to perform spatio-temporal sampling
 #%end
 
 
@@ -65,6 +65,7 @@ import grass.temporal as tgis
 
 ############################################################################
 
+
 def main():
 
     # Get the options
@@ -82,7 +83,8 @@ def main():
     # Make sure the temporal database exists
     tgis.create_temporal_database()
 
-    tgis.sample_stds_by_stds_topology(intype, samtype, inputs, sampler, header, separator, method, spatial)
+    tgis.sample_stds_by_stds_topology(intype, samtype, inputs, sampler,
+                                      header, separator, method, spatial)
 
 if __name__ == "__main__":
     options, flags = grass.parser()

+ 49 - 49
temporal/t.support/t.support.py

@@ -2,15 +2,15 @@
 # -*- 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
+# MODULE:       t.support
+# AUTHOR(S):    Soeren Gebbert
 #
-#		This program is free software under the GNU General Public
-#		License (version 2). Read the file COPYING that comes with GRASS
-#		for details.
+# 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.
 #
 #############################################################################
 
@@ -67,6 +67,7 @@ import grass.script as grass
 
 ############################################################################
 
+
 def main():
 
     # Get the options
@@ -82,13 +83,13 @@ def main():
     tgis.create_temporal_database()
 
     #Get the current mapset to create the id of the space time dataset
-    mapset =  grass.gisenv()["MAPSET"]
+    mapset = grass.gisenv()["MAPSET"]
 
     if name.find("@") >= 0:
         id = name
     else:
         id = name + "@" + mapset
-        
+
     dbif = tgis.SQLDatabaseInterfaceConnection()
     dbif.connect()
 
@@ -96,24 +97,25 @@ def main():
 
     if stds.is_in_db(dbif=dbif) == False:
         dbif.close()
-        grass.fatal(_("Space time %s dataset <%s> not found") % (stds.get_new_map_instance(None).get_type(), id))
+        grass.fatal(_("Space time %s dataset <%s> not found") % (
+            stds.get_new_map_instance(None).get_type(), id))
 
     stds.select(dbif=dbif)
-    
+
     update = False
     if title:
-	stds.metadata.set_title(title=title)
-	update = True
-	# Update only non-null entries
+        stds.metadata.set_title(title=title)
+        update = True
+        # Update only non-null entries
     if description:
-	stds.metadata.set_description(description=description)
-	update = True
+        stds.metadata.set_description(description=description)
+        update = True
     if semantic:
-	stds.base.set_semantic_type(semantic_type=semantic)
-	update = True
+        stds.base.set_semantic_type(semantic_type=semantic)
+        update = True
 
     if update:
-	stds.update(dbif=dbif)
+        stds.update(dbif=dbif)
 
     if map_update:
         #Update the registered maps from the grass spatial database
@@ -123,41 +125,40 @@ def main():
 
         count = 0
         maps = stds.get_registered_maps_as_objects(dbif=dbif)
-        
+
         # We collect the delete and update statements
         for map in maps:
-	    
-	    grass.percent(count, len(maps), 1)
-	    count += 1
-	    
-	    map.select(dbif=dbif)
-	    
-	    # Check if the map is present in the grass spatial database
-	    # Update if present, delete if not present
-	    if map.map_exists():
-		# Read new metadata from the spatial database
-		map.load()
-		statement += map.update(dbif=dbif, execute=False)
-	    else:
-		# Delete the map from the temporal database
-		# We need to update all effected space time datasets
-		rows = map.get_registered_datasets(dbif)
-		if rows: 
-		    for row in rows:
-			dataset_dict[row["id"]] = row["id"]
-		# Collect the delete statements
-		statement += map.delete(dbif=dbif, update=False, execute=False)
-	
+
+            grass.percent(count, len(maps), 1)
+            count += 1
+
+            map.select(dbif=dbif)
+
+            # Check if the map is present in the grass spatial database
+            # Update if present, delete if not present
+            if map.map_exists():
+                # Read new metadata from the spatial database
+                map.load()
+                statement += map.update(dbif=dbif, execute=False)
+            else:
+                # Delete the map from the temporal database
+                # We need to update all effected space time datasets
+                rows = map.get_registered_datasets(dbif)
+                if rows:
+                    for row in rows:
+                        dataset_dict[row["id"]] = row["id"]
+                # Collect the delete statements
+                statement += map.delete(dbif=dbif, update=False, execute=False)
 
         # Execute the collected SQL statements
         dbif.execute_transaction(statement)
-        
-	# Update the effected space time datasets
+
+        # Update the effected space time datasets
         for id in dataset_dict:
-	    stds_new = stds.get_new_instance(id)
-	    stds_new.select(dbif=dbif)
+            stds_new = stds.get_new_instance(id)
+            stds_new.select(dbif=dbif)
             stds_new.update_from_registered_maps(dbif=dbif)
-        
+
     if map_update or update:
         stds.update_from_registered_maps(dbif=dbif)
 
@@ -166,4 +167,3 @@ def main():
 if __name__ == "__main__":
     options, flags = grass.parser()
     main()
-

+ 12 - 10
temporal/t.topology/t.topology.py

@@ -4,7 +4,7 @@
 #
 # 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
 #
@@ -39,6 +39,7 @@ import grass.temporal as tgis
 
 ############################################################################
 
+
 def main():
 
     # Get the options
@@ -54,19 +55,21 @@ def main():
     if name.find("@") >= 0:
         id = name
     else:
-        mapset =  grass.gisenv()["MAPSET"]
+        mapset = grass.gisenv()["MAPSET"]
         id = name + "@" + mapset
 
     sp = tgis.dataset_factory(type, 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))
-        
+        grass.fatal(_("Space time %s dataset <%s> not found") % (
+            sp.get_new_map_instance(None).get_type(), id))
+
     # Insert content from db
     sp.select()
 
     # Get ordered map list
-    maps = sp.get_registered_maps_as_objects(where=where, order="start_time", dbif=None)
+    maps = sp.get_registered_maps_as_objects(
+        where=where, order="start_time", dbif=None)
 
     if tmatrix:
         sp.print_temporal_relationships(maps)
@@ -84,13 +87,13 @@ def main():
     check = sp.check_temporal_topology(maps)
     if check:
         #      0123456789012345678901234567890
-        print " | Temporal topology is: ...... valid"                
+        print " | Temporal topology is: ...... valid"
     else:
         #      0123456789012345678901234567890
-        print " | Temporal topology is: ...... invalid"                
+        print " | Temporal topology is: ...... invalid"
 
     dict = sp.count_temporal_types(maps)
- 
+
     for key in dict.keys():
         if key == "interval":
             #      0123456789012345678901234567890
@@ -101,7 +104,7 @@ def main():
             print " | Invalid time stamps: ....... %s" % (dict[key])
 
     #      0123456789012345678901234567890
-    print " | Number of gaps: ............ %i" % sp.count_gaps(maps)                
+    print " | Number of gaps: ............ %i" % sp.count_gaps(maps)
 
     if sp.is_time_absolute():
         gran = tgis.compute_absolute_time_granularity(maps)
@@ -145,4 +148,3 @@ def main():
 if __name__ == "__main__":
     options, flags = grass.parser()
     main()
-

+ 41 - 36
temporal/t.unregister/t.unregister.py

@@ -2,15 +2,15 @@
 # -*- coding: utf-8 -*-
 ############################################################################
 #
-# MODULE:	t.unregister
-# AUTHOR(S):	Soeren Gebbert
-#               
-# PURPOSE:	Unregister raster, vector and raster3d maps from the temporal database or a specific space time dataset
-# COPYRIGHT:	(C) 2011 by the GRASS Development Team
+# MODULE:       t.unregister
+# AUTHOR(S):    Soeren Gebbert
 #
-#		This program is free software under the GNU General Public
-#		License (version 2). Read the file COPYING that comes with GRASS
-#		for details.
+# PURPOSE:      Unregister raster, vector and raster3d maps from the temporal database or a specific 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.
 #
 #############################################################################
 
@@ -44,6 +44,7 @@ import grass.temporal as tgis
 
 ############################################################################
 
+
 def main():
 
     # Get the options
@@ -56,12 +57,13 @@ def main():
     tgis.create_temporal_database()
 
     if maps and file:
-        grass.fatal(_("%s= and %s= are mutually exclusive") % ("input","file"))
+        grass.fatal(_(
+            "%s= and %s= are mutually exclusive") % ("input", "file"))
 
     if not maps and not file:
-        grass.fatal(_("%s= or %s= must be specified") % ("input","file"))
+        grass.fatal(_("%s= or %s= must be specified") % ("input", "file"))
 
-    mapset =  grass.gisenv()["MAPSET"]
+    mapset = grass.gisenv()["MAPSET"]
 
     dbif = tgis.SQLDatabaseInterfaceConnection()
     dbif.connect()
@@ -83,25 +85,26 @@ def main():
 
         if sp.is_in_db(dbif) == False:
             dbif.close()
-            grass.fatal(_("Space time %s dataset <%s> not found") % (sp.get_new_map_instance(None).get_type(), id))
+            grass.fatal(_("Space time %s dataset <%s> not found")
+                        % (sp.get_new_map_instance(None).get_type(), id))
 
     maplist = []
 
-    dummy = tgis.raster_dataset(None)
+    dummy = tgis.RasterDataset(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)
+    if maps is not 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")
@@ -113,9 +116,9 @@ def main():
                 break
 
             mapname = line.strip()
-	    mapid = dummy.build_id(mapname, mapset)
+            mapid = dummy.build_id(mapname, mapset)
             maplist.append(mapid)
-            
+
     num_maps = len(maplist)
     update_dict = {}
     count = 0
@@ -125,8 +128,8 @@ def main():
     # Unregister already registered maps
     grass.message(_("Unregistered maps"))
     for mapid in maplist:
-	grass.percent(count, num_maps, 1)
-            
+        grass.percent(count, num_maps, 1)
+
         map = tgis.dataset_factory(type, mapid)
 
         # Unregister map if in database
@@ -135,8 +138,9 @@ def main():
             if name:
                 sp.metadata.select(dbif)
                 # Collect SQL statements
-                statement += sp.unregister_map(map=map, dbif=dbif, execute=False)
- 
+                statement += sp.unregister_map(
+                    map=map, dbif=dbif, execute=False)
+
             # Unregister from temporal database
             else:
                 # We need to update all datasets after the removement of maps
@@ -149,17 +153,18 @@ def main():
                 # Collect SQL statements
                 statement += map.delete(dbif=dbif, update=False, execute=False)
         else:
-            grass.warning(_("Unable to find %s map <%s> in temporal database"%(map.get_type(), map.get_id())))
-		
-	count += 1
+            grass.warning(_("Unable to find %s map <%s> in temporal database" %
+                            (map.get_type(), map.get_id())))
+
+        count += 1
 
     # Execute the collected SQL statenents
     dbif.execute_transaction(statement)
-	
+
     grass.percent(num_maps, num_maps, 1)
 
     # Update space time datasets
-    
+
     grass.message(_("Unregistered maps from space time dataset(s)"))
     if name:
         sp.update_from_registered_maps(dbif)
@@ -179,7 +184,7 @@ def main():
             sp.metadata.select(dbif)
             sp.update_from_registered_maps(dbif)
             grass.percent(count, len(update_dict), 1)
-	    count += 1
+            count += 1
 
     dbif.close()
 

+ 51 - 42
temporal/t.vect.db.select/t.vect.db.select.py

@@ -2,15 +2,15 @@
 # -*- coding: utf-8 -*-
 ############################################################################
 #
-# MODULE:	t.vect.db.select
-# AUTHOR(S):	Soeren Gebbert
+# MODULE:       t.vect.db.select
+# AUTHOR(S):    Soeren Gebbert
 #
-# PURPOSE:	Prints attributes of vector maps registered in a space time vector dataset.
-# COPYRIGHT:	(C) 2011 by the GRASS Development Team
+# PURPOSE:      Prints attributes of vector maps registered in 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.
+#               This program is free software under the GNU General Public
+#               License (version 2). Read the file COPYING that comes with GRASS
+#               for details.
 #
 #############################################################################
 
@@ -52,6 +52,7 @@ import grass.script.raster as raster
 
 ############################################################################
 
+
 def main():
 
     # Get the options
@@ -70,54 +71,62 @@ def main():
 
     # Make sure the temporal database exists
     tgis.create_temporal_database()
-   
-    mapset =  grass.gisenv()["MAPSET"]
+
+    mapset = grass.gisenv()["MAPSET"]
 
     if input.find("@") >= 0:
         id = input
     else:
         id = input + "@" + mapset
 
-    sp = tgis.space_time_vector_dataset(id)
-    
+    sp = tgis.SpaceTimeVectorDataset(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))
+        grass.fatal(_("Space time %s dataset <%s> not found") % (
+            sp.get_new_map_instance(None).get_type(), id))
 
     sp.select()
-    
-    rows = sp.get_registered_maps("name,layer,mapset,start_time,end_time", tempwhere, "start_time", None)
+
+    rows = sp.get_registered_maps("name,layer,mapset,start_time,end_time",
+                                  tempwhere, "start_time", None)
 
     col_names = ""
     if rows:
-	for row in rows:
-	    vector_name = "%s@%s"%(row["name"], row["mapset"])
-	    # In case a layer is defined in the vector dataset, we override the option layer
-	    if row["layer"]:
-		layer = row["layer"]
-	    
-	    select = grass.read_command("v.db.select", map=vector_name, layer=layer, columns=columns, fs="%s"%(fs), where=where)
-	    
-	    if not select:
-		grass.fatal(_("Unable to run v.db.select for vector map <%s> with layer %s")%(vector_name, layer))
-	    # The first line are the column names
-	    list = select.split("\n")
-	    count = 0
-	    for entry in list:
-	        if entry.strip() != "":
-		    # print the column names in case they change
-		    if count == 0:
-			col_names_new = "start_time%send_time%s%s"%(fs, fs, entry)
-			if col_names != col_names_new:
-			    col_names = col_names_new
-			    print col_names
-		    else:
-			if row["end_time"]:
-			    print "%s%s%s%s%s"%(row["start_time"],fs, row["end_time"], fs, entry)
-			else:
-			    print "%s%s%s%s"%(row["start_time"], fs, fs, entry)
-		    count += 1
+        for row in rows:
+            vector_name = "%s@%s" % (row["name"], row["mapset"])
+            # In case a layer is defined in the vector dataset, 
+            # we override the option layer
+            if row["layer"]:
+                layer = row["layer"]
+
+            select = grass.read_command("v.db.select", map=vector_name, 
+                                        layer=layer, columns=columns, 
+                                        fs="%s" % (fs), where=where)
+
+            if not select:
+                grass.fatal(_("Unable to run v.db.select for vector map <%s> "
+                              "with layer %s") % (vector_name, layer))
+            # The first line are the column names
+            list = select.split("\n")
+            count = 0
+            for entry in list:
+                if entry.strip() != "":
+                    # print the column names in case they change
+                    if count == 0:
+                        col_names_new = "start_time%send_time%s%s" % (
+                            fs, fs, entry)
+                        if col_names != col_names_new:
+                            col_names = col_names_new
+                            print col_names
+                    else:
+                        if row["end_time"]:
+                            print "%s%s%s%s%s" % (row["start_time"], fs, 
+                                                  row["end_time"], fs, entry)
+                        else:
+                            print "%s%s%s%s" % (row["start_time"],
+                                                fs, fs, entry)
+                    count += 1
 
 if __name__ == "__main__":
     options, flags = grass.parser()
     main()
-

+ 2 - 2
temporal/t.vect.db.select/test.t.vect.db.select.sh

@@ -19,7 +19,7 @@ t.register -i input=precip_abs1 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 s
 
 # The @test
 # We need to create a nice space time vector dataset with layers for testing
-t.vect.observe.strds input=prec strds=precip_abs1 output=prec_observer column=observation
+t.vect.observe.strds input=prec strds=precip_abs1 output=prec_observer vector=prec_observer column=observation
 t.vect.list input=prec_observer
 t.vect.db.select input=prec_observer
 t.vect.db.select input=prec_observer where="cat = 1" fs="  |  "
@@ -28,7 +28,7 @@ t.vect.db.select input=prec_observer where="cat = 1" fs="  |  " columns=observat
 # Time instances
 t.register --o input=precip_abs1 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2004-01-01 00:00:00" increment="3 months"
 
-t.vect.observe.strds --o input=prec strds=precip_abs1 output=prec_observer
+t.vect.observe.strds --o input=prec strds=precip_abs1 output=prec_observer vector=prec_observer 
 t.vect.list input=prec_observer
 t.vect.db.select input=prec_observer
 t.vect.db.select input=prec_observer where="cat = 1" fs="  |  "

+ 22 - 21
temporal/t.vect.export/t.vect.export.py

@@ -2,15 +2,15 @@
 # -*- coding: utf-8 -*-
 ############################################################################
 #
-# MODULE:	t.vect.export
-# AUTHOR(S):	Soeren Gebbert
-#               
-# PURPOSE:	Export a space time vector dataset.as GRASS specific archive file
-# COPYRIGHT:	(C) 2011 by the GRASS Development Team
+# MODULE:       t.vect.export
+# AUTHOR(S):    Soeren Gebbert
 #
-#		This program is free software under the GNU General Public
-#		License (version 2). Read the file COPYING that comes with GRASS
-#		for details.
+# PURPOSE:      Export a space time vector dataset.as GRASS specific archive file
+# 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.
 #
 #############################################################################
 
@@ -60,23 +60,24 @@
 import grass.script as grass
 import grass.temporal as tgis
 
-    
+
 ############################################################################
 def main():
 
-	# Get the options
-	_input = options["input"]
-	output = options["output"]
-	compression = options["compression"]
-	workdir = options["workdir"]
-	where = options["where"]
-	_format = options["format"]
+    # Get the options
+    _input = options["input"]
+    output = options["output"]
+    compression = options["compression"]
+    workdir = options["workdir"]
+    where = options["where"]
+    _format = options["format"]
+
+    # Make sure the temporal database exists
+    tgis.create_temporal_database()
+    # Export the space time raster dataset
+    tgis.export_stds(
+        _input, output, compression, workdir, where, _format, "stvds")
 
-	# Make sure the temporal database exists
-	tgis.create_temporal_database()
-	# Export the space time raster dataset
-	tgis.export_stds(_input, output, compression, workdir, where, _format, "stvds")
-     
 ############################################################################
 if __name__ == "__main__":
     options, flags = grass.parser()

+ 5 - 4
temporal/t.vect.extract/t.vect.extract.py

@@ -67,6 +67,7 @@ from multiprocessing import Process
 
 ############################################################################
 
+
 def main():
 
     # Get the options
@@ -82,12 +83,12 @@ def main():
 
     # Make sure the temporal database exists
     tgis.create_temporal_database()
-    
-    tgis.extract_dataset(input, output, "vector", where, expression, base, nprocs, register_null, layer, type)
-    
+
+    tgis.extract_dataset(input, output, "vector", where, expression,
+                         base, nprocs, register_null, layer, type)
+
 ###############################################################################
 
 if __name__ == "__main__":
     options, flags = grass.parser()
     main()
-

+ 1 - 1
temporal/t.vect.extract/test.t.vect.extract.layer.sh

@@ -19,7 +19,7 @@ t.create --o type=strds temporaltype=absolute output=precip_abs1 title="A test"
 t.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
-t.vect.observe.strds input=prec strds=precip_abs1 output=prec_observer column=prec
+t.vect.observe.strds input=prec strds=precip_abs1 output=prec_observer vector=prec_observer column=prec
 v.info prec_observer
 t.info type=stvds input=prec_observer
 t.vect.list input=prec_observer

+ 15 - 15
temporal/t.vect.import/t.vect.import.py

@@ -4,7 +4,7 @@
 #
 # MODULE:        t.vect.import
 # AUTHOR(S):     Soeren Gebbert
-#               
+#
 # PURPOSE:        Import a space time vector dataset archive file
 # COPYRIGHT:        (C) 2011 by the GRASS Development Team
 #
@@ -73,23 +73,23 @@
 import grass.script as grass
 import grass.temporal as tgis
 
+
 def main():
 
-	# Get the options
-	input = options["input"]
-	output = options["output"]
-	extrdir = options["extrdir"]
-	title = options["title"]
-	descr = options["description"]
-	location = options["location"]
-	exp = flags["e"]
-	overr = flags["o"]
-	create = flags["c"]
-	
-	tgis.import_stds(input, output, extrdir, title, descr, location, 
-                None, exp, overr, create, "stvds")
+    # Get the options
+    input = options["input"]
+    output = options["output"]
+    extrdir = options["extrdir"]
+    title = options["title"]
+    descr = options["description"]
+    location = options["location"]
+    exp = flags["e"]
+    overr = flags["o"]
+    create = flags["c"]
+
+    tgis.import_stds(input, output, extrdir, title, descr, location,
+                     None, exp, overr, create, "stvds")
 
 if __name__ == "__main__":
     options, flags = grass.parser()
     main()
-

+ 7 - 5
temporal/t.vect.list/t.vect.list.py

@@ -4,8 +4,8 @@
 #
 # MODULE:	t.vect.list
 # AUTHOR(S):	Soeren Gebbert
-#               
-# PURPOSE:	List registered maps of a space time vector dataset 
+#
+# 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
@@ -36,7 +36,7 @@
 #%option
 #% key: columns
 #% type: string
-#% description: Select columns to be printed to stdout 
+#% description: Select columns to be printed to stdout
 #% required: no
 #% multiple: yes
 #% options: id,name,layer,creator,mapset,temporal_type,creation_time,start_time,end_time,north,south,west,east,points,lines,boundaries,centroids,faces,kernels,primitives,nodes,areas,islands,holes,volumes
@@ -65,7 +65,7 @@
 
 #%flag
 #% key: h
-#% description: Print column names 
+#% description: Print column names
 #%end
 
 import grass.script as grass
@@ -73,6 +73,7 @@ import grass.temporal as tgis
 
 ############################################################################
 
+
 def main():
 
     # Get the options
@@ -87,7 +88,8 @@ def main():
     # Make sure the temporal database exists
     tgis.create_temporal_database()
 
-    tgis.list_maps_of_stds("stvds", input, columns, order, where, separator, method, header)
+    tgis.list_maps_of_stds(
+        "stvds", input, columns, order, where, separator, method, header)
 
 if __name__ == "__main__":
     options, flags = grass.parser()

+ 97 - 73
temporal/t.vect.observe.strds/t.vect.observe.strds.py

@@ -2,15 +2,15 @@
 # -*- coding: utf-8 -*-
 ############################################################################
 #
-# MODULE:	t.vect.oberve.rast
-# AUTHOR(S):	Soeren Gebbert
+# MODULE:       t.vect.oberve.rast
+# AUTHOR(S):    Soeren Gebbert
 #
-# PURPOSE:	Observe specific locations in a space time raster dataset over a periode of time using vector points
-# COPYRIGHT:	(C) 2011 by the GRASS Development Team
+# PURPOSE:      Observe specific locations in a space time raster dataset over a periode of time using vector points
+# 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.
+#               This program is free software under the GNU General Public
+#               License (version 2). Read the file COPYING that comes with GRASS
+#               for details.
 #
 #############################################################################
 
@@ -32,13 +32,13 @@
 
 #%option G_OPT_V_OUTPUT
 #% key: vector_output
-#% description: Name of the new created vector map that stores the sampled values 
+#% description: Name of the new created vector map that stores the sampled values
 #%end
 
 #%option
 #% key: column
 #% type: string
-#% description: Name of the vector column to be created and to store sampled raster values, otherwise the space time raster name is used as column name 
+#% description: Name of the vector column to be created and to store sampled raster values, otherwise the space time raster name is used as column name
 #% required: no
 #% multiple: no
 #%end
@@ -57,6 +57,7 @@ import grass.script.raster as raster
 
 ############################################################################
 
+
 def main():
 
     # Get the options
@@ -76,16 +77,16 @@ def main():
     # We need a database interface
     dbif = tgis.SQLDatabaseInterfaceConnection()
     dbif.connect()
-   
-    mapset =  grass.gisenv()["MAPSET"]
+
+    mapset = grass.gisenv()["MAPSET"]
 
     if strds.find("@") >= 0:
         strds_id = strds
     else:
         strds_id = strds + "@" + mapset
 
-    strds_sp = tgis.space_time_raster_dataset(strds_id)
-    
+    strds_sp = tgis.SpaceTimeRasterDataset(strds_id)
+
     if strds_sp.is_in_db() == False:
         dbif.close()
         grass.fatal(_("Space time raster dataset <%s> not found") % (strds_id))
@@ -97,24 +98,27 @@ def main():
     else:
         id = output + "@" + mapset
 
-    out_sp = tgis.space_time_vector_dataset(id)
-    
-    if out_sp.is_in_db(dbif) == True and grass.overwrite() == False: 
+    out_sp = tgis.SpaceTimeVectorDataset(id)
+
+    if out_sp.is_in_db(dbif) == True and grass.overwrite() == False:
         dbif.close()
-        grass.fatal(_("Dataset <%s> found in temporal database, use the overwrite flag to overwrite") % (id))
+        grass.fatal(_("Dataset <%s> found in temporal database, "
+                      "use the overwrite flag to overwrite") % (id))
 
     # Overwrite existing stvds
     if out_sp.is_in_db(dbif) == True and grass.overwrite() == True:
         out_sp.select(dbif)
         out_sp.delete(dbif)
-        out_sp = tgis.space_time_vector_dataset(id)
+        out_sp = tgis.SpaceTimeVectorDataset(id)
 
     # Select the raster maps
-    rows = strds_sp.get_registered_maps("name,mapset,start_time,end_time", tempwhere, "start_time", dbif)
+    rows = strds_sp.get_registered_maps(
+        "name,mapset,start_time,end_time", tempwhere, "start_time", dbif)
 
     if not rows:
         dbif.close()
-        grass.fatal(_("Space time vector dataset <%s> is empty") % out_sp.get_id())
+        grass.fatal(_("Space time vector dataset <%s> is empty") %
+                    out_sp.get_id())
 
     num_rows = len(rows)
 
@@ -122,95 +126,116 @@ def main():
     vector_db = grass.vector.vector_db(input)
 
     # We copy the vector table and create the new layers
-    
+
     if vector_db:
-	# Use the first layer to copy the categories from
-        layers= "1,"
+        # Use the first layer to copy the categories from
+        layers = "1,"
     else:
-        layers= ""
+        layers = ""
     first = True
     for layer in range(num_rows):
         layer += 1
         # Skip existing layer
-	if vector_db and vector_db.has_key(layer) and vector_db[layer]["layer"] == layer:
-	    continue
+        if vector_db and layer in vector_db and \
+           vector_db[layer]["layer"] == layer:
+            continue
         if first:
-            layers += "%i"%(layer)    
+            layers += "%i" % (layer)
             first = False
         else:
-            layers += ",%i"%(layer)    
+            layers += ",%i" % (layer)
 
     # Use the name of the space time vector dataset as new vector name
     vectmap = vector_output
-	
+
     # We create a new vector map using the categories of the original map
-    ret = grass.run_command("v.category", input=input, layer=layers, output=vectmap, option="transfer", overwrite=grass.overwrite())
+    ret = grass.run_command("v.category", input=input, layer=layers,
+                            output=vectmap, option="transfer", 
+                            overwrite=grass.overwrite())
     if ret != 0:
-        grass.fatal(_("Unable to create new layers for vector map <%s>") % (vectmap))
- 
+        grass.fatal(_("Unable to create new layers for vector map <%s>")
+                    % (vectmap))
+
     # Create the output space time vector dataset
-    out_sp.set_initial_values(strds_sp.get_temporal_type(), \
-                              strds_sp.get_semantic_type(),\
-                              _("Observaion of space time raster dataset <%s>")%(strds_id),\
-                              _("Observation of space time raster dataset <%s> with vector map <%s>")%(strds_id, input))
+    out_sp.set_initial_values(strds_sp.get_temporal_type(),
+                              strds_sp.get_semantic_type(),
+                              _("Observaion of space time raster "
+                                "dataset <%s>") % (strds_id),
+                              _("Observation of space time raster dataset <%s>"
+                                " with vector map <%s>") % (strds_id, input))
 
     out_sp.insert(dbif)
-       
+
     dummy = out_sp.get_new_map_instance(None)
 
-    # Sample the space time raster dataset with the vector map at specific layer with v.what.rast
+    # Sample the space time raster dataset with the vector 
+    # map at specific layer with v.what.rast
     count = 1
     for row in rows:
         start = row["start_time"]
         end = row["end_time"]
         rastmap = row["name"] + "@" + row["mapset"]
 
-	if column:
-	    col_name = column
-	else:
-	    # Create a new column with name of the sampled space time raster dataset
-	    col_name = row["name"]
-
-	coltype = "DOUBLE PRECISION"
-	# Get raster map type
-	rasterinfo = raster.raster_info(rastmap)
-	if rasterinfo["datatype"] == "CELL":
-	    coltype = "INT"
-	
+        if column:
+            col_name = column
+        else:
+            # Create a new column with name of the 
+            # sampled space time raster dataset
+            col_name = row["name"]
+
+        coltype = "DOUBLE PRECISION"
+        # Get raster map type
+        rasterinfo = raster.raster_info(rastmap)
+        if rasterinfo["datatype"] == "CELL":
+            coltype = "INT"
+
         # Try to add a column
-	if vector_db and vector_db.has_key(count) and vector_db[count]["table"]:
-	    ret = grass.run_command("v.db.addcolumn", map=vectmap, layer=count, column="%s %s" % (col_name, coltype), overwrite=grass.overwrite())
-	    if ret != 0:
-	        dbif.close()
-	        grass.fatal(_("Unable to add column %s to vector map <%s> with layer %i")%(col_name, vectmap, count))
+        if vector_db and count in vector_db and vector_db[count]["table"]:
+            ret = grass.run_command("v.db.addcolumn", map=vectmap, 
+                                    layer=count, 
+                                    column="%s %s" % (col_name, coltype), 
+                                    overwrite=grass.overwrite())
+            if ret != 0:
+                dbif.close()
+                grass.fatal(_("Unable to add column %s to vector map <%s> "
+                              "with layer %i") % (col_name, vectmap, count))
         else:
             # Try to add a new table
-            grass.message("Add table to layer %i"%(count))
-	    ret = grass.run_command("v.db.addtable", map=vectmap, layer=count, columns="%s %s" % (col_name, coltype), overwrite=grass.overwrite())
-	    if ret != 0:
-	        dbif.close()
-	        grass.fatal(_("Unable to add table to vector map <%s> with layer %i")%(vectmap, count))
-
-	# Call v.what.rast
-	ret = grass.run_command("v.what.rast", map=vectmap, layer=count, raster=rastmap, column=col_name, where=where)
-	if ret != 0:
-	    dbif.close()
-	    grass.fatal(_("Unable to run v.what.rast for vector map <%s> with layer %i and raster map <%s>")%(vectmap, count, rastmap))
-        
-        vect = out_sp.get_new_map_instance(dummy.build_id(vectmap, mapset, str(count)))
+            grass.message("Add table to layer %i" % (count))
+            ret = grass.run_command("v.db.addtable", map=vectmap, layer=count, 
+                                    columns="%s %s" % (col_name, coltype), 
+                                    overwrite=grass.overwrite())
+            if ret != 0:
+                dbif.close()
+                grass.fatal(_("Unable to add table to vector map "
+                              "<%s> with layer %i") % (vectmap, count))
+
+        # Call v.what.rast
+        ret = grass.run_command("v.what.rast", map=vectmap,
+                                layer=count, raster=rastmap, 
+                                column=col_name, where=where)
+        if ret != 0:
+            dbif.close()
+            grass.fatal(_("Unable to run v.what.rast for vector map <%s> "
+                          "with layer %i and raster map <%s>") % \
+                        (vectmap, count, rastmap))
+
+        vect = out_sp.get_new_map_instance(dummy.build_id(vectmap, 
+                                                          mapset, str(count)))
         vect.load()
- 
+
         if out_sp.is_time_absolute():
             vect.set_absolute_time(start, end)
         else:
-            vect.set_relative_time(start, end, strds_sp.get_relative_time_unit())
-       
+            vect.set_relative_time(
+                start, end, strds_sp.get_relative_time_unit())
+
         if vect.is_in_db(dbif):
             vect.update_all(dbif)
         else:
             vect.insert(dbif)
 
-        out_sp.register_map(vect, dbif) 
+        out_sp.register_map(vect, dbif)
         count += 1
 
     out_sp.update_from_registered_maps(dbif)
@@ -219,4 +244,3 @@ def main():
 if __name__ == "__main__":
     options, flags = grass.parser()
     main()
-

+ 1 - 1
temporal/t.vect.observe.strds/test.t.vect.observe.strds.sh

@@ -25,7 +25,7 @@ t.info type=stvds input=prec_observer
 t.vect.list input=prec_observer
 t.vect.db.select input=prec_observer
 
-t.vect.observe.strds input=test_1 strds=precip_abs1 output=test_1_observer vector=test_1_observer
+t.vect.observe.strds input=test_1 strds=precip_abs1 output=test_1_observer  vector=test_1_observer
 v.info test_1_observer
 t.info type=stvds input=test_1_observer
 t.vect.list input=test_1_observer

+ 5 - 4
temporal/t.vect.univar/t.vect.univar.py

@@ -59,7 +59,7 @@
 
 #%flag
 #% key: h
-#% description: Print column names 
+#% description: Print column names
 #%end
 
 import grass.script as grass
@@ -67,6 +67,7 @@ import grass.temporal as tgis
 
 ############################################################################
 
+
 def main():
 
     # Get the options
@@ -82,10 +83,10 @@ def main():
 
     # Make sure the temporal database exists
     tgis.create_temporal_database()
-    
-    tgis.print_vector_dataset_univar_statistics(input, twhere, layer, type, column, where, extended, header, fs)
+
+    tgis.print_vector_dataset_univar_statistics(
+        input, twhere, layer, type, column, where, extended, header, fs)
 
 if __name__ == "__main__":
     options, flags = grass.parser()
     main()
-

+ 76 - 52
temporal/t.vect.what.strds/t.vect.what.strds.py

@@ -2,15 +2,15 @@
 # -*- coding: utf-8 -*-
 ############################################################################
 #
-# MODULE:	t.vect.what.strds
-# AUTHOR(S):	Soeren Gebbert
+# MODULE:       t.vect.what.strds
+# AUTHOR(S):    Soeren Gebbert
 #
-# PURPOSE:	Uploads raster map values at spatial and temporal positions of vector points to the tables.
-# COPYRIGHT:	(C) 2011 by the GRASS Development Team
+# PURPOSE:      Uploads raster map values at spatial and temporal positions of vector points to the tables.
+# 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.
+#               This program is free software under the GNU General Public
+#               License (version 2). Read the file COPYING that comes with GRASS
+#               for details.
 #
 #############################################################################
 
@@ -63,6 +63,7 @@ import grass.script.raster as raster
 
 ############################################################################
 
+
 def main():
 
     # Get the options
@@ -82,19 +83,20 @@ def main():
     # We need a database interface
     dbif = tgis.SQLDatabaseInterfaceConnection()
     dbif.connect()
-   
-    mapset =  grass.gisenv()["MAPSET"]
+
+    mapset = grass.gisenv()["MAPSET"]
 
     if input.find("@") >= 0:
         id = input
     else:
         id = input + "@" + mapset
 
-    sp = tgis.space_time_vector_dataset(id)
-    
+    sp = tgis.SpaceTimeVectorDataset(id)
+
     if sp.is_in_db() == False:
         dbif.close()
-        grass.fatal(_("Space time %s dataset <%s> not found") % (sp.get_new_map_instance(None).get_type(), id))
+        grass.fatal(_("Space time %s dataset <%s> not found") % (
+            sp.get_new_map_instance(None).get_type(), id))
 
     sp.select(dbif)
 
@@ -103,8 +105,8 @@ def main():
     else:
         strds_id = strds + "@" + mapset
 
-    strds_sp = tgis.space_time_raster_dataset(strds_id)
-    
+    strds_sp = tgis.SpaceTimeRasterDataset(strds_id)
+
     if strds_sp.is_in_db() == False:
         dbif.close()
         grass.fatal(_("Dataset <%s> not found in temporal database") % (id))
@@ -113,20 +115,23 @@ def main():
 
     if strds_sp.get_temporal_type() != sp.get_temporal_type():
         dbif.close()
-        grass.fatal(_("Input and aggregation dataset must have the same temporal type"))
+        grass.fatal(_("Input and aggregation dataset must "
+                      "have the same temporal type"))
 
     # Check if intervals are present in the sample dataset
     if sp.get_temporal_type() == "absolute":
         map_time = sp.absolute_time.get_map_time()
     else:
         map_time = sp.relative_time.get_map_time()
-    
+
     if map_time != "interval":
         dbif.close()
-        grass.fatal(_("All registered maps of the space time vector dataset must have time intervals"))
+        grass.fatal(_("All registered maps of the space time vector "
+                      "dataset must have time intervals"))
 
-    rows = sp.get_registered_maps("name,layer,mapset,start_time,end_time", tempwhere, "start_time", dbif)
-    dummy = tgis.vector_dataset(None)
+    rows = sp.get_registered_maps("name,layer,mapset,start_time,end_time",
+                                  tempwhere, "start_time", dbif)
+    dummy = tgis.VectorDataset(None)
 
     if not rows:
         dbif.close()
@@ -140,28 +145,34 @@ def main():
         layer = row["layer"]
         count = 0
 
-        raster_maps = tgis.collect_map_names(strds_sp, dbif, start, end, sampling)
-        
+        raster_maps = tgis.collect_map_names(
+            strds_sp, dbif, start, end, sampling)
+
         aggreagated_map_name = None
-                
+
         if raster_maps:
-	    # Aggregation
-	    if method != "disabled" and len(raster_maps) > 1:
-	      # Generate the temporary map name
-	      aggreagated_map_name = "aggreagated_map_name_"+ str(os.getpid()) 
-	      new_map = tgis.aggregate_raster_maps(raster_maps, aggreagated_map_name, start, end, 0, method, False, dbif)
-	      aggreagated_map_name = aggreagated_map_name + "_0" 
-	      if new_map == None:
-		  continue
-	      # We overwrite the raster_maps list
-	      raster_maps = (new_map.get_id(), )
-	      
+            # Aggregation
+            if method != "disabled" and len(raster_maps) > 1:
+                # Generate the temporary map name
+                aggreagated_map_name = "aggreagated_map_name_" + \
+                    str(os.getpid())
+                new_map = tgis.aggregate_raster_maps(raster_maps, 
+                                                     aggreagated_map_name, 
+                                                     start, end, 0, method, 
+                                                     False, dbif)
+                aggreagated_map_name = aggreagated_map_name + "_0"
+                if new_map is None:
+                    continue
+                # We overwrite the raster_maps list
+                raster_maps = (new_map.get_id(), )
+
             for rastermap in raster_maps:
-                
+
                 if column:
                     col_name = column
                 else:
-                    # Create a new column with the SQL compliant name of the sampled raster map
+                    # Create a new column with the SQL compliant 
+                    # name of the sampled raster map
                     col_name = rastermap.split("@")[0].replace(".", "_")
 
                 coltype = "DOUBLE PRECISION"
@@ -169,31 +180,45 @@ def main():
                 rasterinfo = raster.raster_info(rastermap)
                 if rasterinfo["datatype"] == "CELL":
                     coltype = "INT"
-		
-		if layer:
-		    ret = grass.run_command("v.db.addcolumn", map=vectmap, layer=layer, column="%s %s" % (col_name, coltype), overwrite=grass.overwrite())
-		else:
-		    ret = grass.run_command("v.db.addcolumn", map=vectmap, column="%s %s" % (col_name, coltype), overwrite=grass.overwrite())
-		    
+
+                if layer:
+                    ret = grass.run_command("v.db.addcolumn", 
+                                            map=vectmap, layer=layer, 
+                                            column="%s %s" % (col_name, coltype), 
+                                            overwrite=grass.overwrite())
+                else:
+                    ret = grass.run_command("v.db.addcolumn", map=vectmap, 
+                                            column="%s %s" % (col_name, coltype), 
+                                            overwrite=grass.overwrite())
+
                 if ret != 0:
                     dbif.close()
-                    grass.fatal(_("Unable to add column %s to vector map <%s>")%(col_name, vectmap))
+                    grass.fatal(_("Unable to add column %s to vector map <%s>")
+                                % (col_name, vectmap))
 
                 # Call v.what.rast
                 if layer:
-		    ret = grass.run_command("v.what.rast", map=vectmap, layer=layer, raster=rastermap, column=col_name, where=where)
-		else:
-		    ret = grass.run_command("v.what.rast", map=vectmap, raster=rastermap, column=col_name, where=where)
+                    ret = grass.run_command("v.what.rast", map=vectmap, 
+                                            layer=layer, raster=rastermap, 
+                                            column=col_name, where=where)
+                else:
+                    ret = grass.run_command("v.what.rast", map=vectmap, 
+                                            raster=rastermap, column=col_name, 
+                                            where=where)
                 if ret != 0:
                     dbif.close()
-                    grass.fatal(_("Unable to run v.what.rast for vector map <%s> and raster map <%s>")%(vectmap, rastermap))
+                    grass.fatal(_("Unable to run v.what.rast for vector map "
+                                  "<%s> and raster map <%s>") % (vectmap, 
+                                                                 rastermap))
 
                 if aggreagated_map_name:
-		    ret = grass.run_command("g.remove", rast=aggreagated_map_name)
-		    if ret != 0:
-			dbif.close()
-			grass.fatal(_("Unable to remove raster map <%s>")%(aggreagated_map_name))
-                    
+                    ret = grass.run_command("g.remove",
+                                            rast=aggreagated_map_name)
+                    if ret != 0:
+                        dbif.close()
+                        grass.fatal(_("Unable to remove raster map <%s>")
+                                    % (aggreagated_map_name))
+
                 # Use the first map in case a column names was provided
                 if column:
                     break
@@ -203,4 +228,3 @@ def main():
 if __name__ == "__main__":
     options, flags = grass.parser()
     main()
-