[GRASS-SVN] r65032 - grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.economic

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Apr 9 06:06:55 PDT 2015


Author: osfraid
Date: 2015-04-09 06:06:55 -0700 (Thu, 09 Apr 2015)
New Revision: 65032

Modified:
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.economic/r.green.biomassfor.economic.html
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.economic/r.green.biomassfor.economic.py
Log:
add new version of r.green.biomassfor.economic and html file

Modified: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.economic/r.green.biomassfor.economic.html
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.economic/r.green.biomassfor.economic.html	2015-04-09 13:06:08 UTC (rev 65031)
+++ grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.economic/r.green.biomassfor.economic.html	2015-04-09 13:06:55 UTC (rev 65032)
@@ -0,0 +1,187 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<title>GRASS GIS manual: r.green.biomassfor.economic.py</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<link rel="stylesheet" href="grassdocs.css" type="text/css">
+</head>
+<body bgcolor="white">
+<div id="container">
+
+<a href="index.html"><img src="grass_logo.png" alt="GRASS logo"></a>
+<hr class="header">
+
+<h2>NOME</h2>
+<em><b>r.green.biomassfor.economic.py</b></em>  - Estimates bioenergy that can be collected to supply heating plants or biomass logistic centres and that is associated with a positive net revenue for the entire production process
+<h2>PAROLE CHIAVE</h2>
+<h2>SINOPSI</h2>
+<div id="name"><b>r.green.biomassfor.economic.py</b><br></div>
+<b>r.green.biomassfor.economic.py --help</b><br>
+<div id="synopsis"><b>r.green.biomassfor.economic.py</b> [-<b>rx</b>] <b>field_prefix</b>=<em>name</em>  [<b>prices</b>=<em>float</em>[,<i>float</i>,...]]  <b>output_prefix</b>=<em>name</em>  [<b>dhp</b>=<em>name</em>]  <b>yield1</b>=<em>name</em> <b>yield_surface</b>=<em>name</em> <b>management</b>=<em>name</em> <b>treatment</b>=<em>name</em> <b>forest_roads</b>=<em>name</em> <b>main_roads</b>=<em>name</em> <b>dtm2</b>=<em>name</em>  [<b>soilp2_map</b>=<em>name</em>]   [<b>tree_diam</b>=<em>name</em>]   [<b>tree_vol</b>=<em>name</em>]   [<b>rivers</b>=<em>name</em>]   [<b>lakes</b>=<em>name</em>]   [<b>roughness</b>=<em>name</em>]  <b>forest</b>=<em>name</em>  [<b>slp_min_cc</b>=<em>float</em>]   [<b>slp_max_cc</b>=<em>float</em>]   [<b>dist_max_cc</b>=<em>float</em>]   [<b>slp_max_fw</b>=<em>float</em>]   [<b>dist_max_fw</b>=<em>float</em>]   [<b>slp_max_cop</b>=<em>float</em>]   [<b>dist_max_cop</b>=<em>float</em>]   [<b>price_energy_woodchips</b>=<em>float</em>]   [<b>co
 st_chainsaw</b>=<em>float</em>]   [<b>cost_processor</b>=<em>float</em>]   [<b>cost_harvester</b>=<em>float</em>]   [<b>cost_cablehf</b>=<em>float</em>]   [<b>cost_cablec</b>=<em>float</em>]   [<b>cost_forwarder</b>=<em>float</em>]   [<b>cost_skidder</b>=<em>float</em>]   [<b>cost_chipping</b>=<em>float</em>]   [<b>cost_transport</b>=<em>float</em>]   [<b>energy_tops_hf</b>=<em>float</em>]   [<b>energy_cormometric_vol_hf</b>=<em>float</em>]   [<b>energy_tops_cop</b>=<em>float</em>]   [--<b>overwrite</b>]  [--<b>help</b>]  [--<b>verbose</b>]  [--<b>quiet</b>]  [--<b>ui</b>] 
