[GRASS-SVN] r59299 - grass-addons/grass6/raster/r.stack
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Mar 23 23:57:19 PDT 2014
Author: hamish
Date: 2014-03-23 23:57:18 -0700 (Sun, 23 Mar 2014)
New Revision: 59299
Modified:
grass-addons/grass6/raster/r.stack/r.stack
Log:
optionally use r.patch.many to speed up processing
Modified: grass-addons/grass6/raster/r.stack/r.stack
===================================================================
--- grass-addons/grass6/raster/r.stack/r.stack 2014-03-24 01:07:29 UTC (rev 59298)
+++ grass-addons/grass6/raster/r.stack/r.stack 2014-03-24 06:57:18 UTC (rev 59299)
@@ -40,7 +40,18 @@
#% description: Name for output raster map
#% gisprompt: new,cell,raster
#%End
+#%Option
+#% key: workers
+#% type: integer
+#% multiple: no
+#% key_desc: value
+#% label: Number of parallel sessions
+#% description: Set to 0 to run serially (default).
+#% options: 0-2048
+#% answer: 0
+#%End
+
if [ -z "$GISBASE" ] ; then
echo "You must be in GRASS GIS to run this program." 1>&2
exit 1
@@ -66,6 +77,11 @@
exit 1
fi
+if [ "$GIS_OPT_WORKERS" -ne 0 ] && [ ! -x "`which r.patch.many`" ] ; then
+ g.message "r.patch.many addon required, please install it first"
+ exit 1
+fi
+
# set environment so that awk works properly from all locales
unset LC_ALL
LC_NUMERIC=C
@@ -104,6 +120,12 @@
g.region s="$NEW_SOUTH"
#g.copy maps>1 to temporary maps, and set their bounds
+
+############
+# We make the stack vertical because empty rows are skipped
+# over quickly during processing, while empty columns are not.
+############
+
g.message "Preparation ..."
NUM=0
ORIG_IFS="$IFS"
@@ -130,10 +152,12 @@
g.message "Patching ..."
-# todo?: if number of maps,rows is excessive, perhaps it is more efficient to
-# build up by chunks, then patch the chunks together.
-# Empty rows are skipped over quickly though. (this is why the stack is vertical)
-r.patch input="$FIRST_MAP,$TEMP_MAPS" output="$GIS_OPT_OUTPUT"
+if [ "$GIS_OPT_WORKERS" -eq 0 ] ; then
+ r.patch input="$FIRST_MAP,$TEMP_MAPS" output="$GIS_OPT_OUTPUT"
+else
+ r.patch.many input="$FIRST_MAP,$TEMP_MAPS" output="$GIS_OPT_OUTPUT" \
+ workers="$GIS_OPT_WORKERS"
+fi
# r.patch uses the color map from the first map, which is unwanted here.
#r.colors -r "$GIS_OPT_OUTPUT"
More information about the grass-commit
mailing list