[GRASS-SVN] r57150 - in grass/trunk/temporal: t.info t.list t.merge t.rast.gapfill

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jul 15 08:28:03 PDT 2013


Author: huhabla
Date: 2013-07-15 08:28:03 -0700 (Mon, 15 Jul 2013)
New Revision: 57150

Modified:
   grass/trunk/temporal/t.info/t.info.html
   grass/trunk/temporal/t.list/t.list.html
   grass/trunk/temporal/t.merge/t.merge.html
   grass/trunk/temporal/t.rast.gapfill/t.rast.gapfill.html
   grass/trunk/temporal/t.rast.gapfill/t.rast.gapfill.py
Log:
Documentation update and t.rast.gapfill map overwrite handling corrected.


Modified: grass/trunk/temporal/t.info/t.info.html
===================================================================
--- grass/trunk/temporal/t.info/t.info.html	2013-07-15 15:08:59 UTC (rev 57149)
+++ grass/trunk/temporal/t.info/t.info.html	2013-07-15 15:28:03 UTC (rev 57150)
@@ -33,7 +33,7 @@
  | SQL template path:.......... /home/soeren/src/grass7.0/grass_trunk/dist.x86_64-unknown-linux-gnu/etc/sql
  +----------------------------------------------------------------------------+
 
-r.mapcalc --o expr="map1 = rand(0, 10)" 
+r.mapcalc expr="map1 = rand(0, 10)" 
 
 t.create type=strds temporaltype=absolute \
          output=precipitation_daily \

Modified: grass/trunk/temporal/t.list/t.list.html
===================================================================
--- grass/trunk/temporal/t.list/t.list.html	2013-07-15 15:08:59 UTC (rev 57149)
+++ grass/trunk/temporal/t.list/t.list.html	2013-07-15 15:28:03 UTC (rev 57150)
@@ -10,6 +10,41 @@
 be printed for each dataset and the order of the datasets. In addition a SQL WHERE statement can
 be specified to select a subset of the requested datasets.
 
+
+<h2>Examples</h2>
+
+In this example we will create 3 raster maps and register them first only in the
+temporal database an then in the newly created space time raster dataset.
+We use t.list to show what maps are already in the 
+
+<div class="code"><pre>
+r.mapcalc expr="map1 = rand(0, 10)" 
+r.mapcalc expr="map2 = rand(10, 20)" 
+r.mapcalc expr="map3 = rand(20, 30)" 
+
+t.register type=rast maps=map1 start=2012-08-20 end=2012-08-21
+t.register type=rast maps=map2 start=2012-08-21 end=2012-08-22
+t.register type=rast maps=map3 start=2012-08-22 end=2012-08-23
+
+t.list rast
+
+map1 at soeren
+map2 at soeren
+map3 at soeren
+
+t.create type=strds temporaltype=absolute \
+         output=precipitation_daily \
+         title="Daily precipitation" \
+         description="Test dataset with daily precipitation"
+         
+t.register type=rast input=precipitation_daily maps=map1,map2,map3
+
+t.list strds
+
+precipitation_daily at soeren
+
+</pre></div>
+
 <h2>SEE ALSO</h2>
 
 <em>

Modified: grass/trunk/temporal/t.merge/t.merge.html
===================================================================
--- grass/trunk/temporal/t.merge/t.merge.html	2013-07-15 15:08:59 UTC (rev 57149)
+++ grass/trunk/temporal/t.merge/t.merge.html	2013-07-15 15:28:03 UTC (rev 57150)
@@ -10,6 +10,192 @@
 Maps from the input space time datasets will be registered only once in the 
 output space time dataset, hence the same maps can be registered in different input space time datasets.
 