+</div>
+
+<div id="flags">
+<h3>Flag:</h3>
+<dl>
+<dt><b>-r</b></dt>
+<dd>Remove all operational maps</dd>
+
+<dt><b>-x</b></dt>
+<dd>Raster wood typologies ready to import (prefix_voltypx)</dd>
+
+<dt><b>--overwrite</b></dt>
+<dd>Permetti al file di output di sovrascrivere file esistenti</dd>
+<dt><b>--help</b></dt>
+<dd>Print usage summary</dd>
+<dt><b>--verbose</b></dt>
+<dd>Output verboso del modulo</dd>
+<dt><b>--quiet</b></dt>
+<dd>Output quieto del modulo</dd>
+<dt><b>--ui</b></dt>
+<dd>Force launching GUI dialog</dd>
+</dl>
+</div>
+
+<div id="parameters">
+<h3>Parametri:</h3>
+<dl>
+<dt><b>field_prefix</b>=<em>name</em> <b>[required]</b></dt>
+<dd>Prefix for forest type yield fields (prefix_voltypx)</dd>
+
+<dt><b>prices</b>=<em>float[,<i>float</i>,...]</em></dt>
+<dd>Market price for a-th assortment €/m³</dd>
+
+<dt><b>output_prefix</b>=<em>name</em> <b>[required]</b></dt>
+<dd>Prefix for economic bioenergy (HF,CC and total)</dd>
+
+<dt><b>dhp</b>=<em>name</em></dt>
+<dd>Name of vector district heating points</dd>
+<dd>Name of vector district heating points</dd>
+
+<dt><b>yield1</b>=<em>name</em> <b>[required]</b></dt>
+<dd>Map of forest yield (cubic meters)</dd>
+
+<dt><b>yield_surface</b>=<em>name</em> <b>[required]</b></dt>
+<dd>Map of stand surface (ha)</dd>
+
+<dt><b>management</b>=<em>name</em> <b>[required]</b></dt>
+<dd>Map of forest management (1: high forest, 2:coppice)</dd>
+
+<dt><b>treatment</b>=<em>name</em> <b>[required]</b></dt>
+<dd>Map of forest treatment (1: final felling, 2:thinning)</dd>
+
+<dt><b>forest_roads</b>=<em>name</em> <b>[required]</b></dt>
+<dd>Raster map of forest roads (0, 1)</dd>
+
+<dt><b>main_roads</b>=<em>name</em> <b>[required]</b></dt>
+<dd>Raster map of main roads (0, 1)</dd>
+
+<dt><b>dtm2</b>=<em>name</em> <b>[required]</b></dt>
+<dd>Name of Digital terrain model map</dd>
+
+<dt><b>soilp2_map</b>=<em>name</em></dt>
+<dd>Soil production map</dd>
+
+<dt><b>tree_diam</b>=<em>name</em></dt>
+<dd>Average tree diameter map</dd>
+
+<dt><b>tree_vol</b>=<em>name</em></dt>
+<dd>Average tree volume map</dd>
+
+<dt><b>rivers</b>=<em>name</em></dt>
+<dd>Raster map of rivers (0, 1)</dd>
+
+<dt><b>lakes</b>=<em>name</em></dt>
+<dd>Raster map of lakes (0, 1)</dd>
+
+<dt><b>roughness</b>=<em>name</em></dt>
+<dd>Name of roughness map</dd>
+
+<dt><b>forest</b>=<em>name</em> <b>[required]</b></dt>
+<dd>Name of vector parcel map</dd>
+<dd>Name of vector parcel map</dd>
+
+<dt><b>slp_min_cc</b>=<em>float</em></dt>
+<dd>Percent slope lower limit with Cable Crane</dd>
+<dd>Default: <em>30.</em></dd>
+
+<dt><b>slp_max_cc</b>=<em>float</em></dt>
+<dd>Percent slope higher limit with Cable Crane</dd>
+<dd>Default: <em>100.</em></dd>
+
+<dt><b>dist_max_cc</b>=<em>float</em></dt>
+<dd>Maximum distance with Cable Crane</dd>
+<dd>Default: <em>800.</em></dd>
+
+<dt><b>slp_max_fw</b>=<em>float</em></dt>
+<dd>Percent slope higher limit with Forwarder</dd>
+<dd>Default: <em>30.</em></dd>
+
+<dt><b>dist_max_fw</b>=<em>float</em></dt>
+<dd>Maximum distance with Forwarder</dd>
+<dd>Default: <em>600.</em></dd>
+
+<dt><b>slp_max_cop</b>=<em>float</em></dt>
+<dd>Percent slope higher limit with other techniques for Coppices</dd>
+<dd>Default: <em>30.</em></dd>
+
+<dt><b>dist_max_cop</b>=<em>float</em></dt>
+<dd>Maximum distance with other techniques for Coppices</dd>
+<dd>Default: <em>600.</em></dd>
+
+<dt><b>price_energy_woodchips</b>=<em>float</em></dt>
+<dd>Price for energy from woodchips €/MWh</dd>
+<dd>Default: <em>19.50</em></dd>
+
+<dt><b>cost_chainsaw</b>=<em>float</em></dt>
+<dd>Felling and/or felling-processing cost with chainsaw €/h</dd>
+<dd>Default: <em>13.17</em></dd>
+
+<dt><b>cost_processor</b>=<em>float</em></dt>
+<dd>Processing cost with processor €/h</dd>
+<dd>Default: <em>87.42</em></dd>
+
+<dt><b>cost_harvester</b>=<em>float</em></dt>
+<dd>Felling and processing cost with harvester €/h</dd>
+<dd>Default: <em>96.33</em></dd>
+
+<dt><b>cost_cablehf</b>=<em>float</em></dt>
+<dd>Extraction cost with high power cable crane €/h</dd>
+<dd>Default: <em>111.44</em></dd>
+
+<dt><b>cost_cablec</b>=<em>float</em></dt>
+<dd>Extraction cost with medium power cable crane €/h</dd>
+<dd>Default: <em>104.31</em></dd>
+
+<dt><b>cost_forwarder</b>=<em>float</em></dt>
+<dd>Extraction cost with forwarder €/h</dd>
+<dd>Default: <em>70.70</em></dd>
+
+<dt><b>cost_skidder</b>=<em>float</em></dt>
+<dd>Extraction cost with skidder €/h</dd>
+<dd>Default: <em>64.36</em></dd>
+
+<dt><b>cost_chipping</b>=<em>float</em></dt>
+<dd>Chipping cost €/h</dd>
+<dd>Default: <em>150.87</em></dd>
+
+<dt><b>cost_transport</b>=<em>float</em></dt>
+<dd>Transport with truck €/h</dd>
+<dd>Default: <em>64.90</em></dd>
+
+<dt><b>energy_tops_hf</b>=<em>float</em></dt>
+<dd>Energy for tops and branches in high forest in MWh/m³</dd>
+<dd>Default: <em>0.49</em></dd>
+
+<dt><b>energy_cormometric_vol_hf</b>=<em>float</em></dt>
+<dd>Energy for the whole tree in high forest (tops, branches and stem) in MWh/m³</dd>
+<dd>Default: <em>1.97</em></dd>
+
+<dt><b>energy_tops_cop</b>=<em>float</em></dt>
+<dd>Energy for tops and branches for Coppices in MWh/m³</dd>
+<dd>Default: <em>0.55</em></dd>
+
+</dl>
+</div>
+</body>
+</html>

