[GRASS-SVN] r64420 - grass-addons/grass7/raster/r.popgrowth

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Feb 3 05:03:51 PST 2015


Author: jradinger
Date: 2015-02-03 05:03:51 -0800 (Tue, 03 Feb 2015)
New Revision: 64420

Modified:
   grass-addons/grass7/raster/r.popgrowth/r.popgrowth.py
Log:
No output value where there is no intial population

Modified: grass-addons/grass7/raster/r.popgrowth/r.popgrowth.py
===================================================================
--- grass-addons/grass7/raster/r.popgrowth/r.popgrowth.py	2015-02-03 12:52:52 UTC (rev 64419)
+++ grass-addons/grass7/raster/r.popgrowth/r.popgrowth.py	2015-02-03 13:03:51 UTC (rev 64420)
@@ -263,15 +263,17 @@
 
 		# Retransform in case of patches
 		if options['population_patches']:
-			grass.mapcalc("$exponential_output = round(($n0*1.0/$n0_tmp)*$exponential_output_tmp)",
+			grass.mapcalc("$exponential_output = if($n0,(round(($n0*1.0/$n0_tmp)*$exponential_output_tmp)),null())",
 				ricker_output=options['exponential_output'],
 				n0=options['n_initial'],
 				n0_tmp="n0_tmp_%d" % os.getpid(),
 				ricker_output_tmp="exponential_output_tmp_%d" % os.getpid())
 
 		else:
-			grass.run_command("g.copy",
-				raster="exponential_output_tmp_%d" % os.getpid() + ","+options['exponential_output'])
+			grass.mapcalc("$exponential_output = if($n0,$exponential_output_tmp,null())",
+				exponential_output=options['exponential_output'],
+				n0=options['n_initial'],
+				exponential_output_tmp="exponential_output_tmp_%d" % os.getpid())
 		
 	################# Ricker Model #################
 	if options['ricker_output']:
@@ -337,20 +339,23 @@
 
 		# Retransform in case of patches
 		if options['population_patches']:
-			grass.mapcalc("$ricker_output = round(($n0*1.0/$n0_tmp)*$ricker_output_tmp)",
+			grass.mapcalc("$ricker_output = if($n0,(round(($n0*1.0/$n0_tmp)*$ricker_output_tmp)),null())",
 				ricker_output=options['ricker_output'],
 				n0=options['n_initial'],
 				n0_tmp="n0_tmp_%d" % os.getpid(),
 				ricker_output_tmp="ricker_output_tmp_%d" % os.getpid())
 
 		else:
-			grass.run_command("g.copy",
-				raster="ricker_output_tmp_%d" % os.getpid() +","+options['ricker_output'])
+			grass.mapcalc("$ricker_output = if($n0,$ricker_output_tmp,null())",
+				ricker_output=options['ricker_output'],
+				n0=options['n_initial'],
+				ricker_output_tmp="ricker_output_tmp_%d" % os.getpid())
 		
+		
+		
+				
 
 
-
-
 	return 0
 
 



More information about the grass-commit mailing list