[GRASS-SVN] r55818 - in grass/trunk: lib/python/temporal temporal/t.rast.list temporal/t.rast.mapcalc temporal/t.rast.out.vtk temporal/t.rast.to.rast3 temporal/t.rename temporal/t.support temporal/t.vect.observe.strds
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Apr 15 16:18:28 PDT 2013
Author: huhabla
Date: 2013-04-15 16:18:27 -0700 (Mon, 15 Apr 2013)
New Revision: 55818
Modified:
grass/trunk/lib/python/temporal/abstract_dataset.py
grass/trunk/lib/python/temporal/abstract_space_time_dataset.py
grass/trunk/lib/python/temporal/datetime_math.py
grass/trunk/lib/python/temporal/space_time_datasets_tools.py
grass/trunk/lib/python/temporal/temporal_granularity.py
grass/trunk/temporal/t.rast.list/t.rast.list.py
grass/trunk/temporal/t.rast.list/test.t.rast.list.sh
grass/trunk/temporal/t.rast.mapcalc/test.t.rast.mapcalc.sh
grass/trunk/temporal/t.rast.out.vtk/test.t.rast.out.vtk.sh
grass/trunk/temporal/t.rast.to.rast3/t.rast.to.rast3.py
grass/trunk/temporal/t.rename/test.t.rename.sh
grass/trunk/temporal/t.support/test.t.support.sh
grass/trunk/temporal/t.vect.observe.strds/test.t.vect.observe.strds.layer_bug.sh
Log:
Better handling of space time dataset granularity
Modified: grass/trunk/lib/python/temporal/abstract_dataset.py
===================================================================
--- grass/trunk/lib/python/temporal/abstract_dataset.py 2013-04-15 22:06:58 UTC (rev 55817)
+++ grass/trunk/lib/python/temporal/abstract_dataset.py 2013-04-15 23:18:27 UTC (rev 55818)
@@ -172,7 +172,8 @@
Return True if success or False otherwise
"""
# Check unit
- units = ["years", "months", "days", "hours", "minutes", "seconds"]
+ units = ["year", "years", "month", "months", "day", "days", "hour",
+ "hours", "minute", "minutes", "second", "seconds"]
if unit not in units:
return False
return True
Modified: grass/trunk/lib/python/temporal/abstract_space_time_dataset.py
===================================================================
--- grass/trunk/lib/python/temporal/abstract_space_time_dataset.py 2013-04-15 22:06:58 UTC (rev 55817)
+++ grass/trunk/lib/python/temporal/abstract_space_time_dataset.py 2013-04-15 23:18:27 UTC (rev 55818)
@@ -223,6 +223,11 @@
"""
temporal_type = self.get_temporal_type()
+
+ check = check_granularity_string(granularity, temporal_type)
+ if not check:
+ core.fatal(_("Wrong granularity: \"%s\"") % str(granularity))
+
if temporal_type == "absolute":
self.set_time_to_absolute()
@@ -680,26 +685,40 @@
In case more map information are needed, use the select()
method for each listed object.
- @param gran: The granularity to be used, if None the granularity of
+ @param gran: The granularity string to be used, if None the granularity of
the space time dataset is used.
+ Absolute time has
+ the format "number unit", relative time has the format "number".
+ The unit in case of absolute time can be one of "second, seconds,
+ minute, minutes, hour, hours, day, days, week, weeks, month, months,
+ year, years". The unit of the relative time granule is always the
+ space time dataset unit and can not be changed.
@param dbif: The database interface to be used
@return ordered object list, in case nothing found None is returned
"""
+
dbif, connect = init_dbif(dbif)
obj_list = []
-
+
if gran is None:
gran = self.get_granularity()
+
+ check = check_granularity_string(gran, self.get_temporal_type())
+ if not check:
+ core.fatal(_("Wrong granularity: \"%s\"") % str(gran))
start, end = self.get_valid_time()
+ if start is None or end is None:
+ return None
+
# Time instances and mixed time
is_irregular = False
- # We need to adjust the end time in case the the dataset ha no
+ # We need to adjust the end time in case the the dataset has no
# interval time, so we can catch time instances at the end
if self.get_map_time() != "interval":
is_irregular = True
@@ -715,8 +734,11 @@
else:
next = start + gran
- where = "(start_time <= '%s' and end_time >= '%s')" % (start, next)
-
+ # First we search for intervals that are are equal the granule or contain it
+ where = create_temporal_relation_sql_where_statement(
+ start=start, end=next, use_start=False, use_during=False,
+ use_overlap=False, use_contain=True, use_equal=True,
+ use_follows=False, use_precedes=False)
rows = self.get_registered_maps("id", where, "start_time", dbif)
found_gap = False
@@ -731,8 +753,8 @@
maplist = []
for row in rows:
- # Take the first map
- map = self.get_new_map_instance(rows[0]["id"])
+
+ map = self.get_new_map_instance(row["id"])
if self.is_time_absolute():
map.set_absolute_time(start, next)
@@ -744,33 +766,50 @@
obj_list.append(copy.copy(maplist))
else:
- # We truely found a gap and maybe a time instance
+ # We may found a gap or a gap after a time instance
found_gap = True
- # Searching for time instances with start time in the current
- # granule
- where = "(start_time = '%s')" % (start)
+ # Searching for time instances and intervals that are during the
+ # current granule or overlapping it
+ where = create_temporal_relation_sql_where_statement(
+ start=start, end=next, use_start=True, use_during=True,
+ use_overlap=True, use_contain=False, use_equal=False,
+ use_follows=False, use_precedes=False)
+
+ rows = self.get_registered_maps("id,start_time,end_time", where, "start_time", dbif)
- rows = self.get_registered_maps("id", where, "start_time", dbif)
-
if rows is not None and len(rows) != 0:
+ # No gap if we found something in the granule with intervaltime
if len(rows) > 1:
core.warning(_("More than one map found in a granule. "
"Temporal granularity seems to be invalid or"
" the chosen granularity is not a greatest "
"common divider of all time instances "
"in the dataset."))
-
+
maplist = []
+ count = 0
for row in rows:
- # Take the first map
- map = self.get_new_map_instance(rows[0]["id"])
+ if count == 0:
+ if row["end_time"] is not None or row["start_time"] != start:
+ found_gap = False
+ count += 1
+
+ map = self.get_new_map_instance(row["id"])
if self.is_time_absolute():
- map.set_absolute_time(start, None)
+ if row["end_time"] is not None or row["start_time"] != start:
+ map.set_absolute_time(start, next)
+ else:
+ map.set_absolute_time(start, None)
elif self.is_time_relative():
- map.set_relative_time(start, None,
+
+ if row["end_time"] is not None or row["start_time"] != start:
+ map.set_relative_time(start, next,
self.get_relative_time_unit())
+ else:
+ map.set_relative_time(start, None,
+ self.get_relative_time_unit())
maplist.append(copy.copy(map))
@@ -802,6 +841,7 @@
if connect:
dbif.close()
+
if obj_list:
return obj_list
Modified: grass/trunk/lib/python/temporal/datetime_math.py
===================================================================
--- grass/trunk/lib/python/temporal/datetime_math.py 2013-04-15 22:06:58 UTC (rev 55817)
+++ grass/trunk/lib/python/temporal/datetime_math.py 2013-04-15 23:18:27 UTC (rev 55818)
@@ -132,19 +132,19 @@
if len(inc) < 2:
core.error(_("Wrong increment format: %s") % (increment))
return None
- if inc[1].find("seconds") >= 0:
+ if inc[1].find("seconds") >= 0 or inc[1].find("second") >= 0:
seconds = mult * int(inc[0])
- elif inc[1].find("minutes") >= 0:
+ elif inc[1].find("minutes") >= 0 or inc[1].find("minute") >= 0:
minutes = mult * int(inc[0])
- elif inc[1].find("hours") >= 0:
+ elif inc[1].find("hours") >= 0 or inc[1].find("hour") >= 0:
hours = mult * int(inc[0])
- elif inc[1].find("days") >= 0:
+ elif inc[1].find("days") >= 0 or inc[1].find("day") >= 0:
days = mult * int(inc[0])
- elif inc[1].find("weeks") >= 0:
+ elif inc[1].find("weeks") >= 0 or inc[1].find("week") >= 0:
weeks = mult * int(inc[0])
- elif inc[1].find("months") >= 0:
+ elif inc[1].find("months") >= 0 or inc[1].find("month") >= 0:
months = mult * int(inc[0])
- elif inc[1].find("years") >= 0:
+ elif inc[1].find("years") >= 0 or inc[1].find("year") >= 0:
years = mult * int(inc[0])
else:
core.error(_("Wrong increment format: %s") % (increment))
@@ -277,19 +277,19 @@
granlist.append(granpart.strip().split(" "))
for inc in granlist:
- if inc[1].find("seconds") >= 0:
+ if inc[1].find("seconds") >= 0 or inc[1].find("second") >= 0:
has_seconds = True
- elif inc[1].find("minutes") >= 0:
+ elif inc[1].find("minutes") >= 0 or inc[1].find("minute") >= 0:
has_minutes = True
- elif inc[1].find("hours") >= 0:
+ elif inc[1].find("hours") >= 0 or inc[1].find("hour") >= 0:
has_hours = True
- elif inc[1].find("days") >= 0:
+ elif inc[1].find("days") >= 0 or inc[1].find("day") >= 0:
has_days = True
- elif inc[1].find("weeks") >= 0:
+ elif inc[1].find("weeks") >= 0 or inc[1].find("week") >= 0:
has_weeks = True
- elif inc[1].find("months") >= 0:
+ elif inc[1].find("months") >= 0 or inc[1].find("month") >= 0:
has_months = True
- elif inc[1].find("years") >= 0:
+ elif inc[1].find("years") >= 0 or inc[1].find("year") >= 0:
has_years = True
else:
core.error(_("Wrong granularity format: %s") % (granularity))
Modified: grass/trunk/lib/python/temporal/space_time_datasets_tools.py
===================================================================
--- grass/trunk/lib/python/temporal/space_time_datasets_tools.py 2013-04-15 22:06:58 UTC (rev 55817)
+++ grass/trunk/lib/python/temporal/space_time_datasets_tools.py 2013-04-15 23:18:27 UTC (rev 55818)
@@ -444,7 +444,7 @@
###############################################################################
-def list_maps_of_stds(type, input, columns, order, where, separator, method, header):
+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
@param type: The type of the maps raster, raster3d or vector
@@ -467,6 +467,8 @@
- "gran": List map using the granularity of the space time dataset,
columns are identical to deltagaps
@param header: Set True to print column names
+ @param gran The user defined granule to be used if method=gran is set, in case gran=None the
+ granule of the space time dataset is used
"""
mapset = core.gisenv()["MAPSET"]
@@ -475,12 +477,14 @@
else:
id = input + "@" + mapset
+ dbif, connected = init_dbif(None)
+
sp = dataset_factory(type, id)
- if not sp.is_in_db():
+ if not sp.is_in_db(dbif=dbif):
core.fatal(_("Dataset <%s> not found in temporal database") % (id))
- sp.select()
+ sp.select(dbif=dbif)
if separator is None or separator == "":
separator = "\t"
@@ -492,11 +496,14 @@
else:
columns = "id,name,mapset,start_time,end_time"
if method == "deltagaps":
- maps = sp.get_registered_maps_as_objects_with_gaps(where, None)
+ maps = sp.get_registered_maps_as_objects_with_gaps(where=where, dbif=dbif)
elif method == "delta":
- maps = sp.get_registered_maps_as_objects(where, "start_time", None)
+ maps = sp.get_registered_maps_as_objects(where=where, order="start_time", dbif=dbif)
elif method == "gran":
- maps = sp.get_registered_maps_as_objects_by_granularity(None)
+ if gran is not None and gran != "":
+ maps = sp.get_registered_maps_as_objects_by_granularity(gran=gran, dbif=dbif)
+ else:
+ maps = sp.get_registered_maps_as_objects_by_granularity(dbif=dbif)
if header:
string = ""
@@ -561,7 +568,7 @@
if method == "comma":
columns = "id"
- rows = sp.get_registered_maps(columns, where, order, None)
+ rows = sp.get_registered_maps(columns, where, order, dbif)
if rows:
if method == "comma":
@@ -602,7 +609,8 @@
count += 1
print output
-
+ if connected:
+ dbif.close()
###############################################################################
Modified: grass/trunk/lib/python/temporal/temporal_granularity.py
===================================================================
--- grass/trunk/lib/python/temporal/temporal_granularity.py 2013-04-15 22:06:58 UTC (rev 55817)
+++ grass/trunk/lib/python/temporal/temporal_granularity.py 2013-04-15 23:18:27 UTC (rev 55818)
@@ -24,8 +24,42 @@
from datetime_math import *
###############################################################################
+
+def check_granularity_string(granularity, temporal_type):
+ """!Check if the granularity string is valid
+
+ @param granularity The granularity string
+ @param temporal_type The temporal type of the granularity relative or absolute
+ @return True if valid, False if invalid
+ """
+ temporal_type
+
+ if granularity is None:
+ return False
+ if temporal_type == "absolute":
+ num, unit = granularity.split(" ")
+ if unit not in ["second", "seconds", "minute", "minutes", "hour",
+ "hours", "day", "days", "week", "weeks", "month",
+ "months", "year", "years"]:
+ return False
+
+ try:
+ integer = int(num)
+ except:
+ return False
+ elif temporal_type == "relative":
+ try:
+ integer = int(granularity)
+ except:
+ return False
+ else:
+ return False
+
+ return True
+###############################################################################
+
def compute_relative_time_granularity(maps):
"""!Compute the relative time granularity
@@ -216,17 +250,35 @@
granularity = ulist[0]
if use_seconds:
- return "%i seconds" % granularity
+ if granularity == 1:
+ return "%i second" % granularity
+ else:
+ return "%i seconds" % granularity
elif use_minutes:
- return "%i minutes" % granularity
+ if granularity == 1:
+ return "%i minute" % granularity
+ else:
+ return "%i minutes" % granularity
elif use_hours:
- return "%i hours" % granularity
+ if granularity == 1:
+ return "%i hour" % granularity
+ else:
+ return "%i hours" % granularity
elif use_days:
- return "%i days" % granularity
+ if granularity == 1:
+ return "%i day" % granularity
+ else:
+ return "%i days" % granularity
elif use_months:
- return "%i months" % granularity
+ if granularity == 1:
+ return "%i month" % granularity
+ else:
+ return "%i months" % granularity
elif use_years:
- return "%i years" % granularity
+ if granularity == 1:
+ return "%i year" % granularity
+ else:
+ return "%i years" % granularity
return None
Modified: grass/trunk/temporal/t.rast.list/t.rast.list.py
===================================================================
--- grass/trunk/temporal/t.rast.list/t.rast.list.py 2013-04-15 22:06:58 UTC (rev 55817)
+++ grass/trunk/temporal/t.rast.list/t.rast.list.py 2013-04-15 23:18:27 UTC (rev 55818)
@@ -59,6 +59,14 @@
#%end
#%option
+#% key: granule
+#% type: string
+#% description: The granule to be used for listing. The granule must be specified as string eg.: absolute time "1 months" or relative time "1"
+#% required: no
+#% multiple: no
+#%end
+
+#%option
#% key: separator
#% type: string
#% description: Separator character between the columns, default is tabular "\t"
@@ -85,13 +93,14 @@
where = options["where"]
separator = options["separator"]
method = options["method"]
+ granule = options["granule"]
header = flags["h"]
# Make sure the temporal database exists
tgis.init()
tgis.list_maps_of_stds(
- "strds", input, columns, order, where, separator, method, header)
+ "strds", input, columns, order, where, separator, method, header, granule)
if __name__ == "__main__":
options, flags = grass.parser()
Modified: grass/trunk/temporal/t.rast.list/test.t.rast.list.sh
===================================================================
--- grass/trunk/temporal/t.rast.list/test.t.rast.list.sh 2013-04-15 22:06:58 UTC (rev 55817)
+++ grass/trunk/temporal/t.rast.list/test.t.rast.list.sh 2013-04-15 23:18:27 UTC (rev 55818)
@@ -68,22 +68,25 @@
t.create --o type=strds temporaltype=absolute output=precip_abs0 title="A test with input files" descr="A test with input files"
# The @test
-t.register type=rast --o -i input=precip_abs0 file="${n1}" start="2001-01-01" increment="1 months"
+t.register type=rast --o -i input=precip_abs0 file="${n1}" start="2001-01-01" increment="1 month"
t.rast.list separator=" | " method=comma input=precip_abs0
t.rast.list -h input=precip_abs0
t.rast.list -h separator=" | " method=cols input=precip_abs0
t.rast.list -h separator=" | " method=delta input=precip_abs0
t.rast.list -h separator=" | " method=deltagaps input=precip_abs0
t.rast.list -h separator=" | " method=gran input=precip_abs0
+t.rast.list -h separator=" | " method=gran input=precip_abs0 gran="2 months"
+t.rast.list -h separator=" | " method=gran input=precip_abs0 gran="1 day"
-t.register type=rast --o input=precip_abs0 file="${n1}" start="2001-01-01" increment="1 months"
+t.register type=rast --o input=precip_abs0 file="${n1}" start="2001-01-01" increment="1 month"
t.rast.list separator=" | " method=comma input=precip_abs0
t.rast.list -h input=precip_abs0
t.rast.list -h separator=" | " method=cols input=precip_abs0
t.rast.list -h separator=" | " method=delta input=precip_abs0
t.rast.list -h separator=" | " method=deltagaps input=precip_abs0
-# ERROR: no interval time
t.rast.list -h separator=" | " method=gran input=precip_abs0
+t.rast.list -h separator=" | " method=gran input=precip_abs0 gran="2 months"
+t.rast.list -h separator=" | " method=gran input=precip_abs0 gran="6 days"
t.register type=rast --o -i input=precip_abs0 file="${n2}"
t.rast.list separator=" | " method=comma input=precip_abs0
@@ -92,18 +95,24 @@
t.rast.list -h separator=" | " method=delta input=precip_abs0
t.rast.list -h separator=" | " method=deltagaps input=precip_abs0
t.rast.list -h separator=" | " method=gran input=precip_abs0
+t.rast.list -h separator=" | " method=gran input=precip_abs0 gran="2 months"
+t.rast.list -h separator=" | " method=gran input=precip_abs0 gran="6 days"
t.register type=rast --o -i input=precip_abs0 file="${n3}"
t.rast.list separator=" | " method=comma input=precip_abs0
t.rast.list -h separator=" | " method=delta input=precip_abs0
t.rast.list -h separator=" | " method=deltagaps input=precip_abs0
t.rast.list -h separator=" | " method=gran input=precip_abs0
+t.rast.list -h separator=" | " method=gran input=precip_abs0 gran="2 months"
+t.rast.list -h separator=" | " method=gran input=precip_abs0 gran="6 days"
t.register type=rast --o -i input=precip_abs0 file="${n4}"
t.rast.list separator=" | " method=comma input=precip_abs0
t.rast.list -h separator=" | " method=delta input=precip_abs0
t.rast.list -h separator=" | " method=deltagaps input=precip_abs0
t.rast.list -h separator=" | " method=gran input=precip_abs0
+t.rast.list -h separator=" | " method=gran input=precip_abs0 gran="2 months"
+t.rast.list -h separator=" | " method=gran input=precip_abs0 gran="6 days"
t.register type=rast --o -i input=precip_abs0 file="${n5}"
t.rast.list separator=" | " method=comma input=precip_abs0
@@ -112,6 +121,8 @@
t.rast.list -h separator=" | " method=delta input=precip_abs0
t.rast.list -h separator=" | " method=deltagaps input=precip_abs0
t.rast.list -h separator=" | " method=gran input=precip_abs0
+t.rast.list -h separator=" | " method=gran input=precip_abs0 gran="8 months"
+t.rast.list -h separator=" | " method=gran input=precip_abs0 gran="13 days"
t.unregister type=rast maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6
t.remove type=strds input=precip_abs0
Modified: grass/trunk/temporal/t.rast.mapcalc/test.t.rast.mapcalc.sh
===================================================================
--- grass/trunk/temporal/t.rast.mapcalc/test.t.rast.mapcalc.sh 2013-04-15 22:06:58 UTC (rev 55817)
+++ grass/trunk/temporal/t.rast.mapcalc/test.t.rast.mapcalc.sh 2013-04-15 23:18:27 UTC (rev 55818)
@@ -16,29 +16,29 @@
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 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 -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.info precip_abs1
t.info precip_abs2
# The first @test
-t.rast.mapcalc --o --v -n inputs=precip_abs1,precip_abs2 output=precip_abs3 \
+t.rast.mapcalc --o -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 --v -s inputs=precip_abs1,precip_abs2,precip_abs3 output=precip_abs4 \
+t.rast.mapcalc --o -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 --v -s inputs=precip_abs1,precip_abs2 output=precip_abs4 \
+t.rast.mapcalc --o -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 --v -sn inputs=precip_abs1,precip_abs2 output=precip_abs4 \
+t.rast.mapcalc --o -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
Modified: grass/trunk/temporal/t.rast.out.vtk/test.t.rast.out.vtk.sh
===================================================================
--- grass/trunk/temporal/t.rast.out.vtk/test.t.rast.out.vtk.sh 2013-04-15 22:06:58 UTC (rev 55817)
+++ grass/trunk/temporal/t.rast.out.vtk/test.t.rast.out.vtk.sh 2013-04-15 23:18:27 UTC (rev 55818)
@@ -32,17 +32,17 @@
# The first @test
mkdir /tmp/test1
-t.register -i type=rast input=precip_abs1 file="${n1}"
+t.register -i --o type=rast input=precip_abs1 file="${n1}"
t.rast.out.vtk input=precip_abs1 expdir=/tmp/test1
ls -al /tmp/test1
mkdir /tmp/test2
-t.register -i type=rast input=precip_abs2 file="${n1}"
+t.register -i --o type=rast input=precip_abs2 file="${n1}"
t.rast.out.vtk input=precip_abs2 expdir=/tmp/test2 elevation=elevation
ls -al /tmp/test2
mkdir /tmp/test3
-t.register -i type=rast input=precip_abs3 file="${n1}"
+t.register -i --o type=rast input=precip_abs3 file="${n1}"
t.rast.out.vtk -g input=precip_abs3 expdir=/tmp/test3 elevation=elevation
ls -al /tmp/test3
Modified: grass/trunk/temporal/t.rast.to.rast3/t.rast.to.rast3.py
===================================================================
--- grass/trunk/temporal/t.rast.to.rast3/t.rast.to.rast3.py 2013-04-15 22:06:58 UTC (rev 55817)
+++ grass/trunk/temporal/t.rast.to.rast3/t.rast.to.rast3.py 2013-04-15 23:18:27 UTC (rev 55818)
@@ -84,37 +84,38 @@
if sp.is_time_absolute():
unit = granularity.split(" ")[1]
- granularity = int(granularity.split(" ")[0])
+ granularity = float(granularity.split(" ")[0])
+
+ print "Gran from stds %0.15f"%(granularity)
- if unit == "years":
- bottom = start.year - 1900
- top = granularity * num_maps
- elif unit == "months":
- bottom = (start.year - 1900) * 12 + start.month
- top = granularity * num_maps
+ if unit == "years" or unit == "year":
+ bottom = float(start.year - 1900)
+ top = float(granularity * num_maps)
+ elif unit == "months" or unit == "month":
+ bottom = float((start.year - 1900) * 12 + start.month)
+ top = float(granularity * num_maps)
else:
- bottom = tgis.time_delta_to_relative_time(start - reftime)
- days = 0
- hours = 0
- minutes = 0
- seconds = 0
- if unit == "days":
- days = granularity
- if unit == "hours":
- hours = granularity
- if unit == "minutes":
- minutes = granularity
- if unit == "seconds":
- seconds = granularity
+ bottom = float(tgis.time_delta_to_relative_time(start - reftime))
+ days = 0.0
+ hours = 0.0
+ minutes = 0.0
+ seconds = 0.0
+ if unit == "days" or unit == "day":
+ days = float(granularity)
+ if unit == "hours" or unit == "hour":
+ hours = float(granularity)
+ if unit == "minutes" or unit == "minute":
+ minutes = float(granularity)
+ if unit == "seconds" or unit == "second":
+ seconds = float(granularity)
- granularity = days + hours / 24.0 + minutes / \
- 1440.0 + seconds / 86400.0
+ granularity = float(days + hours / 24.0 + minutes / \
+ 1440.0 + seconds / 86400.0)
else:
unit = sp.get_relative_time_unit()
bottom = start
- top = bottom + granularity * num_maps
-
+ top = float(bottom + granularity * float(num_maps))
ret = grass.run_command("g.region", t=top, b=bottom, tbres=granularity)
if ret != 0:
Modified: grass/trunk/temporal/t.rename/test.t.rename.sh
===================================================================
--- grass/trunk/temporal/t.rename/test.t.rename.sh 2013-04-15 22:06:58 UTC (rev 55817)
+++ grass/trunk/temporal/t.rename/test.t.rename.sh 2013-04-15 23:18:27 UTC (rev 55818)
@@ -12,16 +12,16 @@
# We need to create three space time dataset
t.create --v --o type=strds temporaltype=absolute output=precip_abs1 \
title="Test" descr="This is the 1 test strds" semantictype=sum
-t.register -i input=precip_abs1 maps=prec_1,prec_2 \
+t.register -i --o input=precip_abs1 maps=prec_1,prec_2 \
start="2001-01-01" increment="1 seconds"
t.create --v --o type=strds temporaltype=absolute output=precip_abs2 \
title="Test" descr="This is the 2 test strds" semantictype=sum
-t.register input=precip_abs2 maps=prec_1,prec_2
+t.register --o input=precip_abs2 maps=prec_1,prec_2
t.create --v --o type=strds temporaltype=absolute output=precip_abs3 \
title="Test" descr="This is the 3 test strds" semantictype=sum
-t.register input=precip_abs3 maps=prec_1,prec_2
+t.register --o input=precip_abs3 maps=prec_1,prec_2
t.info precip_abs1
Modified: grass/trunk/temporal/t.support/test.t.support.sh
===================================================================
--- grass/trunk/temporal/t.support/test.t.support.sh 2013-04-15 22:06:58 UTC (rev 55817)
+++ grass/trunk/temporal/t.support/test.t.support.sh 2013-04-15 23:18:27 UTC (rev 55818)
@@ -16,10 +16,10 @@
# @test Register the maps in two space time datasets
t.create --v --o type=strds temporaltype=absolute output=precip_abs1 title="Test" descr="This is the 1 test strds" semantictype=sum
-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.register -i --o input=precip_abs1 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="1 seconds"
t.create --v --o type=strds temporaltype=absolute output=precip_abs2 title="Test" descr="This is the 2 test strds" semantictype=sum
-t.register -i input=precip_abs2 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6
+t.register -i --o input=precip_abs2 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6
t.create --v --o type=strds temporaltype=relative output=precip_rel1 title="Test" descr="This is the 1 test strds" semantictype=min
Modified: grass/trunk/temporal/t.vect.observe.strds/test.t.vect.observe.strds.layer_bug.sh
===================================================================
--- grass/trunk/temporal/t.vect.observe.strds/test.t.vect.observe.strds.layer_bug.sh 2013-04-15 22:06:58 UTC (rev 55817)
+++ grass/trunk/temporal/t.vect.observe.strds/test.t.vect.observe.strds.layer_bug.sh 2013-04-15 23:18:27 UTC (rev 55818)
@@ -2,6 +2,10 @@
# Here we test the limit of the number of layers
# @preprocess
# The region setting should work for UTM and LL test locations
+
+# temporary disabled test for performance reason
+exit
+
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3
MAP_LIST="map_list.txt"
@@ -18,7 +22,7 @@
v.random --o output=prec n=5 seed=1
t.create --o type=strds temporaltype=absolute output=precip_abs1 title="A test" descr="A test"
-t.register -i input=precip_abs1 file=${MAP_LIST} start="2001-01-01 00:00:00" increment="1 hours"
+t.register -i --o input=precip_abs1 file=${MAP_LIST} start="2001-01-01 00:00:00" increment="1 hours"
# The @test
t.vect.observe.strds input=prec strds=precip_abs1 output=prec_observer vector=prec_observer column="test_val"
More information about the grass-commit
mailing list