Modified: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.economic/r.green.biomassfor.economic.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.economic/r.green.biomassfor.economic.py	2015-04-09 13:06:08 UTC (rev 65031)
+++ grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.economic/r.green.biomassfor.economic.py	2015-04-09 13:06:55 UTC (rev 65032)
@@ -139,13 +139,6 @@
 #% guisection: Opt files
 #%end
 #%option G_OPT_R_INPUT
-#% key: mmfeatures
-#% type: string
-#% description: Raster map of morphometric features
-#% required : no
-#% guisection: Opt files
-#%end
-#%option G_OPT_R_INPUT
 #% key: roughness
 #% type: string
 #% description: Name of roughness map
@@ -249,7 +242,7 @@
 #% guisection: Costs
 #%end
 #%option
-#% key: cost_cableHF
+#% key: cost_cablehf
 #% type: double
 #% description: Extraction cost with high power cable crane €/h
 #% answer: 111.44
@@ -257,7 +250,7 @@
 #% guisection: Costs
 #%end
 #%option
-#% key: cost_cableC
+#% key: cost_cablec
 #% type: double
 #% description: Extraction cost with medium power cable crane €/h
 #% answer: 104.31
@@ -377,7 +370,7 @@
     run_command("g.remove", type="raster", flags="f", name="fell_proc_costC")
     run_command("g.remove", type="raster", flags="f", name="proc_costHFtr1")
     run_command("g.remove", type="raster", flags="f", name="proc_costHFtr2")