+<h2>Examples</h2>
+
+In this example we will create two space time raster datasets and register 
+two unique maps in each of it. Then we merge the two space time raster
+datasets together.
+
+<div class="code"><pre>
+r.mapcalc expr="map1 = rand(0, 10)" 
+r.mapcalc expr="map2 = rand(10, 20)" 
+
+t.create type=strds temporaltype=absolute \
+         output=precipitation_daily_1 \
+         title="Daily precipitation" \
+         description="Test dataset with daily precipitation"
+
+t.register -i type=rast input=precipitation_daily_1 \
+           maps=map1,map2 start=2012-08-20 increment="1 days"
+
+t.info precipitation_daily_1
+
+ +-------------------- Space Time Raster Dataset -----------------------------+
+ |                                                                            |
+ +-------------------- Basic information -------------------------------------+
+ | Id: ........................ precipitation_daily_1 at soeren
+ | Name: ...................... precipitation_daily_1
+ | Mapset: .................... soeren
+ | Creator: ................... soeren
+ | Creation time: ............. 2013-07-15 16:05:36.198668
+ | Temporal type: ............. absolute
+ | Semantic type:.............. mean
+ +-------------------- Absolute time -----------------------------------------+
+ | Start time:................. 2012-08-20 00:00:00
+ | End time:................... 2012-08-22 00:00:00
+ | Granularity:................ 1 day
+ | Temporal type of maps:...... interval
+ +-------------------- Spatial extent ----------------------------------------+
+ | North:...................... 90.0
+ | South:...................... -90.0
+ | East:.. .................... 180.0
+ | West:....................... -180.0
+ | Top:........................ 0.0
+ | Bottom:..................... 0.0
+ +-------------------- Metadata information ----------------------------------+
+ | Raster register table:...... precipitation_daily_1_soeren_raster_register
+ | North-South resolution min:. 1.0
+ | North-South resolution max:. 1.0
+ | East-west resolution min:... 1.0
+ | East-west resolution max:... 1.0
+ | Minimum value min:.......... 0.0
+ | Minimum value max:.......... 10.0
+ | Maximum value min:.......... 9.0
+ | Maximum value max:.......... 19.0
+ | Number of registered maps:.. 2
+ |
+ | Title:
+ | Daily precipitation
+ | Description:
+ | Test dataset with daily precipitation
+ | Command history:
+ | # 2013-07-15 16:05:36 
+ | t.create type="strds" temporaltype="absolute"
+ |     output="precipitation_daily_1" title="Daily precipitation"
+ |     description="Test dataset with daily precipitation"
+ | # 2013-07-15 16:05:36 
+ | t.register -i type="rast"
+ |     input="precipitation_daily_1" maps="map1,map2" start="2012-08-20"
+ |     increment="1 days"
+ | 
+ +----------------------------------------------------------------------------+
+
+r.mapcalc expr="map3 = rand(20, 30)" 
+r.mapcalc expr="map4 = rand(30, 40)" 
+
+t.create type=strds temporaltype=absolute \
+         output=precipitation_daily_2 \
+         title="Daily precipitation" \
+         description="Test dataset with daily precipitation"
+
+t.register -i type=rast input=precipitation_daily_2 \
+           maps=map3,map4 start=2012-08-22 increment="1 days"
+
+t.info precipitation_daily_2
+
+ +-------------------- Space Time Raster Dataset -----------------------------+
+ |                                                                            |
+ +-------------------- Basic information -------------------------------------+
+ | Id: ........................ precipitation_daily_2 at soeren
+ | Name: ...................... precipitation_daily_2
+ | Mapset: .................... soeren
+ | Creator: ................... soeren
+ | Creation time: ............. 2013-07-15 16:05:37.430380
+ | Temporal type: ............. absolute
+ | Semantic type:.............. mean
+ +-------------------- Absolute time -----------------------------------------+
+ | Start time:................. 2012-08-22 00:00:00
+ | End time:................... 2012-08-24 00:00:00
+ | Granularity:................ 1 day
+ | Temporal type of maps:...... interval
+ +-------------------- Spatial extent ----------------------------------------+
+ | North:...................... 90.0
+ | South:...................... -90.0
+ | East:.. .................... 180.0
+ | West:....................... -180.0
+ | Top:........................ 0.0
+ | Bottom:..................... 0.0
+ +-------------------- Metadata information ----------------------------------+
+ | Raster register table:...... precipitation_daily_2_soeren_raster_register
+ | North-South resolution min:. 1.0
+ | North-South resolution max:. 1.0
+ | East-west resolution min:... 1.0
+ | East-west resolution max:... 1.0
+ | Minimum value min:.......... 20.0
+ | Minimum value max:.......... 30.0
+ | Maximum value min:.......... 29.0
+ | Maximum value max:.......... 39.0
+ | Number of registered maps:.. 2
+ |
+ | Title:
+ | Daily precipitation
+ | Description:
+ | Test dataset with daily precipitation
+ | Command history:
+ | # 2013-07-15 16:05:37 
+ | t.create type="strds" temporaltype="absolute"
+ |     output="precipitation_daily_2" title="Daily precipitation"
+ |     description="Test dataset with daily precipitation"
+ | # 2013-07-15 16:05:37 
+ | t.register -i type="rast"
+ |     input="precipitation_daily_2" maps="map3,map4" start="2012-08-22"
+ |     increment="1 days"
+ | 
+ +----------------------------------------------------------------------------+
+
+t.merge input=precipitation_daily_1,precipitation_daily_2 \
+        output=precipitation_daily_3
+
+t.info precipitation_daily_3
+
+ +-------------------- Space Time Raster Dataset -----------------------------+
+ |                                                                            |
+ +-------------------- Basic information -------------------------------------+
+ | Id: ........................ precipitation_daily_3 at soeren
+ | Name: ...................... precipitation_daily_3
+ | Mapset: .................... soeren
+ | Creator: ................... soeren
+ | Creation time: ............. 2013-07-15 16:07:47.292784
+ | Temporal type: ............. absolute
+ | Semantic type:.............. mean
+ +-------------------- Absolute time -----------------------------------------+
+ | Start time:................. 2012-08-20 00:00:00
+ | End time:................... 2012-08-24 00:00:00
+ | Granularity:................ 1 day
+ | Temporal type of maps:...... interval
+ +-------------------- Spatial extent ----------------------------------------+
+ | North:...................... 90.0
+ | South:...................... -90.0
+ | East:.. .................... 180.0
+ | West:....................... -180.0
+ | Top:........................ 0.0
+ | Bottom:..................... 0.0
+ +-------------------- Metadata information ----------------------------------+
+ | Raster register table:...... precipitation_daily_3_soeren_raster_register
+ | North-South resolution min:. 1.0
+ | North-South resolution max:. 1.0
+ | East-west resolution min:... 1.0
+ | East-west resolution max:... 1.0
+ | Minimum value min:.......... 0.0
+ | Minimum value max:.......... 30.0
+ | Maximum value min:.......... 9.0
+ | Maximum value max:.......... 39.0
+ | Number of registered maps:.. 4
+ |
+ | Title:
+ | Merged space time dataset
+ | Description:
+ | Merged space time dataset
+ | Command history:
+ | # 2013-07-15 16:07:47 
+ | t.merge
+ |     input="precipitation_daily_1,precipitation_daily_2"
+ |     output="precipitation_daily_3"
+ | 
+ +----------------------------------------------------------------------------+
+
+</pre></div>
+
 <h2>SEE ALSO</h2>
 
 <em>

