[GRASS-SVN] r58632 - grass-addons/grass7/raster/r.diversity

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jan 6 16:39:18 PST 2014


Author: lucadelu
Date: 2014-01-06 16:39:17 -0800 (Mon, 06 Jan 2014)
New Revision: 58632

Modified:
   grass-addons/grass7/raster/r.diversity/r.diversity.py
Log:
fix indentation, remove unused code

Modified: grass-addons/grass7/raster/r.diversity/r.diversity.py
===================================================================
--- grass-addons/grass7/raster/r.diversity/r.diversity.py	2014-01-07 00:03:52 UTC (rev 58631)
+++ grass-addons/grass7/raster/r.diversity/r.diversity.py	2014-01-07 00:39:17 UTC (rev 58632)
@@ -60,6 +60,7 @@
 #% options: simpson,shannon,pielou,renyi
 #% multiple: yes
 #% description: Name of methods to use
+#% answer: simpson,shannon,pielou,renyi
 #% required: no
 #%end
 #%option
@@ -106,6 +107,8 @@
 
     if alpha != '':
         alpha_value = checkValues(alpha, True)
+    else:
+        alpha_value = ''
 
     # check if ~/.r.li path exists
     if not os.path.exists(rlidir):
@@ -122,13 +125,6 @@
     # if method and exclude option are not null return an error
     if methods != '' and excludes != '':
         grass.fatal(_("You can use method or exclude option not both"))
-    # if method and exclude option are null calculate all module
-    elif methods == '' and excludes == '':
-        # check if alpha_value is set, else return an error
-        if alpha_value == '':
-            grass.fatal(_("Please you must set alpha value for Renyi entropy"))
-        calculateAll(rlidir, map_in, map_out, resolution, alpha_value, quiet,
-                     overwrite)
     # calculate method
     elif methods != '':
         methods = methods.split(',')
@@ -146,28 +142,6 @@
     print 'All works are terminated'
 
 
-# calculate all index
-def calculateAll(home, map_in, map_out, res, alpha, quiet, overw):
-    # for each resolution create the config file and calculate all index
-    for r in res:
-        createConfFile(r, map_in, home)
-        r = str(r)
-        grass.run_command('r.li.simpson', input=map_in, output=map_out + \
-                          '_simpson_size_' + r, conf='conf_diversity_' + r,
-                          quiet=quiet, overwrite=overw)
-        grass.run_command('r.li.shannon', input=map_in, output=map_out + \
-                          '_shannon_size_' + r, conf='conf_diversity_' + r,
-                          quiet=quiet, overwrite=overw)
-        grass.run_command('r.li.pielou', input=map_in, output=map_out + \
-                          '_pielou_size_' + r, conf='conf_diversity_' + r,
-                          quiet=quiet, overwrite=overw)
-        for alp in alpha:
-            grass.run_command('r.li.renyi', input=map_in, output=map_out + \
-                              '_renyi_size_' + r + '_alpha_' + str(alp),
-                              conf='conf_diversity_' + r, alpha=alp,
-                              quiet=quiet, overwrite=overw)
-
-
 # calculate only method included in method option
 def calculateM(home, map_in, map_out, res, alpha, method, quiet, overw):
     # for each resolution create the config file
@@ -183,11 +157,11 @@
                                       '_alpha_' + str(alp), alpha=alp,
                                       conf='conf_diversity_' + r,
                                       quiet=quiet, overwrite=overw)
-                else:
-                    grass.run_command('r.li.' + i, input=map_in,
-                                      output=map_out + '_' + i + '_size_' + r,
-                                      conf='conf_diversity_' + r,
-                                      quiet=quiet, overwrite=overw)
+            else:
+                grass.run_command('r.li.' + i, input=map_in,
+                                  output=map_out + '_' + i + '_size_' + r,
+                                  conf='conf_diversity_' + r,
+                                  quiet=quiet, overwrite=overw)
 
 
 # calculate only method excluded with exclude option
@@ -209,11 +183,11 @@
                                           + '_alpha_' + str(alp), alpha=alp,
                                           conf='conf_diversity_' + r,
                                           quiet=quiet, overwrite=overw)
-        else:
-                grass.run_command('r.li.' + i, input=map_in, output=map_out \
-                                  + '_' + i + '_size_' + r,
-                                  conf='conf_diversity_' + r,
-                                  quiet=quiet, overwrite=overw)
+                else:
+                    grass.run_command('r.li.' + i, input=map_in, output=map_out \
+                                      + '_' + i + '_size_' + r,
+                                      conf='conf_diversity_' + r,
+                                      quiet=quiet, overwrite=overw)
 
 
 # check if alpha value it's set when renyi entropy must be calculate
@@ -228,6 +202,7 @@
             if method.count('renyi') == 1 and alpha == '':
                 grass.fatal(_("Please you must set alpha value for Renyi entropy"))
 
+
 #create configuration file instead using r.li.setup
 def createConfFile(res, inpumap, home):
     # set the name of conf file



More information about the grass-commit mailing list