-    run_command("g.remove", type="raster", flags="f", name="extr_cost_cableHF")
+    run_command("g.remove", type="raster", flags="f", name="extr_cost_cablehf")
     run_command("g.remove", type="raster", flags="f", name="extr_cost_forw")
     run_command("g.remove", type="raster", flags="f", name="extr_cost_other")
     run_command("g.remove", type="raster", flags="f", name="transport_cost")
@@ -425,6 +418,7 @@
     run_command("g.remove", type="raster", flags="f", name="yield_pixp")
     run_command("g.remove", type="raster", flags="f", name="technical_bioenergy")
     run_command("g.remove", type="raster", flags="f", name="slope__")
+    run_command("g.remove", type="raster", flags="f", name="slope___")
     run_command("g.remove", type="raster", flags="f", name="slope_deg__")
 
     for x in range(1,len(pricelist)+1):
@@ -434,13 +428,17 @@
         run_command("g.remove", type="raster", flags="f", name=mapvol2)
 
 
-def yield_pix_process(opts, flgs,vector_forest,yield_,yield_surface,rivers,lakes,mmfeatures,forest_roads,management,treatment,roughness):
+def yield_pix_process(opts, flgs,vector_forest,yield_,yield_surface,rivers,lakes,forest_roads,management,treatment,roughness):
 
 
     run_command("r.slope.aspect", overwrite=ow,elevation=opts['dtm2'], slope="slope__", format="percent")
     run_command("r.slope.aspect", overwrite=ow,elevation=opts['dtm2'], slope="slope_deg__")
 
+    run_command("r.param.scale", overwrite=ow,
+                input=opts['dtm2'], output="morphometric_features",
+                size=3, method="feature")
 
+
     run_command("r.mapcalc", overwrite=ow,
             expression='pix_cross = ((ewres()+nsres())/2)/ cos(slope_deg__)')
 
@@ -448,8 +446,9 @@
         expression='yield_pix1 = ('+yield_+'/'+yield_surface+')*((ewres()*nsres())/10000)')
 
     run_command("r.null", map="yield_pix1", null=0)
+    run_command("r.null", map="morphometric_features", null=0)
 
-    exprmap='frict_surf_extr = pix_cross + if(yield_pix1<=0, 99999)'
+    exprmap='frict_surf_extr = pix_cross + if(yield_pix1<=0, 99999) + if(morphometric_features==6, 99999)'
 
 
     if rivers!='':
@@ -460,9 +459,6 @@
         run_command("r.null", map=lakes, null=0)
         exprmap+='+ if('+lakes+'>=1, 99999)'
 
-    if mmfeatures!='':
-        exprmap+='+ if('+mmfeatures+'==6, 99999)'
-        run_command("r.null", map=mmfeatures, null=0)
 
     run_command("r.mapcalc",overwrite=ow,expression=exprmap)
 
@@ -536,7 +532,7 @@
 
     
 
-    pricelist=string.split(opts['prices'],',') #trasformo la stringa opts in una lista di stringhe
+    pricelist=string.split(opts['prices'],',') #convert the string in list of string
 
 
     for x in range(1,len(pricelist)+1):
@@ -553,10 +549,7 @@
 
     price_energy_woodchips=float(opts['price_energy_woodchips'])   
     
-    #price1_temp='vol_typ1pix*'+pricelist[0]
-    
-    #TR1='total_revenues1 = technical_surface*(if(management == 1 && treatment==1 || management == 1 && treatment==99999 || management == 2,('+price1_temp+'+(technical_bioenergy*20)), if(management == 1 && treatment==2, technical_bioenergy*'+opts['price_energy_woodchips']+')))'
-    #TR1='total_revenues1 = technical_surface*(if('+management+' == 1 && '+treatment+'==1 || '+management+' == 1 && '+treatment+'==99999 || '+management+' == 2,(%s+(technical_bioenergy*%f)), if('+management+' == 1 && '+treatment+'==2, technical_bioenergy*%f)))' % (prices,price_energy_woodchips, price_energy_woodchips)
+
     TR1='total_revenues1 = technical_surface*(if('+management+' == 1 && '+treatment+'==1 || '+management+' == 1 && '+treatment+'==99999 || '+management+' == 2,('+prices+'+(technical_bioenergy*'+str(price_energy_woodchips)+')), if('+management+' == 1 && '+treatment+'==2, technical_bioenergy*'+str(price_energy_woodchips)+')))'
     
     #IMPORTANT: in order to calculate the total revenue it's required to process both round wood price 
