[GRASS-SVN] r67581 - grass/trunk/temporal/t.rast.aggregate.ds

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jan 14 15:19:40 PST 2016


Author: neteler
Date: 2016-01-14 15:19:40 -0800 (Thu, 14 Jan 2016)
New Revision: 67581

Modified:
   grass/trunk/temporal/t.rast.aggregate.ds/t.rast.aggregate.ds.html
Log:
t.rast.aggregate.ds manual: example for MODIS 8-day aggregation (contributed by Vero Andreo)

Modified: grass/trunk/temporal/t.rast.aggregate.ds/t.rast.aggregate.ds.html
===================================================================
--- grass/trunk/temporal/t.rast.aggregate.ds/t.rast.aggregate.ds.html	2016-01-14 23:10:46 UTC (rev 67580)
+++ grass/trunk/temporal/t.rast.aggregate.ds/t.rast.aggregate.ds.html	2016-01-14 23:19:40 UTC (rev 67581)
@@ -12,8 +12,10 @@
 It defines the temporal relations hips between intervals of the sampling 
 dataset and the input space time raster dataset.
 
-<h2>EXAMPLE</h2>
+<h2>EXAMPLES</h2>
 
+<h3>Precipitation aggregation</h3>
+
 In this example we create 7 raster maps that will be registered in a 
 single space time raster dataset named <em>precipitation_daily</em> 
 using a daily temporal granularity. The names of the raster maps are 
@@ -38,7 +40,7 @@
 MAPS="map_1 map_2 map_3 map_4 map_5 map_6 map_7"
 
 for map in ${MAPS} ; do
-    r.mapcalc --o expression="${map} = 1" 
+    r.mapcalc expression="${map} = 1" 
     echo ${map} >> map_list.txt 
 done
 
@@ -240,6 +242,114 @@
  +----------------------------------------------------------------------------+
 </pre></div>
 
+<h3>MODIS satellite sensor daily data aggregation to 8 days</h3>
+
+In this example the aggregation from daily data to eight days is shown.
+This "eight-day week" is used in some MODIS satellite sensor products.
+
+<div class="code"><pre>
+# NOTE: the example is written in shell language
+
+# create maps every 8 days as seed maps
+for year in `seq 2000 2001` ; do
+   for doy in `seq -w 1 8 365` ; do 
+      r.mapcalc -s expression="8day_${year}_${doy} = rand(0.0,40.0)"
+   done
+done
+
+# From de name of each map, we take year and doy, and convert it
+# to a YYYY-MM-DD date for start and end, and create a file with
+# mapnames, start date and end date
+
+g.list type=raster pattern=8day_20??_* > names_list
+
+for NAME in `cat names_list` ; do
+   
+   # Parse
+   YEAR=`echo $NAME | cut -d'_' -f2`
+   DOY=`echo $NAME | cut -d'_' -f3`
+   
+   # convert YYYY_DOY to YYYY-MM-DD
+   DOY=`echo "$DOY" | sed 's/^0*//'`
+   doy_end=0
+
+   if [ $DOY -le "353" ] ; then
+      doy_end=$(( $DOY + 8 ))
+   elif [ $DOY -eq "361" ] ; then 
+      if [ $[$YEAR % 4] -eq 0 ] && [ $[$YEAR % 100] -ne 0 ] || [ $[$YEAR % 400] -eq 0 ] ; then
+         doy_end=$(( $DOY + 6 ))
+      else
+	     doy_end=$(( $DOY + 5 ))
+      fi
+   fi
+
+   DATE_START=`date -d "${YEAR}-01-01 +$(( ${DOY} - 1 ))days" +%Y-%m-%d`
+   DATE_END=`date -d "${YEAR}-01-01 +$(( ${doy_end} -1 ))days" +%Y-%m-%d`
+   
+   # text file with mapnames, start date and end date
+   echo "$NAME|$DATE_START|$DATE_END" >> list_map_start_end_time.txt
+         
+done
+
+# check the list created. 
+cat list_map_start_end_time.txt
+8day_2000_001|2000-01-01|2000-01-09
+8day_2000_009|2000-01-09|2000-01-17
+...
+8day_2000_353|2000-12-18|2000-12-26
+8day_2000_361|2000-12-26|2001-01-01
+8day_2001_001|2001-01-01|2001-01-09
+8day_2001_009|2001-01-09|2001-01-17
+...
+8day_2001_345|2001-12-11|2001-12-19
+8day_2001_353|2001-12-19|2001-12-27
+8day_2001_361|2001-12-27|2002-01-01
+
+# all maps except for the last map in each year represent 8-days 
+# intervals. But the aggregation starts all over again every 
+# January 1st.
+
+# create 8-day MODIS-like strds
+t.create type=strds temporaltype=absolute \
+   output=8day_ts title="8 day time series" \
+   description="STRDS with MODIS like 8 day aggregation"
+ 
+# register maps
+t.register type=raster input=8day_ts \
+   file=list_map_start_end_time.txt
+
+# check
+t.info input=8day_ts
+t.rast.list input=8day_ts
+
+# finally, copy the aggregation to a daily time series
+t.rast.aggregate.ds -s input=daily_ts sample=8day_ts \
+   output=8day_agg basename=8day_agg \
+   method=average sampling=contains
+
+# add metadata
+t.support input=8day_agg \
+   title="8 day aggregated ts" \
+   description="8 day MODIS-like aggregated dataset"
+
+# check map list in newly created aggregated strds
+t.rast.list input=8day_agg
+name|mapset|start_time|end_time
+8day_agg_2000_01_01|modis|2000-01-01 00:00:00|2000-01-09 00:00:00
+8day_agg_2000_01_09|modis|2000-01-09 00:00:00|2000-01-17 00:00:00
+8day_agg_2000_01_17|modis|2000-01-17 00:00:00|2000-01-25 00:00:00
+...
+8day_agg_2000_12_18|modis|2000-12-18 00:00:00|2000-12-26 00:00:00
+8day_agg_2000_12_26|modis|2000-12-26 00:00:00|2001-01-01 00:00:00
+8day_agg_2001_01_01|modis|2001-01-01 00:00:00|2001-01-09 00:00:00
+...
+8day_agg_2001_12_11|modis|2001-12-11 00:00:00|2001-12-19 00:00:00
+8day_agg_2001_12_19|modis|2001-12-19 00:00:00|2001-12-27 00:00:00
+8day_agg_2001_12_27|modis|2001-12-27 00:00:00|2002-01-01 00:00:00
+</pre></div>
+
+
+
 <h2>SEE ALSO</h2>
 
 <em>



More information about the grass-commit mailing list