[GRASS-SVN] r68182 - grass/trunk/lib/python/temporal
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Mar 29 02:23:26 PDT 2016
Author: zarch
Date: 2016-03-29 02:23:26 -0700 (Tue, 29 Mar 2016)
New Revision: 68182
Modified:
grass/trunk/lib/python/temporal/__init__.py
grass/trunk/lib/python/temporal/abstract_dataset.py
grass/trunk/lib/python/temporal/abstract_map_dataset.py
grass/trunk/lib/python/temporal/abstract_space_time_dataset.py
grass/trunk/lib/python/temporal/aggregation.py
grass/trunk/lib/python/temporal/base.py
grass/trunk/lib/python/temporal/c_libraries_interface.py
grass/trunk/lib/python/temporal/core.py
grass/trunk/lib/python/temporal/datetime_math.py
grass/trunk/lib/python/temporal/extract.py
grass/trunk/lib/python/temporal/factory.py
grass/trunk/lib/python/temporal/gui_support.py
grass/trunk/lib/python/temporal/list_stds.py
grass/trunk/lib/python/temporal/mapcalc.py
grass/trunk/lib/python/temporal/metadata.py
grass/trunk/lib/python/temporal/open_stds.py
grass/trunk/lib/python/temporal/register.py
grass/trunk/lib/python/temporal/sampling.py
grass/trunk/lib/python/temporal/space_time_datasets.py
grass/trunk/lib/python/temporal/spatial_extent.py
grass/trunk/lib/python/temporal/spatial_topology_dataset_connector.py
grass/trunk/lib/python/temporal/spatio_temporal_relationships.py
grass/trunk/lib/python/temporal/stds_export.py
grass/trunk/lib/python/temporal/stds_import.py
grass/trunk/lib/python/temporal/temporal_algebra.py
grass/trunk/lib/python/temporal/temporal_extent.py
grass/trunk/lib/python/temporal/temporal_granularity.py
grass/trunk/lib/python/temporal/temporal_operator.py
grass/trunk/lib/python/temporal/temporal_raster3d_algebra.py
grass/trunk/lib/python/temporal/temporal_raster_algebra.py
grass/trunk/lib/python/temporal/temporal_raster_base_algebra.py
grass/trunk/lib/python/temporal/temporal_topology_dataset_connector.py
grass/trunk/lib/python/temporal/temporal_vector_algebra.py
grass/trunk/lib/python/temporal/univar_statistics.py
Log:
temporal: revert changes (r68139 and r68177) since they are not fixing bugs and therefore they should go in relbr72
Modified: grass/trunk/lib/python/temporal/__init__.py
===================================================================
--- grass/trunk/lib/python/temporal/__init__.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/__init__.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -1,35 +1,33 @@
-from __future__ import (absolute_import)
-
-from .core import *
-from .base import *
-from .spatial_extent import *
-from .metadata import *
-from .abstract_dataset import *
-from .abstract_map_dataset import *
-from .abstract_space_time_dataset import *
-from .space_time_datasets import *
-from .datetime_math import *
-from .open_stds import *
-from .factory import *
-from .gui_support import *
-from .list_stds import *
-from .register import *
-from .sampling import *
-from .aggregation import *
-from .extract import *
-from .stds_export import *
-from .stds_import import *
-from .mapcalc import *
-from .univar_statistics import *
-from .c_libraries_interface import *
-from .spatio_temporal_relationships import *
-from .spatial_topology_dataset_connector import *
-from .temporal_extent import *
-from .temporal_topology_dataset_connector import *
-from .temporal_granularity import *
-from .temporal_algebra import *
-from .temporal_vector_algebra import *
-from .temporal_raster_base_algebra import *
-from .temporal_raster_algebra import *
-from .temporal_raster3d_algebra import *
-from .temporal_operator import *
+from core import *
+from base import *
+from spatial_extent import *
+from metadata import *
+from abstract_dataset import *
+from abstract_map_dataset import *
+from abstract_space_time_dataset import *
+from space_time_datasets import *
+from datetime_math import *
+from open_stds import *
+from factory import *
+from gui_support import *
+from list_stds import *
+from register import *
+from sampling import *
+from aggregation import *
+from extract import *
+from stds_export import *
+from stds_import import *
+from mapcalc import *
+from univar_statistics import *
+from c_libraries_interface import *
+from spatio_temporal_relationships import *
+from spatial_topology_dataset_connector import *
+from temporal_extent import *
+from temporal_topology_dataset_connector import *
+from temporal_granularity import *
+from temporal_algebra import *
+from temporal_vector_algebra import *
+from temporal_raster_base_algebra import *
+from temporal_raster_algebra import *
+from temporal_raster3d_algebra import *
+from temporal_operator import *
Modified: grass/trunk/lib/python/temporal/abstract_dataset.py
===================================================================
--- grass/trunk/lib/python/temporal/abstract_dataset.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/abstract_dataset.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -11,11 +11,11 @@
:authors: Soeren Gebbert
"""
from abc import ABCMeta, abstractmethod
-from .temporal_extent import *
-from .spatial_extent import *
-from .metadata import *
-from .temporal_topology_dataset_connector import *
-from .spatial_topology_dataset_connector import *
+from temporal_extent import *
+from spatial_extent import *
+from metadata import *
+from temporal_topology_dataset_connector import *
+from spatial_topology_dataset_connector import *
###############################################################################
Modified: grass/trunk/lib/python/temporal/abstract_map_dataset.py
===================================================================
--- grass/trunk/lib/python/temporal/abstract_map_dataset.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/abstract_map_dataset.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -10,9 +10,8 @@
:authors: Soeren Gebbert
"""
-from __future__ import print_function
-from .abstract_dataset import *
-from .datetime_math import *
+from abstract_dataset import *
+from datetime_math import *
class AbstractMapDataset(AbstractDataset):
@@ -200,16 +199,16 @@
if self.get_type() == "raster":
# 1 2 3 4 5 6 7
# 0123456789012345678901234567890123456789012345678901234567890123456789012345678
- print(" +-------------------- Raster Dataset ----------------------------------------+")
+ print " +-------------------- Raster Dataset ----------------------------------------+"
if self.get_type() == "raster3d":
# 1 2 3 4 5 6 7
# 0123456789012345678901234567890123456789012345678901234567890123456789012345678
- print(" +-------------------- 3D Raster Dataset -------------------------------------+")
+ print " +-------------------- 3D Raster Dataset -------------------------------------+"
if self.get_type() == "vector":
# 1 2 3 4 5 6 7
# 0123456789012345678901234567890123456789012345678901234567890123456789012345678
- print(" +-------------------- Vector Dataset ----------------------------------------+")
- print(" | |")
+ print " +-------------------- Vector Dataset ----------------------------------------+"
+ print " | |"
self.base.print_info()
self.temporal_extent.print_info()
if self.is_topology_build():
@@ -229,8 +228,8 @@
else:
string += ",%s" % ds
count += 1
- print(" | Registered datasets ........ " + string)
- print(" +----------------------------------------------------------------------------+")
+ print " | Registered datasets ........ " + string
+ print " +----------------------------------------------------------------------------+"
def print_shell_info(self):
"""Print information about this object in shell style"""
@@ -248,7 +247,7 @@
else:
string += ",%s" % ds
count += 1
- print("registered_datasets=" + string)
+ print "registered_datasets=" + string
if self.is_topology_build():
self.print_topology_shell_info()
@@ -540,25 +539,25 @@
>>> map = tgis.RasterDataset(None)
>>> temp_ext = tgis.RasterRelativeTime(start_time=1, end_time=2, unit="years")
>>> map.set_temporal_extent(temp_ext)
- >>> print(map.get_temporal_extent_as_tuple())
+ >>> print map.get_temporal_extent_as_tuple()
(1, 2)
>>> map = tgis.VectorDataset(None)
>>> temp_ext = tgis.VectorAbsoluteTime(start_time=datetime.datetime(2000, 1, 1),
... end_time=datetime.datetime(2001, 1, 1))
>>> map.set_temporal_extent(temp_ext)
- >>> print(map.get_temporal_extent_as_tuple())
+ >>> print map.get_temporal_extent_as_tuple()
(datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2001, 1, 1, 0, 0))
>>> map1 = tgis.VectorDataset("A at P")
>>> check = map1.set_absolute_time(datetime.datetime(2000,5,5), datetime.datetime(2005,6,6))
- >>> print(map1.get_temporal_extent_as_tuple())
+ >>> print map1.get_temporal_extent_as_tuple()
(datetime.datetime(2000, 5, 5, 0, 0), datetime.datetime(2005, 6, 6, 0, 0))
>>> map2 = tgis.RasterDataset("B at P")
>>> check = map2.set_absolute_time(datetime.datetime(1990,1,1), datetime.datetime(1999,8,1))
- >>> print(map2.get_temporal_extent_as_tuple())
+ >>> print map2.get_temporal_extent_as_tuple()
(datetime.datetime(1990, 1, 1, 0, 0), datetime.datetime(1999, 8, 1, 0, 0))
>>> map2.set_temporal_extent(map1.get_temporal_extent())
- >>> print(map2.get_temporal_extent_as_tuple())
+ >>> print map2.get_temporal_extent_as_tuple()
(datetime.datetime(2000, 5, 5, 0, 0), datetime.datetime(2005, 6, 6, 0, 0))
"""
@@ -711,7 +710,7 @@
>>> map = tgis.RasterDataset(None)
>>> spat_ext = tgis.SpatialExtent(north=10, south=-10, east=20, west=-20, top=5, bottom=-5)
>>> map.set_spatial_extent(spat_ext)
- >>> print(map.get_spatial_extent_as_tuple())
+ >>> print map.get_spatial_extent_as_tuple()
(10.0, -10.0, 20.0, -20.0, 5.0, -5.0)
"""
@@ -730,7 +729,7 @@
>>> spat_ext = tgis.SpatialExtent(north=10, south=-10, east=20, west=-20, top=5, bottom=-5)
>>> map.set_spatial_extent(spat_ext)
>>> map.spatial_buffer(10)
- >>> print(map.get_spatial_extent_as_tuple())
+ >>> print map.get_spatial_extent_as_tuple()
(20.0, -20.0, 30.0, -30.0, 15.0, -15.0)
"""
@@ -757,7 +756,7 @@
>>> spat_ext = tgis.SpatialExtent(north=10, south=-10, east=20, west=-20, top=5, bottom=-5)
>>> map.set_spatial_extent(spat_ext)
>>> map.spatial_buffer_2d(10)
- >>> print(map.get_spatial_extent_as_tuple())
+ >>> print map.get_spatial_extent_as_tuple()
(20.0, -20.0, 30.0, -30.0, 5.0, -5.0)
"""
Modified: grass/trunk/lib/python/temporal/abstract_space_time_dataset.py
===================================================================
--- grass/trunk/lib/python/temporal/abstract_space_time_dataset.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/abstract_space_time_dataset.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -10,12 +10,11 @@
:authors: Soeren Gebbert
"""
-from __future__ import print_function
import sys
import uuid
-from .abstract_dataset import *
-from .temporal_granularity import *
-from .spatio_temporal_relationships import *
+from abstract_dataset import *
+from temporal_granularity import *
+from spatio_temporal_relationships import *
###############################################################################
@@ -99,21 +98,21 @@
if self.get_type() == "strds":
# 1 2 3 4 5 6 7
# 0123456789012345678901234567890123456789012345678901234567890123456789012345678
- print(" +-------------------- Space Time Raster Dataset -----------------------------+")
+ print " +-------------------- Space Time Raster Dataset -----------------------------+"
if self.get_type() == "str3ds":
# 1 2 3 4 5 6 7
# 0123456789012345678901234567890123456789012345678901234567890123456789012345678
- print(" +-------------------- Space Time 3D Raster Dataset --------------------------+")
+ print " +-------------------- Space Time 3D Raster Dataset --------------------------+"
if self.get_type() == "stvds":
# 1 2 3 4 5 6 7
# 0123456789012345678901234567890123456789012345678901234567890123456789012345678
- print(" +-------------------- Space Time Vector Dataset -----------------------------+")
- print(" | |")
+ print " +-------------------- Space Time Vector Dataset -----------------------------+"
+ print " | |"
self.base.print_info()
self.temporal_extent.print_info()
self.spatial_extent.print_info()
self.metadata.print_info()
- print(" +----------------------------------------------------------------------------+")
+ print " +----------------------------------------------------------------------------+"
def print_shell_info(self):
"""Print information about this class in shell style"""
@@ -1138,7 +1137,7 @@
... maps.append(map)
>>> grans = tgis.AbstractSpaceTimeDataset.resample_maplist_by_granularity(maps,0,8,1)
>>> for map_list in grans:
- ... print(map_list[0].get_id(), map_list[0].get_temporal_extent_as_tuple())
+ ... print map_list[0].get_id(), map_list[0].get_temporal_extent_as_tuple()
None (0, 1)
None (1, 2)
map0 at PERMANENT (2, 3)
@@ -1157,7 +1156,7 @@
>>> maps.append(map2)
>>> grans = tgis.AbstractSpaceTimeDataset.resample_maplist_by_granularity(maps,0,16,2)
>>> for map_list in grans:
- ... print(map_list[0].get_id(), map_list[0].get_temporal_extent_as_tuple())
+ ... print map_list[0].get_id(), map_list[0].get_temporal_extent_as_tuple()
None (0, 2)
map1 at PERMANENT (2, 4)
map1 at PERMANENT (4, 6)
@@ -1176,7 +1175,7 @@
>>> maps.append(map2)
>>> grans = tgis.AbstractSpaceTimeDataset.resample_maplist_by_granularity(maps,0,16,2)
>>> for map_list in grans:
- ... print(map_list[0].get_id(), map_list[0].get_temporal_extent_as_tuple())
+ ... print map_list[0].get_id(), map_list[0].get_temporal_extent_as_tuple()
None (0, 2)
map1 at PERMANENT (2, 4)
None (4, 6)
@@ -1195,7 +1194,7 @@
>>> maps.append(map2)
>>> grans = tgis.AbstractSpaceTimeDataset.resample_maplist_by_granularity(maps,datetime(2000,1,1),datetime(2001,4,1),"1 month")
>>> for map_list in grans:
- ... print(map_list[0].get_id(), map_list[0].get_temporal_extent_as_tuple())
+ ... print map_list[0].get_id(), map_list[0].get_temporal_extent_as_tuple()
None (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2000, 2, 1, 0, 0))
None (datetime.datetime(2000, 2, 1, 0, 0), datetime.datetime(2000, 3, 1, 0, 0))
None (datetime.datetime(2000, 3, 1, 0, 0), datetime.datetime(2000, 4, 1, 0, 0))
Modified: grass/trunk/lib/python/temporal/aggregation.py
===================================================================
--- grass/trunk/lib/python/temporal/aggregation.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/aggregation.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -17,10 +17,10 @@
:author: Soeren Gebbert
"""
-from .space_time_datasets import *
-from .datetime_math import create_suffix_from_datetime
-from .datetime_math import create_time_suffix
-from .datetime_math import create_numeric_suffic
+from space_time_datasets import *
+from datetime_math import create_suffix_from_datetime
+from datetime_math import create_time_suffix
+from datetime_math import create_numeric_suffic
import grass.script as gscript
from grass.exceptions import CalledModuleError
Modified: grass/trunk/lib/python/temporal/base.py
===================================================================
--- grass/trunk/lib/python/temporal/base.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/base.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -24,9 +24,9 @@
:author: Soeren Gebbert
"""
-from __future__ import print_function
+
from datetime import datetime
-from .core import *
+from core import *
###############################################################################
@@ -186,7 +186,7 @@
def print_self(self):
"""Print the content of the internal dictionary to stdout
"""
- print(self.D)
+ print self.D
###############################################################################
@@ -276,7 +276,7 @@
if None a temporary connection will be established
"""
sql = self.get_delete_statement()
- #print(sql)
+ #print sql
if dbif:
dbif.execute(sql, mapset=self.mapset)
@@ -350,8 +350,8 @@
if None a temporary connection will be established
"""
sql, args = self.get_select_statement()
- #print(sql)
- #print(args)
+ #print sql
+ #print args
if dbif:
if len(args) == 0:
@@ -408,8 +408,8 @@
if None a temporary connection will be established
"""
sql, args = self.get_insert_statement()
- #print(sql)
- #print(args)
+ #print sql
+ #print args
if dbif:
dbif.execute(sql, args, mapset=self.mapset)
@@ -462,8 +462,8 @@
self.msgr.fatal(_("Missing identifer"))
sql, args = self.get_update_statement(ident)
- #print(sql)
- #print(args)
+ #print sql
+ #print args
if dbif:
dbif.execute(sql, args, mapset=self.mapset)
@@ -513,8 +513,8 @@
self.msgr.fatal(_("Missing identifer"))
sql, args = self.get_update_all_statement(ident)
- #print(sql)
- #print(args)
+ #print sql
+ #print args
if dbif:
dbif.execute(sql, args, mapset=self.mapset)
@@ -766,26 +766,26 @@
def print_info(self):
"""Print information about this class in human readable style"""
# 0123456789012345678901234567890
- print( " +-------------------- Basic information -------------------------------------+")
- print( " | Id: ........................ " + str(self.get_id()))
- print(" | Name: ...................... " + str(self.get_name()))
- print(" | Mapset: .................... " + str(self.get_mapset()))
+ print " +-------------------- Basic information -------------------------------------+"
+ print " | Id: ........................ " + str(self.get_id())
+ print " | Name: ...................... " + str(self.get_name())
+ print " | Mapset: .................... " + str(self.get_mapset())
if self.get_layer():
- print(" | Layer:...................... " + str(self.get_layer()))
- print(" | Creator: ................... " + str(self.get_creator()))
- print(" | Temporal type: ............. " + str(self.get_ttype()))
- print(" | Creation time: ............. " + str(self.get_ctime()))
+ print " | Layer:...................... " + str(self.get_layer())
+ print " | Creator: ................... " + str(self.get_creator())
+ print " | Temporal type: ............. " + str(self.get_ttype())
+ print " | Creation time: ............. " + str(self.get_ctime())
def print_shell_info(self):
"""Print information about this class in shell style"""
- print("id=" + str(self.get_id()))
- print("name=" + str(self.get_name()))
- print("mapset=" + str(self.get_mapset()))
+ print "id=" + str(self.get_id())
+ print "name=" + str(self.get_name())
+ print "mapset=" + str(self.get_mapset())
if self.get_layer():
- print("layer=" + str(self.get_layer()))
- print("creator=" + str(self.get_creator()))
- print("temporal_type=" + str(self.get_ttype()))
- print("creation_time=" + str(self.get_ctime()))
+ print "layer=" + str(self.get_layer())
+ print "creator=" + str(self.get_creator())
+ print "temporal_type=" + str(self.get_ttype())
+ print "creation_time=" + str(self.get_ctime())
###############################################################################
@@ -912,15 +912,15 @@
"""Print information about this class in human readable style"""
DatasetBase.print_info(self)
# 0123456789012345678901234567890
- print(" | Modification time:.......... " + str(self.get_mtime()))
- print(" | Semantic type:.............. " + str(
- self.get_semantic_type()))
+ print " | Modification time:.......... " + str(self.get_mtime())
+ print " | Semantic type:.............. " + str(
+ self.get_semantic_type())
def print_shell_info(self):
"""Print information about this class in shell style"""
DatasetBase.print_shell_info(self)
- print("modification_time=" + str(self.get_mtime()))
- print("semantic_type=" + str(self.get_semantic_type()))
+ print "modification_time=" + str(self.get_mtime())
+ print "semantic_type=" + str(self.get_semantic_type())
###############################################################################
Modified: grass/trunk/lib/python/temporal/c_libraries_interface.py
===================================================================
--- grass/trunk/lib/python/temporal/c_libraries_interface.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/c_libraries_interface.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -18,7 +18,7 @@
from multiprocessing import Process, Lock, Pipe
import logging
from ctypes import *
-from .core import *
+from core import *
import grass.lib.gis as libgis
import grass.lib.raster as libraster
import grass.lib.vector as libvector
@@ -59,7 +59,7 @@
def _read_map_full_info(lock, conn, data):
- """Read full map specific metadata from the spatial database using
+ """Read full map specific metadata from the spatial database using
PyGRASS functions.
:param lock: A multiprocessing.Lock instance
@@ -85,21 +85,21 @@
def _read_raster_full_info(name, mapset):
"""Read raster info, history and cats using PyGRASS RasterRow
- and return a dictionary. Colors should be supported in the
+ and return a dictionary. Colors should be supported in the
future.
"""
-
+
info = {}
r = RasterRow(name=name, mapset=mapset)
if r.exist() is True:
r.open("r")
-
+
for item in r.info:
info[item[0]] = item[1]
for item in r.hist:
info[item[0]] = item[1]
-
+
info["full_name"] = r.name_mapset()
info["mtype"] = r.mtype
if r.cats:
@@ -150,14 +150,14 @@
info["title"] = v.title
info["thresh"] = v.thresh
info["zone"] = v.zone
- vtypes = ['areas', 'dblinks', 'faces', 'holes', 'islands',
- 'kernels', 'lines', 'nodes', 'points', 'updated_lines',
+ vtypes = ['areas', 'dblinks', 'faces', 'holes', 'islands',
+ 'kernels', 'lines', 'nodes', 'points', 'updated_lines',
'updated_nodes', 'volumes']
for vtype in vtypes:
info[vtype] = v.number_of(vtype)
-
+
info.update(v.num_primitives())
-
+
if v.table is not None:
info["columns"] = v.table.columns
@@ -293,15 +293,15 @@
while mapsets[count]:
char_list = ""
mapset = mapsets[count]
-
+
permission = libgis.G_mapset_permissions(mapset)
in_search_path = libgis.G_is_mapset_in_search_path(mapset)
-
+
c = 0
while mapset[c] != "\x00":
char_list += mapset[c]
c += 1
-
+
if permission >= 0 and in_search_path == 1:
mapset_list.append(char_list)
@@ -1172,10 +1172,10 @@
self.client_conn.send([RPCDefs.READ_MAP_INFO, RPCDefs.TYPE_RASTER,
name, mapset, None])
return self.safe_receive("read_raster_info")
-
+
def read_raster_full_info(self, name, mapset):
"""Read raster info, history and cats using PyGRASS RasterRow
- and return a dictionary. Colors should be supported in the
+ and return a dictionary. Colors should be supported in the
future.
:param name: The name of the map
@@ -1184,7 +1184,7 @@
or None in case of an error
"""
self.check_server()
- self.client_conn.send([RPCDefs.READ_MAP_FULL_INFO,
+ self.client_conn.send([RPCDefs.READ_MAP_FULL_INFO,
RPCDefs.TYPE_RASTER,
name, mapset, None])
return self.safe_receive("read_raster_full_info")
@@ -1379,7 +1379,7 @@
def read_vector_full_info(self, name, mapset):
"""Read vector info using PyGRASS VectorTopo
- and return a dictionary.
+ and return a dictionary.
:param name: The name of the map
:param mapset: The mapset of the map
@@ -1387,7 +1387,7 @@
or None in case of an error
"""
self.check_server()
- self.client_conn.send([RPCDefs.READ_MAP_FULL_INFO,
+ self.client_conn.send([RPCDefs.READ_MAP_FULL_INFO,
RPCDefs.TYPE_VECTOR,
name, mapset, None])
return self.safe_receive("read_vector_full_info")
Modified: grass/trunk/lib/python/temporal/core.py
===================================================================
--- grass/trunk/lib/python/temporal/core.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/core.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -36,7 +36,7 @@
import grass.script as gscript
from datetime import datetime
-from .c_libraries_interface import *
+from c_libraries_interface import *
from grass.pygrass import messages
# Import all supported database backends
# Ignore import errors since they are checked later
@@ -70,7 +70,7 @@
sortby = 'cumulative'
ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
ps.print_stats()
- print(s.getvalue())
+ print s.getvalue()
else:
func()
@@ -1161,9 +1161,9 @@
if self.connected:
try:
return self.cursor.mogrify(sql, args)
- except Exception as exc:
- print(sql, args)
- raise exc
+ except:
+ print sql, args
+ raise
else:
self.connect()
statement = self.cursor.mogrify(sql, args)
Modified: grass/trunk/lib/python/temporal/datetime_math.py
===================================================================
--- grass/trunk/lib/python/temporal/datetime_math.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/datetime_math.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -9,7 +9,7 @@
:authors: Soeren Gebbert
"""
from datetime import datetime, timedelta
-from .core import *
+from core import *
import copy
try:
@@ -863,9 +863,9 @@
def create_time_suffix(mapp, end=False):
"""Create a datetime string based on a map datetime object
-
+
:param mapp: a temporal map dataset
- :param end: True if you want add also end time to the suffix
+ :param end: True if you want add also end time to the suffix
"""
start = mapp.temporal_extent.get_start_time()
sstring = start.isoformat().replace(':', '_').replace('-', '_')
Modified: grass/trunk/lib/python/temporal/extract.py
===================================================================
--- grass/trunk/lib/python/temporal/extract.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/extract.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -10,11 +10,11 @@
"""
from grass.script.utils import get_num_suffix
-from .space_time_datasets import *
-from .open_stds import *
-from .datetime_math import create_suffix_from_datetime
-from .datetime_math import create_time_suffix
-from .datetime_math import create_numeric_suffic
+from space_time_datasets import *
+from open_stds import *
+from datetime_math import create_suffix_from_datetime
+from datetime_math import create_time_suffix
+from datetime_math import create_numeric_suffic
from multiprocessing import Process
import grass.script as gscript
from grass.exceptions import CalledModuleError
@@ -183,7 +183,7 @@
msgr.percent(0, num_rows, 1)
temporal_type, semantic_type, title, description = sp.get_initial_values()
- new_sp = open_new_stds(output, type, sp.get_temporal_type(), title,
+ new_sp = open_new_stds(output, type, sp.get_temporal_type(), title,
description, semantic_type, dbif,
gscript.overwrite())
Modified: grass/trunk/lib/python/temporal/factory.py
===================================================================
--- grass/trunk/lib/python/temporal/factory.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/factory.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -18,7 +18,7 @@
:authors: Soeren Gebbert
"""
-from .space_time_datasets import *
+from space_time_datasets import *
###############################################################################
Modified: grass/trunk/lib/python/temporal/gui_support.py
===================================================================
--- grass/trunk/lib/python/temporal/gui_support.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/gui_support.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -10,8 +10,8 @@
:authors: Soeren Gebbert
"""
-from .space_time_datasets import *
-from .factory import *
+from space_time_datasets import *
+from factory import *
import grass.script as gscript
###############################################################################
Modified: grass/trunk/lib/python/temporal/list_stds.py
===================================================================
--- grass/trunk/lib/python/temporal/list_stds.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/list_stds.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -17,11 +17,11 @@
:authors: Soeren Gebbert
"""
-from __future__ import print_function
-from .space_time_datasets import *
-from .factory import *
-from .open_stds import *
+from space_time_datasets import *
+from factory import *
+from open_stds import *
+
###############################################################################
@@ -58,13 +58,13 @@
>>> rows = stds_list[mapset]
>>> for row in rows:
... if row["name"] == name:
- ... print(True)
+ ... print True
True
>>> stds_list = tgis.get_dataset_list("strds", "absolute", columns="name,mapset", where="mapset = '%s'"%(mapset))
>>> rows = stds_list[mapset]
>>> for row in rows:
... if row["name"] == name and row["mapset"] == mapset:
- ... print(True)
+ ... print True
True
>>> check = sp.delete()
@@ -192,7 +192,7 @@
if outpath:
outfile.write('{st}\n'.format(st=string))
else:
- print(string)
+ print string
if maps and len(maps) > 0:
@@ -240,7 +240,7 @@
if outpath:
outfile.write('{st}\n'.format(st=string))
else:
- print(string)
+ print string
else:
# In comma separated mode only map ids are needed
@@ -262,7 +262,7 @@
if outpath:
outfile.write('{st}\n'.format(st=string))
else:
- print(string)
+ print string
elif method == "cols":
# Print the column names if requested
@@ -281,7 +281,7 @@
if outpath:
outfile.write('{st}\n'.format(st=output))
else:
- print(output)
+ print output
for row in rows:
output = ""
@@ -295,7 +295,7 @@
if outpath:
outfile.write('{st}\n'.format(st=output))
else:
- print(output)
+ print output
if outpath:
outfile.close()
if connected:
Modified: grass/trunk/lib/python/temporal/mapcalc.py
===================================================================
--- grass/trunk/lib/python/temporal/mapcalc.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/mapcalc.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -9,8 +9,8 @@
:authors: Soeren Gebbert
"""
-from .space_time_datasets import *
-from .open_stds import *
+from space_time_datasets import *
+from open_stds import *
from multiprocessing import Process
import grass.script as gscript
from grass.exceptions import CalledModuleError
Modified: grass/trunk/lib/python/temporal/metadata.py
===================================================================
--- grass/trunk/lib/python/temporal/metadata.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/metadata.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -21,8 +21,7 @@
:authors: Soeren Gebbert
"""
-from __future__ import print_function
-from .base import *
+from base import *
###############################################################################
@@ -235,26 +234,26 @@
def print_info(self):
"""Print information about this class in human readable style"""
# 0123456789012345678901234567890
- print(" | Datatype:................... " + str(self.get_datatype()))
- print(" | Number of columns:.......... " + str(self.get_cols()))
- print(" | Number of rows:............. " + str(self.get_rows()))
- print(" | Number of cells:............ " + str(
- self.get_number_of_cells()))
- print(" | North-South resolution:..... " + str(self.get_nsres()))
- print(" | East-west resolution:....... " + str(self.get_ewres()))
- print(" | Minimum value:.............. " + str(self.get_min()))
- print(" | Maximum value:.............. " + str(self.get_max()))
+ print " | Datatype:................... " + str(self.get_datatype())
+ print " | Number of columns:.......... " + str(self.get_cols())
+ print " | Number of rows:............. " + str(self.get_rows())
+ print " | Number of cells:............ " + str(
+ self.get_number_of_cells())
+ print " | North-South resolution:..... " + str(self.get_nsres())
+ print " | East-west resolution:....... " + str(self.get_ewres())
+ print " | Minimum value:.............. " + str(self.get_min())
+ print " | Maximum value:.............. " + str(self.get_max())
def print_shell_info(self):
"""Print information about this class in shell style"""
- print("datatype=" + str(self.get_datatype()))
- print("cols=" + str(self.get_cols()))
- print("rows=" + str(self.get_rows()))
- print("number_of_cells=" + str(self.get_number_of_cells()))
- print("nsres=" + str(self.get_nsres()))
- print("ewres=" + str(self.get_ewres()))
- print("min=" + str(self.get_min()))
- print("max=" + str(self.get_max()))
+ print "datatype=" + str(self.get_datatype())
+ print "cols=" + str(self.get_cols())
+ print "rows=" + str(self.get_rows())
+ print "number_of_cells=" + str(self.get_number_of_cells())
+ print "nsres=" + str(self.get_nsres())
+ print "ewres=" + str(self.get_ewres())
+ print "min=" + str(self.get_min())
+ print "max=" + str(self.get_max())
###############################################################################
@@ -324,7 +323,7 @@
def print_info(self):
"""Print information about this class in human readable style"""
- print(" +-------------------- Metadata information ----------------------------------+")
+ print " +-------------------- Metadata information ----------------------------------+"
# 0123456789012345678901234567890
RasterMetadataBase.print_info(self)
@@ -446,18 +445,18 @@
def print_info(self):
"""Print information about this class in human readable style"""
- print(" +-------------------- Metadata information ----------------------------------+")
+ print " +-------------------- Metadata information ----------------------------------+"
# 0123456789012345678901234567890
RasterMetadataBase.print_info(self)
# 0123456789012345678901234567890
- print(" | Number of depths:........... " + str(self.get_depths()))
- print(" | Top-Bottom resolution:...... " + str(self.get_tbres()))
+ print " | Number of depths:........... " + str(self.get_depths())
+ print " | Top-Bottom resolution:...... " + str(self.get_tbres())
def print_shell_info(self):
"""Print information about this class in shell style"""
RasterMetadataBase.print_shell_info(self)
- print("depths=" + str(self.get_depths()))
- print("tbres=" + str(self.get_tbres()))
+ print "depths=" + str(self.get_depths())
+ print "tbres=" + str(self.get_tbres())
###############################################################################
@@ -764,36 +763,36 @@
def print_info(self):
"""Print information about this class in human readable style"""
# 0123456789012345678901234567890
- print(" +-------------------- Metadata information ----------------------------------+")
- print(" | Is map 3d .................. " + str(self.get_3d_info()))
- print(" | Number of points ........... " + str(self.get_number_of_points()))
- print(" | Number of lines ............ " + str(self.get_number_of_lines()))
- print(" | Number of boundaries ....... " + str(self.get_number_of_boundaries()))
- print(" | Number of centroids ........ " + str(self.get_number_of_centroids()))
- print(" | Number of faces ............ " + str(self.get_number_of_faces()))
- print(" | Number of kernels .......... " + str(self.get_number_of_kernels()))
- print(" | Number of primitives ....... " + str(self.get_number_of_primitives()))
- print(" | Number of nodes ............ " + str(self.get_number_of_nodes()))
- print(" | Number of areas ............ " + str(self.get_number_of_areas()))
- print(" | Number of islands .......... " + str(self.get_number_of_islands()))
- print(" | Number of holes ............ " + str(self.get_number_of_holes()))
- print(" | Number of volumes .......... " + str(self.get_number_of_volumes()))
+ print " +-------------------- Metadata information ----------------------------------+"
+ print " | Is map 3d .................. " + str(self.get_3d_info())
+ print " | Number of points ........... " + str(self.get_number_of_points())
+ print " | Number of lines ............ " + str(self.get_number_of_lines())
+ print " | Number of boundaries ....... " + str(self.get_number_of_boundaries())
+ print " | Number of centroids ........ " + str(self.get_number_of_centroids())
+ print " | Number of faces ............ " + str(self.get_number_of_faces())
+ print " | Number of kernels .......... " + str(self.get_number_of_kernels())
+ print " | Number of primitives ....... " + str(self.get_number_of_primitives())
+ print " | Number of nodes ............ " + str(self.get_number_of_nodes())
+ print " | Number of areas ............ " + str(self.get_number_of_areas())
+ print " | Number of islands .......... " + str(self.get_number_of_islands())
+ print " | Number of holes ............ " + str(self.get_number_of_holes())
+ print " | Number of volumes .......... " + str(self.get_number_of_volumes())
def print_shell_info(self):
"""Print information about this class in shell style"""
- print("is_3d=" + str(self.get_3d_info()))
- print("points=" + str(self.get_number_of_points()))
- print("lines=" + str(self.get_number_of_lines()))
- print("boundaries=" + str(self.get_number_of_boundaries()))
- print("centroids=" + str(self.get_number_of_centroids()))
- print("faces=" + str(self.get_number_of_faces()))
- print("kernels=" + str(self.get_number_of_kernels()))
- print("primitives=" + str(self.get_number_of_primitives()))
- print("nodes=" + str(self.get_number_of_nodes()))
- print("areas=" + str(self.get_number_of_areas()))
- print("islands=" + str(self.get_number_of_islands()))
- print("holes=" + str(self.get_number_of_holes()))
- print("volumes=" + str(self.get_number_of_volumes()))
+ print "is_3d=" + str(self.get_3d_info())
+ print "points=" + str(self.get_number_of_points())
+ print "lines=" + str(self.get_number_of_lines())
+ print "boundaries=" + str(self.get_number_of_boundaries())
+ print "centroids=" + str(self.get_number_of_centroids())
+ print "faces=" + str(self.get_number_of_faces())
+ print "kernels=" + str(self.get_number_of_kernels())
+ print "primitives=" + str(self.get_number_of_primitives())
+ print "nodes=" + str(self.get_number_of_nodes())
+ print "areas=" + str(self.get_number_of_areas())
+ print "islands=" + str(self.get_number_of_islands())
+ print "holes=" + str(self.get_number_of_holes())
+ print "volumes=" + str(self.get_number_of_volumes())
###############################################################################
@@ -909,29 +908,29 @@
def print_info(self):
"""Print information about this class in human readable style"""
# 0123456789012345678901234567890
- print(" | Number of registered maps:.. " + str(
- self.get_number_of_maps()))
- print(" |")
- print(" | Title:")
- print(" | " + str(self.get_title()))
- print(" | Description:")
- print(" | " + str(self.get_description()))
- print(" | Command history:")
+ print " | Number of registered maps:.. " + str(
+ self.get_number_of_maps())
+ print " |"
+ print " | Title:"
+ print " | " + str(self.get_title())
+ print " | Description:"
+ print " | " + str(self.get_description())
+ print " | Command history:"
command = self.get_command()
if command:
for token in command.split("\n"):
- print(" | " + str(token))
+ print " | " + str(token)
def print_history(self):
"""Print history information about this class in human readable
shell style
"""
# 0123456789012345678901234567890
- print("# Title:")
- print("# " + str(self.get_title()))
- print("# Description:")
- print("# " + str(self.get_description()))
- print("# Command history:")
+ print "# Title:"
+ print "# " + str(self.get_title())
+ print "# Description:"
+ print "# " + str(self.get_description())
+ print "# Command history:"
command = self.get_command()
if command:
@@ -947,15 +946,15 @@
count += 1
if len(token) > 1:
if token[0] == "#":
- print(token)
+ print token
elif count < len(print_list):
- print(token + " \\")
+ print token + " \\"
else:
- print(token)
+ print token
def print_shell_info(self):
"""Print information about this class in shell style"""
- print("number_of_maps=" + str(self.get_number_of_maps()))
+ print "number_of_maps=" + str(self.get_number_of_maps())
###############################################################################
@@ -1143,29 +1142,29 @@
def print_info(self):
"""Print information about this class in human readable style"""
# 0123456789012345678901234567890
- print(" | North-South resolution min:. " + str(self.get_nsres_min()))
- print(" | North-South resolution max:. " + str(self.get_nsres_max()))
- print(" | East-west resolution min:... " + str(self.get_ewres_min()))
- print(" | East-west resolution max:... " + str(self.get_ewres_max()))
- print(" | Minimum value min:.......... " + str(self.get_min_min()))
- print(" | Minimum value max:.......... " + str(self.get_min_max()))
- print(" | Maximum value min:.......... " + str(self.get_max_min()))
- print(" | Maximum value max:.......... " + str(self.get_max_max()))
- print(" | Aggregation type:........... " + str(self.get_aggregation_type()))
+ print " | North-South resolution min:. " + str(self.get_nsres_min())
+ print " | North-South resolution max:. " + str(self.get_nsres_max())
+ print " | East-west resolution min:... " + str(self.get_ewres_min())
+ print " | East-west resolution max:... " + str(self.get_ewres_max())
+ print " | Minimum value min:.......... " + str(self.get_min_min())
+ print " | Minimum value max:.......... " + str(self.get_min_max())
+ print " | Maximum value min:.......... " + str(self.get_max_min())
+ print " | Maximum value max:.......... " + str(self.get_max_max())
+ print " | Aggregation type:........... " + str(self.get_aggregation_type())
STDSMetadataBase.print_info(self)
def print_shell_info(self):
"""Print information about this class in shell style"""
- print("aggregation_type=" + str(self.get_aggregation_type()))
+ print "aggregation_type=" + str(self.get_aggregation_type())
STDSMetadataBase.print_shell_info(self)
- print("nsres_min=" + str(self.get_nsres_min()))
- print("nsres_max=" + str(self.get_nsres_max()))
- print("ewres_min=" + str(self.get_ewres_min()))
- print("ewres_max=" + str(self.get_ewres_max()))
- print("min_min=" + str(self.get_min_min()))
- print("min_max=" + str(self.get_min_max()))
- print("max_min=" + str(self.get_max_min()))
- print("max_max=" + str(self.get_max_max()))
+ print "nsres_min=" + str(self.get_nsres_min())
+ print "nsres_max=" + str(self.get_nsres_max())
+ print "ewres_min=" + str(self.get_ewres_min())
+ print "ewres_max=" + str(self.get_ewres_max())
+ print "min_min=" + str(self.get_min_min())
+ print "min_max=" + str(self.get_min_max())
+ print "max_min=" + str(self.get_max_min())
+ print "max_max=" + str(self.get_max_max())
###############################################################################
@@ -1262,16 +1261,16 @@
def print_info(self):
"""Print information about this class in human readable style"""
- print(" +-------------------- Metadata information ----------------------------------+")
+ print " +-------------------- Metadata information ----------------------------------+"
# 0123456789012345678901234567890
- print(" | Raster register table:...... " + str(
- self.get_raster_register()))
+ print " | Raster register table:...... " + str(
+ self.get_raster_register())
STDSRasterMetadataBase.print_info(self)
def print_shell_info(self):
"""Print information about this class in shell style"""
STDSRasterMetadataBase.print_shell_info(self)
- print("raster_register=" + str(self.get_raster_register()))
+ print "raster_register=" + str(self.get_raster_register())
###############################################################################
@@ -1398,21 +1397,21 @@
def print_info(self):
"""Print information about this class in human readable style"""
- print(" +-------------------- Metadata information ----------------------------------+")
+ print " +-------------------- Metadata information ----------------------------------+"
# 0123456789012345678901234567890
# 0123456789012345678901234567890
- print(" | 3D raster register table:... " + str(
- self.get_raster3d_register()))
- print(" | Top-bottom resolution min:.. " + str(self.get_ewres_min()))
- print(" | Top-bottom resolution max:.. " + str(self.get_ewres_max()))
+ print " | 3D raster register table:... " + str(
+ self.get_raster3d_register())
+ print " | Top-bottom resolution min:.. " + str(self.get_ewres_min())
+ print " | Top-bottom resolution max:.. " + str(self.get_ewres_max())
STDSRasterMetadataBase.print_info(self)
def print_shell_info(self):
"""Print information about this class in shell style"""
STDSRasterMetadataBase.print_shell_info(self)
- print("tbres_min=" + str(self.get_tbres_min()))
- print("tbres_max=" + str(self.get_tbres_max()))
- print("raster3d_register=" + str(self.get_raster3d_register()))
+ print "tbres_min=" + str(self.get_tbres_min())
+ print "tbres_max=" + str(self.get_tbres_max())
+ print "raster3d_register=" + str(self.get_raster3d_register())
###############################################################################
@@ -1663,40 +1662,40 @@
def print_info(self):
"""Print information about this class in human readable style"""
- print(" +-------------------- Metadata information ----------------------------------+")
+ print " +-------------------- Metadata information ----------------------------------+"
# 0123456789012345678901234567890
- print(" | Vector register table:...... " + str(
- self.get_vector_register()))
- print(" | Number of points ........... " + str(self.number_of_points))
- print(" | Number of lines ............ " + str(self.number_of_lines))
- print(" | Number of boundaries ....... " + str(self.number_of_boundaries))
- print(" | Number of centroids ........ " + str(self.number_of_centroids))
- print(" | Number of faces ............ " + str(self.number_of_faces))
- print(" | Number of kernels .......... " + str(self.number_of_kernels))
- print(" | Number of primitives ....... " + str(self.number_of_primitives))
- print(" | Number of nodes ............ " + str(self.number_of_nodes))
- print(" | Number of areas ............ " + str(self.number_of_areas))
- print(" | Number of islands .......... " + str(self.number_of_islands))
- print(" | Number of holes ............ " + str(self.number_of_holes))
- print(" | Number of volumes .......... " + str(self.number_of_volumes))
+ print " | Vector register table:...... " + str(
+ self.get_vector_register())
+ print " | Number of points ........... " + str(self.number_of_points)
+ print " | Number of lines ............ " + str(self.number_of_lines)
+ print " | Number of boundaries ....... " + str(self.number_of_boundaries)
+ print " | Number of centroids ........ " + str(self.number_of_centroids)
+ print " | Number of faces ............ " + str(self.number_of_faces)
+ print " | Number of kernels .......... " + str(self.number_of_kernels)
+ print " | Number of primitives ....... " + str(self.number_of_primitives)
+ print " | Number of nodes ............ " + str(self.number_of_nodes)
+ print " | Number of areas ............ " + str(self.number_of_areas)
+ print " | Number of islands .......... " + str(self.number_of_islands)
+ print " | Number of holes ............ " + str(self.number_of_holes)
+ print " | Number of volumes .......... " + str(self.number_of_volumes)
STDSMetadataBase.print_info(self)
def print_shell_info(self):
"""Print information about this class in shell style"""
STDSMetadataBase.print_shell_info(self)
- print("vector_register=" + str(self.get_vector_register()))
- print("points=" + str(self.get_number_of_points()))
- print("lines=" + str(self.get_number_of_lines()))
- print("boundaries=" + str(self.get_number_of_boundaries()))
- print("centroids=" + str(self.get_number_of_centroids()))
- print("faces=" + str(self.get_number_of_faces()))
- print("kernels=" + str(self.get_number_of_kernels()))
- print("primitives=" + str(self.get_number_of_primitives()))
- print("nodes=" + str(self.get_number_of_nodes()))
- print("areas=" + str(self.get_number_of_areas()))
- print("islands=" + str(self.get_number_of_islands()))
- print("holes=" + str(self.get_number_of_holes()))
- print("volumes=" + str(self.get_number_of_volumes()))
+ print "vector_register=" + str(self.get_vector_register())
+ print "points=" + str(self.get_number_of_points())
+ print "lines=" + str(self.get_number_of_lines())
+ print "boundaries=" + str(self.get_number_of_boundaries())
+ print "centroids=" + str(self.get_number_of_centroids())
+ print "faces=" + str(self.get_number_of_faces())
+ print "kernels=" + str(self.get_number_of_kernels())
+ print "primitives=" + str(self.get_number_of_primitives())
+ print "nodes=" + str(self.get_number_of_nodes())
+ print "areas=" + str(self.get_number_of_areas())
+ print "islands=" + str(self.get_number_of_islands())
+ print "holes=" + str(self.get_number_of_holes())
+ print "volumes=" + str(self.get_number_of_volumes())
###############################################################################
Modified: grass/trunk/lib/python/temporal/open_stds.py
===================================================================
--- grass/trunk/lib/python/temporal/open_stds.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/open_stds.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -18,7 +18,7 @@
:authors: Soeren Gebbert
"""
-from .factory import *
+from factory import *
###############################################################################
@@ -37,7 +37,7 @@
:param type: The type of the space time dataset (strd, str3ds, stvds,
raster, vector, raster3d)
:param dbif: The optional database interface to be used
-
+
:return: New stds object
"""
Modified: grass/trunk/lib/python/temporal/register.py
===================================================================
--- grass/trunk/lib/python/temporal/register.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/register.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -17,7 +17,7 @@
:authors: Soeren Gebbert
"""
-from .open_stds import *
+from open_stds import *
import grass.script as gscript
###############################################################################
Modified: grass/trunk/lib/python/temporal/sampling.py
===================================================================
--- grass/trunk/lib/python/temporal/sampling.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/sampling.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -16,10 +16,10 @@
:authors: Soeren Gebbert
"""
-from __future__ import print_function
-from .factory import *
+from factory import *
+
def sample_stds_by_stds_topology(intype, sampletype, inputs, sampler, header,
separator, method, spatial=False,
print_only=True):
@@ -122,7 +122,7 @@
string += "%s%s" % ("end_time", separator)
string += "%s%s" % ("interval_length", separator)
string += "%s" % ("distance_from_begin")
- print(string)
+ print string
first_time, dummy = mapmatrizes[0][0]["granule"].get_temporal_extent_as_tuple()
@@ -163,7 +163,7 @@
string += "%s%s" % (end, separator)
string += "%s%s" % (delta, separator)
string += "%s" % (delta_first)
- print(string)
+ print string
dbif.close()
if len(mapmatrizes) > 0:
Modified: grass/trunk/lib/python/temporal/space_time_datasets.py
===================================================================
--- grass/trunk/lib/python/temporal/space_time_datasets.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/space_time_datasets.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -9,8 +9,8 @@
:authors: Soeren Gebbert
"""
import getpass
-from .abstract_map_dataset import *
-from .abstract_space_time_dataset import *
+from abstract_map_dataset import *
+from abstract_space_time_dataset import *
import grass.script.array as garray
###############################################################################
Modified: grass/trunk/lib/python/temporal/spatial_extent.py
===================================================================
--- grass/trunk/lib/python/temporal/spatial_extent.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/spatial_extent.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -33,8 +33,7 @@
:authors: Soeren Gebbert
"""
-from __future__ import print_function
-from .base import *
+from base import *
class SpatialExtent(SQLDatabaseInterface):
@@ -1783,22 +1782,22 @@
def print_info(self):
"""Print information about this class in human readable style"""
# 0123456789012345678901234567890
- print(" +-------------------- Spatial extent ----------------------------------------+")
- print(" | North:...................... " + str(self.get_north()))
- print(" | South:...................... " + str(self.get_south()))
- print(" | East:.. .................... " + str(self.get_east()))
- print(" | West:....................... " + str(self.get_west()))
- print(" | Top:........................ " + str(self.get_top()))
- print(" | Bottom:..................... " + str(self.get_bottom()))
+ print " +-------------------- Spatial extent ----------------------------------------+"
+ print " | North:...................... " + str(self.get_north())
+ print " | South:...................... " + str(self.get_south())
+ print " | East:.. .................... " + str(self.get_east())
+ print " | West:....................... " + str(self.get_west())
+ print " | Top:........................ " + str(self.get_top())
+ print " | Bottom:..................... " + str(self.get_bottom())
def print_shell_info(self):
"""Print information about this class in shell style"""
- print("north=" + str(self.get_north()))
- print("south=" + str(self.get_south()))
- print("east=" + str(self.get_east()))
- print("west=" + str(self.get_west()))
- print("top=" + str(self.get_top()))
- print("bottom=" + str(self.get_bottom()))
+ print "north=" + str(self.get_north())
+ print "south=" + str(self.get_south())
+ print "east=" + str(self.get_east())
+ print "west=" + str(self.get_west())
+ print "top=" + str(self.get_top())
+ print "bottom=" + str(self.get_bottom())
###############################################################################
Modified: grass/trunk/lib/python/temporal/spatial_topology_dataset_connector.py
===================================================================
--- grass/trunk/lib/python/temporal/spatial_topology_dataset_connector.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/spatial_topology_dataset_connector.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -14,7 +14,6 @@
:authors: Soeren Gebbert
"""
-from __future__ import print_function
import copy
@@ -69,7 +68,7 @@
meet=a at P
>>> rlist = tmr.get_spatial_relations()
>>> if "COVER" in rlist.keys():
- ... print(rlist["COVER"][0].get_id())
+ ... print rlist["COVER"][0].get_id()
a at P
"""
@@ -319,54 +318,54 @@
def print_spatial_topology_info(self):
"""Print information about this class in human readable style"""
- print(" +-------------------- Spatial Topology --------------------------------------+")
+ print " +-------------------- Spatial Topology --------------------------------------+"
# 0123456789012345678901234567890
if self.equivalent is not None:
- print(" | Equivalent: ................ " +
- self._generate_map_list_string(self.equivalent))
+ print " | Equivalent: ................ " + \
+ self._generate_map_list_string(self.equivalent)
if self.cover is not None:
- print(" | Cover: ..................... " +
- self._generate_map_list_string(self.cover))
+ print " | Cover: ..................... " + \
+ self._generate_map_list_string(self.cover)
if self.covered is not None:
- print(" | Covered: ................... " +
- self._generate_map_list_string(self.covered))
+ print " | Covered: ................... " + \
+ self._generate_map_list_string(self.covered)
if self.overlap is not None:
- print(" | Overlap: ................... " +
- self._generate_map_list_string(self.overlap))
+ print " | Overlap: ................... " + \
+ self._generate_map_list_string(self.overlap)
if self.in_ is not None:
- print(" | In: ........................ " +
- self._generate_map_list_string(self.in_))
+ print " | In: ........................ " + \
+ self._generate_map_list_string(self.in_)
if self.contain is not None:
- print(" | Contain: ................... " +
- self._generate_map_list_string(self.contain))
+ print " | Contain: ................... " + \
+ self._generate_map_list_string(self.contain)
if self.meet is not None:
- print(" | Meet: ...................... " +
- self._generate_map_list_string(self.meet))
+ print " | Meet: ...................... " + \
+ self._generate_map_list_string(self.meet)
def print_spatial_topology_shell_info(self):
"""Print information about this class in shell style"""
if self.equivalent is not None:
- print("equivalent=" + self._generate_map_list_string(self.equivalent,
- False))
+ print "equivalent=" + self._generate_map_list_string(self.equivalent,
+ False)
if self.cover is not None:
- print("cover=" + self._generate_map_list_string(
- self.cover, False))
+ print "cover=" + self._generate_map_list_string(
+ self.cover, False)
if self.covered is not None:
- print("covered=" +
- self._generate_map_list_string(self.covered, False))
+ print "covered=" + \
+ self._generate_map_list_string(self.covered, False)
if self.overlap is not None:
- print("overlap=" +
- self._generate_map_list_string(self.overlap))
+ print "overlap=" + \
+ self._generate_map_list_string(self.overlap)
if self.in_ is not None:
- print("in=" +
- self._generate_map_list_string(self.in_))
+ print "in=" + \
+ self._generate_map_list_string(self.in_)
if self.contain is not None:
- print("contain=" +
- self._generate_map_list_string(self.contain))
+ print "contain=" + \
+ self._generate_map_list_string(self.contain)
if self.meet is not None:
- print("meet=" +
- self._generate_map_list_string(self.meet))
+ print "meet=" + \
+ self._generate_map_list_string(self.meet)
###############################################################################
Modified: grass/trunk/lib/python/temporal/spatio_temporal_relationships.py
===================================================================
--- grass/trunk/lib/python/temporal/spatio_temporal_relationships.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/spatio_temporal_relationships.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -17,8 +17,8 @@
:authors: Soeren Gebbert
"""
-from .abstract_dataset import *
-from .datetime_math import *
+from abstract_dataset import *
+from datetime_math import *
import grass.lib.vector as vector
import grass.lib.rtree as rtree
import grass.lib.gis as gis
Modified: grass/trunk/lib/python/temporal/stds_export.py
===================================================================
--- grass/trunk/lib/python/temporal/stds_export.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/stds_export.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -30,9 +30,9 @@
import tarfile
import tempfile
-from .space_time_datasets import *
-from .factory import *
-from .open_stds import *
+from space_time_datasets import *
+from factory import *
+from open_stds import *
import grass.script as gscript
from grass.exceptions import CalledModuleError
@@ -52,7 +52,7 @@
############################################################################
-def _export_raster_maps_as_gdal(rows, tar, list_file, new_cwd, fs, format_,
+def _export_raster_maps_as_gdal(rows, tar, list_file, new_cwd, fs, format_,
type_):
for row in rows:
name = row["name"]
Modified: grass/trunk/lib/python/temporal/stds_import.py
===================================================================
--- grass/trunk/lib/python/temporal/stds_import.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/stds_import.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -33,10 +33,10 @@
import os.path
import tarfile
-from .space_time_datasets import *
-from .register import *
-from . import factory
-from .factory import *
+from space_time_datasets import *
+from register import *
+import factory
+from factory import *
import grass.script as gscript
from grass.exceptions import CalledModuleError
@@ -244,7 +244,7 @@
temp_file = open(temp_name, "w")
proj_name = os.path.abspath(proj_file_name)
- # We need to convert projection strings generated
+ # We need to convert projection strings generated
# from other programms than g.proj into
# new line format so that the grass file comparison function
# can be used to compare the projections
Modified: grass/trunk/lib/python/temporal/temporal_algebra.py
===================================================================
--- grass/trunk/lib/python/temporal/temporal_algebra.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/temporal_algebra.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -367,7 +367,7 @@
None || None
A* = if condition None then A else B
C = A*
-
+
>>> p = tgis.TemporalAlgebraLexer()
>>> p.build()
>>> p.debug = True
@@ -390,7 +390,7 @@
LexToken(LPAREN,'(',1,32)
LexToken(NAME,'C',1,33)
LexToken(RPAREN,')',1,34)
-
+
>>> p = tgis.TemporalAlgebraLexer()
>>> p.build()
>>> p.debug = True
@@ -412,7 +412,7 @@
LexToken(COMMA,',',1,33)
LexToken(NAME,'A',1,35)
LexToken(RPAREN,')',1,36)
-
+
>>> p = tgis.TemporalAlgebraLexer()
>>> p.build()
>>> p.debug = True
@@ -438,7 +438,6 @@
LexToken(RPAREN,')',1,48)
"""
-from __future__ import print_function
try:
import ply.lex as lex
@@ -449,17 +448,17 @@
import os
import copy
import grass.pygrass.modules as pymod
-from .space_time_datasets import *
-from .factory import *
-from .open_stds import *
-from .temporal_operator import *
+from space_time_datasets import *
+from factory import *
+from open_stds import *
+from temporal_operator import *
##############################################################################
class TemporalAlgebraLexer(object):
"""Lexical analyzer for the GRASS GIS temporal algebra"""
- # Functions that defines an if condition, temporal buffering, snapping and
+ # Functions that defines an if condition, temporal buffering, snapping and
# selection of maps with temporal extent.
conditional_functions = {
'if' : 'IF',
@@ -472,7 +471,7 @@
'str3ds' : 'STR3DS',
'stvds' : 'STVDS',
}
-
+
# Variables with date and time strings
datetime_functions = {
'start_time' : 'START_TIME', # start time as HH::MM:SS
@@ -566,7 +565,7 @@
t_T_REL_OPERATOR = r'\{([a-zA-Z\| ])+\}'
t_T_SELECT = r':'
t_T_NOT_SELECT = r'!:'
- t_LPAREN = r'\('
+ t_LPAREN = r'\('
t_RPAREN = r'\)'
t_COMMA = r','
t_CEQUALS = r'=='
@@ -665,7 +664,7 @@
while True:
tok = self.lexer.token()
if not tok: break
- print(tok)
+ print tok
###############################################################################
@@ -737,7 +736,7 @@
('left', 'AND', 'OR', 'T_COMP_OPERATOR'), #2
)
- def __init__(self, pid=None, run = True, debug = False, spatial = False,
+ def __init__(self, pid=None, run = True, debug = False, spatial = False,
null = False, register_null = False, nprocs = 1):
self.run = run
self.debug = debug
@@ -762,45 +761,45 @@
def __del__(self):
if self.dbif.connected:
self.dbif.close()
-
+
def setup_common_granularity(self, expression, stdstype = 'strds', lexer = None):
"""Configure the temporal algebra to use the common granularity of all
space time datasets in the expression to generate the map lists.
-
+
This function will analyze the expression to detect space time datasets
and computes the common granularity from all granularities.
-
+
This granularity is then be used to generate the map lists. Hence, all
maps from all STDS will have equidistant temporal extents. The only meaningful
temporal relation is "equal".
-
+
:param expression: The algebra expression to analyze
-
+
:param lexer: The temporal algebra lexer (select, raster, voxel, vector) that should be used to
parse the expression, default is TemporalAlgebraLexer
-
+
:return: True if successful, False otherwise
-
+
"""
l = lexer
# Split the expression to ignore the left part
expressions = expression.split("=")[1:]
expression = " ".join(expressions)
-
+
# Check if spatio-temporal operators are present in the expression
if "{" in expression or "}" in expression:
self.msgr.error(_("Spatio temporal operators are not supported in granularity algebra mode"))
return False
-
+
# detect all STDS
if l is None:
l = TemporalAlgebraLexer()
l.build()
l.lexer.input(expression)
-
+
name_list = []
tokens = []
-
+
count = 0
while True:
tok = l.lexer.token()
@@ -812,7 +811,7 @@
if count > 1:
if tokens[count - 2] == "MAP" or tokens[count - 2] == "TMAP":
ignore = True
-
+
if tok.type == "NAME" and ignore == False:
name_list.append(tok.value)
count += 1
@@ -832,23 +831,23 @@
grans.append(stds.get_granularity())
start_times.append(stds.get_temporal_extent_as_tuple()[0])
ttypes[stds.get_temporal_type()] = stds.get_temporal_type()
-
+
# Only one temporal type is allowed
if len(ttypes) > 1:
self.msgr.error(_("All input space time datasets must have the same temporal type."))
return False
-
+
# Compute the common granularity
if "absolute" in ttypes.keys():
self.granularity = compute_common_absolute_time_granularity(grans, start_times)
else:
self.granularity = compute_common_relative_time_granularity(grans)
-
+
self.use_granularity = True
-
+
return True
- def parse(self, expression, stdstype = 'strds', maptype = 'rast', mapclass = RasterDataset,
+ def parse(self, expression, stdstype = 'strds', maptype = 'rast', mapclass = RasterDataset,
basename = None, overwrite=False):
self.lexer = TemporalAlgebraLexer()
self.lexer.build()
@@ -878,7 +877,7 @@
self.names[name] = name
return name
- def generate_new_map(self, base_map, bool_op = 'and', copy = True, rename = True,
+ def generate_new_map(self, base_map, bool_op = 'and', copy = True, rename = True,
remove = False):
"""Generate a new map using the spatio-temporal extent of the base map
@@ -968,7 +967,7 @@
if temp_ext != None:
mapA.set_temporal_extent(temp_ext)
else:
- returncode = 0
+ returncode = 0
elif temp_op == 'd':
temp_ext = mapA.temporal_disjoint_union(mapB)
if temp_ext != None:
@@ -984,25 +983,25 @@
return(returncode)
def set_temporal_extent_list(self, maplist, topolist = ["EQUAL"], temporal = 'l' ):
- """ Change temporal extent of map list based on temporal relations to
+ """ Change temporal extent of map list based on temporal relations to
other map list and given temporal operator.
- :param maplist: List of map objects for which relations has been build
+ :param maplist: List of map objects for which relations has been build
correctely.
:param topolist: List of strings of temporal relations.
:param temporal: The temporal operator specifying the temporal
- extent operation (intersection, union, disjoint
+ extent operation (intersection, union, disjoint
union, right reference, left reference).
:return: Map list with specified temporal extent.
"""
resultdict = {}
-
+
for map_i in maplist:
# Loop over temporal related maps and create overlay modules.
tbrelations = map_i.get_temporal_relations()
# Generate an intermediate map for the result map list.
- map_new = self.generate_new_map(base_map=map_i, bool_op = 'and',
+ map_new = self.generate_new_map(base_map=map_i, bool_op = 'and',
copy = True, rename = True)
# Combine temporal and spatial extents of intermediate map with related maps.
for topo in topolist:
@@ -1010,7 +1009,7 @@
for map_j in (tbrelations[topo]):
if temporal == 'r':
# Generate an intermediate map for the result map list.
- map_new = self.generate_new_map(base_map=map_i, bool_op = 'and',
+ map_new = self.generate_new_map(base_map=map_i, bool_op = 'and',
copy = True, rename = True)
# Create overlayed map extent.
returncode = self.overlay_map_extent(map_new, map_j, 'and', \
@@ -1025,10 +1024,10 @@
# print(map_new.cmd_list)
# resultlist.append(map_new)
resultdict[map_new.get_id()] = map_new
-
+
# Create r.mapcalc expression string for the operation.
- #cmdstring = self.build_command_string(s_expr_a = map_new,
- # s_expr_b = map_j,
+ #cmdstring = self.build_command_string(s_expr_a = map_new,
+ # s_expr_b = map_j,
# operator = function)
# Conditional append of module command.
#map_new.cmd_list = cmdstring
@@ -1040,24 +1039,24 @@
# Get sorted map objects as values from result dictionoary.
resultlist = resultdict.values()
resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
-
+
return(resultlist)
-
+
######################### Temporal functions ##############################
def remove_maps(self):
"""Removes empty or intermediate maps of different type.
"""
-
+
map_names = {}
map_names["raster"] = []
map_names["raster3d"] = []
map_names["vector"] = []
-
+
if self.removable_maps:
for map in self.removable_maps.values():
map_names[map.get_type()].append(map.get_name())
-
+
for key in map_names.keys():
if map_names[key]:
self.msgr.message(_("Removing un-needed or empty %s maps"%(key)))
@@ -1065,7 +1064,7 @@
def _remove_maps(self, namelist, map_type):
"""Remove maps of specific type
-
+
:param namelist: List of map names to be removed
:param map_type: The type of the maps (raster, raster_3d or vector)
"""
@@ -1073,13 +1072,13 @@
chunklist = [namelist[i:i + max] for i in range(0, len(namelist), max)]
for chunk in chunklist:
stringlist = ",".join(chunk)
-
+
if self.run:
m = copy.deepcopy(self.m_mremove)
m.inputs["type"].value = map_type
m.inputs["name"].value = stringlist
m.flags["f"].value = True
- print(m.get_bash())
+ print m.get_bash()
m.run()
def check_stds(self, input, clear = False, stds_type = None, check_type=True):
@@ -1088,7 +1087,7 @@
:param input: Name of space time data set as string or list of maps.
:param clear: Reset the stored conditional values to empty list.
:param check_type: Check the type of the space time dataset to match the global stds type
- :param stds_type: The type of the space time dataset to be opened, if not provided
+ :param stds_type: The type of the space time dataset to be opened, if not provided
then self.stdstype will be used
:return: List of maps.
@@ -1144,7 +1143,7 @@
elif isinstance(input, self.mapclass):
# Check if the input is a single map and return it as list with one entry.
maplist = [input]
-
+
elif isinstance(input, list):
maplist = input
# Create map_value as empty list item.
@@ -1159,19 +1158,19 @@
map_i.condition_value = []
else:
self.msgr.fatal(_("Wrong type of input " + str(input)))
-
+
# We generate a unique map id that will be used
- # in the topology analysis, since the maplist can
- # contain maps with equal map ids
+ # in the topology analysis, since the maplist can
+ # contain maps with equal map ids
for map in maplist:
map.uid = self.generate_map_name()
if self.debug:
- print(map.get_name(), map.uid, map.get_temporal_extent_as_tuple())
-
+ print map.get_name(), map.uid, map.get_temporal_extent_as_tuple()
+
return(maplist)
def get_temporal_topo_list(self, maplistA, maplistB = None, topolist = ["EQUAL"],
- assign_val = False, count_map = False, compare_bool = False,
+ assign_val = False, count_map = False, compare_bool = False,
compop = None, aggregate = None):
"""Build temporal topology for two space time data sets, copy map objects
for given relation into map list.
@@ -1188,7 +1187,7 @@
related map list and compariosn operator.
:param compop: Comparison operator, && or ||.
:param aggregate: Aggregation operator for relation map list, & or |.
-
+
:return: List of maps from maplistA that fulfil the topological relationships
to maplistB specified in topolist.
@@ -1216,8 +1215,8 @@
>>> for map in resultlist:
... if map.get_equal():
... relations = map.get_equal()
- ... print("Map %s has equal relation to map %s"%(map.get_name(),
- ... relations[0].get_name()))
+ ... print "Map %s has equal relation to map %s"%(map.get_name(),
+ ... relations[0].get_name())
Map a0 has equal relation to map b0
Map a1 has equal relation to map b1
Map a2 has equal relation to map b2
@@ -1249,8 +1248,8 @@
>>> for map in resultlist:
... if map.get_starts():
... relations = map.get_starts()
- ... print("Map %s has start relation to map %s"%(map.get_name(),
- ... relations[0].get_name()))
+ ... print "Map %s has start relation to map %s"%(map.get_name(),
+ ... relations[0].get_name())
Map a0 has start relation to map b0
Map a1 has start relation to map b1
Map a2 has start relation to map b2
@@ -1264,8 +1263,8 @@
>>> for map in resultlist:
... if map.get_during():
... relations = map.get_during()
- ... print("Map %s has during relation to map %s"%(map.get_name(),
- ... relations[0].get_name()))
+ ... print "Map %s has during relation to map %s"%(map.get_name(),
+ ... relations[0].get_name())
Map a0 has during relation to map b0
Map a1 has during relation to map b0
Map a2 has during relation to map b1
@@ -1367,22 +1366,22 @@
# Use unique identifier, since map names may be equal
resultdict[map_i.uid] = map_i
resultlist = resultdict.values()
-
+
# Sort list of maps chronological.
resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
-
+
return(resultlist)
-
+
def assign_bool_value(self, map_i, tbrelations, topolist = ["EQUAL"]):
- """ Function to assign boolean map value based on the map_values from the
+ """ Function to assign boolean map value based on the map_values from the
compared map list by topological relationships.
-
+
:param map_i: Map object with temporal extent.
:param tbrelations: List of temporal relation to map_i.
:param topolist: List of strings for given temporal relations.
-
- :return: Map object with conditional value that has been assigned by
- relation maps that fulfil the topological relationships to
+
+ :return: Map object with conditional value that has been assigned by
+ relation maps that fulfil the topological relationships to
maplistB specified in topolist.
"""
condition_value_list = []
@@ -1401,19 +1400,19 @@
else:
resultbool = False
map_i.condition_value = [resultbool]
-
+
return(resultbool)
def compare_bool_value(self, map_i, tbrelations, compop, aggregate, topolist = ["EQUAL"]):
- """ Function to evaluate two map lists with boolean values by boolean
- comparison operator.
-
+ """ Function to evaluate two map lists with boolean values by boolean
+ comparison operator.
+
:param map_i: Map object with temporal extent.
:param tbrelations: List of temporal relation to map_i.
:param topolist: List of strings for given temporal relations.
:param compop: Comparison operator, && or ||.
:param aggregate: Aggregation operator for relation map list, & or |.
-
+
:return: Map object with conditional value that has been evaluated by
comparison operators.
"""
@@ -1445,20 +1444,20 @@
print(resultbool)
# Add boolean value to result list.
map_i.condition_value = [resultbool]
-
+
return(resultbool)
-
+
def eval_toperator(self, operator, optype = 'relation'):
"""This function evaluates a string containing temporal operations.
:param operator: String of temporal operations, e.g. {!=,equal|during,l}.
:param optype: String to define operator type.
-
+
:return :List of temporal relations (equal, during), the given function
(!:) and the interval/instances (l).
-
+
.. code-block:: python
-
+
>>> import grass.temporal as tgis
>>> tgis.init()
>>> p = tgis.TemporalOperatorParser()
@@ -1471,7 +1470,7 @@
p = TemporalOperatorParser()
p.parse(operator, optype)
p.relations = [rel.upper() for rel in p.relations]
-
+
return(p.relations, p.temporal, p.function, p.aggregate)
def perform_temporal_selection(self, maplistA, maplistB, topolist = ["EQUAL"],
@@ -1516,8 +1515,8 @@
>>> for map in resultlist:
... if map.get_equal():
... relations = map.get_equal()
- ... print("Map %s has equal relation to map %s"%(map.get_name(),
- ... relations[0].get_name()))
+ ... print "Map %s has equal relation to map %s"%(map.get_name(),
+ ... relations[0].get_name())
Map a5 has equal relation to map b0
Map a6 has equal relation to map b1
Map a7 has equal relation to map b2
@@ -1527,7 +1526,7 @@
... True)
>>> for map in resultlist:
... if not map.get_equal():
- ... print("Map %s has no equal relation to mapset mapsB"%(map.get_name()))
+ ... print "Map %s has no equal relation to mapset mapsB"%(map.get_name())
Map a0 has no equal relation to mapset mapsB
Map a1 has no equal relation to mapset mapsB
Map a2 has no equal relation to mapset mapsB
@@ -1663,7 +1662,7 @@
if unchanged == True:
if self.debug:
print('Leave temporal extend of result map: ' + map_i.get_map_id() + ' unchanged.')
-
+
resultlist = resultdict.values()
# Sort list of maps chronological.
resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
@@ -1683,7 +1682,7 @@
:return: Dictionary with temporal functions for given input map.
.. code-block:: python
-
+
>>> import grass.temporal as tgis
>>> import datetime
>>> tgis.init()
@@ -1854,14 +1853,14 @@
""" This function evaluates temporal variable expressions of a conditional
expression in two steps.
At first it combines stepwise the single conditions by their relations with LALR.
- In this prossess sub condition map lists will be created which will include
- information of the underlying single conditions. Important: The temporal
- relations between conditions are evaluated by implicit aggregation.
- In the second step the aggregated condition map list will be compared with the
+ In this prossess sub condition map lists will be created which will include
+ information of the underlying single conditions. Important: The temporal
+ relations between conditions are evaluated by implicit aggregation.
+ In the second step the aggregated condition map list will be compared with the
map list of conclusion statements by the given temporal relation.
-
- The result is writen as 'condition_value' attribute to the resulting map objects.
- These attribute consists of boolean expressions and operators which can be
+
+ The result is writen as 'condition_value' attribute to the resulting map objects.
+ These attribute consists of boolean expressions and operators which can be
evaluated with the eval_condition_list function.
[True, '||', False, '&&', True]
@@ -1874,17 +1873,17 @@
:param thenlist: Map list object of the conclusion statement.
It will be compared and evaluated by the conditions.
-
- :param topolist: List of temporal relations between the conditions and the
+
+ :param topolist: List of temporal relations between the conditions and the
conclusions.
-
+
:return: Map list with conditional values for all temporal expressions.
"""
-
- # Evaluate the temporal variable expression and compute the temporal combination
+
+ # Evaluate the temporal variable expression and compute the temporal combination
# of conditions.
-
+
# Check if the input expression is a valid single global variable.
if isinstance(tvarexpr, GlobalTemporalVar) and tvarexpr.get_type() == "global" :
# Use method eval_global_var to evaluate expression.
@@ -1931,14 +1930,14 @@
resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
return(resultlist)
-
+
def eval_condition_list(self, maplist, inverse = False):
""" This function evaluates conditional values of a map list.
A recursive function is used to evaluate comparison statements
from left to right in the given conditional list.
- For example:
-
+ For example:
+
- [True, '||', False, '&&', True] -> True
- [True, '||', False, '&&', False] -> False
- [True, '&&', False, '&&', True] -> False
@@ -2022,12 +2021,12 @@
if isinstance(t[3], list):
num = len(t[3])
count = 0
- register_list = []
+ register_list = []
if num > 0:
process_queue = pymod.ParallelModuleQueue(int(self.nprocs))
for map_i in t[3]:
- # Test if temporal extents have been changed by temporal
- # relation operators (i|r).
+ # Test if temporal extents have been changed by temporal
+ # relation operators (i|r).
if count == 0:
maps_stds_type = map_i.get_new_stds_instance(None).get_type()
map_type = map_i.get_type()
@@ -2083,14 +2082,14 @@
# Wait for running processes
process_queue.wait()
-
+
# Open connection to temporal database.
- # Create result space time dataset based on the map stds type
+ # Create result space time dataset based on the map stds type
resultstds = open_new_stds(t[1],maps_stds_type, \
'absolute', t[1], t[1], \
'mean', self.dbif, \
- overwrite = self.overwrite)
- for map_i in register_list:
+ overwrite = self.overwrite)
+ for map_i in register_list:
# Get meta data from grass database.
map_i.load()
# Check if temporal extents have changed and a new map was created
@@ -2120,7 +2119,7 @@
self.msgr.warning("Empty result space time dataset. "\
"No map has been registered in %s" %(t[1] ))
# Open connection to temporal database.
- # Create result space time dataset.
+ # Create result space time dataset.
resultstds = open_new_stds(t[1], self.stdstype, \
'absolute', t[1], t[1], \
'mean', dbif, \
@@ -2132,7 +2131,7 @@
t[0] = t[3]
if self.debug:
- print(t[1], "=", t[3])
+ print t[1], "=", t[3]
def p_stds_1(self, t):
# Definition of a space time dataset
@@ -2153,7 +2152,7 @@
def p_expr_strds_function(self, t):
# Explicitly specify a space time raster dataset
- # R = A : strds(B)
+ # R = A : strds(B)
"""
expr : STRDS LPAREN stds RPAREN
"""
@@ -2162,11 +2161,11 @@
else:
t[0] = t[3]
if self.debug:
- print("Opening STRDS: ", t[0])
+ print "Opening STRDS: ", t[0]
def p_expr_str3ds_function(self, t):
# Explicitly specify a space time raster dataset
- # R = A : str3ds(B)
+ # R = A : str3ds(B)
"""
expr : STR3DS LPAREN stds RPAREN
"""
@@ -2175,28 +2174,28 @@
else:
t[0] = t[3]
if self.debug:
- print("Opening STR3DS: ", t[0])
+ print "Opening STR3DS: ", t[0]
def p_expr_stvds_function(self, t):
# Explicitly specify a space time vector dataset
- # R = A : stvds(B)
+ # R = A : stvds(B)
"""
expr : STVDS LPAREN stds RPAREN
"""
if self.run:
- print(t[3])
+ print t[3]
t[0] = self.check_stds(t[3], stds_type = "stvds", check_type=False)
else:
t[0] = t[3]
if self.debug:
- print("Opening STVDS: ", t[0])
+ print "Opening STVDS: ", t[0]
def p_expr_tmap_function(self, t):
# Add a single map.
- # Only the spatial extent of the map is evaluated.
+ # Only the spatial extent of the map is evaluated.
# Temporal extent is not existing.
# Examples:
- # R = tmap(A)
+ # R = tmap(A)
"""
expr : TMAP LPAREN stds RPAREN
"""
@@ -2228,7 +2227,7 @@
t[0] = "tmap(", t[3] , ")"
if self.debug:
- print("tmap(", t[3] , ")")
+ print "tmap(", t[3] , ")"
def p_expr_tmerge_function(self, t):
# Merge two maplists of same STDS type into a result map list.
@@ -2245,7 +2244,7 @@
# Check input map.
maplistA = self.check_stds(t[3])
maplistB = self.check_stds(t[5])
-
+
# Check empty lists.
if len(maplistA) == 0 and len(maplistB) == 0:
self.msgr.warning(_("Merging empty map lists"))
@@ -2265,14 +2264,14 @@
grass.fatal(_("Space time datasets to merge must have the same temporal type"))
resultlist = maplistA + maplistB
-
+
# Return map list.
t[0] = resultlist
else:
t[0] = "merge(", t[3], ",", t[5], ")"
if self.debug:
- print("merge(", t[3], ",", t[5], ")")
+ print "merge(", t[3], ",", t[5], ")"
def p_t_hash(self,t):
"""
@@ -2333,7 +2332,7 @@
t[0] = "td(" + str(t[3]) + ")"
if self.debug:
- print("td(" + str(t[3]) + ")")
+ print "td(" + str(t[3]) + ")"
def p_t_time_var(self, t):
@@ -2397,11 +2396,11 @@
map_i.condition_value = boolname
except:
self.msgr.fatal("Error: the given expression does not contain a correct time difference object.")
-
+
t[0] = maplist
-
+
if self.debug:
- print(t[1], t[2], t[3])
+ print t[1], t[2], t[3]
def p_t_var_expr_number(self, t):
# Examples:
@@ -2410,7 +2409,7 @@
# start_day(B) < start_month(A)
"""
t_var_expr : t_var LPAREN stds RPAREN comp_op number
- | t_var LPAREN expr RPAREN comp_op number
+ | t_var LPAREN expr RPAREN comp_op number
"""
# TODO: Implement comparison operator for map lists.
#| t_var LPAREN stds RPAREN comp_op t_var LPAREN stds RPAREN
@@ -2430,7 +2429,7 @@
t[0] = resultlist
if self.debug:
- print(t[1], t[3], t[5], t[6])
+ print t[1], t[3], t[5], t[6]
def p_t_var_expr_time(self, t):
# Examples:
@@ -2463,12 +2462,12 @@
gvar.value = t[6]
# Evaluate temporal variable for given maplist.
resultlist = self.eval_global_var(gvar, maplist)
-
+
t[0] = resultlist
if self.debug:
- print(t[1], t[3], t[5], t[6])
+ print t[1], t[3], t[5], t[6]
def p_t_var_expr_comp(self, t):
"""
@@ -2482,18 +2481,18 @@
relations = ["EQUAL"]
temporal = "l"
function = t[2] + t[3]
- aggregate = t[2]
- # Build conditional values based on topological relationships.
+ aggregate = t[2]
+ # Build conditional values based on topological relationships.
complist = self.get_temporal_topo_list(tvarexprA, tvarexprB, topolist = relations,
compare_bool = True, compop = function[0], aggregate = aggregate)
# Set temporal extent based on topological relationships.
- resultlist = self.set_temporal_extent_list(complist, topolist = relations,
+ resultlist = self.set_temporal_extent_list(complist, topolist = relations,
temporal = temporal)
-
+
t[0] = resultlist
if self.debug:
- print(t[1], t[2] + t[3], t[4])
+ print t[1], t[2] + t[3], t[4]
def p_t_var_expr_comp_op(self, t):
"""
@@ -2508,13 +2507,13 @@
complist = self.get_temporal_topo_list(tvarexprA, tvarexprB, topolist = relations,
compare_bool = True, compop = function[0], aggregate = aggregate)
# Set temporal extent based on topological relationships.
- resultlist = self.set_temporal_extent_list(complist, topolist = relations,
+ resultlist = self.set_temporal_extent_list(complist, topolist = relations,
temporal = temporal)
t[0] = resultlist
if self.debug:
- print(t[1], t[2], t[3])
+ print t[1], t[2], t[3]
def p_expr_t_select(self, t):
# Temporal equal selection
@@ -2541,7 +2540,7 @@
t[0] = t[1] , "*"
if self.debug:
- print(str(t[1]), "* = ", t[1], t[2], t[3])
+ print str(t[1]), "* = ", t[1], t[2], t[3]
def p_expr_t_not_select(self, t):
# Temporal equal selection
@@ -2567,7 +2566,7 @@
t[0] = t[1] + "*"
if self.debug:
- print(t[1] + "* = ", t[1], t[2], t[3])
+ print t[1] + "* = ", t[1], t[2], t[3]
def p_expr_t_select_operator(self, t):
@@ -2600,7 +2599,7 @@
# Perform selection.
selectlist = self.perform_temporal_selection(maplistA, maplistB,
topolist = operators[0], inverse = negation)
- selectlist = self.set_granularity(selectlist, maplistB, operators[1],
+ selectlist = self.set_granularity(selectlist, maplistB, operators[1],
operators[0])
# Return map list.
t[0] = selectlist
@@ -2608,7 +2607,7 @@
t[0] = t[1] + "*"
if self.debug:
- print(t[1] + "* = ", t[1], t[2], t[3])
+ print t[1] + "* = ", t[1], t[2], t[3]
def p_expr_condition_if(self, t):
@@ -2623,7 +2622,7 @@
thenlist = self.check_stds(t[5])
# Get temporal conditional statement.
tvarexpr = t[3]
- thencond = self.build_condition_list(tvarexpr, thenlist)
+ thencond = self.build_condition_list(tvarexpr, thenlist)
thenresult = self.eval_condition_list(thencond)
# Clear the map and conditional values of the map list.
resultlist = self.check_stds(thenresult, clear = True)
@@ -2633,7 +2632,7 @@
t[0] = t[5] + "*"
if self.debug:
- print(str(t[5]) + "* = ", "if condition", str(t[3]), ' then ', str(t[5]))
+ print str(t[5]) + "* = ", "if condition", str(t[3]), ' then ', str(t[5])
def p_expr_condition_if_relation(self, t):
# Examples
@@ -2648,8 +2647,8 @@
# Get temporal conditional statement.
tvarexpr = t[5]
topolist = self.eval_toperator(t[3], optype = 'relation')[0]
- thencond = self.build_condition_list(tvarexpr, thenlist, topolist)
- thenresult = self.eval_condition_list(thencond)
+ thencond = self.build_condition_list(tvarexpr, thenlist, topolist)
+ thenresult = self.eval_condition_list(thencond)
# Clear the map and conditional values of the map list.
resultlist = self.check_stds(thenresult, clear = True)
# Return resulting map list.
@@ -2658,7 +2657,7 @@
t[0] = t[7] + "*"
if self.debug:
- print("result* = ", "if ", str(t[3]), "condition", str(t[5]), " then ", str(t[7]))
+ print "result* = ", "if ", str(t[3]), "condition", str(t[5]), " then ", str(t[7])
def p_expr_condition_elif(self, t):
# Examples
@@ -2691,7 +2690,7 @@
t[0] = t[5] + "*"
if self.debug:
- print(str(t[5]) + "* = ", "if condition", str(t[3]), " then ", str(t[5]), ' else ', str(t[7]))
+ print str(t[5]) + "* = ", "if condition", str(t[3]), " then ", str(t[5]), ' else ', str(t[7])
def p_expr_condition_elif_relation(self, t):
# Examples
@@ -2731,9 +2730,9 @@
if self.debug:
if t[5]:
- print(str(t[7]), "* = ", "if condition", str(t[5]), " then ", str(t[7]), ' else ', str(t[9]))
+ print str(t[7]), "* = ", "if condition", str(t[5]), " then ", str(t[7]), ' else ', str(t[9])
else:
- print(str(t[9]), "* = ", "if condition", str(t[5]), " then ", str(t[7]), ' else ', str(t[9]))
+ print str(t[9]), "* = ", "if condition", str(t[5]), " then ", str(t[7]), ' else ', str(t[9])
def p_expr_t_buff(self, t):
# Examples
@@ -2762,9 +2761,9 @@
if self.debug:
if len(t) == 10:
- print(str(t[3]) + "* = buff_t(", str(t[3]), "," , '"', str(t[6]), str(t[7]), '"', ")")
+ print str(t[3]) + "* = buff_t(", str(t[3]), "," , '"', str(t[6]), str(t[7]), '"', ")"
elif len(t) == 7:
- print(str(t[3]) + "* = buff_t(", str(t[3]), ",", str(t[5]), ")")
+ print str(t[3]) + "* = buff_t(", str(t[3]), ",", str(t[5]), ")"
def p_expr_t_snap(self, t):
# Examples
@@ -2783,7 +2782,7 @@
t[0] = t[3] + "*"
if self.debug:
- print(str(t[3]) + "* = tsnap(", str(t[3]), ")")
+ print str(t[3]) + "* = tsnap(", str(t[3]), ")"
def p_expr_t_shift(self, t):
# Examples
@@ -2811,9 +2810,9 @@
if self.debug:
if len(t) == 10:
- print(str(t[3]) + "* = tshift(", str(t[3]), "," , '"', str(t[6]), str(t[7]), '"', ")")
+ print str(t[3]) + "* = tshift(", str(t[3]), "," , '"', str(t[6]), str(t[7]), '"', ")"
elif len(t) == 7:
- print(str(t[3]) + "* = tshift(", str(t[3]), ",", str(t[5]), ")")
+ print str(t[3]) + "* = tshift(", str(t[3]), ",", str(t[5]), ")"
# Handle errors.
def p_error(self, t):
Modified: grass/trunk/lib/python/temporal/temporal_extent.py
===================================================================
--- grass/trunk/lib/python/temporal/temporal_extent.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/temporal_extent.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -19,8 +19,7 @@
:authors: Soeren Gebbert
"""
-from __future__ import print_function
-from .base import *
+from base import *
###############################################################################
@@ -157,13 +156,13 @@
>>> A = TemporalExtent(start_time=5, end_time=8 )
>>> B = TemporalExtent(start_time=3, end_time=4 )
>>> inter = A.intersect(B)
- >>> print(inter)
+ >>> print inter
None
>>> A = TemporalExtent(start_time=5, end_time=8 )
>>> B = TemporalExtent(start_time=3, end_time=None )
>>> inter = A.intersect(B)
- >>> print(inter)
+ >>> print inter
None
"""
@@ -397,13 +396,13 @@
>>> A = TemporalExtent(start_time=5, end_time=8 )
>>> B = TemporalExtent(start_time=3, end_time=4 )
>>> inter = A.intersect(B)
- >>> print(inter)
+ >>> print inter
None
>>> A = TemporalExtent(start_time=5, end_time=8 )
>>> B = TemporalExtent(start_time=3, end_time=None )
>>> inter = A.intersect(B)
- >>> print(inter)
+ >>> print inter
None
"""
@@ -1029,13 +1028,13 @@
def print_info(self):
"""Print information about this class in human readable style"""
# 0123456789012345678901234567890
- print(" | Start time:................. " + str(self.get_start_time()))
- print(" | End time:................... " + str(self.get_end_time()))
+ print " | Start time:................. " + str(self.get_start_time())
+ print " | End time:................... " + str(self.get_end_time())
def print_shell_info(self):
"""Print information about this class in shell style"""
- print("start_time=" + str(self.get_start_time()))
- print("end_time=" + str(self.get_end_time()))
+ print "start_time=" + str(self.get_start_time())
+ print "end_time=" + str(self.get_end_time())
###############################################################################
@@ -1053,7 +1052,7 @@
def print_info(self):
"""Print information about this class in human readable style"""
# 0123456789012345678901234567890
- print(" +-------------------- Absolute time -----------------------------------------+")
+ print " +-------------------- Absolute time -----------------------------------------+"
TemporalExtent.print_info(self)
def print_shell_info(self):
@@ -1178,14 +1177,14 @@
"""Print information about this class in human readable style"""
AbsoluteTemporalExtent.print_info(self)
# 0123456789012345678901234567890
- print(" | Granularity:................ " + str(self.get_granularity()))
- print(" | Temporal type of maps:...... " + str(self.get_map_time()))
+ print " | Granularity:................ " + str(self.get_granularity())
+ print " | Temporal type of maps:...... " + str(self.get_map_time())
def print_shell_info(self):
"""Print information about this class in shell style"""
AbsoluteTemporalExtent.print_shell_info(self)
- print("granularity=" + str(self.get_granularity()))
- print("map_time=" + str(self.get_map_time()))
+ print "granularity=" + str(self.get_granularity())
+ print "map_time=" + str(self.get_map_time())
###############################################################################
@@ -1295,14 +1294,14 @@
def print_info(self):
"""Print information about this class in human readable style"""
# 0123456789012345678901234567890
- print(" +-------------------- Relative time -----------------------------------------+")
+ print " +-------------------- Relative time -----------------------------------------+"
TemporalExtent.print_info(self)
- print(" | Relative time unit:......... " + str(self.get_unit()))
+ print " | Relative time unit:......... " + str(self.get_unit())
def print_shell_info(self):
"""Print information about this class in shell style"""
TemporalExtent.print_shell_info(self)
- print("unit=" + str(self.get_unit()))
+ print "unit=" + str(self.get_unit())
###############################################################################
@@ -1427,14 +1426,14 @@
"""Print information about this class in human readable style"""
RelativeTemporalExtent.print_info(self)
# 0123456789012345678901234567890
- print(" | Granularity:................ " + str(self.get_granularity()))
- print(" | Temporal type of maps:...... " + str(self.get_map_time()))
+ print " | Granularity:................ " + str(self.get_granularity())
+ print " | Temporal type of maps:...... " + str(self.get_map_time())
def print_shell_info(self):
"""Print information about this class in shell style"""
RelativeTemporalExtent.print_shell_info(self)
- print("granularity=" + str(self.get_granularity()))
- print("map_time=" + str(self.get_map_time()))
+ print "granularity=" + str(self.get_granularity())
+ print "map_time=" + str(self.get_map_time())
###############################################################################
Modified: grass/trunk/lib/python/temporal/temporal_granularity.py
===================================================================
--- grass/trunk/lib/python/temporal/temporal_granularity.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/temporal_granularity.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -17,8 +17,8 @@
:authors: Soeren Gebbert
"""
-from .abstract_dataset import *
-from .datetime_math import *
+from abstract_dataset import *
+from datetime_math import *
###############################################################################
@@ -497,7 +497,7 @@
def compute_common_relative_time_granularity(gran_list):
"""Compute the greatest common granule from a list of relative time granules
-
+
.. code-block:: python
>>> import grass.temporal as tgis
@@ -505,7 +505,7 @@
>>> grans = [1,2,30]
>>> tgis.compute_common_relative_time_granularity(grans)
1
-
+
>>> import grass.temporal as tgis
>>> tgis.init()
>>> grans = [10,20,30]
@@ -756,23 +756,23 @@
>>> grans = ["1 second", "2 seconds", "30 seconds"]
>>> tgis.compute_common_absolute_time_granularity(grans)
'1 second'
-
+
>>> grans = ["3 second", "6 seconds", "30 seconds"]
>>> tgis.compute_common_absolute_time_granularity(grans)
'3 seconds'
-
+
>>> grans = ["12 second", "18 seconds", "30 seconds", "10 minutes"]
>>> tgis.compute_common_absolute_time_granularity(grans)
'6 seconds'
-
+
>>> grans = ["20 second", "10 minutes", "2 hours"]
>>> tgis.compute_common_absolute_time_granularity(grans)
'20 seconds'
-
+
>>> grans = ["7200 second", "240 minutes", "1 year"]
>>> tgis.compute_common_absolute_time_granularity(grans)
'7200 seconds'
-
+
>>> grans = ["7200 second", "89 minutes", "1 year"]
>>> tgis.compute_common_absolute_time_granularity(grans)
'60 seconds'
@@ -821,37 +821,37 @@
>>> tgis.compute_common_absolute_time_granularity(grans)
'1 year'
"""
-
+
has_seconds = False # 0
has_minutes = False # 1
has_hours = False # 2
has_days = False # 3
has_months = False # 4
has_years = False # 5
-
+
seconds = []
minutes = []
hours = []
days = []
months = []
years = []
-
+
min_gran = 6
max_gran = -1
-
+
for entry in gran_list:
if not check_granularity_string(entry, "absolute"):
return False
num, gran = entry.split()
-
+
if gran in ["seconds", "second"]:
has_seconds = True
if min_gran > 0:
min_gran = 0
if max_gran < 0:
max_gran = 0
-
+
seconds.append(int(num))
if gran in ["minutes", "minute"]:
@@ -860,7 +860,7 @@
min_gran = 1
if max_gran < 1:
max_gran = 1
-
+
minutes.append(int(num))
if gran in ["hours", "hour"]:
@@ -869,7 +869,7 @@
min_gran = 2
if max_gran < 2:
max_gran = 2
-
+
hours.append(int(num))
if gran in ["days", "day"]:
@@ -878,7 +878,7 @@
min_gran = 3
if max_gran < 3:
max_gran = 3
-
+
days.append(int(num))
if gran in ["months", "month"]:
@@ -887,7 +887,7 @@
min_gran = 4
if max_gran < 4:
max_gran = 4
-
+
months.append(int(num))
if gran in ["years", "year"]:
@@ -896,9 +896,9 @@
min_gran = 5
if max_gran < 5:
max_gran = 5
-
+
years.append(int(num))
-
+
if has_seconds:
if has_minutes:
minutes.sort()
@@ -925,7 +925,7 @@
if num > 1:
gran += "s"
return "%i %s"%(num, gran)
-
+
elif has_minutes:
if has_hours:
hours.sort()
@@ -948,7 +948,7 @@
if num > 1:
gran += "s"
return "%i %s"%(num, gran)
-
+
elif has_hours:
if has_days:
days.sort()
@@ -995,15 +995,15 @@
if num > 1:
gran += "s"
return "%i %s"%(num, gran)
-
+
elif has_years:
num = gcd_list(years)
gran = "year"
if num > 1:
gran += "s"
return "%i %s"%(num, gran)
+
-
###############################################################################
# http://akiscode.com/articles/gcd_of_a_list.shtml
# Copyright (c) 2010 Stephen Akiki
Modified: grass/trunk/lib/python/temporal/temporal_operator.py
===================================================================
--- grass/trunk/lib/python/temporal/temporal_operator.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/temporal_operator.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -14,96 +14,95 @@
>>> p = TemporalOperatorParser()
>>> expression = "{equal| during}"
>>> p.parse(expression, optype = 'relation')
- >>> print((p.relations, p.temporal, p.function))
+ >>> print(p.relations, p.temporal, p.function)
(['equal', 'during'], None, None)
- >>> p = TemporalOperatorParser()
+ >>> p = TemporalOperatorParser()
>>> expression = "{contains | starts}"
>>> p.parse(expression)
- >>> print((p.relations, p.temporal, p.function))
+ >>> print(p.relations, p.temporal, p.function)
(['contains', 'starts'], None, None)
- >>> p = TemporalOperatorParser()
+ >>> p = TemporalOperatorParser()
>>> expression = "{&&, during}"
>>> p.parse(expression, optype = 'boolean')
- >>> print((p.relations, p.temporal, p.function,p.aggregate))
+ >>> print(p.relations, p.temporal, p.function,p.aggregate)
(['during'], 'l', '&&', '&')
- >>> p = TemporalOperatorParser()
+ >>> p = TemporalOperatorParser()
>>> expression = "{||, equal | during}"
>>> p.parse(expression, optype = 'boolean')
- >>> print((p.relations, p.temporal, p.function,p.aggregate))
+ >>> print(p.relations, p.temporal, p.function,p.aggregate)
(['equal', 'during'], 'l', '||', '|')
- >>> p = TemporalOperatorParser()
+ >>> p = TemporalOperatorParser()
>>> expression = "{||, equal | during, &}"
>>> p.parse(expression, optype = 'boolean')
- >>> print((p.relations, p.temporal, p.function,p.aggregate))
+ >>> print(p.relations, p.temporal, p.function,p.aggregate)
(['equal', 'during'], 'l', '||', '&')
- >>> p = TemporalOperatorParser()
+ >>> p = TemporalOperatorParser()
>>> expression = "{&&, during, |}"
>>> p.parse(expression, optype = 'boolean')
- >>> print((p.relations, p.temporal, p.function,p.aggregate))
+ >>> print(p.relations, p.temporal, p.function,p.aggregate)
(['during'], 'l', '&&', '|')
- >>> p = TemporalOperatorParser()
+ >>> p = TemporalOperatorParser()
>>> expression = "{&&, during, |, r}"
>>> p.parse(expression, optype = 'boolean')
- >>> print((p.relations, p.temporal, p.function,p.aggregate))
+ >>> print(p.relations, p.temporal, p.function,p.aggregate)
(['during'], 'r', '&&', '|')
- >>> p = TemporalOperatorParser()
+ >>> p = TemporalOperatorParser()
>>> expression = "{&&, during, u}"
>>> p.parse(expression, optype = 'boolean')
- >>> print((p.relations, p.temporal, p.function,p.aggregate))
+ >>> print(p.relations, p.temporal, p.function,p.aggregate)
(['during'], 'u', '&&', '&')
- >>> p = TemporalOperatorParser()
+ >>> p = TemporalOperatorParser()
>>> expression = "{:, during, r}"
>>> p.parse(expression, optype = 'select')
- >>> print((p.relations, p.temporal, p.function))
+ >>> print(p.relations, p.temporal, p.function)
(['during'], 'r', ':')
- >>> p = TemporalOperatorParser()
+ >>> p = TemporalOperatorParser()
>>> expression = "{!:, equal | contains, d}"
>>> p.parse(expression, optype = 'select')
- >>> print((p.relations, p.temporal, p.function))
+ >>> print(p.relations, p.temporal, p.function)
(['equal', 'contains'], 'd', '!:')
- >>> p = TemporalOperatorParser()
+ >>> p = TemporalOperatorParser()
>>> expression = "{#, during, r}"
>>> p.parse(expression, optype = 'hash')
- >>> print((p.relations, p.temporal, p.function))
+ >>> print(p.relations, p.temporal, p.function)
(['during'], 'r', '#')
- >>> p = TemporalOperatorParser()
+ >>> p = TemporalOperatorParser()
>>> expression = "{#, equal | contains}"
>>> p.parse(expression, optype = 'hash')
- >>> print((p.relations, p.temporal, p.function))
+ >>> print(p.relations, p.temporal, p.function)
(['equal', 'contains'], 'l', '#')
- >>> p = TemporalOperatorParser()
+ >>> p = TemporalOperatorParser()
>>> expression = "{+, during, r}"
>>> p.parse(expression, optype = 'raster')
- >>> print((p.relations, p.temporal, p.function))
+ >>> print(p.relations, p.temporal, p.function)
(['during'], 'r', '+')
- >>> p = TemporalOperatorParser()
+ >>> p = TemporalOperatorParser()
>>> expression = "{/, equal | contains}"
>>> p.parse(expression, optype = 'raster')
- >>> print((p.relations, p.temporal, p.function))
+ >>> print(p.relations, p.temporal, p.function)
(['equal', 'contains'], 'l', '/')
- >>> p = TemporalOperatorParser()
+ >>> p = TemporalOperatorParser()
>>> expression = "{+, equal | contains,intersect}"
>>> p.parse(expression, optype = 'raster')
- >>> print((p.relations, p.temporal, p.function))
+ >>> print(p.relations, p.temporal, p.function)
(['equal', 'contains'], 'i', '+')
- >>> p = TemporalOperatorParser()
+ >>> p = TemporalOperatorParser()
>>> expression = "{*, contains,disjoint}"
>>> p.parse(expression, optype = 'raster')
- >>> print((p.relations, p.temporal, p.function))
+ >>> print(p.relations, p.temporal, p.function)
(['contains'], 'd', '*')
- >>> p = TemporalOperatorParser()
+ >>> p = TemporalOperatorParser()
>>> expression = "{~, equal,left}"
>>> p.parse(expression, optype = 'overlay')
- >>> print((p.relations, p.temporal, p.function))
+ >>> print(p.relations, p.temporal, p.function)
(['equal'], 'l', '~')
- >>> p = TemporalOperatorParser()
+ >>> p = TemporalOperatorParser()
>>> expression = "{^, over,right}"
>>> p.parse(expression, optype = 'overlay')
- >>> print((p.relations, p.temporal, p.function))
+ >>> print(p.relations, p.temporal, p.function)
(['overlaps', 'overlapped'], 'r', '^')
"""
-from __future__ import print_function
try:
import ply.lex as lex
@@ -135,7 +134,7 @@
'COMMA',
'LEFTREF',
'RIGHTREF',
- 'UNION',
+ 'UNION',
'DISJOINT',
'INTERSECT',
'HASH',
@@ -143,11 +142,11 @@
'AND',
'DISOR',
'XOR',
- 'NOT',
+ 'NOT',
'MOD',
'DIV',
'MULT',
- 'ADD',
+ 'ADD',
'SUB',
'T_SELECT',
'T_NOT_SELECT',
@@ -172,7 +171,7 @@
t_AND = r'[&]'
t_DISOR = r'\+'
t_XOR = r'\^'
- t_NOT = r'\~'
+ t_NOT = r'\~'
t_MOD = r'[\%]'
t_DIV = r'[\/]'
t_MULT = r'[\*]'
@@ -235,7 +234,7 @@
while True:
tok = self.lexer.token()
if not tok: break
- print(tok)
+ print tok
###############################################################################
@@ -252,19 +251,19 @@
self.aggregate = None
def parse(self, expression, optype = 'relation'):
- self.optype = optype
+ self.optype = optype
self.parser.parse(expression)
- # The parameter optype can be of type: select {:, during, r}, boolean{&&, contains, |},
+ # The parameter optype can be of type: select {:, during, r}, boolean{&&, contains, |},
# raster{*, equal, |}, vector {|, starts, &},
# hash{#, during, l} or relation {during}.
-
+
# Error rule for syntax errors.
def p_error(self, t):
raise SyntaxError("Unexpected syntax error")
# Get the tokens from the lexer class
tokens = TemporalOperatorLexer.tokens
-
+
def p_relation_operator(self, t):
# The expression should always return a list of maps.
"""
@@ -295,7 +294,7 @@
"""
if not self.optype == 'boolean':
raise SyntaxError("invalid syntax")
- else:
+ else:
# Set three operator components.
if isinstance(t[5], list):
self.relations = t[5]
@@ -304,7 +303,7 @@
self.temporal = "l"
self.function = t[2] + t[3]
self.aggregate = t[2]
-
+
t[0] = t[2]
def p_relation_bool_combi_operator(self, t):
@@ -321,7 +320,7 @@
"""
if not self.optype == 'boolean':
raise SyntaxError("invalid syntax")
- else:
+ else:
# Set three operator components.
if isinstance(t[5], list):
self.relations = t[5]
@@ -330,7 +329,7 @@
self.temporal = "l"
self.function = t[2] + t[3]
self.aggregate = t[7]
-
+
t[0] = t[2]
def p_relation_bool_combi_operator2(self, t):
@@ -343,7 +342,7 @@
"""
if not self.optype == 'boolean':
raise SyntaxError("invalid syntax")
- else:
+ else:
# Set three operator components.
if isinstance(t[5], list):
self.relations = t[5]
@@ -352,9 +351,9 @@
self.temporal = t[7]
self.function = t[2] + t[3]
self.aggregate = t[2]
-
+
t[0] = t[2]
-
+
def p_relation_bool_combi_operator3(self, t):
# The expression should always return a list of maps.
"""
@@ -369,7 +368,7 @@
"""
if not self.optype == 'boolean':
raise SyntaxError("invalid syntax")
- else:
+ else:
# Set three operator components.
if isinstance(t[5], list):
self.relations = t[5]
@@ -378,9 +377,9 @@
self.temporal = t[9]
self.function = t[2] + t[3]
self.aggregate = t[7]
-
+
t[0] = t[2]
-
+
def p_select_relation_operator(self, t):
# The expression should always return a list of maps.
"""
@@ -613,3 +612,4 @@
if __name__ == "__main__":
import doctest
doctest.testmod()
+
Modified: grass/trunk/lib/python/temporal/temporal_raster3d_algebra.py
===================================================================
--- grass/trunk/lib/python/temporal/temporal_raster3d_algebra.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/temporal_raster3d_algebra.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -10,8 +10,10 @@
:authors: Thomas Leppelt and Soeren Gebbert
"""
-from .temporal_raster_base_algebra import *
+import grass.pygrass.modules as pygrass
+from temporal_raster_base_algebra import *
+
###############################################################################
class TemporalRaster3DAlgebraParser(TemporalRasterBaseAlgebraParser):
@@ -32,7 +34,7 @@
while True:
tok = l.lexer.token()
if not tok: break
-
+
if tok.type == "STVDS" or tok.type == "STRDS" or tok.type == "STR3DS":
raise SyntaxError("Syntax error near '%s'" %(tok.type))
Modified: grass/trunk/lib/python/temporal/temporal_raster_algebra.py
===================================================================
--- grass/trunk/lib/python/temporal/temporal_raster_algebra.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/temporal_raster_algebra.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -52,7 +52,7 @@
"""
-from .temporal_raster_base_algebra import *
+from temporal_raster_base_algebra import *
###############################################################################
@@ -74,10 +74,10 @@
while True:
tok = l.lexer.token()
if not tok: break
-
+
if tok.type == "STVDS" or tok.type == "STRDS" or tok.type == "STR3DS":
raise SyntaxError("Syntax error near '%s'" %(tok.type))
-
+
self.lexer = TemporalRasterAlgebraLexer()
self.lexer.build()
self.parser = yacc.yacc(module=self, debug=self.debug)
Modified: grass/trunk/lib/python/temporal/temporal_raster_base_algebra.py
===================================================================
--- grass/trunk/lib/python/temporal/temporal_raster_base_algebra.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/temporal_raster_base_algebra.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -16,7 +16,7 @@
>>> p.debug = True
>>> expression = 'R = A {+,equal,l} B '
>>> p.test(expression)
- R = A {+,equal,l} B
+ R = A {+,equal,l} B
LexToken(NAME,'R',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(NAME,'A',1,4)
@@ -24,7 +24,7 @@
LexToken(NAME,'B',1,18)
>>> expression = 'R = A {*,equal|during,r} B '
>>> p.test(expression)
- R = A {*,equal|during,r} B
+ R = A {*,equal|during,r} B
LexToken(NAME,'R',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(NAME,'A',1,4)
@@ -32,7 +32,7 @@
LexToken(NAME,'B',1,25)
>>> expression = 'R = A {+,equal|during} B '
>>> p.test(expression)
- R = A {+,equal|during} B
+ R = A {+,equal|during} B
LexToken(NAME,'R',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(NAME,'A',1,4)
@@ -40,10 +40,10 @@
LexToken(NAME,'B',1,23)
"""
-from __future__ import print_function
+
import grass.pygrass.modules as pymod
-from .temporal_operator import *
-from .temporal_algebra import *
+from temporal_operator import *
+from temporal_algebra import *
##############################################################################
@@ -70,12 +70,12 @@
'isnull' : 'ISNULL',
'isntnull': 'ISNTNULL',
'null' : 'NULL',
- 'exist' : 'EXIST',
+ 'exist' : 'EXIST',
}
-
+
# Functions that defines single maps with time stamp and without temporal extent.
map_functions = {'map' : 'MAP'}
-
+
# This is the list of token names.
raster_tokens = (
'MOD',
@@ -153,12 +153,12 @@
######################### Temporal functions ##############################
def get_temporal_topo_list(self, maplistA, maplistB = None, topolist = ["EQUAL"],
- assign_val = False, count_map = False, compare_bool = False,
- compare_cmd = False, compop = None, aggregate = None,
+ assign_val = False, count_map = False, compare_bool = False,
+ compare_cmd = False, compop = None, aggregate = None,
new = False, convert = False, operator_cmd = False):
"""Build temporal topology for two space time data sets, copy map objects
for given relation into map list.
-
+
:param maplistA: List of maps.
:param maplistB: List of maps.
:param topolist: List of strings of temporal relations.
@@ -174,11 +174,11 @@
:param compop: Comparison operator, && or ||.
:param aggregate: Aggregation operator for relation map list, & or |.
:param new: Boolean if new temporary maps should be created.
- :param convert: Boolean if conditional values should be converted to
+ :param convert: Boolean if conditional values should be converted to
r.mapcalc command strings.
- :param operator_cmd: Boolean for aggregate arithmetic operators implicitly
+ :param operator_cmd: Boolean for aggregate arithmetic operators implicitly
in command list values based on related map lists.
-
+
:return: List of maps from maplistA that fulfil the topological relationships
to maplistB specified in topolist.
"""
@@ -219,7 +219,7 @@
self.compare_cmd_value(map_i, tbrelations, compop, aggregate, topolist, convert)
elif operator_cmd:
self.operator_cmd_value(map_i, tbrelations, compop, topolist)
-
+
for topo in topolist:
if topo.upper() in tbrelations.keys():
if count_map:
@@ -233,30 +233,30 @@
# Use unique identifier, since map names may be equal
resultdict[map_i.uid] = map_i
resultlist = resultdict.values()
-
+
# Sort list of maps chronological.
resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
-
- return(resultlist)
-
+
+ return(resultlist)
+
def build_command_string(self, map_i, relmap, operator = None, cmd_type = None):
- """This function build the r.mapcalc command string for conditionals,
+ """This function build the r.mapcalc command string for conditionals,
spatial variable combinations and boolean comparisons.
-
+
For Example: 'if(a1 == 1, b1, c2)' or 'exist(a1) && sin(b1)'
-
+
:param map_i: map object with temporal extent and built relations.
:param relmap: map object with defined temporal relation to map_i.
- :param operator: String representing operator between two spatial variables
+ :param operator: String representing operator between two spatial variables
(&&,||,+,-,*,/).
:param cmd_type: map object with defined temporal relation to map_i:
condition, conclusion or operator.
-
- :return: the resulting command string for conditionals or spatial variable
+
+ :return: the resulting command string for conditionals or spatial variable
combinations
- """
+ """
def sub_cmdstring(map_i):
- """This function search for command string in a map object and
+ """This function search for command string in a map object and
return substitute string (contained commandstring or map name)"""
if "cmd_list" in dir(map_i):
map_sub = map_i.cmd_list
@@ -268,8 +268,8 @@
except:
map_sub = map_i
return(map_sub)
-
- # Check for type of operation, conditional or spatial variable combination
+
+ # Check for type of operation, conditional or spatial variable combination
# and Create r.mapcalc expression string for the operation.
cmdstring = ""
if cmd_type == 'condition':
@@ -289,18 +289,18 @@
cmdstring = "(%s %s %s)" %(leftsub, operator, rightsub)
return(cmdstring)
- def compare_cmd_value(self, map_i, tbrelations, compop, aggregate,
+ def compare_cmd_value(self, map_i, tbrelations, compop, aggregate,
topolist = ["EQUAL"], convert = False):
- """ Function to evaluate two map lists with boolean values by boolean
- comparison operator. Extended temporal algebra version with command
+ """ Function to evaluate two map lists with boolean values by boolean
+ comparison operator. Extended temporal algebra version with command
list builder for temporal raster algebra.
-
+
:param map_i: Map object with temporal extent.
:param tbrelations: List of temporal relation to map_i.
:param topolist: List of strings for given temporal relations.
:param compop: Comparison operator, && or ||.
:param aggregate: Aggregation operator for relation map list, & or |.
- :param convert: Boolean if conditional values should be converted to
+ :param convert: Boolean if conditional values should be converted to
r.mapcalc command strings.
:return: Map object with conditional value that has been evaluated by
@@ -315,7 +315,7 @@
leftcmd = map_i.cmd_list
cmd_value_list = [leftcmd]
count = 0
-
+
for topo in topolist:
if topo.upper() in tbrelations.keys():
relationmaplist = tbrelations[topo.upper()]
@@ -337,18 +337,18 @@
cmd_value_str = ''.join(map(str, cmd_value_list))
# Add command list to result map.
map_i.cmd_list = cmd_value_str
-
+
return(cmd_value_str)
def operator_cmd_value(self, map_i, tbrelations, operator, topolist = ["EQUAL"]):
""" Function to evaluate two map lists by given arithmetic operator.
-
+
:param map_i: Map object with temporal extent.
:param tbrelations: List of temporal relation to map_i.
:param topolist: List of strings for given temporal relations.
:param operator: Arithmetic operator, +-*/%.
- :return: Map object with command list with operators that has been
+ :return: Map object with command list with operators that has been
evaluated by implicit aggregration.
"""
# Build comandlist list with elements from related maps and given relation operator.
@@ -359,26 +359,26 @@
relationmaplist = tbrelations[topo.upper()]
for relationmap in relationmaplist:
# Create r.mapcalc expression string for the operation.
- cmdstring = self.build_command_string(leftcmd,
- relationmap,
- operator = operator,
+ cmdstring = self.build_command_string(leftcmd,
+ relationmap,
+ operator = operator,
cmd_type = "operator")
leftcmd = cmdstring
# Add command list to result map.
map_i.cmd_list = cmdstring
-
+
return(cmdstring)
-
- def set_temporal_extent_list(self, maplist, topolist = ["EQUAL"], temporal = 'l' ,
+
+ def set_temporal_extent_list(self, maplist, topolist = ["EQUAL"], temporal = 'l' ,
cmd_bool = False, cmd_type = None, operator = None):
- """ Change temporal extent of map list based on temporal relations to
+ """ Change temporal extent of map list based on temporal relations to
other map list and given temporal operator.
- :param maplist: List of map objects for which relations has been build
+ :param maplist: List of map objects for which relations has been build
correctely.
:param topolist: List of strings of temporal relations.
:param temporal: The temporal operator specifying the temporal
- extent operation (intersection, union, disjoint
+ extent operation (intersection, union, disjoint
union, right reference, left reference).
:param cmd_bool: Boolean if command string should be merged for related maps.
:param cmd_type: map object with defined temporal relation to map_i:
@@ -388,26 +388,26 @@
:return: Map list with specified temporal extent and optional command string.
"""
resultdict = {}
-
+
for map_i in maplist:
# Loop over temporal related maps and create overlay modules.
tbrelations = map_i.get_temporal_relations()
# Generate an intermediate map for the result map list.
- map_new = self.generate_new_map(base_map=map_i, bool_op = 'and',
+ map_new = self.generate_new_map(base_map=map_i, bool_op = 'and',
copy = True, rename = True)
-
+
# Combine temporal and spatial extents of intermediate map with related maps.
for topo in topolist:
if topo in tbrelations.keys():
for map_j in (tbrelations[topo]):
if temporal == 'r':
# Generate an intermediate map for the result map list.
- map_new = self.generate_new_map(base_map=map_i, bool_op = 'and',
+ map_new = self.generate_new_map(base_map=map_i, bool_op = 'and',
copy = True, rename = True)
# Create overlayed map extent.
returncode = self.overlay_map_extent(map_new, map_j, 'and', \
temp_op = temporal)
-
+
# Stop the loop if no temporal or spatial relationship exist.
if returncode == 0:
break
@@ -417,9 +417,9 @@
# resultlist.append(map_new)
if cmd_bool:
# Create r.mapcalc expression string for the operation.
- cmdstring = self.build_command_string(map_i,
- map_j,
- operator = operator,
+ cmdstring = self.build_command_string(map_i,
+ map_j,
+ operator = operator,
cmd_type = cmd_type)
# Conditional append of module command.
map_new.cmd_list = cmdstring
@@ -433,12 +433,12 @@
# Get sorted map objects as values from result dictionoary.
resultlist = resultdict.values()
resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
-
+
return(resultlist)
-
- def build_condition_cmd_list(self, iflist, thenlist, elselist = None,
- condition_topolist = ["EQUAL"],
- conclusion_topolist = ["EQUAL"],
+
+ def build_condition_cmd_list(self, iflist, thenlist, elselist = None,
+ condition_topolist = ["EQUAL"],
+ conclusion_topolist = ["EQUAL"],
temporal = 'l', null = False):
"""This function build the r.mapcalc command strings for spatial conditionals.
For Example: 'if(a1 == 1, b1, c2)'
@@ -446,52 +446,52 @@
:param iflist: Map list with temporal extents and command list.
:param thenlist: Map list with temporal extents and command list or numeric string.
:param elselist: Map list with temporal extents and command list or numeric string.
- :param condition_topolist: List of strings for given temporal relations between
+ :param condition_topolist: List of strings for given temporal relations between
conditions and conclusions.
- :param conclusion_topolist: List of strings for given temporal relations between
+ :param conclusion_topolist: List of strings for given temporal relations between
conditions (then and else).
:param temporal: The temporal operator specifying the temporal
- extent operation (intersection, union, disjoint
+ extent operation (intersection, union, disjoint
union, right reference, left reference).
:param null: Boolean if null map support should be activated.
:return: map list with resulting command string for given condition type.
- """
+ """
resultlist = []
# First merge conclusion command maplists or strings.
# Check if alternative conclusion map list is given.
if all([isinstance(thenlist, list), isinstance(elselist, list)]):
# Build conclusion command map list.
conclusiontopolist = self.get_temporal_topo_list(thenlist, elselist, conclusion_topolist)
- conclusionlist = self.set_temporal_extent_list(conclusiontopolist,
- topolist = conclusion_topolist,
- temporal = temporal ,
- cmd_bool = True,
+ conclusionlist = self.set_temporal_extent_list(conclusiontopolist,
+ topolist = conclusion_topolist,
+ temporal = temporal ,
+ cmd_bool = True,
cmd_type = "conclusion")
# Check if any conclusion is a numeric statements.
elif any([isinstance(thenlist, str), isinstance(elselist, str)]):
- conclusionlist = []
+ conclusionlist = []
# Check if only alternative conclusion is a numeric statements.
if all([isinstance(thenlist, list), isinstance(elselist, str)]):
listinput = thenlist
numinput = elselist
for map_i in listinput:
# Create r.mapcalc expression string for the operation.
- cmdstring = self.build_command_string( map_i,
- numinput,
+ cmdstring = self.build_command_string( map_i,
+ numinput,
cmd_type = 'conclusion')
# Conditional append of module command.
map_i.cmd_list = cmdstring
# Append map to result map list.
conclusionlist.append(map_i)
# Check if only direct conclusion is a numeric statements.
- elif all([isinstance(thenlist, str), isinstance(elselist, list)]):
+ elif all([isinstance(thenlist, str), isinstance(elselist, list)]):
listinput = elselist
numinput = thenlist
for map_i in listinput:
# Create r.mapcalc expression string for the operation.
- cmdstring = self.build_command_string(numinput,
- map_i,
+ cmdstring = self.build_command_string(numinput,
+ map_i,
cmd_type = 'conclusion')
# Conditional append of module command.
map_i.cmd_list = cmdstring
@@ -502,14 +502,14 @@
else:
# The direct conclusion is used.
conclusionlist = thenlist
- # Use the conclusion map or string to merge it with the condition and
+ # Use the conclusion map or string to merge it with the condition and
# return maplist.
if isinstance(conclusionlist, str):
resultlist = []
for map_i in iflist:
# Create r.mapcalc expression string for the operation.
- cmdstring = self.build_command_string(map_i,
- conclusionlist,
+ cmdstring = self.build_command_string(map_i,
+ conclusionlist,
cmd_type = 'condition')
# Conditional append of module command.
map_i.cmd_list = cmdstring
@@ -518,12 +518,12 @@
return(resultlist)
elif isinstance(conclusionlist, list):
# Build result command map list between conditions and conclusions.
- conditiontopolist = self.get_temporal_topo_list(iflist, conclusionlist,
+ conditiontopolist = self.get_temporal_topo_list(iflist, conclusionlist,
topolist = condition_topolist)
- resultlist = self.set_temporal_extent_list(conditiontopolist,
- topolist = condition_topolist,
- temporal = 'r' ,
- cmd_bool = True,
+ resultlist = self.set_temporal_extent_list(conditiontopolist,
+ topolist = condition_topolist,
+ temporal = 'r' ,
+ cmd_bool = True,
cmd_type = "condition")
return(resultlist)
@@ -570,21 +570,21 @@
m.inputs["expression"].value = str(m_expression)
m.flags["overwrite"].value = self.overwrite
process_queue.put(m)
-
+
elif map_i.map_exists():
# Copy map if it exists
map_test = map_i.get_new_instance(newident + "@" + self.mapset)
map_test.set_temporal_extent(map_i.get_temporal_extent())
map_test.set_spatial_extent(map_i.get_spatial_extent())
map_test_list.append(map_test)
-
+
m = copy.deepcopy(self.m_mapcalc)
m_expression = newident + "=" + map_i.get_map_id()
m.inputs["expression"].value = str(m_expression)
m.flags["overwrite"].value = self.overwrite
- print(m.get_bash())
+ print m.get_bash()
process_queue.put(m)
-
+
else:
self.msgr.error(_("Error computing map <%s>"%(map_i.get_id()) ))
count += 1
@@ -629,13 +629,13 @@
t[0] = register_list
self.remove_maps()
-
+
def p_expr_spmap_function(self, t):
# Add a single map.
- # Only the spatial extent of the map is evaluated.
+ # Only the spatial extent of the map is evaluated.
# Temporal extent is not existing.
# Examples:
- # R = map(A)
+ # R = map(A)
"""
mapexpr : MAP LPAREN stds RPAREN
"""
@@ -666,7 +666,7 @@
t[0] = "map(" + t[3] + ")"
if self.debug:
- print("map(" + t[3] + ")")
+ print "map(" + t[3] + ")"
def p_arith1_operation(self, t):
"""
@@ -692,7 +692,7 @@
# Check input stds.
maplistA = self.check_stds(t[1])
maplistB = self.check_stds(t[3])
-
+
topolist = self.get_temporal_topo_list(maplistA, maplistB)
if self.run:
@@ -718,8 +718,8 @@
name = self.generate_map_name()
# Create r.mapcalc expression string for the operation.
- cmdstring = self.build_command_string(map_i, map_j,
- operator = t[2],
+ cmdstring = self.build_command_string(map_i, map_j,
+ operator = t[2],
cmd_type = "operator")
# Conditional append of module command.
map_new.cmd_list = cmdstring
@@ -732,7 +732,7 @@
if self.debug:
for map in resultlist:
- print(map.cmd_list)
+ print map.cmd_list
def p_arith1_operation_numeric1(self, t):
"""
@@ -747,13 +747,13 @@
| stds DIV numberstr
| expr DIV numberstr
| stds MULT numberstr
- | expr MULT numberstr
+ | expr MULT numberstr
| stds MOD mapexpr
| expr MOD mapexpr
| stds DIV mapexpr
| expr DIV mapexpr
| stds MULT mapexpr
- | expr MULT mapexpr
+ | expr MULT mapexpr
"""
# Check input stds.
maplist = self.check_stds(t[1])
@@ -776,7 +776,7 @@
if self.debug:
for map in resultlist:
- print(map.cmd_list)
+ print map.cmd_list
def p_arith1_operation_numeric2(self, t):
@@ -792,13 +792,13 @@
| numberstr DIV stds
| numberstr DIV expr
| numberstr MULT stds
- | numberstr MULT expr
+ | numberstr MULT expr
| mapexpr MOD stds
| mapexpr MOD expr
| mapexpr DIV stds
| mapexpr DIV expr
| mapexpr MULT stds
- | mapexpr MULT expr
+ | mapexpr MULT expr
"""
# Check input stds.
maplist = self.check_stds(t[3])
@@ -821,7 +821,7 @@
if self.debug:
for map in resultlist:
- print(map.cmd_list)
+ print map.cmd_list
def p_arith2_operation(self, t):
@@ -867,10 +867,10 @@
else:
# Generate an intermediate map
name = self.generate_map_name()
-
+
# Create r.mapcalc expression string for the operation.
- cmdstring = self.build_command_string(map_i, map_j,
- operator = t[2],
+ cmdstring = self.build_command_string(map_i, map_j,
+ operator = t[2],
cmd_type = "operator")
# Conditional append of module command.
map_new.cmd_list = cmdstring
@@ -884,7 +884,7 @@
if self.debug:
for map in resultlist:
- print(map.cmd_list)
+ print map.cmd_list
def p_arith2_operation_numeric1(self, t):
"""
@@ -895,7 +895,7 @@
| stds ADD numberstr
| expr ADD numberstr
| stds SUB numberstr
- | expr SUB numberstr
+ | expr SUB numberstr
| stds ADD mapexpr
| expr ADD mapexpr
| stds SUB mapexpr
@@ -922,7 +922,7 @@
if self.debug:
for map in resultlist:
- print(map.cmd_list)
+ print map.cmd_list
def p_arith2_operation_numeric2(self, t):
"""
@@ -932,12 +932,12 @@
| number SUB expr
| numberstr ADD stds
| numberstr ADD expr
- | numberstr SUB stds
- | numberstr SUB expr
+ | numberstr SUB stds
+ | numberstr SUB expr
| mapexpr ADD stds
| mapexpr ADD expr
| mapexpr SUB stds
- | mapexpr SUB expr
+ | mapexpr SUB expr
"""
# Check input stds.
maplist = self.check_stds(t[3])
@@ -960,7 +960,7 @@
if self.debug:
for map in resultlist:
- print(map.cmd_list)
+ print map.cmd_list
def p_arith1_operation_relation(self, t):
"""
@@ -971,7 +971,7 @@
| stds T_ARITH1_OPERATOR t_td_var
| expr T_ARITH1_OPERATOR t_td_var
"""
- if self.run:
+ if self.run:
# Check input stds.
maplistA = self.check_stds(t[1])
maplistB = self.check_stds(t[3])
@@ -980,14 +980,14 @@
complist = self.get_temporal_topo_list(maplistA, maplistB, topolist = relations,
operator_cmd = True, compop = function)
# Set temporal extent based on topological relationships.
- resultlist = self.set_temporal_extent_list(complist, topolist = relations,
+ resultlist = self.set_temporal_extent_list(complist, topolist = relations,
temporal = temporal)
+
+ t[0] = resultlist
- t[0] = resultlist
-
if self.debug:
for map in resultlist:
- print(map.cmd_list)
+ print map.cmd_list
def p_arith2_operation_relation(self, t):
"""
@@ -998,7 +998,7 @@
| stds T_ARITH2_OPERATOR t_td_var
| expr T_ARITH2_OPERATOR t_td_var
"""
- if self.run:
+ if self.run:
# Check input stds.
maplistA = self.check_stds(t[1])
maplistB = self.check_stds(t[3])
@@ -1007,14 +1007,14 @@
complist = self.get_temporal_topo_list(maplistA, maplistB, topolist = relations,
operator_cmd = True, compop = function)
# Set temporal extent based on topological relationships.
- resultlist = self.set_temporal_extent_list(complist, topolist = relations,
+ resultlist = self.set_temporal_extent_list(complist, topolist = relations,
temporal = temporal)
-
+
t[0] = resultlist
-
+
if self.debug:
for map in resultlist:
- print(map.cmd_list)
+ print map.cmd_list
def p_arith_operation_numeric_string(self, t):
"""
@@ -1030,7 +1030,7 @@
if self.debug:
print(numstring)
-
+
def p_mapcalc_function(self, t):
# Supported mapcalc functions.
"""
@@ -1051,7 +1051,7 @@
if self.debug:
for map in resultlist:
- print(map.cmd_list)
+ print map.cmd_list
def p_mapcalc_operation1(self, t):
@@ -1082,7 +1082,7 @@
if self.debug:
for map in resultlist:
- print(map.cmd_list)
+ print map.cmd_list
def p_mapexpr_operation(self, t):
# Examples:
@@ -1099,7 +1099,7 @@
t[0] = cmdstring
if self.debug:
- print(mapstring)
+ print mapstring
def p_s_var_expr_1(self, t):
# Examples:
@@ -1128,7 +1128,7 @@
if self.debug:
for map in resultlist:
- print(map.cmd_list)
+ print map.cmd_list
def p_s_var_expr_2(self, t):
# Examples:
@@ -1157,7 +1157,7 @@
if self.debug:
for map in resultlist:
- print(map.cmd_list)
+ print map.cmd_list
def p_s_var_expr_3(self, t):
# Examples:
@@ -1186,7 +1186,7 @@
if self.debug:
for map in resultlist:
- print(map.cmd_list)
+ print map.cmd_list
def p_s_var_expr_4(self, t):
# Examples:
@@ -1215,8 +1215,8 @@
if self.debug:
for map in resultlist:
- print(map.cmd_list)
-
+ print map.cmd_list
+
def p_s_var_expr_comp(self, t):
# Examples:
# A <= 2 || B == 10
@@ -1224,7 +1224,7 @@
"""
s_var_expr : s_var_expr AND AND s_var_expr
| s_var_expr OR OR s_var_expr
- """
+ """
if self.run:
# Check input stds.
s_var_exprA = self.check_stds(t[1])
@@ -1233,18 +1233,18 @@
temporal = "l"
function = t[2] + t[3]
aggregate = t[2]
- # Build conditional values based on topological relationships.
+ # Build conditional values based on topological relationships.
complist = self.get_temporal_topo_list(s_var_exprA, s_var_exprB, topolist = relations,
compare_cmd = True, compop = function, aggregate = aggregate)
# Set temporal extent based on topological relationships.
- resultlist = self.set_temporal_extent_list(complist, topolist = relations,
+ resultlist = self.set_temporal_extent_list(complist, topolist = relations,
temporal = temporal)
-
+
t[0] = resultlist
if self.debug:
for map in resultlist:
- print(map.cmd_list)
+ print map.cmd_list
def p_s_var_expr_comp_op(self, t):
# Examples:
@@ -1263,14 +1263,14 @@
complist = self.get_temporal_topo_list(s_var_exprA, s_var_exprB, topolist = relations,
compare_cmd = True, compop = function, aggregate = aggregate)
# Set temporal extent based on topological relationships.
- resultlist = self.set_temporal_extent_list(complist, topolist = relations,
+ resultlist = self.set_temporal_extent_list(complist, topolist = relations,
temporal = temporal)
-
+
t[0] = resultlist
if self.debug:
for map in resultlist:
- print(map.cmd_list)
+ print map.cmd_list
def p_s_expr_condition_if(self, t):
# Examples:
@@ -1284,16 +1284,16 @@
"""
ifmaplist = self.check_stds(t[3])
thenmaplist = self.check_stds(t[5])
- resultlist = self.build_condition_cmd_list(ifmaplist, thenmaplist,
- elselist = None,
- condition_topolist = ["EQUAL"],
- conclusion_topolist = ["EQUAL"],
+ resultlist = self.build_condition_cmd_list(ifmaplist, thenmaplist,
+ elselist = None,
+ condition_topolist = ["EQUAL"],
+ conclusion_topolist = ["EQUAL"],
temporal = 'r', null = False)
t[0] = resultlist
if self.debug:
for map in resultlist:
- print(map.cmd_list)
+ print map.cmd_list
def p_s_numeric_condition_if(self, t):
# Examples:
@@ -1325,7 +1325,7 @@
if self.debug:
for map in resultlist:
- print(map.cmd_list)
+ print map.cmd_list
def p_s_expr_condition_if_relation(self, t):
# Examples:
@@ -1336,20 +1336,20 @@
| IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA stds RPAREN
| IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA expr RPAREN
"""
- relations, temporal, function, aggregation = self.eval_toperator(t[3],
+ relations, temporal, function, aggregation = self.eval_toperator(t[3],
optype = 'relation')
ifmaplist = self.check_stds(t[5])
thenmaplist = self.check_stds(t[7])
- resultlist = self.build_condition_cmd_list(ifmaplist, thenmaplist,
- elselist = None,
- condition_topolist = relations,
- conclusion_topolist = ["EQUAL"],
+ resultlist = self.build_condition_cmd_list(ifmaplist, thenmaplist,
+ elselist = None,
+ condition_topolist = relations,
+ conclusion_topolist = ["EQUAL"],
temporal = 'r', null = False)
t[0] = resultlist
if self.debug:
for map in resultlist:
- print(map.cmd_list)
+ print map.cmd_list
def p_s_expr_condition_elif(self, t):
# Examples:
@@ -1369,17 +1369,17 @@
thenmaplist = self.check_stds(t[5])
elsemaplist = self.check_stds(t[7])
# Create conditional command map list.
- resultlist = self.build_condition_cmd_list(ifmaplist, thenmaplist,
- elselist = elsemaplist,
- condition_topolist = ["EQUAL"],
- conclusion_topolist = ["EQUAL"],
+ resultlist = self.build_condition_cmd_list(ifmaplist, thenmaplist,
+ elselist = elsemaplist,
+ condition_topolist = ["EQUAL"],
+ conclusion_topolist = ["EQUAL"],
temporal = 'r', null = False)
t[0] = resultlist
if self.debug:
for map in resultlist:
- print(map.cmd_list)
+ print map.cmd_list
def p_s_numeric_condition_elif(self, t):
# Examples:
@@ -1393,7 +1393,7 @@
| IF LPAREN ts_var_expr COMMA number COMMA number RPAREN
| IF LPAREN ts_var_expr COMMA NULL LPAREN RPAREN COMMA number RPAREN
| IF LPAREN ts_var_expr COMMA number COMMA NULL LPAREN RPAREN RPAREN
- | IF LPAREN ts_var_expr COMMA NULL LPAREN RPAREN COMMA NULL LPAREN RPAREN RPAREN
+ | IF LPAREN ts_var_expr COMMA NULL LPAREN RPAREN COMMA NULL LPAREN RPAREN RPAREN
"""
ifmaplist = self.check_stds(t[3])
resultlist = []
@@ -1414,16 +1414,16 @@
numelse = str(numelse)
print(numthen + " " +numelse )
# Create conditional command map list.
- resultlist = self.build_condition_cmd_list(ifmaplist, numthen, numelse,
- condition_topolist = ["EQUAL"],
- conclusion_topolist = ["EQUAL"],
+ resultlist = self.build_condition_cmd_list(ifmaplist, numthen, numelse,
+ condition_topolist = ["EQUAL"],
+ conclusion_topolist = ["EQUAL"],
temporal = 'r', null = False)
t[0] = resultlist
if self.debug:
for map in resultlist:
- print(map.cmd_list)
+ print map.cmd_list
def p_s_numeric_expr_condition_elif(self, t):
# Examples:
@@ -1445,7 +1445,7 @@
| IF LPAREN ts_var_expr COMMA stds COMMA number RPAREN
| IF LPAREN ts_var_expr COMMA stds COMMA NULL LPAREN RPAREN RPAREN
| IF LPAREN ts_var_expr COMMA expr COMMA number RPAREN
- | IF LPAREN ts_var_expr COMMA expr COMMA NULL LPAREN RPAREN RPAREN
+ | IF LPAREN ts_var_expr COMMA expr COMMA NULL LPAREN RPAREN RPAREN
"""
ifmaplist = self.check_stds(t[3])
# Select input for r.mapcalc expression based on length of PLY object.
@@ -1465,16 +1465,16 @@
elseinput = str(t[7] + t[8] + t[9])
# Create conditional command map list.
- resultlist = self.build_condition_cmd_list(ifmaplist, theninput, elseinput,
- condition_topolist = ["EQUAL"],
- conclusion_topolist = ["EQUAL"],
+ resultlist = self.build_condition_cmd_list(ifmaplist, theninput, elseinput,
+ condition_topolist = ["EQUAL"],
+ conclusion_topolist = ["EQUAL"],
temporal = 'r', null = False)
t[0] = resultlist
if self.debug:
for map in resultlist:
- print(map.cmd_list)
+ print map.cmd_list
def p_s_numeric_expr_condition_elif_relation(self, t):
# Examples:
@@ -1496,7 +1496,7 @@
| IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA stds COMMA number RPAREN
| IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA stds COMMA NULL LPAREN RPAREN RPAREN
| IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA expr COMMA number RPAREN
- | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA expr COMMA NULL LPAREN RPAREN RPAREN
+ | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA expr COMMA NULL LPAREN RPAREN RPAREN
"""
relations, temporal, function, aggregation = self.eval_toperator(t[3], optype = 'relation')
ifmaplist = self.check_stds(t[5])
@@ -1517,16 +1517,16 @@
elseinput = str(t[9] + t[10] + t[11])
# Create conditional command map list.
- resultlist = self.build_condition_cmd_list(ifmaplist, theninput, elseinput,
- condition_topolist = relations,
- conclusion_topolist = ["EQUAL"],
+ resultlist = self.build_condition_cmd_list(ifmaplist, theninput, elseinput,
+ condition_topolist = relations,
+ conclusion_topolist = ["EQUAL"],
temporal = 'r', null = False)
t[0] = resultlist
if self.debug:
for map in resultlist:
- print(map.cmd_list)
+ print map.cmd_list
def p_s_expr_condition_elif_relation(self, t):
@@ -1546,18 +1546,18 @@
ifmaplist = self.check_stds(t[5])
thenmaplist = self.check_stds(t[7])
elsemaplist = self.check_stds(t[9])
-
+
# Create conditional command map list.
- resultlist = self.build_condition_cmd_list(ifmaplist, thenmaplist, elsemaplist,
- condition_topolist = relations,
- conclusion_topolist = ["EQUAL"],
+ resultlist = self.build_condition_cmd_list(ifmaplist, thenmaplist, elsemaplist,
+ condition_topolist = relations,
+ conclusion_topolist = ["EQUAL"],
temporal = 'r', null = False)
t[0] = resultlist
if self.debug:
for map in resultlist:
- print(map.cmd_list)
+ print map.cmd_list
def p_ts_var_expr1(self, t):
# Combination of spatial and temporal conditional expressions.
@@ -1588,19 +1588,19 @@
temporal = "l"
function = t[2] + t[3]
aggregate = t[2]
- # Build conditional values based on topological relationships.
- complist = self.get_temporal_topo_list(s_var_exprA, s_var_exprB,
- topolist = relations, compare_cmd = True,
- compop = function, aggregate = aggregate,
+ # Build conditional values based on topological relationships.
+ complist = self.get_temporal_topo_list(s_var_exprA, s_var_exprB,
+ topolist = relations, compare_cmd = True,
+ compop = function, aggregate = aggregate,
convert = True)
# Set temporal extent based on topological relationships.
- resultlist = self.set_temporal_extent_list(complist, topolist = relations,
+ resultlist = self.set_temporal_extent_list(complist, topolist = relations,
temporal = temporal)
t[0] = resultlist
-
+
def p_hash_operation(self, t):
- # Calculate the number of maps within an interval of another map from a
+ # Calculate the number of maps within an interval of another map from a
# second space time dataset.
# A # B
# A {equal,r#} B
@@ -1628,7 +1628,7 @@
if self.debug:
for map in resultlist:
- print(map.cmd_list)
+ print map.cmd_list
###############################################################################
Modified: grass/trunk/lib/python/temporal/temporal_topology_dataset_connector.py
===================================================================
--- grass/trunk/lib/python/temporal/temporal_topology_dataset_connector.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/temporal_topology_dataset_connector.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -16,7 +16,6 @@
:authors: Soeren Gebbert
"""
-from __future__ import print_function
import copy
@@ -105,7 +104,7 @@
finished=a at P
>>> rlist = tmr.get_temporal_relations()
>>> if "FINISHED" in rlist.keys():
- ... print(rlist["FINISHED"][0].get_id())
+ ... print rlist["FINISHED"][0].get_id()
a at P
"""
@@ -504,85 +503,85 @@
def print_temporal_topology_info(self):
"""Print information about this class in human readable style"""
- print(" +-------------------- Temporal Topology -------------------------------------+")
+ print " +-------------------- Temporal Topology -------------------------------------+"
# 0123456789012345678901234567890
if self.next() is not None:
- print(" | Next: ...................... " + str(self.next().get_id()))
+ print " | Next: ...................... " + str(self.next().get_id())
if self.prev() is not None:
- print(" | Previous: .................. " + str(self.prev().get_id()))
+ print " | Previous: .................. " + str(self.prev().get_id())
if self.equal is not None:
- print(" | Equal:...................... " +
- self._generate_map_list_string(self.equal))
+ print " | Equal:...................... " + \
+ self._generate_map_list_string(self.equal)
if self.follows is not None:
- print(" | Follows: ................... " +
- self._generate_map_list_string(self.follows))
+ print " | Follows: ................... " + \
+ self._generate_map_list_string(self.follows)
if self.precedes is not None:
- print(" | Precedes: .................. " +
- self._generate_map_list_string(self.precedes))
+ print " | Precedes: .................. " + \
+ self._generate_map_list_string(self.precedes)
if self.overlaps is not None:
- print(" | Overlaps: .................. " +
- self._generate_map_list_string(self.overlaps))
+ print " | Overlaps: .................. " + \
+ self._generate_map_list_string(self.overlaps)
if self.overlapped is not None:
- print(" | Overlapped: ................ " +
- self._generate_map_list_string(self.overlapped))
+ print " | Overlapped: ................ " + \
+ self._generate_map_list_string(self.overlapped)
if self.during is not None:
- print(" | During: .................... " +
- self._generate_map_list_string(self.during))
+ print " | During: .................... " + \
+ self._generate_map_list_string(self.during)
if self.contains is not None:
- print(" | Contains: .................. " +
- self._generate_map_list_string(self.contains))
+ print " | Contains: .................. " + \
+ self._generate_map_list_string(self.contains)
if self.starts is not None:
- print(" | Starts:.. .................. " +
- self._generate_map_list_string(self.starts))
+ print " | Starts:.. .................. " + \
+ self._generate_map_list_string(self.starts)
if self.started is not None:
- print(" | Started:. .................. " +
- self._generate_map_list_string(self.started))
+ print " | Started:. .................. " + \
+ self._generate_map_list_string(self.started)
if self.finishes is not None:
- print(" | Finishes:................... " +
- self._generate_map_list_string(self.finishes))
+ print " | Finishes:................... " + \
+ self._generate_map_list_string(self.finishes)
if self.finished is not None:
- print(" | Finished:................... " +
- self._generate_map_list_string(self.finished))
+ print " | Finished:................... " + \
+ self._generate_map_list_string(self.finished)
def print_temporal_topology_shell_info(self):
"""Print information about this class in shell style"""
if self.next() is not None:
- print("next=" + self.next().get_id())
+ print "next=" + self.next().get_id()
if self.prev() is not None:
- print("prev=" + self.prev().get_id())
+ print "prev=" + self.prev().get_id()
if self.equal is not None:
- print("equal=" + self._generate_map_list_string(self.equal, False))
+ print "equal=" + self._generate_map_list_string(self.equal, False)
if self.follows is not None:
- print("follows=" + self._generate_map_list_string(self.follows,
- False))
+ print "follows=" + self._generate_map_list_string(self.follows,
+ False)
if self.precedes is not None:
- print("precedes=" + self._generate_map_list_string(
- self.precedes, False))
+ print "precedes=" + self._generate_map_list_string(
+ self.precedes, False)
if self.overlaps is not None:
- print("overlaps=" + self._generate_map_list_string(
- self.overlaps, False))
+ print "overlaps=" + self._generate_map_list_string(
+ self.overlaps, False)
if self.overlapped is not None:
- print("overlapped=" +
- self._generate_map_list_string(self.overlapped, False))
+ print "overlapped=" + \
+ self._generate_map_list_string(self.overlapped, False)
if self.during is not None:
- print("during=" + self._generate_map_list_string(self.during,
- False))
+ print "during=" + self._generate_map_list_string(self.during,
+ False)
if self.contains is not None:
- print("contains=" + self._generate_map_list_string(
- self.contains, False))
+ print "contains=" + self._generate_map_list_string(
+ self.contains, False)
if self.starts is not None:
- print("starts=" +
- self._generate_map_list_string(self.starts))
+ print "starts=" + \
+ self._generate_map_list_string(self.starts)
if self.started is not None:
- print("started=" +
- self._generate_map_list_string(self.started))
+ print "started=" + \
+ self._generate_map_list_string(self.started)
if self.finishes is not None:
- print("finishes=" +
- self._generate_map_list_string(self.finishes))
+ print "finishes=" + \
+ self._generate_map_list_string(self.finishes)
if self.finished is not None:
- print("finished=" +
- self._generate_map_list_string(self.finished))
+ print "finished=" + \
+ self._generate_map_list_string(self.finished)
###############################################################################
Modified: grass/trunk/lib/python/temporal/temporal_vector_algebra.py
===================================================================
--- grass/trunk/lib/python/temporal/temporal_vector_algebra.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/temporal_vector_algebra.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -41,10 +41,10 @@
LexToken(RPAREN,')',1,16)
"""
-from __future__ import print_function
+
import grass.pygrass.modules as pygrass
-from .temporal_operator import *
-from .temporal_algebra import *
+from temporal_operator import *
+from temporal_algebra import *
##############################################################################
@@ -129,7 +129,7 @@
while True:
tok = l.lexer.token()
if not tok: break
-
+
if tok.type == "STVDS" or tok.type == "STRDS" or tok.type == "STR3DS":
raise SyntaxError("Syntax error near '%s'" %(tok.type))
@@ -149,12 +149,12 @@
######################### Temporal functions ##############################
def get_temporal_topo_list(self, maplistA, maplistB = None, topolist = ["EQUAL"],
- assign_val = False, count_map = False, compare_bool = False,
- compare_cmd = False, compop = None, aggregate = None,
+ assign_val = False, count_map = False, compare_bool = False,
+ compare_cmd = False, compop = None, aggregate = None,
new = False, convert = False, overlay_cmd = False):
"""Build temporal topology for two space time data sets, copy map objects
for given relation into map list.
-
+
:param maplistA: List of maps.
:param maplistB: List of maps.
:param topolist: List of strings of temporal relations.
@@ -170,11 +170,11 @@
:param compop: Comparison operator, && or ||.
:param aggregate: Aggregation operator for relation map list, & or |.
:param new: Boolean if new temporary maps should be created.
- :param convert: Boolean if conditional values should be converted to
+ :param convert: Boolean if conditional values should be converted to
r.mapcalc command strings.
- :param overlay_cmd: Boolean for aggregate overlay operators implicitly
+ :param overlay_cmd: Boolean for aggregate overlay operators implicitly
in command list values based on related map lists.
-
+
:return: List of maps from maplistA that fulfil the topological relationships
to maplistB specified in topolist.
"""
@@ -215,7 +215,7 @@
self.compare_cmd_value(map_i, tbrelations, compop, aggregate, topolist, convert)
elif overlay_cmd:
self.overlay_cmd_value(map_i, tbrelations, compop, topolist)
-
+
for topo in topolist:
if topo.upper() in tbrelations.keys():
if count_map:
@@ -229,21 +229,21 @@
# Use unique identifier, since map names may be equal
resultdict[map_i.uid] = map_i
resultlist = resultdict.values()
-
+
# Sort list of maps chronological.
resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
-
+
return(resultlist)
def overlay_cmd_value(self, map_i, tbrelations, function, topolist = ["EQUAL"]):
""" Function to evaluate two map lists by given overlay operator.
-
+
:param map_i: Map object with temporal extent.
:param tbrelations: List of temporal relation to map_i.
:param topolist: List of strings for given temporal relations.
:param function: Overlay operator, &|+^~.
-
- :return: Map object with command list with operators that has been
+
+ :return: Map object with command list with operators that has been
evaluated by implicit aggregration.
"""
# Build comandlist list with elements from related maps and given relation operator.
@@ -292,30 +292,30 @@
mapainput = name
# Add command list to result map.
map_i.cmd_list = resultlist
-
+
return(resultlist)
def set_temporal_extent_list(self, maplist, topolist = ["EQUAL"], temporal = 'l' ):
- """ Change temporal extent of map list based on temporal relations to
+ """ Change temporal extent of map list based on temporal relations to
other map list and given temporal operator.
- :param maplist: List of map objects for which relations has been build
+ :param maplist: List of map objects for which relations has been build
correctely.
:param topolist: List of strings of temporal relations.
:param temporal: The temporal operator specifying the temporal
- extent operation (intersection, union, disjoint
+ extent operation (intersection, union, disjoint
union, right reference, left reference).
:return: Map list with specified temporal extent.
"""
resultdict = {}
-
+
for map_i in maplist:
# Loop over temporal related maps and create overlay modules.
tbrelations = map_i.get_temporal_relations()
# Generate an intermediate map for the result map list.
- map_new = self.generate_new_map(base_map=map_i, bool_op = 'and',
- copy = True, rename = False,
+ map_new = self.generate_new_map(base_map=map_i, bool_op = 'and',
+ copy = True, rename = False,
remove = True)
# Combine temporal and spatial extents of intermediate map with related maps.
for topo in topolist:
@@ -323,8 +323,8 @@
for map_j in (tbrelations[topo]):
if temporal == 'r':
# Generate an intermediate map for the result map list.
- map_new = self.generate_new_map(base_map=map_i, bool_op = 'and',
- copy = True, rename = False,
+ map_new = self.generate_new_map(base_map=map_i, bool_op = 'and',
+ copy = True, rename = False,
remove = True)
# Create overlayed map extent.
returncode = self.overlay_map_extent(map_new, map_j, 'and', \
@@ -344,9 +344,9 @@
# Get sorted map objects as values from result dictionoary.
resultlist = resultdict.values()
resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
-
+
return(resultlist)
-
+
###########################################################################
def p_statement_assign(self, t):
@@ -427,7 +427,7 @@
count += 1
register_list.append(map_i)
else:
- # Test if temporal extents have been changed by temporal
+ # Test if temporal extents have been changed by temporal
# relation operators (i|r). This is a code copy from temporal_algebra.py
map_i_extent = map_i.get_temporal_extent_as_tuple()
map_test = map_i.get_new_instance(map_i.get_id())
@@ -483,11 +483,11 @@
# Map is original from an input STVDS
map_i.load()
# Register map in result space time dataset.
- print(map_i.get_temporal_extent_as_tuple())
+ print map_i.get_temporal_extent_as_tuple()
success = resultstds.register_map(map_i, dbif=dbif)
resultstds.update_from_registered_maps(dbif)
-
- # Remove intermediate maps
+
+ # Remove intermediate maps
self.remove_maps()
if connected:
dbif.close()
@@ -521,13 +521,13 @@
maplistA = self.check_stds(t[1])
maplistB = self.check_stds(t[3])
relations = ["EQUAL"]
- temporal = 'l'
- function = t[2]
+ temporal = 'l'
+ function = t[2]
# Build commmand list for related maps.
complist = self.get_temporal_topo_list(maplistA, maplistB, topolist = relations,
compop = function, overlay_cmd = True)
# Set temporal extent based on topological relationships.
- resultlist = self.set_temporal_extent_list(complist, topolist = relations,
+ resultlist = self.set_temporal_extent_list(complist, topolist = relations,
temporal = temporal)
t[0] = resultlist
@@ -550,9 +550,9 @@
complist = self.get_temporal_topo_list(maplistA, maplistB, topolist = relations,
compop = function, overlay_cmd = True)
# Set temporal extent based on topological relationships.
- resultlist = self.set_temporal_extent_list(complist, topolist = relations,
+ resultlist = self.set_temporal_extent_list(complist, topolist = relations,
temporal = temporal)
-
+
t[0] = resultlist
if self.debug:
str(t[1]) + t[2] + str(t[3])
Modified: grass/trunk/lib/python/temporal/univar_statistics.py
===================================================================
--- grass/trunk/lib/python/temporal/univar_statistics.py 2016-03-29 08:10:14 UTC (rev 68181)
+++ grass/trunk/lib/python/temporal/univar_statistics.py 2016-03-29 09:23:26 UTC (rev 68182)
@@ -18,9 +18,8 @@
:authors: Soeren Gebbert
"""
-from __future__ import print_function
-from .open_stds import *
+from open_stds import *
import grass.script as gscript
###############################################################################
@@ -72,7 +71,7 @@
string += "third_quartile" + fs + "percentile_90"
if output is None:
- print(string)
+ print string
else:
out_file.write(string + "\n")
@@ -114,7 +113,7 @@
string += fs + str(stats["third_quartile"]) + fs + str(stats["percentile_90"])
if output is None:
- print(string)
+ print string
else:
out_file.write(string + "\n")
@@ -192,7 +191,7 @@
"third_quartile" + fs + "percentile_90"
if output is None:
- print(string)
+ print string
else:
out_file.write(string + "\n")
@@ -255,7 +254,7 @@
string += fs + fs + fs + fs
if output is None:
- print(string)
+ print string
else:
out_file.write(string + "\n")
More information about the grass-commit
mailing list