@@ -600,31 +593,34 @@
 
     dhp=opts['dhp']
 
+    run_command("r.mapcalc",overwrite=ow,
+                expression="slope___=if(slope__<=100,slope__,100)")
+
     # Calculate productivity
     #view the paper appendix for the formulas
     run_command("r.mapcalc", overwrite=ow,
-                expression='fell_productHFtr1 = if('+management+' ==1 && ('+treatment+' ==1 || '+treatment+' ==99999) && '+tree_diam+' <99999,(cable_crane_extraction*(42-(2.6*'+tree_diam+'))/(-20))*1.65*(1-(slope__/100)), if('+management+' ==1 && ('+treatment+' ==1 || '+treatment+' ==99999) && '+tree_diam+' == 99999,(cable_crane_extraction*(42-(2.6*35))/(-20))*1.65*(1-(slope__/100))))')
+                expression='fell_productHFtr1 = if('+management+' ==1 && ('+treatment+' ==1 || '+treatment+' ==99999) && '+tree_diam+' <99999,(cable_crane_extraction*(42-(2.6*'+tree_diam+'))/(-20))*1.65*(1-(slope___/100)), if('+management+' ==1 && ('+treatment+' ==1 || '+treatment+' ==99999) && '+tree_diam+' == 99999,(cable_crane_extraction*(42-(2.6*35))/(-20))*1.65*(1-(slope___/100))))')
     run_command("r.null", map="fell_productHFtr1", null=0)
     run_command("r.mapcalc", overwrite=ow,
-                expression='fell_productHFtr2 = if('+management+' ==1 && '+treatment+' ==2 && '+tree_diam+' <99999,(cable_crane_extraction*(42-(2.6*'+tree_diam+'))/(-20))*1.65*(1-((1000-(90*slope__)/(-80))/100)), if('+management+' ==1 && '+treatment+' ==2 && '+tree_diam+' == 99999,(cable_crane_extraction*(42-(2.6*35))/(-20))*1.65*(1-((1000-(90*slope__)/(-80))/100))))')
+                expression='fell_productHFtr2 = if('+management+' ==1 && '+treatment+' ==2 && '+tree_diam+' <99999,(cable_crane_extraction*(42-(2.6*'+tree_diam+'))/(-20))*1.65*(1-((1000-(90*slope___)/(-80))/100)), if('+management+' ==1 && '+treatment+' ==2 && '+tree_diam+' == 99999,(cable_crane_extraction*(42-(2.6*35))/(-20))*1.65*(1-((1000-(90*slope___)/(-80))/100))))')
     run_command("r.null", map="fell_productHFtr2", null=0)
     run_command("r.mapcalc", overwrite=ow,
-                expression='fell_proc_productC = if('+management+' ==2 && '+soilp2_map+' <99999,((0.3-(1.1*'+soilp2_map+'))/(-4))*(1-(slope__/100)), if('+management+' ==2 && '+soilp2_map+' == 99999,((0.3-(1.1*3))/(-4))*(1-(slope__/100))))')
+                expression='fell_proc_productC = if('+management+' ==2 && '+soilp2_map+' <99999,((0.3-(1.1*'+soilp2_map+'))/(-4))*(1-(slope___/100)), if('+management+' ==2 && '+soilp2_map+' == 99999,((0.3-(1.1*3))/(-4))*(1-(slope___/100))))')
     run_command("r.null", map="fell_proc_productC", null=0)
+    ###### check fell_proc_productC ######
+
     #9999: default value, if is present take into the process the average value (in case of fertility is 33)
 