Modified: grass/trunk/temporal/t.rast.gapfill/t.rast.gapfill.html
===================================================================
--- grass/trunk/temporal/t.rast.gapfill/t.rast.gapfill.html	2013-07-15 15:08:59 UTC (rev 57149)
+++ grass/trunk/temporal/t.rast.gapfill/t.rast.gapfill.html	2013-07-15 15:28:03 UTC (rev 57150)
@@ -1,10 +1,72 @@
 <h2>DESCRIPTION</h2>
 
-TBD.
+This modules fills temporal gaps in space time raster datasets using linear 
+interpolation. Temporal gaps will be detected all gaps in the input space time 
+raster dataset automatically. The predecessor and successor maps of the gaps 
+will be identified and are used to linear interpolate the raster map between
+them. 
 
+<h2>Note</h2>
+This module uses <a href="r.series.interpol.html">r.series.interpol</a> to
+perform the interpolation for each gap independently. Hence several interpolation
+processes can be run in parallel.
+<h2>Examples</h2>
+
+In this example we will create 3 raster maps and register them in the
+temporal database an then in the newly created space time raster dataset.
+There are gaps of one day size between the raster maps. The values of
+the maps are chosen so that the interpolated values can be estimated.
+We expect to maps with values 2 and 4 after interpolation, since we have two gaps.
+
+<div class="code"><pre>
+r.mapcalc expr="map1 = 1" 
+r.mapcalc expr="map2 = 3" 
+r.mapcalc expr="map3 = 5" 
+
+t.register type=rast maps=map1 start=2012-08-20 end=2012-08-21
+t.register type=rast maps=map2 start=2012-08-22 end=2012-08-23
+t.register type=rast maps=map3 start=2012-08-24 end=2012-08-25
+
+t.create type=strds temporaltype=absolute \
+         output=precipitation_daily \
+         title="Daily precipitation" \
+         description="Test dataset with daily precipitation"
+         
+t.register type=rast input=precipitation_daily maps=map1,map2,map3
+
+t.rast.list -h input=precipitation_daily columns=name,start_time,min,max
+
+name    start_time  min max
+map1    2012-08-20 00:00:00 1.0 1.0
+map2    2012-08-22 00:00:00 3.0 3.0
+map3    2012-08-24 00:00:00 5.0 5.0
+
+t.rast.list -h input=precipitation_daily method=deltagaps
+
+id  name    mapset  start_time  end_time    interval_length distance_from_begin
+map1 at soeren map1    soeren  2012-08-20 00:00:00 2012-08-21 00:00:00 1.0 0.0
+None        None    None    2012-08-21 00:00:00 2012-08-22 00:00:00 1.0 1.0
+map2 at soeren map2    soeren  2012-08-22 00:00:00 2012-08-23 00:00:00 1.0 2.0
+None        None    None    2012-08-23 00:00:00 2012-08-24 00:00:00 1.0 3.0
+map3 at soeren map3    soeren  2012-08-24 00:00:00 2012-08-25 00:00:00 1.0 4.0
+
+t.rast.gapfill input=precipitation_daily base=gap
+
+t.rast.list -h input=precipitation_daily columns=name,start_time,min,max
+
+name    start_time  min max
+map1    2012-08-20 00:00:00 1.0 1.0
+gap_6   2012-08-21 00:00:00 2.0 2.0
+map2    2012-08-22 00:00:00 3.0 3.0
+gap_7   2012-08-23 00:00:00 4.0 4.0
+map3    2012-08-24 00:00:00 5.0 5.0
+
+</pre></div>
+
 <h2>SEE ALSO</h2>
 
 <em>
