[GRASS-SVN] r52193 - grass/branches/develbranch_6/scripts/r.colors.stddev

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Jun 23 04:28:29 PDT 2012


Author: hamish
Date: 2012-06-23 04:28:29 -0700 (Sat, 23 Jun 2012)
New Revision: 52193

Modified:
   grass/branches/develbranch_6/scripts/r.colors.stddev/r.colors.stddev
Log:
take advantage of modern r.univar functionality to only need to run it once, speeding up zero-crossing mode by 3 or 4 times

Modified: grass/branches/develbranch_6/scripts/r.colors.stddev/r.colors.stddev
===================================================================
--- grass/branches/develbranch_6/scripts/r.colors.stddev/r.colors.stddev	2012-06-23 09:18:34 UTC (rev 52192)
+++ grass/branches/develbranch_6/scripts/r.colors.stddev/r.colors.stddev	2012-06-23 11:28:29 UTC (rev 52193)
@@ -6,7 +6,7 @@
 #                 New Zealand
 # PURPOSE:      Set color rules based on stddev from a map's mean value.
 #
-# COPYRIGHT:    (c) 2007 Hamish Bowman, and the GRASS Development Team
+# COPYRIGHT:    (c) 2007-2012 Hamish Bowman, and the GRASS Development Team
 #               This program is free software under the GNU General Public
 #               License (>=v2). Read the file COPYING that comes with GRASS
 #               for details.
@@ -45,16 +45,15 @@
 fi
 
 
-eval `r.univar -g "$GIS_OPT_INPUT"`
-# $? is result of the eval not r.univar (???)
-#if [ $? -ne 0 ] ; then
-#   g.region -e "Problem running r.univar"
-#   exit 1
-#fi
+if [ $GIS_FLAG_Z -eq 0 ] ; then
 
+   eval `r.univar -g "$GIS_OPT_INPUT"`
+   # $? is result of the eval not r.univar (???)
+   #if [ $? -ne 0 ] ; then
+   #   g.message -e "Problem running r.univar"
+   #   exit 1
+   #fi
 
-if [ $GIS_FLAG_Z -eq 0 ] ; then
-
    MEAN_MINUS_2STDEV=`echo "$mean $stddev" | awk '{print $1 - 2*$2}'`
    MEAN_PLUS_2STDEV=`echo "$mean $stddev" | awk '{print $1 + 2*$2}'`
 
@@ -102,9 +101,17 @@
    r.mapcalc "r_col_stdev_abs_$$ = abs($GIS_OPT_INPUT)"
    eval `r.info -r "r_col_stdev_abs_$$"`
 
-   # current r.univar truncates percentage to the base integer
-   STDDEV2=`r.univar -eg "r_col_stdev_abs_$$" perc=95.4500 | grep ^percentile | cut -f2 -d=`
+   SIGMA1=68.2689
+   SIGMA2=95.4500
+   SIGMA3=99.7300
 
+   eval `r.univar -eg "r_col_stdev_abs_$$" perc="$SIGMA1,$SIGMA2,$SIGMA3" | grep '^percentile'`
+
+   STDDEV1="$percentile_68_2689"
+   STDDEV2="$percentile_95_45"
+   STDDEV3="$percentile_99_73"
+
+
    if [ $GIS_FLAG_B -eq 0 ] ; then
      # zero centered smooth blue/white/red
      r.colors "$GIS_OPT_INPUT" color=rules << EOF
@@ -117,10 +124,6 @@
    else
      # zero centered banded  black/red/yellow/green/yellow/red/black
 
-     # current r.univar truncates percentage to the base integer
-     STDDEV1=`r.univar -eg "r_col_stdev_abs_$$" perc=68.2689 | grep ^percentile | cut -f2 -d=`
-     STDDEV3=`r.univar -eg "r_col_stdev_abs_$$" perc=99.7300 | grep ^percentile | cut -f2 -d=`
-
      # >3 S.D. outliers colored black so they show up in d.histogram w/ white background
      r.colors "$GIS_OPT_INPUT" color=rules << EOF
        -$max black



More information about the grass-commit mailing list