-    #r.mapcalc --o 'fell_proc_productC = if(management at PERMANENT ==2 && soil_prod at PERMANENT <99999,((0.3-(1.1*soil_prod at PERMANENT))/(-4))*(1-(slope at PERMANENT/100)), if(management at PERMANENT ==2 && soil_prod at PERMANENT == 99999,((0.3-(1.1*3))/(-4))*(1-((1000-(90*slope at PERMANENT)/(-80))/100))))'
 
 
-
     run_command("r.mapcalc", overwrite=ow,
                 expression='proc_productHFtr1 = if('+management+' == 1 && ('+treatment+' == 1 || '+treatment+' ==99999) && '+tree_diam+'==99999, cable_crane_extraction*0.363*35^1.116, if('+management+' == 1 && ('+treatment+' == 1 || '+treatment+' ==99999) && '+tree_diam+'<99999, cable_crane_extraction*0.363*'+tree_diam+'^1.116))')
     run_command("r.null", map="proc_productHFtr1", null=0)
     run_command("r.mapcalc", overwrite=ow,
-                expression='fell_proc_productHFtr1 = if('+management+' == 1 && ('+treatment+' == 1 || '+treatment+' ==99999) && '+tree_vol+'<9.999, forwarder_extraction*60/(1.5*(2.71^(0.1480-0.3894*2+0.0002*(slope__^2)-0.2674*2.5))+(1.0667+(0.3094/'+tree_vol+')-0.1846*1)), if('+management+' == 1 && ('+treatment+' == 1 || '+treatment+' ==99999) && '+tree_vol+'==9.999, forwarder_extraction*60/(1.5*(2.71^(0.1480-0.3894*2+0.0002*(slope__^2)-0.2674*2.5))+(1.0667+(0.3094/0.7)-0.1846*1))))')
+                expression='fell_proc_productHFtr1 = if('+management+' == 1 && ('+treatment+' == 1 || '+treatment+' ==99999) && '+tree_vol+'<9.999, forwarder_extraction*60/(1.5*(2.71^(0.1480-0.3894*2+0.0002*(slope___^2)-0.2674*2.5))+(1.0667+(0.3094/'+tree_vol+')-0.1846*1)), if('+management+' == 1 && ('+treatment+' == 1 || '+treatment+' ==99999) && '+tree_vol+'==9.999, forwarder_extraction*60/(1.5*(2.71^(0.1480-0.3894*2+0.0002*(slope___^2)-0.2674*2.5))+(1.0667+(0.3094/0.7)-0.1846*1))))')
     run_command("r.null", map="fell_proc_productHFtr1", null=0)
     run_command("r.mapcalc", overwrite=ow,
-                expression='fell_proc_productHFtr2 = if('+management+' == 1 && '+treatment+' == 2 && '+tree_vol+'<9.999, forwarder_extraction*60/(1.5*(2.71^(0.1480-0.3894*2+0.0002*(slope__^2)-0.2674*2.5))+(1.0667+(0.3094/'+tree_vol+')-0.1846*1))*0.8, if('+management+' == 1 && '+treatment+' == 2 && '+tree_vol+'==9.999, forwarder_extraction*60/(1.5*(2.71^(0.1480-0.3894*2+0.0002*(slope__^2)-0.2674*2.5))+(1.0667+(0.3094/0.7)-0.1846*1))*0.8))')
+                expression='fell_proc_productHFtr2 = if('+management+' == 1 && '+treatment+' == 2 && '+tree_vol+'<9.999, forwarder_extraction*60/(1.5*(2.71^(0.1480-0.3894*2+0.0002*(slope___^2)-0.2674*2.5))+(1.0667+(0.3094/'+tree_vol+')-0.1846*1))*0.8, if('+management+' == 1 && '+treatment+' == 2 && '+tree_vol+'==9.999, forwarder_extraction*60/(1.5*(2.71^(0.1480-0.3894*2+0.0002*(slope___^2)-0.2674*2.5))+(1.0667+(0.3094/0.7)-0.1846*1))*0.8))')
     run_command("r.null", map="fell_proc_productHFtr2", null=0)
     run_command("r.mapcalc", overwrite=ow,
                 expression='chipp_prodHF = if('+management+' ==1 && ('+treatment+' == 1 ||  '+treatment+' == 99999), yield_pix/34, if('+management+' ==1 && '+treatment+' == 2, yield_pix/20.1))')
@@ -662,7 +658,7 @@
                 expression='frict_surf_tr1 =  frict_surf_extr*tot_roads_neg')
     run_command("r.mapcalc", overwrite=ow,
                 expression='frict_surf_tr = frict_surf_tr1+(tot_roads*((ewres()+nsres())/2))')