+<a href="r.series.interpol.html">r.series.interpol</a>,
 <a href="t.create.html">t.create</a>,
 <a href="t.info.html">t.info</a>
 </em>

Modified: grass/trunk/temporal/t.rast.gapfill/t.rast.gapfill.py
===================================================================
--- grass/trunk/temporal/t.rast.gapfill/t.rast.gapfill.py	2013-07-15 15:08:59 UTC (rev 57149)
+++ grass/trunk/temporal/t.rast.gapfill/t.rast.gapfill.py	2013-07-15 15:28:03 UTC (rev 57150)
@@ -49,6 +49,7 @@
 #%end
 
 from multiprocessing import Process
+import copy
 import grass.script as grass
 import grass.temporal as tgis
 
@@ -89,6 +90,7 @@
     num = len(maps)
 
     gap_list = []
+    overwrite_flags = {}
 
     # Identify all gaps and create new names
     count = 0
@@ -97,9 +99,15 @@
             count += 1
             _id = "%s_%d@%s" % (base, num + count, mapset)
             _map.set_id(_id)
+            overwrite_flags[_id] = False
             if _map.map_exists() or _map.is_in_db(dbif):
-                grass.fatal(_("Map with name <%s> already exists. "
-                              "Please use another base name." % (_id)))
+                if not grass.overwrite:
+                        grass.fatal(_("Map with name <%s> already exists. "
+                                      "Please use another base name." % (_id)))
+                else:
+                    if _map.is_in_db(dbif):
+                        overwrite_flags[_id] = True
+                        
 
             gap_list.append(_map)
 
@@ -108,7 +116,7 @@
         return
 
     # Build the temporal topology
-    tb = tgis.temporal_topology_builder()
+    tb = tgis.SpatioTemporalTopologyBuilder()
     tb.build(maps)
 
     # Do some checks before computation
@@ -162,6 +170,20 @@
 
     # Insert new interpolated maps in temporal database and dataset
     for _map in gap_list:
+        id = _map.get_id()
+        if overwrite_flags[id] == True:
+            if _map.is_time_absolute():
+                start, end, tz = _map.get_absolute_time()
+                if _map.is_in_db():
+                    _map.delete(dbif)
+                _map = sp.get_new_map_instance(id)
+                _map.set_absolute_time(start, end, tz)
+            else:
+                start, end, unit = _map.get_relative_time()
+                if _map.is_in_db():
+                    _map.delete(dbif)
+                _map = sp.get_new_map_instance(id)
+                _map.set_relative_time(start, end, tz)
         _map.load()
         _map.insert(dbif)
         sp.register_map(_map, dbif)



More information about the grass-commit mailing list