[GRASS-SVN] r60534 - in grass/branches/releasebranch_7_0: lib/python/temporal temporal/t.list temporal/t.rast.aggregate temporal/t.rast.aggregate.ds temporal/t.rast.extract temporal/t.rast.gapfill temporal/t.rast.mapcalc temporal/t.rast.neighbors temporal/t.register temporal/t.select temporal/t.support temporal/t.unregister
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed May 28 04:12:25 PDT 2014
Author: huhabla
Date: 2014-05-28 04:12:25 -0700 (Wed, 28 May 2014)
New Revision: 60534
Modified:
grass/branches/releasebranch_7_0/lib/python/temporal/abstract_map_dataset.py
grass/branches/releasebranch_7_0/lib/python/temporal/abstract_space_time_dataset.py
grass/branches/releasebranch_7_0/lib/python/temporal/aggregation.py
grass/branches/releasebranch_7_0/lib/python/temporal/c_libraries_interface.py
grass/branches/releasebranch_7_0/lib/python/temporal/extract.py
grass/branches/releasebranch_7_0/lib/python/temporal/list_stds.py
grass/branches/releasebranch_7_0/lib/python/temporal/mapcalc.py
grass/branches/releasebranch_7_0/lib/python/temporal/register.py
grass/branches/releasebranch_7_0/lib/python/temporal/space_time_datasets.py
grass/branches/releasebranch_7_0/lib/python/temporal/temporal_extent.py
grass/branches/releasebranch_7_0/lib/python/temporal/temporal_raster_base_algebra.py
grass/branches/releasebranch_7_0/lib/python/temporal/unittests_temporal_raster_algebra.py
grass/branches/releasebranch_7_0/temporal/t.list/t.list.py
grass/branches/releasebranch_7_0/temporal/t.rast.aggregate.ds/t.rast.aggregate.ds.py
grass/branches/releasebranch_7_0/temporal/t.rast.aggregate.ds/test.t.rast.aggregate.ds.sh
grass/branches/releasebranch_7_0/temporal/t.rast.aggregate/t.rast.aggregate.py
grass/branches/releasebranch_7_0/temporal/t.rast.aggregate/test.t.rast.aggregate.sh
grass/branches/releasebranch_7_0/temporal/t.rast.extract/test.t.rast.extract.sh
grass/branches/releasebranch_7_0/temporal/t.rast.gapfill/test.t.rast.gapfill.sh
grass/branches/releasebranch_7_0/temporal/t.rast.mapcalc/test.t.rast.mapcalc.sh
grass/branches/releasebranch_7_0/temporal/t.rast.neighbors/t.rast.neighbors.py
grass/branches/releasebranch_7_0/temporal/t.register/test.t.register.raster.sh
grass/branches/releasebranch_7_0/temporal/t.select/test.t.select.sh
grass/branches/releasebranch_7_0/temporal/t.support/t.support.py
grass/branches/releasebranch_7_0/temporal/t.unregister/t.unregister.py
Log:
Backport of grass71 bugfixes: correct return value catching in parallel module runs, mapset ordered listing of STDS, API renaming, test updates
Modified: grass/branches/releasebranch_7_0/lib/python/temporal/abstract_map_dataset.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/abstract_map_dataset.py 2014-05-28 11:09:47 UTC (rev 60533)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/abstract_map_dataset.py 2014-05-28 11:12:25 UTC (rev 60534)
@@ -214,7 +214,7 @@
self.print_topology_info()
self.spatial_extent.print_info()
self.metadata.print_info()
- datasets = self.get_registered_datasets()
+ datasets = self.get_registered_stds()
count = 0
string = ""
if datasets is not None:
@@ -236,7 +236,7 @@
self.temporal_extent.print_shell_info()
self.spatial_extent.print_shell_info()
self.metadata.print_shell_info()
- datasets = self.get_registered_datasets()
+ datasets = self.get_registered_stds()
count = 0
string = ""
if datasets is not None:
@@ -875,7 +875,7 @@
dbif, connected = init_dbif(dbif)
# Get all datasets in which this map is registered
- datasets = self.get_registered_datasets(dbif)
+ datasets = self.get_registered_stds(dbif)
# For each stds in which the map is registered
if datasets is not None:
@@ -899,7 +899,7 @@
return statement
- def get_registered_datasets(self, dbif=None):
+ def get_registered_stds(self, dbif=None):
"""!Return all space time dataset ids in which this map is registered
as as a list of strings, or None if this map is not
registered in any space time dataset.
@@ -923,7 +923,7 @@
return datasets
- def add_dataset_to_register(self, stds_id, dbif=None, execute=True):
+ def add_stds_to_register(self, stds_id, dbif=None, execute=True):
"""!Add a new space time dataset to the register
@param stds_id The id of the space time dataset to be registered
@@ -937,7 +937,7 @@
"""
dbif, connected = init_dbif(dbif=dbif)
- datasets = self.get_registered_datasets(dbif=dbif)
+ datasets = self.get_registered_stds(dbif=dbif)
if stds_id is None or stds_id == "":
return ""
@@ -969,7 +969,7 @@
return statement
- def remove_dataset_from_register(self, stds_id, dbif=None, execute=True):
+ def remove_stds_from_register(self, stds_id, dbif=None, execute=True):
"""!Remove a space time dataset from the register
@param stds_id The id of the space time dataset to removed from the registered
@@ -983,7 +983,7 @@
"""
dbif, connected = init_dbif(dbif)
- datasets = self.get_registered_datasets(dbif=dbif)
+ datasets = self.get_registered_stds(dbif=dbif)
# Check if no datasets are present
if datasets is None:
Modified: grass/branches/releasebranch_7_0/lib/python/temporal/abstract_space_time_dataset.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/abstract_space_time_dataset.py 2014-05-28 11:09:47 UTC (rev 60533)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/abstract_space_time_dataset.py 2014-05-28 11:12:25 UTC (rev 60534)
@@ -1810,7 +1810,7 @@
dbif=dbif)
# Save the datasets that must be updated
- datasets = map.get_registered_datasets(dbif)
+ datasets = map.get_registered_stds(dbif)
if datasets:
for dataset in datasets:
datatsets_to_modify[dataset] = dataset
@@ -1882,8 +1882,8 @@
# We need to rename the space time dataset in the maps register table
if maps:
for map in maps:
- map.remove_dataset_from_register(stds_id=old_ident, dbif=dbif)
- map.add_dataset_to_register(stds_id=ident, dbif=dbif)
+ map.remove_stds_from_register(stds_id=old_ident, dbif=dbif)
+ map.add_stds_to_register(stds_id=ident, dbif=dbif)
# Execute the accumulated statements
dbif.execute_transaction(statement)
@@ -2111,7 +2111,7 @@
return False
# Register the stds in the map stds register table column
- statement += map.add_dataset_to_register(stds_id=self.base.get_id(),
+ statement += map.add_stds_to_register(stds_id=self.base.get_id(),
dbif=dbif, execute=False)
# Now put the raster name in the stds map register table
@@ -2179,7 +2179,7 @@
# Remove the space time dataset from the dataset register
# We need to execute the statement here, otherwise the space time dataset will not be
# removed correctly
- map.remove_dataset_from_register(self.base.get_id(),
+ map.remove_stds_from_register(self.base.get_id(),
dbif=dbif, execute=True)
# Remove the map from the space time dataset register
Modified: grass/branches/releasebranch_7_0/lib/python/temporal/aggregation.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/aggregation.py 2014-05-28 11:09:47 UTC (rev 60533)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/aggregation.py 2014-05-28 11:12:25 UTC (rev 60534)
@@ -102,7 +102,7 @@
def aggregate_raster_maps(inputs, base, start, end, count, method,
- register_null, dbif):
+ register_null, dbif, offset=0):
"""!Aggregate a list of raster input maps with r.series
@param inputs The names of the raster maps to be aggregated
@@ -117,12 +117,13 @@
@param register_null If true null maps will be registered in the space
time raster dataset, if false not
@param dbif The temporal database interface to use
+ @param offset Offset to be added to the map counter to create the map ids
"""
msgr = get_tgis_message_interface()
msgr.verbose(_("Aggregate %s raster maps") % (len(inputs)))
- output = "%s_%i" % (base, count)
+ output = "%s_%i" % (base, int(offset) + count)
mapset = get_current_mapset()
map_id = output + "@" + mapset
@@ -151,10 +152,16 @@
file.write(string)
file.close()
+
# Run r.series
- ret = core.run_command("r.series", flags="z", file=filename,
- output=output, overwrite=core.overwrite(),
- method=method)
+ if len(inputs) > 1000 :
+ ret = core.run_command("r.series", flags="z", file=filename,
+ output=output, overwrite=core.overwrite(),
+ method=method)
+ else:
+ ret = core.run_command("r.series", file=filename,
+ output=output, overwrite=core.overwrite(),
+ method=method)
if ret != 0:
dbif.close()
Modified: grass/branches/releasebranch_7_0/lib/python/temporal/c_libraries_interface.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/c_libraries_interface.py 2014-05-28 11:09:47 UTC (rev 60533)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/c_libraries_interface.py 2014-05-28 11:12:25 UTC (rev 60534)
@@ -38,13 +38,50 @@
READ_MAP_INFO=5
MAP_EXISTS=6
READ_MAP_INFO=7
+ AVAILABLE_MAPSETS = 8
TYPE_RASTER=0
TYPE_RASTER3D=1
TYPE_VECTOR=2
###############################################################################
+def available_mapsets(lock, conn, data):
+ """!Return all available mapsets the user can access as a list of strings
+
+ @param lock A multiprocessing.Lock instance
+ @param conn A multiprocessing.Pipe instance used to send True or False
+ @param data The list of data entries [function_id]
+
+ @return Names of available mapsets as list of strings
+ """
+
+ mapsets = libgis.G_available_mapsets()
+ count = 0
+ mapset_list = []
+ while mapsets[count]:
+ char_list = ""
+ mapset = mapsets[count]
+ if libgis.G__mapset_permissions(mapset) > 0:
+ count += 1
+ c = 0
+ while mapset[c] != "\x00":
+ char_list += mapset[c]
+ c += 1
+
+ mapset_list.append(char_list)
+
+ # We need to sort the mapset list, but the first one should be
+ # the current mapset
+ current_mapset = libgis.G_mapset()
+ mapset_list.remove(current_mapset)
+ mapset_list.sort()
+ mapset_list.reverse()
+ mapset_list.append(current_mapset)
+ mapset_list.reverse()
+
+ conn.send(mapset_list)
+
def _has_timestamp(lock, conn, data):
"""!Check if the file based GRASS timestamp is present and send
True or False using the provided pipe.
@@ -586,7 +623,7 @@
@param conn A multiprocessing.Pipe
"""
# Crerate the function array
- functions = [0]*8
+ functions = [0]*9
functions[RPCDefs.STOP] = _stop
functions[RPCDefs.HAS_TIMESTAMP] = _has_timestamp
functions[RPCDefs.WRITE_TIMESTAMP] = _write_timestamp
@@ -594,6 +631,7 @@
functions[RPCDefs.REMOVE_TIMESTAMP] = _remove_timestamp
functions[RPCDefs.READ_MAP_INFO] = _read_map_info
functions[RPCDefs.MAP_EXISTS] = _map_exists
+ functions[RPCDefs.AVAILABLE_MAPSETS] = available_mapsets
libgis.G_gisinit("c_library_server")
libgis.G_debug(1, "Start C-interface server")
@@ -643,7 +681,12 @@
>>> grass.run_command("v.timestamp", map="test", date='12 Mar 1995 10:34:40', overwrite=True, quiet=True)
0
-
+ # Check mapsets
+ >>> ciface = tgis.CLibrariesInterface()
+ >>> mapsets = ciface.available_mapsets()
+ >>> mapsets[0] == tgis.get_current_mapset()
+ True
+
# Raster map
>>> ciface = tgis.CLibrariesInterface()
>>> check = ciface.raster_map_exists("test", tgis.get_current_mapset())
@@ -1031,6 +1074,19 @@
name, mapset, layer, timestring])
return self.client_conn.recv()
+ def available_mapsets(self):
+ """!Return all available mapsets the user can access as a list of strings
+
+ @param lock A multiprocessing.Lock instance
+ @param conn A multiprocessing.Pipe instance used to send True or False
+ @param data Can be None
+
+ @return Names of available mapsets as list of strings
+ """
+ self._check_restart_server()
+ self.client_conn.send([RPCDefs.AVAILABLE_MAPSETS, ])
+ return self.client_conn.recv()
+
def stop(self):
"""!Stop the messenger server and close the pipe
"""
Modified: grass/branches/releasebranch_7_0/lib/python/temporal/extract.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/extract.py 2014-05-28 11:09:47 UTC (rev 60533)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/extract.py 2014-05-28 11:12:25 UTC (rev 60534)
@@ -152,7 +152,6 @@
for proc in proc_list:
proc.join()
exitcodes += proc.exitcode
-
if exitcodes != 0:
dbif.close()
msgr.fatal(_("Error while computation"))
@@ -248,18 +247,18 @@
def run_mapcalc2d(expr):
"""Helper function to run r.mapcalc in parallel"""
- return core.run_command("r.mapcalc", expression=expr,
- overwrite=core.overwrite(), quiet=True)
+ exit(core.run_command("r.mapcalc", expression=expr,
+ overwrite=core.overwrite(), quiet=True))
def run_mapcalc3d(expr):
"""Helper function to run r3.mapcalc in parallel"""
- return core.run_command("r3.mapcalc", expression=expr,
- overwrite=core.overwrite(), quiet=True)
+ exit(core.run_command("r3.mapcalc", expression=expr,
+ overwrite=core.overwrite(), quiet=True))
def run_vector_extraction(input, output, layer, type, where):
"""Helper function to run r.mapcalc in parallel"""
- return core.run_command("v.extract", input=input, output=output,
+ exit(core.run_command("v.extract", input=input, output=output,
layer=layer, type=type, where=where,
- overwrite=core.overwrite(), quiet=True)
+ overwrite=core.overwrite(), quiet=True))
Modified: grass/branches/releasebranch_7_0/lib/python/temporal/list_stds.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/list_stds.py 2014-05-28 11:09:47 UTC (rev 60533)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/list_stds.py 2014-05-28 11:12:25 UTC (rev 60534)
@@ -28,6 +28,83 @@
###############################################################################
+def get_dataset_list(type, temporal_type, columns=None, where=None, order=None):
+ """! Return a list of time stamped maps or space time datasets of a specific temporal type
+ that are registred in the temporal database
+
+ This method returns a dictionary, the keys are the available mapsets,
+ the values are the rows from the SQL database query.
+
+ @param type The type of the datasets (strds, str3ds, stvds, rast, rast3d, vect)
+ @param temporal_type The temporal type of the datasets (absolute, relative)
+ @param columns A comma separated list of columns that will be selected
+ @param where A where statement for selected listing without "WHERE"
+ @param order A comma separated list of columns to order the
+ datasets by category
+
+ @return A dictionary with the rows of the SQL query for each available mapset
+
+ >>> import grass.temporal as tgis
+ >>> tgis.init()
+ >>> name = "list_stds_test"
+ >>> sp = tgis.open_new_space_time_dataset(name=name, type="strds",
+ ... temporaltype="absolute", title="title", descr="descr", semantic="mean", dbif=None, overwrite=True)
+ >>> mapset = tgis.get_current_mapset()
+ >>> stds_list = tgis.get_dataset_list("strds", "absolute", columns="name")
+ >>> rows = stds_list[mapset]
+ >>> for row in rows:
+ ... if row["name"] == name:
+ ... 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
+ True
+ >>> check = sp.delete()
+ """
+ id = None
+ sp = dataset_factory(type, id)
+
+ dbif = SQLDatabaseInterfaceConnection()
+ dbif.connect()
+
+ mapsets = get_tgis_c_library_interface().available_mapsets()
+
+ result = {}
+
+ for mapset in mapsets:
+
+ if temporal_type == "absolute":
+ table = sp.get_type() + "_view_abs_time"
+ else:
+ table = sp.get_type() + "_view_rel_time"
+
+ if columns and columns.find("all") == -1:
+ sql = "SELECT " + str(columns) + " FROM " + table
+ else:
+ sql = "SELECT * FROM " + table
+
+ if where:
+ sql += " WHERE " + where
+ sql += " AND mapset = '%s'"%(mapset)
+ else:
+ sql += " WHERE mapset = '%s'"%(mapset)
+
+ if order:
+ sql += " ORDER BY " + order
+
+ dbif.cursor.execute(sql)
+ rows = dbif.cursor.fetchall()
+
+ if rows:
+ result[mapset] = rows
+
+ return result
+
+###############################################################################
+
def list_maps_of_stds(type, input, columns, order, where, separator, method, header, gran=None):
"""! List the maps of a space time dataset using diffetent methods
@@ -35,7 +112,7 @@
@param input Name of a space time raster dataset
@param columns A comma separated list of columns to be printed to stdout
@param order A comma separated list of columns to order the
- space time dataset by category
+ maps by category
@param where A where statement for selected listing without "WHERE"
e.g: start_time < "2001-01-01" and end_time > "2001-01-01"
@param separator The field separator character between the columns
@@ -185,3 +262,9 @@
print output
if connected:
dbif.close()
+
+###############################################################################
+
+if __name__ == "__main__":
+ import doctest
+ doctest.testmod()
Modified: grass/branches/releasebranch_7_0/lib/python/temporal/mapcalc.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/mapcalc.py 2014-05-28 11:09:47 UTC (rev 60533)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/mapcalc.py 2014-05-28 11:12:25 UTC (rev 60534)
@@ -340,16 +340,16 @@
def _run_mapcalc2d(expr):
"""Helper function to run r.mapcalc in parallel"""
- return core.run_command("r.mapcalc", expression=expr,
- overwrite=core.overwrite(), quiet=True)
+ exit(core.run_command("r.mapcalc", expression=expr,
+ overwrite=core.overwrite(), quiet=True))
###############################################################################
def _run_mapcalc3d(expr):
"""Helper function to run r3.mapcalc in parallel"""
- return core.run_command("r3.mapcalc", expression=expr,
- overwrite=core.overwrite(), quiet=True)
+ exit(core.run_command("r3.mapcalc", expression=expr,
+ overwrite=core.overwrite(), quiet=True))
###############################################################################
@@ -427,55 +427,55 @@
if expr.find("start_year()") >= 0:
if not is_time_absolute:
- msgr.fatal(_("The temporal operators <%s> supports only absolute"\
+ msgr.fatal(_("The temporal operators <%s> supports only absolute "\
"time." % ("start_*")))
expr = expr.replace("start_year()", str(start.year))
if expr.find("start_month()") >= 0:
if not is_time_absolute:
- msgr.fatal(_("The temporal operators <%s> supports only absolute"\
+ msgr.fatal(_("The temporal operators <%s> supports only absolute "\
"time." % ("start_*")))
expr = expr.replace("start_month()", str(start.month))
if expr.find("start_week()") >= 0:
if not is_time_absolute:
- msgr.fatal(_("The temporal operators <%s> supports only absolute"\
+ msgr.fatal(_("The temporal operators <%s> supports only absolute "\
"time." % ("start_*")))
expr = expr.replace("start_week()", str(start.isocalendar()[1]))
if expr.find("start_day()") >= 0:
if not is_time_absolute:
- msgr.fatal(_("The temporal operators <%s> supports only absolute"\
+ msgr.fatal(_("The temporal operators <%s> supports only absolute "\
"time." % ("start_*")))
expr = expr.replace("start_day()", str(start.day))
if expr.find("start_hour()") >= 0:
if not is_time_absolute:
- msgr.fatal(_("The temporal operators <%s> supports only absolute"\
+ msgr.fatal(_("The temporal operators <%s> supports only absolute "\
"time." % ("start_*")))
expr = expr.replace("start_hour()", str(start.hour))
if expr.find("start_minute()") >= 0:
if not is_time_absolute:
- msgr.fatal(_("The temporal operators <%s> supports only absolute"\
+ msgr.fatal(_("The temporal operators <%s> supports only absolute "\
"time." % ("start_*")))
expr = expr.replace("start_minute()", str(start.minute))
if expr.find("start_second()") >= 0:
if not is_time_absolute:
- msgr.fatal(_("The temporal operators <%s> supports only absolute"\
+ msgr.fatal(_("The temporal operators <%s> supports only absolute "\
"time." % ("start_*")))
expr = expr.replace("start_second()", str(start.second))
if expr.find("start_dow()") >= 0:
if not is_time_absolute:
- msgr.fatal(_("The temporal operators <%s> supports only absolute"\
+ msgr.fatal(_("The temporal operators <%s> supports only absolute "\
"time." % ("start_*")))
expr = expr.replace("start_dow()", str(start.isoweekday()))
if expr.find("start_doy()") >= 0:
if not is_time_absolute:
- msgr.fatal(_("The temporal operators <%s> supports only absolute"\
+ msgr.fatal(_("The temporal operators <%s> supports only absolute "\
"time." % ("start_*")))
year = datetime(start.year, 1, 1)
delta = start - year
@@ -510,7 +510,7 @@
if expr.find("end_year()") >= 0:
if not is_time_absolute:
- msgr.fatal(_("The temporal operators <%s> supports only absolute"\
+ msgr.fatal(_("The temporal operators <%s> supports only absolute "\
"time." % ("end_*")))
if not end:
expr = expr.replace("end_year()", "null()")
@@ -519,7 +519,7 @@
if expr.find("end_month()") >= 0:
if not is_time_absolute:
- msgr.fatal(_("The temporal operators <%s> supports only absolute"\
+ msgr.fatal(_("The temporal operators <%s> supports only absolute "\
"time." % ("end_*")))
if not end:
expr = expr.replace("end_month()", "null()")
@@ -528,7 +528,7 @@
if expr.find("end_week()") >= 0:
if not is_time_absolute:
- msgr.fatal(_("The temporal operators <%s> supports only absolute"\
+ msgr.fatal(_("The temporal operators <%s> supports only absolute "\
"time." % ("end_*")))
if not end:
expr = expr.replace("end_week()", "null()")
@@ -537,7 +537,7 @@
if expr.find("end_day()") >= 0:
if not is_time_absolute:
- msgr.fatal(_("The temporal operators <%s> supports only absolute"\
+ msgr.fatal(_("The temporal operators <%s> supports only absolute "\
"time." % ("end_*")))
if not end:
expr = expr.replace("end_day()", "null()")
@@ -546,7 +546,7 @@
if expr.find("end_hour()") >= 0:
if not is_time_absolute:
- msgr.fatal(_("The temporal operators <%s> supports only absolute"\
+ msgr.fatal(_("The temporal operators <%s> supports only absolute "\
"time." % ("end_*")))
if not end:
expr = expr.replace("end_hour()", "null()")
@@ -555,7 +555,7 @@
if expr.find("end_minute()") >= 0:
if not is_time_absolute:
- msgr.fatal(_("The temporal operators <%s> supports only absolute"\
+ msgr.fatal(_("The temporal operators <%s> supports only absolute "\
"time." % ("end_*")))
if not end:
expr = expr.replace("end_minute()", "null()")
@@ -564,7 +564,7 @@
if expr.find("end_second()") >= 0:
if not is_time_absolute:
- msgr.fatal(_("The temporal operators <%s> supports only absolute"\
+ msgr.fatal(_("The temporal operators <%s> supports only absolute "\
"time." % ("end_*")))
if not end:
expr = expr.replace("end_second()", "null()")
@@ -573,7 +573,7 @@
if expr.find("end_dow()") >= 0:
if not is_time_absolute:
- msgr.fatal(_("The temporal operators <%s> supports only absolute"\
+ msgr.fatal(_("The temporal operators <%s> supports only absolute "\
"time." % ("end_*")))
if not end:
expr = expr.replace("end_dow()", "null()")
@@ -582,7 +582,7 @@
if expr.find("end_doy()") >= 0:
if not is_time_absolute:
- msgr.fatal(_("The temporal operators <%s> supports only absolute"\
+ msgr.fatal(_("The temporal operators <%s> supports only absolute "\
"time." % ("end_*")))
if not end:
expr = expr.replace("end_doy()", "null()")
Modified: grass/branches/releasebranch_7_0/lib/python/temporal/register.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/register.py 2014-05-28 11:09:47 UTC (rev 60533)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/register.py 2014-05-28 11:12:25 UTC (rev 60534)
@@ -243,7 +243,7 @@
map.select(dbif)
# Save the datasets that must be updated
- datasets = map.get_registered_datasets(dbif)
+ datasets = map.get_registered_stds(dbif)
if datasets is not None:
for dataset in datasets:
if dataset != "":
Modified: grass/branches/releasebranch_7_0/lib/python/temporal/space_time_datasets.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/space_time_datasets.py 2014-05-28 11:09:47 UTC (rev 60533)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/space_time_datasets.py 2014-05-28 11:12:25 UTC (rev 60534)
@@ -51,6 +51,7 @@
>>> rmap.get_temporal_extent_as_tuple()
(datetime.datetime(1999, 1, 15, 0, 0), None)
>>> rmap.load()
+ True
>>> rmap.spatial_extent.print_info()
+-------------------- Spatial extent ----------------------------------------+
| North:...................... 80.0
@@ -286,37 +287,51 @@
self.get_mapset())
def load(self):
- """!Load all info from an existing raster map into the internal s
- tructure"""
+ """!Load all info from an existing raster map into the internal structure
+
+ This method checks first if the map exists, in case it exists
+ the metadata of the map is put into this object and True is returned.
+
+ @return True is the map exists and the metadata was filled successfully
+ and getting the data was successfull, False otherwise
+ """
+ if self.map_exists() is not True:
+ return False
+
# Fill base information
self.base.set_creator(str(getpass.getuser()))
kvp = self.ciface.read_raster_info(self.get_name(),
self.get_mapset())
- # Fill spatial extent
- self.set_spatial_extent_from_values(north=kvp["north"],
- south=kvp["south"],
- east=kvp["east"],
- west=kvp["west"])
+ if kvp:
+ # Fill spatial extent
+ self.set_spatial_extent_from_values(north=kvp["north"],
+ south=kvp["south"],
+ east=kvp["east"],
+ west=kvp["west"])
- # Fill metadata
- self.metadata.set_nsres(kvp["nsres"])
- self.metadata.set_ewres(kvp["ewres"])
- self.metadata.set_datatype(kvp["datatype"])
- self.metadata.set_min(kvp["min"])
- self.metadata.set_max(kvp["max"])
+ # Fill metadata
+ self.metadata.set_nsres(kvp["nsres"])
+ self.metadata.set_ewres(kvp["ewres"])
+ self.metadata.set_datatype(kvp["datatype"])
+ self.metadata.set_min(kvp["min"])
+ self.metadata.set_max(kvp["max"])
- rows = int(kvp["rows"])
- cols = int(kvp["cols"])
+ rows = int(kvp["rows"])
+ cols = int(kvp["cols"])
- ncells = cols * rows
+ ncells = cols * rows
- self.metadata.set_cols(cols)
- self.metadata.set_rows(rows)
- self.metadata.set_number_of_cells(ncells)
+ self.metadata.set_cols(cols)
+ self.metadata.set_rows(rows)
+ self.metadata.set_number_of_cells(ncells)
+
+ return True
+ return False
+
###############################################################################
class Raster3DDataset(AbstractMapDataset):
@@ -352,6 +367,7 @@
>>> r3map.get_temporal_extent_as_tuple()
(datetime.datetime(1999, 1, 15, 0, 0), None)
>>> r3map.load()
+ True
>>> r3map.spatial_extent.print_info()
+-------------------- Spatial extent ----------------------------------------+
| North:...................... 80.0
@@ -598,8 +614,18 @@
self.get_mapset())
def load(self):
- """!Load all info from an existing raster3d map into the internal structure"""
+ """!Load all info from an existing 3d raster map into the internal structure
+
+ This method checks first if the map exists, in case it exists
+ the metadata of the map is put into this object and True is returned.
+
+ @return True is the map exists and the metadata was filled successfully
+ and getting the data was successfull, False otherwise
+ """
+ if self.map_exists() is not True:
+ return False
+
# Fill base information
self.base.set_creator(str(getpass.getuser()))
@@ -607,29 +633,34 @@
kvp = self.ciface.read_raster3d_info(self.get_name(),
self.get_mapset())
- self.set_spatial_extent_from_values(north=kvp["north"], south=kvp["south"],
- east=kvp["east"], west=kvp["west"],
- top=kvp["top"], bottom=kvp["bottom"])
+ if kvp:
+ self.set_spatial_extent_from_values(north=kvp["north"], south=kvp["south"],
+ east=kvp["east"], west=kvp["west"],
+ top=kvp["top"], bottom=kvp["bottom"])
- # Fill metadata
- self.metadata.set_nsres(kvp["nsres"])
- self.metadata.set_ewres(kvp["ewres"])
- self.metadata.set_tbres(kvp["tbres"])
- self.metadata.set_datatype(kvp["datatype"])
- self.metadata.set_min(kvp["min"])
- self.metadata.set_max(kvp["max"])
+ # Fill metadata
+ self.metadata.set_nsres(kvp["nsres"])
+ self.metadata.set_ewres(kvp["ewres"])
+ self.metadata.set_tbres(kvp["tbres"])
+ self.metadata.set_datatype(kvp["datatype"])
+ self.metadata.set_min(kvp["min"])
+ self.metadata.set_max(kvp["max"])
- rows = int(kvp["rows"])
- cols = int(kvp["cols"])
- depths = int(kvp["depths"])
+ rows = int(kvp["rows"])
+ cols = int(kvp["cols"])
+ depths = int(kvp["depths"])
- ncells = cols * rows * depths
+ ncells = cols * rows * depths
- self.metadata.set_cols(cols)
- self.metadata.set_rows(rows)
- self.metadata.set_depths(depths)
- self.metadata.set_number_of_cells(ncells)
+ self.metadata.set_cols(cols)
+ self.metadata.set_rows(rows)
+ self.metadata.set_depths(depths)
+ self.metadata.set_number_of_cells(ncells)
+
+ return True
+ return False
+
###############################################################################
class VectorDataset(AbstractMapDataset):
@@ -665,6 +696,7 @@
>>> vmap.get_temporal_extent_as_tuple()
(datetime.datetime(1999, 1, 15, 0, 0), None)
>>> vmap.load()
+ True
>>> vmap.absolute_time.print_info()
+-------------------- Absolute time -----------------------------------------+
| Start time:................. 1999-01-15 00:00:00
@@ -869,9 +901,20 @@
def load(self):
- """!Load all info from an existing vector map into the internal
- structure"""
+ """!Load all info from an existing vector map into the internal structure
+
+ This method checks first if the map exists, in case it exists
+ the metadata of the map is put into this object and True is returned.
+
+ @return True is the map exists and the metadata was filled successfully
+ and getting the data was successfull, False otherwise
+ """
+
+ if self.map_exists() is not True:
+ return False
+
+
# Fill base information
self.base.set_creator(str(getpass.getuser()))
@@ -880,26 +923,31 @@
kvp = self.ciface.read_vector_info(self.get_name(),
self.get_mapset())
- # Fill spatial extent
- self.set_spatial_extent_from_values(north=kvp["north"], south=kvp["south"],
- east=kvp["east"], west=kvp["west"],
- top=kvp["top"], bottom=kvp["bottom"])
+ if kvp:
+ # Fill spatial extent
+ self.set_spatial_extent_from_values(north=kvp["north"], south=kvp["south"],
+ east=kvp["east"], west=kvp["west"],
+ top=kvp["top"], bottom=kvp["bottom"])
- # Fill metadata
- self.metadata.set_3d_info(kvp["map3d"])
- self.metadata.set_number_of_points(kvp["points"])
- self.metadata.set_number_of_lines(kvp["lines"])
- self.metadata.set_number_of_boundaries(kvp["boundaries"])
- self.metadata.set_number_of_centroids(kvp["centroids"])
- self.metadata.set_number_of_faces(kvp["faces"])
- self.metadata.set_number_of_kernels(kvp["kernels"])
- self.metadata.set_number_of_primitives(kvp["primitives"])
- self.metadata.set_number_of_nodes(kvp["nodes"])
- self.metadata.set_number_of_areas(kvp["areas"])
- self.metadata.set_number_of_islands(kvp["islands"])
- self.metadata.set_number_of_holes(kvp["holes"])
- self.metadata.set_number_of_volumes(kvp["volumes"])
+ # Fill metadata
+ self.metadata.set_3d_info(kvp["map3d"])
+ self.metadata.set_number_of_points(kvp["points"])
+ self.metadata.set_number_of_lines(kvp["lines"])
+ self.metadata.set_number_of_boundaries(kvp["boundaries"])
+ self.metadata.set_number_of_centroids(kvp["centroids"])
+ self.metadata.set_number_of_faces(kvp["faces"])
+ self.metadata.set_number_of_kernels(kvp["kernels"])
+ self.metadata.set_number_of_primitives(kvp["primitives"])
+ self.metadata.set_number_of_nodes(kvp["nodes"])
+ self.metadata.set_number_of_areas(kvp["areas"])
+ self.metadata.set_number_of_islands(kvp["islands"])
+ self.metadata.set_number_of_holes(kvp["holes"])
+ self.metadata.set_number_of_volumes(kvp["volumes"])
+
+ return True
+ return False
+
###############################################################################
class SpaceTimeRasterDataset(AbstractSpaceTimeDataset):
Modified: grass/branches/releasebranch_7_0/lib/python/temporal/temporal_extent.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/temporal_extent.py 2014-05-28 11:09:47 UTC (rev 60533)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/temporal_extent.py 2014-05-28 11:12:25 UTC (rev 60534)
@@ -27,7 +27,7 @@
###############################################################################
-class AbstractTemporalExtent(SQLDatabaseInterface):
+class TemporalExtent(SQLDatabaseInterface):
"""!This is the abstract time base class for relative and absolute time objects
It abstract class implements the interface to absolute and relative time.
@@ -42,7 +42,7 @@
@code
>>> init()
- >>> A = AbstractTemporalExtent(table="raster_absolute_time",
+ >>> A = TemporalExtent(table="raster_absolute_time",
... ident="soil at PERMANENT", start_time=datetime(2001, 01, 01),
... end_time=datetime(2005,01,01) )
>>> A.id
@@ -58,7 +58,7 @@
start_time=2001-01-01 00:00:00
end_time=2005-01-01 00:00:00
>>> # relative time
- >>> A = AbstractTemporalExtent(table="raster_absolute_time",
+ >>> A = TemporalExtent(table="raster_absolute_time",
... ident="soil at PERMANENT", start_time=0, end_time=1 )
>>> A.id
'soil at PERMANENT'
@@ -95,14 +95,14 @@
@code
- >>> A = AbstractTemporalExtent(start_time=5, end_time=6 )
+ >>> A = TemporalExtent(start_time=5, end_time=6 )
>>> inter = A.intersect(A)
>>> inter.print_info()
| Start time:................. 5
| End time:................... 6
- >>> A = AbstractTemporalExtent(start_time=5, end_time=6 )
- >>> B = AbstractTemporalExtent(start_time=5, end_time=7 )
+ >>> A = TemporalExtent(start_time=5, end_time=6 )
+ >>> B = TemporalExtent(start_time=5, end_time=7 )
>>> inter = A.intersect(B)
>>> inter.print_info()
| Start time:................. 5
@@ -112,8 +112,8 @@
| Start time:................. 5
| End time:................... 6
- >>> A = AbstractTemporalExtent(start_time=3, end_time=6 )
- >>> B = AbstractTemporalExtent(start_time=5, end_time=7 )
+ >>> A = TemporalExtent(start_time=3, end_time=6 )
+ >>> B = TemporalExtent(start_time=5, end_time=7 )
>>> inter = A.intersect(B)
>>> inter.print_info()
| Start time:................. 5
@@ -123,8 +123,8 @@
| Start time:................. 5
| End time:................... 6
- >>> A = AbstractTemporalExtent(start_time=3, end_time=8 )
- >>> B = AbstractTemporalExtent(start_time=5, end_time=6 )
+ >>> A = TemporalExtent(start_time=3, end_time=8 )
+ >>> B = TemporalExtent(start_time=5, end_time=6 )
>>> inter = A.intersect(B)
>>> inter.print_info()
| Start time:................. 5
@@ -134,8 +134,8 @@
| Start time:................. 5
| End time:................... 6
- >>> A = AbstractTemporalExtent(start_time=5, end_time=8 )
- >>> B = AbstractTemporalExtent(start_time=3, end_time=6 )
+ >>> A = TemporalExtent(start_time=5, end_time=8 )
+ >>> B = TemporalExtent(start_time=3, end_time=6 )
>>> inter = A.intersect(B)
>>> inter.print_info()
| Start time:................. 5
@@ -145,8 +145,8 @@
| Start time:................. 5
| End time:................... 6
- >>> A = AbstractTemporalExtent(start_time=5, end_time=None )
- >>> B = AbstractTemporalExtent(start_time=3, end_time=6 )
+ >>> A = TemporalExtent(start_time=5, end_time=None )
+ >>> B = TemporalExtent(start_time=3, end_time=6 )
>>> inter = A.intersect(B)
>>> inter.print_info()
| Start time:................. 5
@@ -156,14 +156,14 @@
| Start time:................. 5
| End time:................... None
- >>> A = AbstractTemporalExtent(start_time=5, end_time=8 )
- >>> B = AbstractTemporalExtent(start_time=3, end_time=4 )
+ >>> A = TemporalExtent(start_time=5, end_time=8 )
+ >>> B = TemporalExtent(start_time=3, end_time=4 )
>>> inter = A.intersect(B)
>>> print inter
None
- >>> A = AbstractTemporalExtent(start_time=5, end_time=8 )
- >>> B = AbstractTemporalExtent(start_time=3, end_time=None )
+ >>> A = TemporalExtent(start_time=5, end_time=8 )
+ >>> B = TemporalExtent(start_time=3, end_time=None )
>>> inter = A.intersect(B)
>>> print inter
None
@@ -176,10 +176,10 @@
return None
if self.D["end_time"] is None:
- return AbstractTemporalExtent(start_time=self.D["start_time"])
+ return TemporalExtent(start_time=self.D["start_time"])
if extent.D["end_time"] is None:
- return AbstractTemporalExtent(start_time=extent.D["start_time"])
+ return TemporalExtent(start_time=extent.D["start_time"])
start = None
end = None
@@ -199,8 +199,8 @@
unit=self.get_unit())
elif issubclass(type(self), AbsoluteTemporalExtent):
return AbsoluteTemporalExtent(start_time=start, end_time=end)
- elif issubclass(type(self), AbstractTemporalExtent):
- return AbstractTemporalExtent(start_time=start, end_time=end)
+ elif issubclass(type(self), TemporalExtent):
+ return TemporalExtent(start_time=start, end_time=end)
def disjoint_union(self, extent):
"""!Creates a disjoint union with this temporal extent and the provided one.
@@ -213,14 +213,14 @@
@code
- >>> A = AbstractTemporalExtent(start_time=5, end_time=6 )
+ >>> A = TemporalExtent(start_time=5, end_time=6 )
>>> inter = A.intersect(A)
>>> inter.print_info()
| Start time:................. 5
| End time:................... 6
- >>> A = AbstractTemporalExtent(start_time=5, end_time=6 )
- >>> B = AbstractTemporalExtent(start_time=5, end_time=7 )
+ >>> A = TemporalExtent(start_time=5, end_time=6 )
+ >>> B = TemporalExtent(start_time=5, end_time=7 )
>>> inter = A.disjoint_union(B)
>>> inter.print_info()
| Start time:................. 5
@@ -230,8 +230,8 @@
| Start time:................. 5
| End time:................... 7
- >>> A = AbstractTemporalExtent(start_time=3, end_time=6 )
- >>> B = AbstractTemporalExtent(start_time=5, end_time=7 )
+ >>> A = TemporalExtent(start_time=3, end_time=6 )
+ >>> B = TemporalExtent(start_time=5, end_time=7 )
>>> inter = A.disjoint_union(B)
>>> inter.print_info()
| Start time:................. 3
@@ -241,8 +241,8 @@
| Start time:................. 3
| End time:................... 7
- >>> A = AbstractTemporalExtent(start_time=3, end_time=8 )
- >>> B = AbstractTemporalExtent(start_time=5, end_time=6 )
+ >>> A = TemporalExtent(start_time=3, end_time=8 )
+ >>> B = TemporalExtent(start_time=5, end_time=6 )
>>> inter = A.disjoint_union(B)
>>> inter.print_info()
| Start time:................. 3
@@ -252,8 +252,8 @@
| Start time:................. 3
| End time:................... 8
- >>> A = AbstractTemporalExtent(start_time=5, end_time=8 )
- >>> B = AbstractTemporalExtent(start_time=3, end_time=6 )
+ >>> A = TemporalExtent(start_time=5, end_time=8 )
+ >>> B = TemporalExtent(start_time=3, end_time=6 )
>>> inter = A.disjoint_union(B)
>>> inter.print_info()
| Start time:................. 3
@@ -263,8 +263,8 @@
| Start time:................. 3
| End time:................... 8
- >>> A = AbstractTemporalExtent(start_time=5, end_time=None )
- >>> B = AbstractTemporalExtent(start_time=3, end_time=6 )
+ >>> A = TemporalExtent(start_time=5, end_time=None )
+ >>> B = TemporalExtent(start_time=3, end_time=6 )
>>> inter = A.disjoint_union(B)
>>> inter.print_info()
| Start time:................. 3
@@ -274,8 +274,8 @@
| Start time:................. 3
| End time:................... 6
- >>> A = AbstractTemporalExtent(start_time=5, end_time=8 )
- >>> B = AbstractTemporalExtent(start_time=3, end_time=4 )
+ >>> A = TemporalExtent(start_time=5, end_time=8 )
+ >>> B = TemporalExtent(start_time=3, end_time=4 )
>>> inter = A.disjoint_union(B)
>>> inter.print_info()
| Start time:................. 3
@@ -284,8 +284,8 @@
>>> inter.print_info()
| Start time:................. 3
| End time:................... 8
- >>> A = AbstractTemporalExtent(start_time=5, end_time=8 )
- >>> B = AbstractTemporalExtent(start_time=3, end_time=None )
+ >>> A = TemporalExtent(start_time=5, end_time=8 )
+ >>> B = TemporalExtent(start_time=3, end_time=None )
>>> inter = A.disjoint_union(B)
>>> inter.print_info()
| Start time:................. 3
@@ -294,8 +294,8 @@
>>> inter.print_info()
| Start time:................. 3
| End time:................... 8
- >>> A = AbstractTemporalExtent(start_time=5, end_time=None )
- >>> B = AbstractTemporalExtent(start_time=3, end_time=8 )
+ >>> A = TemporalExtent(start_time=5, end_time=None )
+ >>> B = TemporalExtent(start_time=3, end_time=8 )
>>> inter = A.disjoint_union(B)
>>> inter.print_info()
| Start time:................. 3
@@ -304,8 +304,8 @@
>>> inter.print_info()
| Start time:................. 3
| End time:................... 8
- >>> A = AbstractTemporalExtent(start_time=5, end_time=None )
- >>> B = AbstractTemporalExtent(start_time=3, end_time=None )
+ >>> A = TemporalExtent(start_time=5, end_time=None )
+ >>> B = TemporalExtent(start_time=3, end_time=None )
>>> inter = A.disjoint_union(B)
>>> inter.print_info()
| Start time:................. 3
@@ -384,8 +384,8 @@
unit=self.get_unit())
elif issubclass(type(self), AbsoluteTemporalExtent):
return AbsoluteTemporalExtent(start_time=start, end_time=end)
- elif issubclass(type(self), AbstractTemporalExtent):
- return AbstractTemporalExtent(start_time=start, end_time=end)
+ elif issubclass(type(self), TemporalExtent):
+ return TemporalExtent(start_time=start, end_time=end)
def union(self, extent):
"""!Creates a union with this temporal extent and the provided one.
@@ -397,14 +397,14 @@
@code
- >>> A = AbstractTemporalExtent(start_time=5, end_time=8 )
- >>> B = AbstractTemporalExtent(start_time=3, end_time=4 )
+ >>> A = TemporalExtent(start_time=5, end_time=8 )
+ >>> B = TemporalExtent(start_time=3, end_time=4 )
>>> inter = A.intersect(B)
>>> print inter
None
- >>> A = AbstractTemporalExtent(start_time=5, end_time=8 )
- >>> B = AbstractTemporalExtent(start_time=3, end_time=None )
+ >>> A = TemporalExtent(start_time=5, end_time=8 )
+ >>> B = TemporalExtent(start_time=3, end_time=None )
>>> inter = A.intersect(B)
>>> print inter
None
@@ -433,8 +433,8 @@
@code
- >>> A = AbstractTemporalExtent(start_time=5, end_time=6 )
- >>> B = AbstractTemporalExtent(start_time=5, end_time=7 )
+ >>> A = TemporalExtent(start_time=5, end_time=6 )
+ >>> B = TemporalExtent(start_time=5, end_time=7 )
>>> A.starts(B)
True
>>> B.starts(A)
@@ -465,8 +465,8 @@
@code
- >>> A = AbstractTemporalExtent(start_time=5, end_time=7 )
- >>> B = AbstractTemporalExtent(start_time=5, end_time=6 )
+ >>> A = TemporalExtent(start_time=5, end_time=7 )
+ >>> B = TemporalExtent(start_time=5, end_time=6 )
>>> A.started(B)
True
>>> B.started(A)
@@ -497,8 +497,8 @@
@code
- >>> A = AbstractTemporalExtent(start_time=6, end_time=7 )
- >>> B = AbstractTemporalExtent(start_time=5, end_time=7 )
+ >>> A = TemporalExtent(start_time=6, end_time=7 )
+ >>> B = TemporalExtent(start_time=5, end_time=7 )
>>> A.finishes(B)
True
>>> B.finishes(A)
@@ -529,8 +529,8 @@
@code
- >>> A = AbstractTemporalExtent(start_time=5, end_time=7 )
- >>> B = AbstractTemporalExtent(start_time=6, end_time=7 )
+ >>> A = TemporalExtent(start_time=5, end_time=7 )
+ >>> B = TemporalExtent(start_time=6, end_time=7 )
>>> A.finished(B)
True
>>> B.finished(A)
@@ -561,8 +561,8 @@
@code
- >>> A = AbstractTemporalExtent(start_time=8, end_time=9 )
- >>> B = AbstractTemporalExtent(start_time=6, end_time=7 )
+ >>> A = TemporalExtent(start_time=8, end_time=9 )
+ >>> B = TemporalExtent(start_time=6, end_time=7 )
>>> A.after(B)
True
>>> B.after(A)
@@ -595,8 +595,8 @@
@code
- >>> A = AbstractTemporalExtent(start_time=6, end_time=7 )
- >>> B = AbstractTemporalExtent(start_time=8, end_time=9 )
+ >>> A = TemporalExtent(start_time=6, end_time=7 )
+ >>> B = TemporalExtent(start_time=8, end_time=9 )
>>> A.before(B)
True
>>> B.before(A)
@@ -632,14 +632,14 @@
@code
- >>> A = AbstractTemporalExtent(start_time=5, end_time=7 )
- >>> B = AbstractTemporalExtent(start_time=7, end_time=9 )
+ >>> A = TemporalExtent(start_time=5, end_time=7 )
+ >>> B = TemporalExtent(start_time=7, end_time=9 )
>>> A.adjacent(B)
True
>>> B.adjacent(A)
True
- >>> A = AbstractTemporalExtent(start_time=5, end_time=7 )
- >>> B = AbstractTemporalExtent(start_time=3, end_time=5 )
+ >>> A = TemporalExtent(start_time=5, end_time=7 )
+ >>> B = TemporalExtent(start_time=3, end_time=5 )
>>> A.adjacent(B)
True
>>> B.adjacent(A)
@@ -671,8 +671,8 @@
@code
- >>> A = AbstractTemporalExtent(start_time=5, end_time=7 )
- >>> B = AbstractTemporalExtent(start_time=3, end_time=5 )
+ >>> A = TemporalExtent(start_time=5, end_time=7 )
+ >>> B = TemporalExtent(start_time=3, end_time=5 )
>>> A.follows(B)
True
>>> B.follows(A)
@@ -703,8 +703,8 @@
@code
- >>> A = AbstractTemporalExtent(start_time=5, end_time=7 )
- >>> B = AbstractTemporalExtent(start_time=7, end_time=9 )
+ >>> A = TemporalExtent(start_time=5, end_time=7 )
+ >>> B = TemporalExtent(start_time=7, end_time=9 )
>>> A.precedes(B)
True
>>> B.precedes(A)
@@ -734,8 +734,8 @@
@code
- >>> A = AbstractTemporalExtent(start_time=5, end_time=7 )
- >>> B = AbstractTemporalExtent(start_time=4, end_time=9 )
+ >>> A = TemporalExtent(start_time=5, end_time=7 )
+ >>> B = TemporalExtent(start_time=4, end_time=9 )
>>> A.during(B)
True
>>> B.during(A)
@@ -776,8 +776,8 @@
@code
- >>> A = AbstractTemporalExtent(start_time=4, end_time=9 )
- >>> B = AbstractTemporalExtent(start_time=5, end_time=8 )
+ >>> A = TemporalExtent(start_time=4, end_time=9 )
+ >>> B = TemporalExtent(start_time=5, end_time=8 )
>>> A.contains(B)
True
>>> B.contains(A)
@@ -818,8 +818,8 @@
@code
- >>> A = AbstractTemporalExtent(start_time=5, end_time=6 )
- >>> B = AbstractTemporalExtent(start_time=5, end_time=6 )
+ >>> A = TemporalExtent(start_time=5, end_time=6 )
+ >>> B = TemporalExtent(start_time=5, end_time=6 )
>>> A.equal(B)
True
>>> B.equal(A)
@@ -856,15 +856,15 @@
@code
- >>> A = AbstractTemporalExtent(start_time=5, end_time=7 )
- >>> B = AbstractTemporalExtent(start_time=6, end_time=8 )
+ >>> A = TemporalExtent(start_time=5, end_time=7 )
+ >>> B = TemporalExtent(start_time=6, end_time=8 )
>>> A.overlaps(B)
True
>>> B.overlaps(A)
False
- >>> A = AbstractTemporalExtent(start_time=5, end_time=6 )
- >>> B = AbstractTemporalExtent(start_time=6, end_time=8 )
+ >>> A = TemporalExtent(start_time=5, end_time=6 )
+ >>> B = TemporalExtent(start_time=6, end_time=8 )
>>> A.overlaps(B)
False
>>> B.overlaps(A)
@@ -897,15 +897,15 @@
@code
- >>> A = AbstractTemporalExtent(start_time=6, end_time=8 )
- >>> B = AbstractTemporalExtent(start_time=5, end_time=7 )
+ >>> A = TemporalExtent(start_time=6, end_time=8 )
+ >>> B = TemporalExtent(start_time=5, end_time=7 )
>>> A.overlapped(B)
True
>>> B.overlapped(A)
False
- >>> A = AbstractTemporalExtent(start_time=6, end_time=8 )
- >>> B = AbstractTemporalExtent(start_time=5, end_time=6 )
+ >>> A = TemporalExtent(start_time=6, end_time=8 )
+ >>> B = TemporalExtent(start_time=5, end_time=6 )
>>> A.overlapped(B)
False
>>> B.overlapped(A)
@@ -1046,25 +1046,25 @@
###############################################################################
-class AbsoluteTemporalExtent(AbstractTemporalExtent):
+class AbsoluteTemporalExtent(TemporalExtent):
"""!This is the absolute time class for all maps and spacetime datasets
start_time and end_time must be of type datetime
"""
def __init__(self, table=None, ident=None, start_time=None, end_time=None):
- AbstractTemporalExtent.__init__(
+ TemporalExtent.__init__(
self, table, ident, start_time, end_time)
def print_info(self):
"""!Print information about this class in human readable style"""
# 0123456789012345678901234567890
print " +-------------------- Absolute time -----------------------------------------+"
- AbstractTemporalExtent.print_info(self)
+ TemporalExtent.print_info(self)
def print_shell_info(self):
"""!Print information about this class in shell style"""
- AbstractTemporalExtent.print_shell_info(self)
+ TemporalExtent.print_shell_info(self)
###############################################################################
@@ -1212,7 +1212,7 @@
###############################################################################
-class RelativeTemporalExtent(AbstractTemporalExtent):
+class RelativeTemporalExtent(TemporalExtent):
"""!This is the relative time class for all maps and space time datasets
start_time and end_time must be of type integer
@@ -1247,7 +1247,7 @@
def __init__(self, table=None, ident=None, start_time=None, end_time=None,
unit=None):
- AbstractTemporalExtent.__init__(
+ TemporalExtent.__init__(
self, table, ident, start_time, end_time)
self.set_unit(unit)
@@ -1287,7 +1287,7 @@
if self.D["unit"] != map.D["unit"]:
return None
- return AbstractTemporalExtent.temporal_relation(self, map)
+ return TemporalExtent.temporal_relation(self, map)
# Properties
unit = property(fget=get_unit, fset=set_unit)
@@ -1296,12 +1296,12 @@
"""!Print information about this class in human readable style"""
# 0123456789012345678901234567890
print " +-------------------- Relative time -----------------------------------------+"
- AbstractTemporalExtent.print_info(self)
+ TemporalExtent.print_info(self)
print " | Relative time unit:......... " + str(self.get_unit())
def print_shell_info(self):
"""!Print information about this class in shell style"""
- AbstractTemporalExtent.print_shell_info(self)
+ TemporalExtent.print_shell_info(self)
print "unit=" + str(self.get_unit())
###############################################################################
Modified: grass/branches/releasebranch_7_0/lib/python/temporal/temporal_raster_base_algebra.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/temporal_raster_base_algebra.py 2014-05-28 11:09:47 UTC (rev 60533)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/temporal_raster_base_algebra.py 2014-05-28 11:12:25 UTC (rev 60534)
@@ -301,7 +301,7 @@
m = copy.deepcopy(self.m_mapcalc)
m_expression = newident + "=" + map_i.cmd_list
- m.inputs["expression"].value = m_expression
+ m.inputs["expression"].value = str(m_expression)
m.flags["overwrite"].value = self.overwrite
process_queue.put(m)
else:
Modified: grass/branches/releasebranch_7_0/lib/python/temporal/unittests_temporal_raster_algebra.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/unittests_temporal_raster_algebra.py 2014-05-28 11:09:47 UTC (rev 60533)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/unittests_temporal_raster_algebra.py 2014-05-28 11:12:25 UTC (rev 60534)
@@ -50,8 +50,42 @@
tgis.register_maps_in_space_time_dataset(type="rast", name="C", maps="c1",
start="2001-01-02", increment="2 day", interval=True)
+
+ def test_temporal_conditional_time_dimension_bug(self):
+ """Testing the conditional time dimension bug, that uses the time
+ dimension of the conditional statement instead the time dimension
+ of the then/else statement."""
+ tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+ tra.parse(expression="D = if({contains}, B == 5, A - 1, A + 1)", basename="d", overwrite=True)
+
+ D = tgis.open_old_space_time_dataset("D", type="strds")
+ D.select()
+ self.assertEqual(D.metadata.get_number_of_maps(), 4)
+ self.assertEqual(D.metadata.get_min_min(), 0) # 1 - 1
+ self.assertEqual(D.metadata.get_max_max(), 5) # 4 + 1
+ start, end = D.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 1))
+ self.assertEqual(end, datetime.datetime(2001, 1, 5))
+ self.assertEqual( D.check_temporal_topology(), True)
+ self.assertEqual(D.get_granularity(), u'1 day')
+
+ def test_simple_arith_hash_1(self):
+ """Simple arithmetic test including the hash operator"""
+ tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+ tra.parse(expression='D = A + A{equal,=#}A', basename="d", overwrite=True)
+
+ D = tgis.open_old_space_time_dataset("D", type="strds")
+ D.select()
+ self.assertEqual(D.metadata.get_number_of_maps(), 4)
+ self.assertEqual(D.metadata.get_min_min(), 2)
+ self.assertEqual(D.metadata.get_max_max(), 5)
+ start, end = D.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 1, 1))
+ self.assertEqual(end, datetime.datetime(2001, 1, 5))
+
+
def test_simple_arith_td_1(self):
- """Simple arithmetic test with if condition"""
+ """Simple arithmetic test"""
tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
tra.parse(expression='D = A + td(A)', basename="d", overwrite=True)
@@ -64,9 +98,8 @@
self.assertEqual(start, datetime.datetime(2001, 1, 1))
self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
def test_simple_arith_td_2(self):
- """Simple arithmetic test with if condition"""
+ """Simple arithmetic test"""
tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
tra.parse(expression='D = A / td(A)', basename="d", overwrite=True)
@@ -80,7 +113,7 @@
self.assertEqual(end, datetime.datetime(2001, 1, 5))
def test_simple_arith_td_3(self):
- """Simple arithmetic test with if condition"""
+ """Simple arithmetic test"""
tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
tra.parse(expression='D = A {equal,+} td(A)', basename="d", overwrite=True)
@@ -95,7 +128,7 @@
def test_simple_arith_td_4(self):
- """Simple arithmetic test with if condition"""
+ """Simple arithmetic test"""
tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
tra.parse(expression='D = A {equal,/} td(A)', basename="d", overwrite=True)
@@ -187,7 +220,7 @@
start, end = D.get_absolute_time()
self.assertEqual(start, datetime.datetime(2001, 1, 1))
self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
+
def test_temporal_intersection_1(self):
"""Simple temporal intersection test"""
tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
Modified: grass/branches/releasebranch_7_0/temporal/t.list/t.list.py
===================================================================
--- grass/branches/releasebranch_7_0/temporal/t.list/t.list.py 2014-05-28 11:09:47 UTC (rev 60533)
+++ grass/branches/releasebranch_7_0/temporal/t.list/t.list.py 2014-05-28 11:12:25 UTC (rev 60534)
@@ -81,15 +81,15 @@
import grass.script as grass
import grass.temporal as tgis
+import sys
############################################################################
-
def main():
# Get the options
type = options["type"]
- temporaltype = options["temporaltype"]
+ temporal_type = options["temporaltype"]
columns = options["columns"]
order = options["order"]
where = options["where"]
@@ -99,69 +99,64 @@
# Make sure the temporal database exists
tgis.init()
- id = None
- sp = tgis.dataset_factory(type, id)
-
- dbif = tgis.SQLDatabaseInterfaceConnection()
- dbif.connect()
-
+ sp = tgis.dataset_factory(type, None)
first = True
- for ttype in temporaltype.split(","):
-
- # Create the sql selection statement
- # Table name
+ sys.stderr.write("----------------------------------------------\n")
+
+ for ttype in temporal_type.split(","):
if ttype == "absolute":
- table = sp.get_type() + "_view_abs_time"
+ time = "absolute time"
else:
- table = sp.get_type() + "_view_rel_time"
-
- if columns.find("all") == -1:
- sql = "SELECT " + str(columns) + " FROM " + table
- else:
- sql = "SELECT * FROM " + table
-
- if where:
- sql += " WHERE " + where
-
- if order:
- sql += " ORDER BY " + order
-
- dbif.cursor.execute(sql)
- rows = dbif.cursor.fetchall()
-
- # Print the query result to stout
- if rows:
- if separator is None or separator == "":
- separator = "\t"
-
- # Print the column names if requested
- if colhead == True and first == True:
- output = ""
- count = 0
- for key in rows[0].keys():
- if count > 0:
- output += separator + str(key)
+ time = "relative time"
+
+ stds_list = tgis.get_dataset_list(type, ttype, columns, where, order)
+
+ # Use the correct order of the mapsets, hence first the current mapset, then
+ # alphabetic ordering
+ mapsets = tgis.get_tgis_c_library_interface().available_mapsets()
+
+ # Print for each mapset separately
+ for key in mapsets:
+ if key in stds_list.keys():
+ rows = stds_list[key]
+
+ if rows:
+ if issubclass(sp.__class__, tgis.AbstractMapDataset):
+ sys.stderr.write(_("Time stamped %s maps with %s available in mapset <%s>:\n")%\
+ (sp.get_type(), time, key))
else:
- output += str(key)
- count += 1
- print output
- first = False
-
- for row in rows:
- output = ""
- count = 0
- for col in row:
- if count > 0:
- output += separator + str(col)
- else:
- output += str(col)
- count += 1
-
- print output
+ sys.stderr.write(_("Space time %s datasets with %s available in mapset <%s>:\n")%\
+ (sp.get_new_map_instance(None).get_type(), time, key))
- dbif.close()
-
+ if separator is None or separator == "":
+ separator = "\t"
+
+ # Print the column names if requested
+ if colhead == True and first == True:
+ output = ""
+ count = 0
+ for key in rows[0].keys():
+ if count > 0:
+ output += separator + str(key)
+ else:
+ output += str(key)
+ count += 1
+ print output
+ first = False
+
+ for row in rows:
+ output = ""
+ count = 0
+ for col in row:
+ if count > 0:
+ output += separator + str(col)
+ else:
+ output += str(col)
+ count += 1
+
+ print output
+
if __name__ == "__main__":
options, flags = grass.parser()
main()
Modified: grass/branches/releasebranch_7_0/temporal/t.rast.aggregate/t.rast.aggregate.py
===================================================================
--- grass/branches/releasebranch_7_0/temporal/t.rast.aggregate/t.rast.aggregate.py 2014-05-28 11:09:47 UTC (rev 60533)
+++ grass/branches/releasebranch_7_0/temporal/t.rast.aggregate/t.rast.aggregate.py 2014-05-28 11:12:25 UTC (rev 60534)
@@ -54,6 +54,15 @@
#% answer: average
#%end
+#%option
+#% key: offset
+#% type: integer
+#% description: Offset that is used to create the output map ids, output map id is generated as: basename_ (count + offset)
+#% required: no
+#% multiple: no
+#% answer: 0
+#%end
+
#%option G_OPT_T_SAMPLE
#%end
@@ -82,6 +91,7 @@
register_null = flags["n"]
method = options["method"]
sampling = options["sampling"]
+ offset = options["offset"]
# Make sure the temporal database exists
tgis.init()
@@ -143,7 +153,7 @@
if input_map_names:
new_map = tgis.aggregate_raster_maps(
input_map_names, base, start, end,
- count, method, register_null, dbif)
+ count, method, register_null, dbif, offset)
if new_map:
# Set the time stamp and write it to the raster map
Modified: grass/branches/releasebranch_7_0/temporal/t.rast.aggregate/test.t.rast.aggregate.sh
===================================================================
--- grass/branches/releasebranch_7_0/temporal/t.rast.aggregate/test.t.rast.aggregate.sh 2014-05-28 11:09:47 UTC (rev 60533)
+++ grass/branches/releasebranch_7_0/temporal/t.rast.aggregate/test.t.rast.aggregate.sh 2014-05-28 11:12:25 UTC (rev 60534)
@@ -2,29 +2,37 @@
# Space time raster dataset aggregation
# We need to set a specific region in the
# @preprocess step of this test.
+
+export GRASS_OVERWRITE=1
+
# The region setting should work for UTM and LL test locations
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3
# Generate data
-r.mapcalc --o expr="prec_1 = rand(0, 550)"
-r.mapcalc --o expr="prec_2 = rand(0, 450)"
-r.mapcalc --o expr="prec_3 = rand(0, 320)"
-r.mapcalc --o expr="prec_4 = rand(0, 510)"
-r.mapcalc --o expr="prec_5 = rand(0, 300)"
-r.mapcalc --o expr="prec_6 = rand(0, 650)"
+r.mapcalc expr="prec_1 = rand(0, 550)"
+r.mapcalc expr="prec_2 = rand(0, 450)"
+r.mapcalc expr="prec_3 = rand(0, 320)"
+r.mapcalc expr="prec_4 = rand(0, 510)"
+r.mapcalc expr="prec_5 = rand(0, 300)"
+r.mapcalc expr="prec_6 = rand(0, 650)"
-t.create --o type=strds temporaltype=absolute output=precip_abs1 title="A test" descr="A test"
-t.register -i type=rast input=precip_abs1 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-15 12:05:45" increment="14 days"
+t.create type=strds temporaltype=absolute output=precip_abs1 title="A test" descr="A test"
+t.register -i type=rast input=precip_abs1 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 \
+ start="2001-01-15 12:05:45" increment="14 days"
# The first @test
-
-t.rast.aggregate --o --v input=precip_abs1 output=precip_abs2 base=prec_sum granularity="2 days" method=average sampling=start,during
+t.rast.aggregate --v input=precip_abs1 output=precip_abs2 \
+ base=prec_sum granularity="2 days" method=average sampling=start,during
t.info type=strds input=precip_abs2
-t.rast.aggregate --o --v input=precip_abs1 output=precip_abs2 base=prec_sum granularity="1 months" method=maximum sampling=start,during
+t.rast.aggregate --v input=precip_abs1 output=precip_abs2 \
+ base=prec_sum granularity="1 months" method=maximum sampling=start,during
t.info type=strds input=precip_abs2
-t.rast.aggregate --o --v input=precip_abs1 output=precip_abs2 base=prec_sum granularity="2 months" method=minimum sampling=start,during
+t.rast.aggregate --v input=precip_abs1 output=precip_abs3 offset=10 \
+ base=prec_sum granularity="2 months" method=minimum sampling=start,during
t.info type=strds input=precip_abs2
-t.rast.aggregate --o --v input=precip_abs1 output=precip_abs2 base=prec_sum granularity="3 months" method=sum sampling=start,during
+t.rast.list input=precip_abs3
+t.rast.aggregate --v input=precip_abs1 output=precip_abs4 offset=100 \
+ base=prec_sum granularity="3 months" method=sum sampling=start,during
t.info type=strds input=precip_abs2
+t.rast.list input=precip_abs4
-t.unregister type=rast maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6
-t.remove type=strds input=precip_abs1,precip_abs2
+t.remove -rf type=strds input=precip_abs1,precip_abs2,precip_abs3,precip_abs4
Modified: grass/branches/releasebranch_7_0/temporal/t.rast.aggregate.ds/t.rast.aggregate.ds.py
===================================================================
--- grass/branches/releasebranch_7_0/temporal/t.rast.aggregate.ds/t.rast.aggregate.ds.py 2014-05-28 11:09:47 UTC (rev 60533)
+++ grass/branches/releasebranch_7_0/temporal/t.rast.aggregate.ds/t.rast.aggregate.ds.py 2014-05-28 11:12:25 UTC (rev 60534)
@@ -55,6 +55,15 @@
#% answer: average
#%end
+#%option
+#% key: offset
+#% type: integer
+#% description: Offset that is used to create the output map ids, output map id is generated as: basename_ (count + offset)
+#% required: no
+#% multiple: no
+#% answer: 0
+#%end
+
#%option G_OPT_T_SAMPLE
#%end
@@ -80,6 +89,7 @@
method = options["method"]
type = options["type"]
sampling = options["sampling"]
+ offset = options["offset"]
# Make sure the temporal database exists
tgis.init()
@@ -125,7 +135,7 @@
if input_map_names:
new_map = tgis.aggregate_raster_maps(input_map_names, base,
start, end, count, method,
- register_null, dbif)
+ register_null, dbif, offset)
if new_map:
# Set the time stamp and write it to the raster map
Modified: grass/branches/releasebranch_7_0/temporal/t.rast.aggregate.ds/test.t.rast.aggregate.ds.sh
===================================================================
--- grass/branches/releasebranch_7_0/temporal/t.rast.aggregate.ds/test.t.rast.aggregate.ds.sh 2014-05-28 11:09:47 UTC (rev 60533)
+++ grass/branches/releasebranch_7_0/temporal/t.rast.aggregate.ds/test.t.rast.aggregate.ds.sh 2014-05-28 11:12:25 UTC (rev 60534)
@@ -1,21 +1,23 @@
#!/bin/sh
# Aggregate a dataset by a second one
+export GRASS_OVERWRITE=1
+
# We need to set a specific region in the
# @preprocess step of this test.
# The region setting should work for UTM and LL test locations
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3
-r.mapcalc --o expr="prec_1 = 100"
-r.mapcalc --o expr="prec_2 = 150"
-r.mapcalc --o expr="prec_3 = 250"
-r.mapcalc --o expr="prec_4 = 250"
-r.mapcalc --o expr="prec_5 = 150"
-r.mapcalc --o expr="prec_6 = 100"
+r.mapcalc expr="prec_1 = 100"
+r.mapcalc expr="prec_2 = 150"
+r.mapcalc expr="prec_3 = 250"
+r.mapcalc expr="prec_4 = 250"
+r.mapcalc expr="prec_5 = 150"
+r.mapcalc expr="prec_6 = 100"
-v.random --o -z output=soil_1 n=20 zmin=0 zmax=100 column=height
-v.random --o -z output=soil_2 n=20 zmin=0 zmax=100 column=height
-v.random --o -z output=soil_3 n=20 zmin=0 zmax=100 column=height
+v.random -z output=soil_1 n=20 zmin=0 zmax=100 column=height
+v.random -z output=soil_2 n=20 zmin=0 zmax=100 column=height
+v.random -z output=soil_3 n=20 zmin=0 zmax=100 column=height
n1=`g.tempfile pid=1 -d`
@@ -25,15 +27,18 @@
soil_3|2001-08-01|2001-12-01
EOF
-t.create --o type=stvds temporaltype=absolute output=soil_abs1 title="A test" descr="A test"
+t.create type=stvds temporaltype=absolute output=soil_abs1 title="A test" descr="A test"
t.register type=vect input=soil_abs1 file="${n1}"
-t.create --o type=strds temporaltype=absolute output=precip_abs1 title="A test" descr="A test"
-t.register -i type=rast input=precip_abs1 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-03-01 00:00:00" increment="1 months"
+t.create type=strds temporaltype=absolute output=precip_abs1 title="A test" descr="A test"
+t.register -i type=rast input=precip_abs1 \
+ maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 \
+ start="2001-03-01 00:00:00" increment="1 months"
# The @test
-t.rast.aggregate.ds --o --v input=precip_abs1 output=precip_abs2 base=prec_sum type=stvds sample=soil_abs1 method=sum sampling=start,during
+t.rast.aggregate.ds --v input=precip_abs1 output=precip_abs2 base=prec_sum \
+ type=stvds sample=soil_abs1 method=sum sampling=start,during offset=100
t.info type=strds input=precip_abs2
t.rast.list input=precip_abs2 method=deltagap
@@ -41,6 +46,5 @@
t.unregister type=vect maps=soil_1,soil_2,soil_3
t.remove type=stvds input=soil_abs1
-t.unregister type=rast maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6
-t.remove type=strds input=precip_abs1,precip_abs2
+t.remove -rf type=strds input=precip_abs1,precip_abs2
g.remove vect=soil_1,soil_2,soil_3
Modified: grass/branches/releasebranch_7_0/temporal/t.rast.extract/test.t.rast.extract.sh
===================================================================
--- grass/branches/releasebranch_7_0/temporal/t.rast.extract/test.t.rast.extract.sh 2014-05-28 11:09:47 UTC (rev 60533)
+++ grass/branches/releasebranch_7_0/temporal/t.rast.extract/test.t.rast.extract.sh 2014-05-28 11:12:25 UTC (rev 60534)
@@ -26,8 +26,12 @@
expression=" if(precip_abs1 > 400, precip_abs1, null())" base=new_prec nprocs=4
t.info type=strds input=precip_abs3
-t.rast.extract --o --v input=precip_abs1 output=precip_abs4 where="start_time > '2001-06-01'"
+# Let the test fail
+g.remove rast=prec_1
+
+t.rast.extract --o --v input=precip_abs1 output=precip_abs4 \
+ where="start_time > '2001-01-01'" expr="precip_abs1/1.0"\
+ base=new_test
t.info type=strds input=precip_abs4
-t.unregister type=rast maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6
-t.remove type=strds input=precip_abs1,precip_abs2,precip_abs3,precip_abs4
+t.remove -rf type=strds input=precip_abs1,precip_abs2,precip_abs3
Modified: grass/branches/releasebranch_7_0/temporal/t.rast.gapfill/test.t.rast.gapfill.sh
===================================================================
--- grass/branches/releasebranch_7_0/temporal/t.rast.gapfill/test.t.rast.gapfill.sh 2014-05-28 11:09:47 UTC (rev 60533)
+++ grass/branches/releasebranch_7_0/temporal/t.rast.gapfill/test.t.rast.gapfill.sh 2014-05-28 11:12:25 UTC (rev 60534)
@@ -3,11 +3,14 @@
# We need to set a specific region in the
# @preprocess step of this test.
# The region setting should work for UTM and LL test locations
+
+export GRASS_OVERWRITE=1
+
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3
-r.mapcalc --o expr="prec_1 = 100"
-r.mapcalc --o expr="prec_2 = 300"
-r.mapcalc --o expr="prec_3 = 500"
+r.mapcalc expr="prec_1 = 100"
+r.mapcalc expr="prec_2 = 300"
+r.mapcalc expr="prec_3 = 500"
n1=`g.tempfile pid=1 -d`
@@ -17,7 +20,7 @@
prec_3|2001-05-01|2001-06-01
EOF
-t.create --v --o type=strds temporaltype=absolute output=precip_abs title="A test" descr="A test"
+t.create --v type=strds temporaltype=absolute output=precip_abs title="A test" descr="A test"
t.register --v type=rast input=precip_abs file="${n1}"
# @test
Modified: grass/branches/releasebranch_7_0/temporal/t.rast.mapcalc/test.t.rast.mapcalc.sh
===================================================================
--- grass/branches/releasebranch_7_0/temporal/t.rast.mapcalc/test.t.rast.mapcalc.sh 2014-05-28 11:09:47 UTC (rev 60533)
+++ grass/branches/releasebranch_7_0/temporal/t.rast.mapcalc/test.t.rast.mapcalc.sh 2014-05-28 11:12:25 UTC (rev 60534)
@@ -1,49 +1,55 @@
#!/bin/sh
# Test for t.rast.mapcalc
+export GRASS_OVERWRITE=1
+
# We need to set a specific region in the
# @preprocess step of this test. We generate
# raster with r.mapcalc and create several space time raster datasets
# The region setting should work for UTM and LL test locations
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3
-r.mapcalc --o expr="prec_1 = rand(0, 550)"
-r.mapcalc --o expr="prec_2 = rand(0, 450)"
-r.mapcalc --o expr="prec_3 = rand(0, 320)"
-r.mapcalc --o expr="prec_4 = rand(0, 510)"
-r.mapcalc --o expr="prec_5 = rand(0, 300)"
-r.mapcalc --o expr="prec_6 = rand(0, 650)"
+r.mapcalc expr="prec_1 = rand(0, 550)"
+r.mapcalc expr="prec_2 = rand(0, 450)"
+r.mapcalc expr="prec_3 = rand(0, 320)"
+r.mapcalc expr="prec_4 = rand(0, 510)"
+r.mapcalc expr="prec_5 = rand(0, 300)"
+r.mapcalc expr="prec_6 = rand(0, 650)"
-t.create --o type=strds temporaltype=absolute output=precip_abs1 title="A test" descr="A test"
-t.create --o type=strds temporaltype=absolute output=precip_abs2 title="A test" descr="A test"
-t.register -i --o type=rast input=precip_abs1 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="3 months"
-t.register --o type=rast input=precip_abs2 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6
+t.create type=strds temporaltype=absolute output=precip_abs1 title="A test" descr="A test"
+t.create type=strds temporaltype=absolute output=precip_abs2 title="A test" descr="A test"
+t.register -i type=rast input=precip_abs1 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="3 months"
+t.register type=rast input=precip_abs2 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6
t.info precip_abs1
t.info precip_abs2
# The first @test
-t.rast.mapcalc --o -n inputs=precip_abs1,precip_abs2 output=precip_abs3 \
+t.rast.mapcalc -n inputs=precip_abs1,precip_abs2 output=precip_abs3 \
expression=" precip_abs1 + precip_abs2" base=new_prec \
method=equal nprocs=5
t.info type=strds input=precip_abs3
-t.rast.mapcalc --o -s inputs=precip_abs1,precip_abs2,precip_abs3 output=precip_abs4 \
+t.rast.mapcalc -s inputs=precip_abs1,precip_abs2,precip_abs3 output=precip_abs4 \
expression=" (precip_abs1 + precip_abs2) / precip_abs2" base=new_prec \
method=equal nprocs=5
t.info type=strds input=precip_abs4
-t.rast.mapcalc --o -s inputs=precip_abs1,precip_abs2 output=precip_abs4 \
+t.rast.mapcalc -s inputs=precip_abs1,precip_abs2 output=precip_abs4 \
expression=" (precip_abs1 + precip_abs2) * null()" base=new_prec \
method=equal nprocs=5
t.info type=strds input=precip_abs4
-t.rast.mapcalc --o -sn inputs=precip_abs1,precip_abs2 output=precip_abs4 \
+t.rast.mapcalc -sn inputs=precip_abs1,precip_abs2 output=precip_abs4 \
expression=" (precip_abs1 + precip_abs2) * null()" base=new_prec \
method=equal nprocs=5
t.info type=strds input=precip_abs4
+# Let the test fail
+g.remove rast=prec_1
+t.rast.mapcalc -sn inputs=precip_abs1,precip_abs2 output=precip_abs4 \
+ expression=" (precip_abs1 + precip_abs2) * null()" base=new_prec \
+ method=equal nprocs=5
+
# @postprocess
-t.unregister type=rast maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6
-t.unregister type=rast maps=new_prec_1,new_prec_2,new_prec_3,new_prec_4,new_prec_5,new_prec_6
-t.remove type=strds input=precip_abs1,precip_abs2,precip_abs3,precip_abs4
+t.remove -rf type=strds input=precip_abs1,precip_abs2,precip_abs3,precip_abs4
Modified: grass/branches/releasebranch_7_0/temporal/t.rast.neighbors/t.rast.neighbors.py
===================================================================
--- grass/branches/releasebranch_7_0/temporal/t.rast.neighbors/t.rast.neighbors.py 2014-05-28 11:09:47 UTC (rev 60533)
+++ grass/branches/releasebranch_7_0/temporal/t.rast.neighbors/t.rast.neighbors.py 2014-05-28 11:12:25 UTC (rev 60534)
@@ -135,7 +135,7 @@
new_maps.append(new_map)
mod = copy.deepcopy(neighbor_module)
- mod(input=map.get_id(), output=new_map.get_id())
+ mod(input=str(map.get_id()), output=str(new_map.get_id()))
print(mod.get_bash())
process_queue.put(mod)
Modified: grass/branches/releasebranch_7_0/temporal/t.register/test.t.register.raster.sh
===================================================================
--- grass/branches/releasebranch_7_0/temporal/t.register/test.t.register.raster.sh 2014-05-28 11:09:47 UTC (rev 60533)
+++ grass/branches/releasebranch_7_0/temporal/t.register/test.t.register.raster.sh 2014-05-28 11:12:25 UTC (rev 60534)
@@ -4,6 +4,8 @@
# The raster maps will be registered in different space time raster
# datasets.
+export GRASS_OVERWRITE=1
+
# We need to set a specific region in the
# @preprocess step of this test. We generate
# raster with r.mapcalc and create several space time raster datasets
@@ -11,81 +13,81 @@
# The region setting should work for UTM and LL test locations
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3
-r.mapcalc --o expr="prec_1 = rand(0, 550)"
-r.mapcalc --o expr="prec_2 = rand(0, 450)"
-r.mapcalc --o expr="prec_3 = rand(0, 320)"
-r.mapcalc --o expr="prec_4 = rand(0, 510)"
-r.mapcalc --o expr="prec_5 = rand(0, 300)"
-r.mapcalc --o expr="prec_6 = rand(0, 650)"
+r.mapcalc expr="prec_1 = rand(0, 550)"
+r.mapcalc expr="prec_2 = rand(0, 450)"
+r.mapcalc expr="prec_3 = rand(0, 320)"
+r.mapcalc expr="prec_4 = rand(0, 510)"
+r.mapcalc expr="prec_5 = rand(0, 300)"
+r.mapcalc expr="prec_6 = rand(0, 650)"
# The first @test
# We create the space time raster inputs and register the raster maps with absolute time interval
-t.create --o type=strds temporaltype=absolute output=precip_abs1 title="A test" descr="A test"
-t.create --o type=strds temporaltype=absolute output=precip_abs2 title="A test" descr="A test"
-t.create --o type=strds temporaltype=absolute output=precip_abs3 title="A test" descr="A test"
-t.create --o type=strds temporaltype=absolute output=precip_abs4 title="A test" descr="A test"
-t.create --o type=strds temporaltype=absolute output=precip_abs5 title="A test" descr="A test"
-t.create --o type=strds temporaltype=absolute output=precip_abs6 title="A test" descr="A test"
-t.create --o type=strds temporaltype=absolute output=precip_abs7 title="A test" descr="A test"
+t.create type=strds temporaltype=absolute output=precip_abs1 title="A test" descr="A test"
+t.create type=strds temporaltype=absolute output=precip_abs2 title="A test" descr="A test"
+t.create type=strds temporaltype=absolute output=precip_abs3 title="A test" descr="A test"
+t.create type=strds temporaltype=absolute output=precip_abs4 title="A test" descr="A test"
+t.create type=strds temporaltype=absolute output=precip_abs5 title="A test" descr="A test"
+t.create type=strds temporaltype=absolute output=precip_abs6 title="A test" descr="A test"
+t.create type=strds temporaltype=absolute output=precip_abs7 title="A test" descr="A test"
-t.register --o -i input=precip_abs1 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="1 seconds"
+t.register -i input=precip_abs1 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="1 seconds"
t.info type=strds input=precip_abs1
t.info -g type=strds input=precip_abs1
r.info map=prec_1
t.rast.list input=precip_abs1
t.topology input=precip_abs1
-t.register --o -i input=precip_abs2 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="20 seconds, 5 minutes"
+t.register -i input=precip_abs2 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="20 seconds, 5 minutes"
t.info type=strds input=precip_abs2
t.info -g type=strds input=precip_abs2
r.info map=prec_1
t.rast.list input=precip_abs2
t.topology input=precip_abs2
-t.register --o -i input=precip_abs3 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="8 hours"
+t.register -i input=precip_abs3 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="8 hours"
t.info -g type=strds input=precip_abs3
r.info map=prec_1
t.rast.list input=precip_abs3
t.topology input=precip_abs3
-t.register --o input=precip_abs4 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="3 days"
+t.register input=precip_abs4 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="3 days"
t.info -g type=strds input=precip_abs4
r.info map=prec_1
t.rast.list input=precip_abs4
t.topology input=precip_abs4
-t.register --o input=precip_abs5 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="4 weeks"
+t.register input=precip_abs5 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="4 weeks"
t.info -g type=strds input=precip_abs5
r.info map=prec_1
t.rast.list input=precip_abs5
t.topology input=precip_abs5
-t.register --o input=precip_abs6 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-08-01" increment="2 months"
+t.register input=precip_abs6 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-08-01" increment="2 months"
t.info -g type=strds input=precip_abs6
r.info map=prec_1
t.rast.list input=precip_abs6
t.topology input=precip_abs6
-t.register --o input=precip_abs7 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="20 years, 3 months, 1 days, 4 hours"
+t.register input=precip_abs7 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="20 years, 3 months, 1 days, 4 hours"
t.info -g type=strds input=precip_abs7
r.info map=prec_1
t.rast.list input=precip_abs7
t.topology input=precip_abs7
# Register with different valid time again
-t.register --o input=precip_abs7 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="99 years, 9 months, 9 days, 9 hours"
+t.register input=precip_abs7 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="99 years, 9 months, 9 days, 9 hours"
t.info -g type=strds input=precip_abs7
r.info map=prec_1
t.rast.list input=precip_abs7
t.topology input=precip_abs7
# Register with different valid time again creating an interval
-t.register --o -i input=precip_abs7 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="99 years, 9 months, 9 days, 9 hours"
+t.register -i input=precip_abs7 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="99 years, 9 months, 9 days, 9 hours"
t.info -g type=strds input=precip_abs7
r.info map=prec_1
t.rast.list input=precip_abs7
t.topology input=precip_abs7
-t.register --o input=precip_abs7 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" end="2002-01-01"
+t.register input=precip_abs7 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" end="2002-01-01"
t.info -g type=strds input=precip_abs7
r.info map=prec_1
t.rast.list input=precip_abs7
@@ -93,7 +95,7 @@
# Check for correct errors
# Increment format error
-t.register -i --o input=precip_abs7 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="months"
+t.register -i input=precip_abs7 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="months"
t.unregister type=rast maps=prec_1,prec_2,prec_3
Modified: grass/branches/releasebranch_7_0/temporal/t.select/test.t.select.sh
===================================================================
--- grass/branches/releasebranch_7_0/temporal/t.select/test.t.select.sh 2014-05-28 11:09:47 UTC (rev 60533)
+++ grass/branches/releasebranch_7_0/temporal/t.select/test.t.select.sh 2014-05-28 11:12:25 UTC (rev 60534)
@@ -1,5 +1,7 @@
#!/usr/bin/sh
+export GRASS_OVERWRITE=1
+
# Test for temporal algebra in LatLon location.
n1=`g.tempfile pid=1 -d`
n2=`g.tempfile pid=2 -d`
Modified: grass/branches/releasebranch_7_0/temporal/t.support/t.support.py
===================================================================
--- grass/branches/releasebranch_7_0/temporal/t.support/t.support.py 2014-05-28 11:09:47 UTC (rev 60533)
+++ grass/branches/releasebranch_7_0/temporal/t.support/t.support.py 2014-05-28 11:12:25 UTC (rev 60534)
@@ -130,7 +130,7 @@
else:
# Delete the map from the temporal database
# We need to update all effected space time datasets
- datasets = map.get_registered_datasets(dbif)
+ datasets = map.get_registered_stds(dbif)
if datasets:
for dataset in datasets:
dataset_dict[dataset] = dataset
Modified: grass/branches/releasebranch_7_0/temporal/t.unregister/t.unregister.py
===================================================================
--- grass/branches/releasebranch_7_0/temporal/t.unregister/t.unregister.py 2014-05-28 11:09:47 UTC (rev 60533)
+++ grass/branches/releasebranch_7_0/temporal/t.unregister/t.unregister.py 2014-05-28 11:12:25 UTC (rev 60534)
@@ -131,7 +131,7 @@
else:
# We need to update all datasets after the removement of maps
map.metadata.select(dbif)
- datasets = map.get_registered_datasets(dbif)
+ datasets = map.get_registered_stds(dbif)
# Store all unique dataset ids in a dictionary
if datasets:
for dataset in datasets:
More information about the grass-commit
mailing list