-    #run_command("r.null", map=dhp, null=0)
+
     try:
         run_command("r.cost", overwrite=ow, input="frict_surf_tr",
                     output="tot_dist", stop_points=opts['forest'], start_points=dhp,
@@ -703,10 +699,10 @@
     run_command("r.mapcalc", overwrite=ow,
                 expression='chipp_cost = '+opts['cost_chipping']+'*chipp_prod')
     run_command("r.mapcalc", overwrite=ow,
-                expression='extr_cost_cableHF = '+opts['cost_cableHF']+'/extr_product_cableHF*yield_pix')
+                expression='extr_cost_cableHF = '+opts['cost_cablehf']+'/extr_product_cableHF*yield_pix')
     run_command("r.null", map="extr_cost_cableHF", null=0)
     run_command("r.mapcalc", overwrite=ow,
-                expression='extr_cost_cableC = '+opts['cost_cableC']+'/extr_product_cableC*yield_pix')
+                expression='extr_cost_cableC = '+opts['cost_cablec']+'/extr_product_cableC*yield_pix')
     run_command("r.null", map="extr_cost_cableC", null=0)
     run_command("r.mapcalc", overwrite=ow,
                 expression='extr_cost_forw ='+opts['cost_forwarder']+'/extr_product_forw*yield_pix')
@@ -717,7 +713,14 @@
     run_command("r.mapcalc", overwrite=ow,
                 expression='transport_cost = '+opts['cost_transport']+'*transport_prod')
     run_command("r.mapcalc", overwrite=ow,
-                expression='prod_costs = fell_costHFtr1 +  fell_costHFtr2+ fell_proc_costC + proc_costHFtr1 + fell_proc_costHFtr1 + fell_proc_costHFtr2 + chipp_cost + extr_cost_cableHF + extr_cost_cableC + extr_cost_forw + extr_product_other + transport_cost')
+                expression='prod_costs1 = fell_costHFtr1 +  fell_costHFtr2+ fell_proc_costC + proc_costHFtr1 + fell_proc_costHFtr1 + fell_proc_costHFtr2 + chipp_cost + extr_cost_cableHF + extr_cost_cableC + extr_cost_forw + extr_product_other + transport_cost')
+    
+
+
+    ######## patch to correct problem of negative costs #######
+    run_command("r.mapcalc", overwrite=ow,expression='prod_costs =  prod_costs1>=0 ? prod_costs1 : 0')
+    ######## end patch ##############
+
     run_command("r.mapcalc", overwrite=ow,
                 expression='direction_cost =  prod_costs *0.05')
     run_command("r.mapcalc", overwrite=ow,
@@ -785,15 +788,6 @@
     ECONTOT=econ_bioenergy+' = ('+econ_bioenergyHF+' + '+econ_bioenergyC+')'
 
 
-    """
-    run_command("r.mapcalc", overwrite=ow,
-                expression='economic_bioenergyHF = economic_surface*(if(management == 1 && treatment==1 || management == 1 && treatment== 99999,yield_pix*'+opts['energy_tops_hf']+', if(management == 1 && treatment==2, yield_pix*'+opts['energy_tops_hf']+'+yield_pix*'+opts['energy_cormometric_vol_hf']+')))')
-    run_command("r.mapcalc", overwrite=ow,
-                expression='economic_bioenergyC = economic_surface*(if(management == 2, yield_pix*'+opts['energy_tops_cop']+'))')
-    run_command("r.mapcalc", overwrite=ow,
-                expression='economic_bioenergy = (economic_bioenergyHF +  economic_bioenergyC)')
-    
-    """
 
     run_command("r.mapcalc", overwrite=ow, expression=ECONHF)
 
@@ -818,7 +812,6 @@
 
     rivers=opts['rivers']
     lakes=opts['lakes']
-    mmfeatures=opts['mmfeatures']
     tree_diam=opts['tree_diam']
     tree_vol=opts['tree_vol']
     soilp2_map=opts['soilp2_map']
@@ -851,7 +844,7 @@
     if flgs['x'] == False:
          import_map(opts, flgs, vector_forest)
 
-    yield_pix_process(opts,flgs,vector_forest,yield_,yield_surface,rivers,lakes,mmfeatures,forest_roads,management,treatment,roughness)
+    yield_pix_process(opts,flgs,vector_forest,yield_,yield_surface,rivers,lakes,forest_roads,management,treatment,roughness)
     
 
     revenues(opts, flgs,yield_surface,management,treatment)



More information about the grass-commit mailing list