[GRASS-SVN] r64648 - in grass-addons/grass7/raster/r.green: . r.green.biomassfor r.green.biomassfor/r.green.biomassfor.economic r.green.biomassfor/r.green.biomassfor.impact r.green.biomassfor/r.green.biomassfor.legal r.green.biomassfor/r.green.biomassfor.recommended r.green.biomassfor/r.green.biomassfor.technical r.green.biomassfor/r.green.biomassfor.theoretical

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Feb 16 05:28:30 PST 2015


Author: osfraid
Date: 2015-02-16 05:28:30 -0800 (Mon, 16 Feb 2015)
New Revision: 64648

Added:
   grass-addons/grass7/raster/r.green/AUTHORS.txt
   grass-addons/grass7/raster/r.green/LICENSE.txt
   grass-addons/grass7/raster/r.green/Makefile
   grass-addons/grass7/raster/r.green/README.txt
   grass-addons/grass7/raster/r.green/r.green.biomassfor/
   grass-addons/grass7/raster/r.green/r.green.biomassfor/Makefile
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.economic/
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.economic/Makefile
   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
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.html
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.impact/
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.impact/Makefile
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.impact/r.green.biomassfor.impact.html
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.impact/r.green.biomassfor.impact.py
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.legal/
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.legal/Makefile
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.legal/r.green.biomassfor.legal.html
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.legal/r.green.biomassfor.legal.py
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.recommended/
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.recommended/Makefile
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.recommended/r.green.biomassfor.recommended.html
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.recommended/r.green.biomassfor.recommended.py
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.technical/
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.technical/Makefile
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.technical/biomasfor.technical.py
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.technical/r.green.biomassfor.technical.html
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.technical/r.green.biomassfor.technical.py
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.theoretical/
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.theoretical/Makefile
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.theoretical/r.green.biomassfor.theoretical.html
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.theoretical/r.green.biomassfor.theoretical.py
Log:
Add new module to assess biomass energy potential from forestry residues

Added: grass-addons/grass7/raster/r.green/AUTHORS.txt
===================================================================
--- grass-addons/grass7/raster/r.green/AUTHORS.txt	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/AUTHORS.txt	2015-02-16 13:28:30 UTC (rev 64648)
@@ -0,0 +1,5 @@
+Giulia    Garegnani  <giulia.garegnani  eurac.edu>
+Francesco Geri       <francesco.geri    gmail.com>
+Gianluca  Grilli     <gianluca.grilli   eurac.edu>
+Pietro    Zambelli   <pietro.zambelli   eurac.edu>
+Sandro    Sacchelli   <sandro.sacchelli   unifi.it>
\ No newline at end of file

Added: grass-addons/grass7/raster/r.green/LICENSE.txt
===================================================================
--- grass-addons/grass7/raster/r.green/LICENSE.txt	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/LICENSE.txt	2015-02-16 13:28:30 UTC (rev 64648)
@@ -0,0 +1,11 @@
+
+                     GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+for more details look here:
+http://www.gnu.org/licenses/gpl.txt 
+

Added: grass-addons/grass7/raster/r.green/Makefile
===================================================================
--- grass-addons/grass7/raster/r.green/Makefile	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/Makefile	2015-02-16 13:28:30 UTC (rev 64648)
@@ -0,0 +1,11 @@
+MODULE_TOPDIR = ../..
+
+PGM=r.green
+
+SUBDIRS = r.green.biomassfor
+
+include $(MODULE_TOPDIR)/include/Make/Dir.make
+
+default: parsubdirs htmldir
+
+install: installsubdirs

Added: grass-addons/grass7/raster/r.green/README.txt
===================================================================
--- grass-addons/grass7/raster/r.green/README.txt	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/README.txt	2015-02-16 13:28:30 UTC (rev 64648)
@@ -0,0 +1,346 @@
+########################
+Recharge-Green modules
+########################
+
+
+
+Wind module
+============
+
+
+Wind theoretical
+------------------
+
+- resource`s input:
+  * raster with the wind speed [m/s]
+  * shape parameter Weibull density function [-]
+  * reference elevation of the wind speed raster map [m]
+
+- input of the wind turbine rotor:
+  * height [m]
+  * diameter [m]
+  * nominal power [kWp]
+  * power curve [file.csv]
+
+- outputs:
+  * raster map wind annual energy production (AEP) [kWh] res 350*350
+  * working hours per year [hours/year]
+
+Methodology
+^^^^^^^^^^^^
+* compute the wind distribution curve
+* integral distribution curve times power curve
+
+
+Wind legal
+------------
+
+- inputs:
+
+- outputs:
+
+
+Methodology
+^^^^^^^^^^^^
+
+
+
+Wind technical
+---------------
+
+- inputs:
+  * raster with the Digital Terrain Model (DTM)
+  * maximum elevation limit [m]
+  * raster maps with constrains (airport, settlements, forest, etc, ina)
+  * constrains distances [m] (airport, settlements, forest, ringing stations)
+  * working hour limit
+
+- output:
+  * raster with areas/clusters that satisfy the given constrains.
+  * raster map with not enough working hours per years
+  * number of turbines for area/estimation of production
+
+
+Methodology
+^^^^^^^^^^^^
+
+* extract the crest of the hill/mountain using r.slope.aspect
+* exclude all the pixels above the maximum elevation limit
+* exclude all the pixels included in the constrains` buffer
+
+
+
+Wind recommended
+------------------
+
+- inputs:
+  * raster with the Digital Terrain Model (DTM)
+  * raster maps with sensitive areas (Natural park, settlements, etc.)
+  * bird path
+
+- outputs:
+  * sorting by visibility
+  * summary table of visual impacts of the potential wind farm over the sensitive areas/clusters.
+
+
+Methodology
+^^^^^^^^^^^^
+
+* compute the view-shed of wind farm using r.viewshed
+* do zoning statistics to produce the summary table using r.univar
+
+
+
+Wind economic
+--------------
+
+inputs
+^^^^^^^
+
+- wind farm characteristics:
+  * installation power [kWp]
+  * investment cost [€/kWp]
+
+- fixed costs:
+  * installation cost for kWp [€/kWp]
+  * vector map with the main transmission lines
+  * linear cost of a new transmission lines [€/km]
+  * vector roads maps
+  * minimum radius acceptable (45 m) => Grassi et al. 2012
+  * minimum road width (12 - 15 m) => Grassi et al. 2012
+  * average cost per bend [€/bend]
+  * average cost to adapt the roads width [€/km]
+  * average cost to make new roads [€/km]
+
+- variable costs:
+  * raster with the working hour per year
+  * maintenance costs per working hour [€/hour]
+
+- energy market:
+  * energy gain per kWp [€/kWp]
+
+outputs
+^^^^^^^^
+
+Summary table with cost details for each potential areas/clusters
+considering:
+- return on investment (ROI)
+- net present value
+
+Methodology
+^^^^^^^^^^^^
+
+
+
+
+Solar module
+=============
+
+
+
+Solar theoretical
+-------------------
+
+- inputs:
+  * solar radiation or DTM
+
+- outputs:
+  * raster map with energy potential per kWp installed [kWh/kWp]
+  * energy maximum theoretical limit.
+
+Methodology
+^^^^^^^^^^^^
+
+
+Solar legal
+------------
+
+# TODO: which legal constraints should we consider?
+
+- inputs:
+
+- outputs:
+
+
+Methodology
+^^^^^^^^^^^^
+
+
+
+Solar technical
+----------------
+
+- inputs:
+  * raster with the Digital Terrain Model (DTM)
+  * maximum elevation limit [m]
+  * maximum slope limit
+
+- output:
+  * raster with areas/clusters that satisfy the given constrains.
+
+
+Methodology
+^^^^^^^^^^^^
+
+
+
+Solar recommended
+---------------------
+
+Distance from sensitive areas.
+
+- inputs:
+
+- outputs:
+
+Methodology
+^^^^^^^^^^^^
+
+
+
+Solar economic
+---------------
+
+inputs
+^^^^^^^
+
+- solar farm characteristics:
+  * installation power [kWp]
+  * investment cost [€/kWp]
+
+- fixed costs:
+  * installation cost for kWp [€/kWp]
+  * vector map with the main transmission lines
+  * linear cost of a new transmission lines [€/km]
+
+- energy market:
+  * energy gain per kWp [€/kWp]
+
+outputs
+^^^^^^^^
+
+Summary table with cost details for each potential areas/clusters
+
+
+
+Hydro module
+=============
+
+
+Hydro Theorethical
+----------------------
+
+- inputs:
+	* DTM
+	* thereshold to generate basins and river or raster with rivers and basins (r.watershed)
+	* shp of rivers from user
+	* shp of points with the ID of the staionn for measures of discharge
+	* path of the files ID.dat with the duration curves [d] [m3/s]
+
+- output:
+	* shp of rivers generated by r.watershed or from user with the specific power [kW/km]
+
+
+Methodology
+^^^^^^^^^^^^
+
+
+Hydro Legal
+------------
+
+- inputs:
+
+
+- output:
+
+
+Methodology
+^^^^^^^^^^^^
+
+
+
+
+Hydro technical
+----------------
+
+
+- inputs:
+  * point vector of the hydro plant with the following features:
+	- kind [water intake, turbine]
+	- discharge [m3/year]
+	- altitude
+	- ID point
+	- ID plant
+  * point vector of the existing plant (irrigation, acqueducts, etc) with the following features:
+	- kind [water intake, return]
+	- annual discharge [m3/year]
+	- ID point
+	- ID plant
+  * plant efficiency [-] default 0.8
+  * legislation for the DMV (to be decided)
+
+  CASE 1 (only run-off the rivers with pipeline)
+    * raster with the Digital Terrain Model (DTM) M (=mandatory)
+    * shp rivers network
+    * raster with run off or measured disharges (?)
+
+  CASE 2 (run-off the rivers in the thalweg + pipeline)
+    * shp of ordered points x y z ID (M) + natural discharge + real discharges
+
+  OPTIONAL
+    * weir position (preferential for water intakes)
+
+  LAW
+    * shp 2000/60 (water directive)
+    * shp 2006/60 (flood directive)
+    * different laws for DMV
+
+  COSTRAINS
+    * maximum elevation limit [m]
+    * minimun distance between two plants
+    * maximum distance between intake adn turbine of the same plant (case with pipeline)
+
+    * plant efficiency [-] default 0.8
+
+
+- output:
+  * shp with river segments with own potential:
+	- annual production [kWh/year]
+	- annual power [kW]
+	- capacity/flow design [m3/s] if the duration curve is given
+        - DMV
+  * raster or shp? with areas/clusters or segments? that satisfy the given constrains.
+
+
+Methodology
+^^^^^^^^^^^^
+
+
+
+Hydro Recommended
+------------------
+
+
+- inputs:
+
+
+- output:
+
+
+Methodology
+^^^^^^^^^^^^
+
+
+
+Hydro economic
+---------------
+
+- inputs:
+  * vector of point with annual production [kWh/year]
+  * n duration of the state incentives or lifetime of the plant [years]
+  * selling price of energy [€]
+  * construction cost [€]
+
+- output:
+  * add column or txt file? with Net Present Value [€]
+

Added: grass-addons/grass7/raster/r.green/r.green.biomassfor/Makefile
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.biomassfor/Makefile	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.biomassfor/Makefile	2015-02-16 13:28:30 UTC (rev 64648)
@@ -0,0 +1,16 @@
+MODULE_TOPDIR = ../../..
+
+PGM=r.green.biomassfor
+
+SUBDIRS = r.green.biomassfor.economic \
+          r.green.biomassfor.theoretical \
+          r.green.biomassfor.recommended \
+          r.green.biomassfor.technical \
+          r.green.biomassfor.legal \
+          r.green.biomassfor.impact \
+
+include $(MODULE_TOPDIR)/include/Make/Dir.make
+
+default: parsubdirs htmldir
+
+install: installsubdirs


Property changes on: grass-addons/grass7/raster/r.green/r.green.biomassfor/Makefile
___________________________________________________________________
Added: svn:executable
   + *

Added: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.economic/Makefile
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.economic/Makefile	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.economic/Makefile	2015-02-16 13:28:30 UTC (rev 64648)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../../../..
+
+PGM = r.green.biomassfor.economic
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script


Property changes on: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.economic/Makefile
___________________________________________________________________
Added: svn:executable
   + *


Property changes on: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.economic/r.green.biomassfor.economic.html
___________________________________________________________________
Added: svn:executable
   + *

Added: 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	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.economic/r.green.biomassfor.economic.py	2015-02-16 13:28:30 UTC (rev 64648)
@@ -0,0 +1,876 @@
+#!/usr/bin/env python
+# -- coding: utf-8 --
+#
+############################################################################
+#!/usr/bin/env python
+#
+# MODULE:      r.green.biomassfor.economic
+# AUTHOR(S):   Sandro Sacchelli, Francesco Geri
+#              Converted to Python by Pietro Zambelli and Francesco Geri, reviewed by Marco Ciolli
+# PURPOSE:     Calculates the economic value of a forests in terms of bioenergy assortments
+# COPYRIGHT:   (C) 2013 by 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.
+#
+#############################################################################
+#
+# default values for prices1: 79.54,81.33,69.51,193,83.45
+#%Module
+#% description: 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
+#% overwrite: yes
+#%End
+#%option 
+#% key: field_prefix
+#% type: string
+#% description: Prefix for forest type yield fields (prefix_voltypx)
+#% key_desc : name
+#% required : yes
+#% guisection: Base
+#%end
+#%option
+#% key: prices
+#% type: double
+#% multiple: yes
+#% description: Market price for a-th assortment €/m³
+#% required : no
+#% guisection: Prices
+#%end
+#%option 
+#% key: output_prefix
+#% type: string
+#% description: Prefix for economic bioenergy (HF,CC and total)
+#% key_desc : name
+#% required : yes
+#% guisection: Base
+#%end
+#%option G_OPT_V_INPUT
+#% key: dhp
+#% type: string
+#% description: Name of vector district heating points
+#% label: Name of vector district heating points
+#% required : no
+#% guisection: Base
+#%end
+#%option G_OPT_R_INPUT
+#% key: yield1
+#% type: string
+#% description: Map of forest yield (cubic meters)
+#% required : yes
+#% guisection: Base
+#%end
+#%option G_OPT_R_INPUT
+#% key: yield_surface
+#% type: string
+#% description: Map of stand surface (ha)
+#% required : yes
+#% guisection: Base
+#%end
+#%option G_OPT_R_INPUT
+#% key: management
+#% type: string
+#% description: Map of forest management (1: high forest, 2:coppice)
+#% required : yes
+#% guisection: Base
+#%end
+#%option G_OPT_R_INPUT
+#% key: treatment
+#% type: string
+#% description: Map of forest treatment (1: final felling, 2:thinning)
+#% required : yes
+#% guisection: Base
+#%end
+#%option G_OPT_R_INPUT
+#% key: forest_roads
+#% type: string
+#% description: Raster map of forest roads (0, 1)
+#% required : yes
+#% guisection: Base
+#%end
+#%option G_OPT_R_INPUT
+#% key: main_roads
+#% type: string
+#% description: Raster map of main roads (0, 1)
+#% required : yes
+#% guisection: Base
+#%end
+#%option G_OPT_R_INPUT
+#% key: dtm2
+#% type: string
+#% description: Name of Digital terrain model map
+#% required : yes
+#% guisection: Base
+#%end
+#%option G_OPT_R_INPUT
+#% key: soilp2_map
+#% type: string
+#% description: Soil production map
+#% required : no
+#% guisection: Opt files
+#%end
+#%option G_OPT_R_INPUT
+#% key: tree_diam
+#% type: string
+#% description: Average tree diameter map
+#% required : no
+#% guisection: Opt files
+#%end
+#%option G_OPT_R_INPUT
+#% key: tree_vol
+#% type: string
+#% description: Average tree volume map
+#% required : no
+#% guisection: Opt files
+#%end
+#%option G_OPT_R_INPUT
+#% key: rivers
+#% type: string
+#% description: Raster map of rivers (0, 1)
+#% required : no
+#% guisection: Opt files
+#%end
+#%option G_OPT_R_INPUT
+#% key: lakes
+#% type: string
+#% description: Raster map of lakes (0, 1)
+#% required : no
+#% 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
+#% required : no
+#% guisection: Opt files
+#%end
+#%option G_OPT_V_INPUT
+#% key: forest
+#% type: string
+#% description: Name of vector parcel map
+#% label: Name of vector parcel map
+#% required : yes
+#% guisection: Base
+#%end
+#%option
+#% key: slp_min_cc
+#% type: double
+#% description: Percent slope lower limit with Cable Crane
+#% answer: 30.
+#% required : no
+#% guisection: Technical data
+#%end
+#%option
+#% key: slp_max_cc
+#% type: double
+#% description: Percent slope higher limit with Cable Crane
+#% answer: 100.
+#% required : no
+#% guisection: Technical data
+#%end
+#%option
+#% key: dist_max_cc
+#% type: double
+#% description: Maximum distance with Cable Crane
+#% answer: 800.
+#% required : no
+#% guisection: Technical data
+#%end
+#%option
+#% key: slp_max_fw
+#% type: double
+#% description: Percent slope higher limit with Forwarder
+#% answer: 30.
+#% required : no
+#% guisection: Technical data
+#%end
+#%option
+#% key: dist_max_fw
+#% type: double
+#% description: Maximum distance with Forwarder
+#% answer: 600.
+#% required : no
+#% guisection: Technical data
+#%end
+#%option
+#% key: slp_max_cop
+#% type: double
+#% description: Percent slope higher limit with other techniques for Coppices
+#% answer: 30.
+#% required : no
+#% guisection: Technical data
+#%end
+#%option
+#% key: dist_max_cop
+#% type: double
+#% description: Maximum distance with other techniques for Coppices
+#% answer: 600.
+#% required : no
+#% guisection: Technical data
+#%end
+#%option
+#% key: price_energy_woodchips
+#% type: double
+#% description: Price for energy from woodchips €/MWh
+#% answer: 19.50
+#% required : no
+#% guisection: Prices
+#%end
+#%option
+#% key: cost_chainsaw
+#% type: double
+#% description: Felling and/or felling-processing cost with chainsaw €/h
+#% answer: 13.17
+#% required : no
+#% guisection: Costs
+#%end
+#%option
+#% key: cost_processor
+#% type: double
+#% description: Processing cost with processor €/h
+#% answer: 87.42
+#% required : no
+#% guisection: Costs
+#%end
+#%option
+#% key: cost_harvester
+#% type: double
+#% description: Felling and processing cost with harvester €/h
+#% answer: 96.33
+#% required : no
+#% guisection: Costs
+#%end
+#%option
+#% key: cost_cableHF
+#% type: double
+#% description: Extraction cost with high power cable crane €/h
+#% answer: 111.44
+#% required : no
+#% guisection: Costs
+#%end
+#%option
+#% key: cost_cableC
+#% type: double
+#% description: Extraction cost with medium power cable crane €/h
+#% answer: 104.31
+#% required : no
+#% guisection: Costs
+#%end
+#%option
+#% key: cost_forwarder
+#% type: double
+#% description: Extraction cost with forwarder €/h
+#% answer: 70.70
+#% required : no
+#% guisection: Costs
+#%end
+#%option
+#% key: cost_skidder
+#% type: double
+#% description: Extraction cost with skidder €/h
+#% answer: 64.36
+#% required : no
+#% guisection: Costs
+#%end
+#%option
+#% key: cost_chipping
+#% type: double
+#% description: Chipping cost €/h
+#% answer: 150.87
+#% required : no
+#% guisection: Costs
+#%end
+#%option
+#% key: cost_transport
+#% type: double
+#% description: Transport with truck €/h
+#% answer: 64.90
+#% required : no
+#% guisection: Costs
+#%end
+#%option
+#% key: energy_tops_hf
+#% type: double
+#% description: Energy for tops and branches in high forest in MWh/m³
+#% answer: 0.49
+#% required : no
+#% guisection: Energy
+#%end
+#%option
+#% key: energy_cormometric_vol_hf
+#% type: double
+#% description: Energy for the whole tree in high forest (tops, branches and stem) in MWh/m³
+#% answer: 1.97
+#% required : no
+#% guisection: Energy
+#%end
+#%option
+#% key: energy_tops_cop
+#% type: double
+#% description: Energy for tops and branches for Coppices in MWh/m³
+#% answer: 0.55
+#% required : no
+#% guisection: Energy
+#%end
+#%flag
+#% key: r
+#% description: Remove all operational maps
+#%end
+#%flag
+#% key: x
+#% description: Raster wood typologies ready to import (prefix_voltypx)
+#%end
+
+
+
+import grass.script as grass
+from grass.script.core import run_command, parser,overwrite
+from grass.pygrass.raster import RasterRow
+import numpy as np
+
+
+import pdb
+import string
+
+ow = overwrite()
+
+
+
+def import_map(opts, flgs,forest):
+    prf_yield = opts['field_prefix']
+    forest_split=str.split(forest,'@')
+
+    campi=str.split(read_command('db.columns', table=forest_split[0]),"\n")
+
+    prefix1=prf_yield+"_voltyp"
+
+    vol_matching = [s for s in campi if prefix1 in s]
+
+
+    for x in vol_matching:
+        run_command("v.to.rast", overwrite=ow, input=forest,
+                output=x, use="attr", attrcolumn=x)
+
+def remove_map(opts, flgs):
+
+    prf_yield = opts['field_prefix']
+
+    pricelist=string.split(opts['prices'],',')
+
+    run_command("g.remove", type="raster", flags="f", name="tot_roads")
+    run_command("g.remove", type="raster", flags="f", name="tot_roads_neg")
+    run_command("g.remove", type="raster", flags="f", name="frict_surf_tr1")
+    run_command("g.remove", type="raster", flags="f", name="frict_surf_tr")
+    run_command("g.remove", type="raster", flags="f", name="transp_dist")
+    run_command("g.remove", type="raster", flags="f", name="transport_prod")
+    run_command("g.remove", type="raster", flags="f", name="fell_costHFtr1")
+    run_command("g.remove", type="raster", flags="f", name="chipp_cost")
+    run_command("g.remove", type="raster", flags="f", name="fell_costHFtr2")
+    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_forw")
+    run_command("g.remove", type="raster", flags="f", name="extr_cost_other")
+    run_command("g.remove", type="raster", flags="f", name="transport_cost")
+    run_command("g.remove", type="raster", flags="f", name="prod_costs")
+    run_command("g.remove", type="raster", flags="f", name="direction_cost")
+    run_command("g.remove", type="raster", flags="f", name="administrative_cost")
+    run_command("g.remove", type="raster", flags="f", name="total_costs")
+    run_command("g.remove", type="raster", flags="f", name="interests")
+    run_command("g.remove", type="raster", flags="f", name="net_revenues")
+    run_command("g.remove", type="raster", flags="f", name="positive_net_revenues")
+    run_command("g.remove", type="raster", flags="f", name="net_rev_pos")
+    run_command("g.remove", type="raster", flags="f", name="economic_surface")
+    run_command("g.remove", type="raster", flags="f", name="chipp_prod")
+    run_command("g.remove", type="raster", flags="f", name="chipp_prodHF")
+    run_command("g.remove", type="raster", flags="f", name="chipp_prodC")
+    run_command("g.remove", type="raster", flags="f", name="extr_cost_cableC")
+    run_command("g.remove", type="raster", flags="f", name="cable_crane_extraction")
+    run_command("g.remove", type="raster", flags="f", name="extr_dist")
+    run_command("g.remove", type="raster", flags="f", name="extr_product_other")
+    run_command("g.remove", type="raster", flags="f", name="extr_cableHF_em")
+    run_command("g.remove", type="raster", flags="f", name="extr_product_cableC")
+    run_command("g.remove", type="raster", flags="f", name="extr_product_cableHF")
+    run_command("g.remove", type="raster", flags="f", name="extr_product_forw")
+    run_command("g.remove", type="raster", flags="f", name="fell_proc_costHFtr1")
+    run_command("g.remove", type="raster", flags="f", name="fell_proc_costHFtr2")
+    run_command("g.remove", type="raster", flags="f", name="fell_proc_productC")
+    run_command("g.remove", type="raster", flags="f", name="fell_proc_productHFtr1")
+    run_command("g.remove", type="raster", flags="f", name="fell_proc_productHFtr2")
+    run_command("g.remove", type="raster", flags="f", name="fell_productHFtr1")
+    run_command("g.remove", type="raster", flags="f", name="fell_productHFtr2")
+    run_command("g.remove", type="raster", flags="f", name="forwarder_extraction")
+    run_command("g.remove", type="raster", flags="f", name="frict_surf_extr")
+    run_command("g.remove", type="raster", flags="f", name="other_extraction")
+    run_command("g.remove", type="raster", flags="f", name="pix_cross")
+    run_command("g.remove", type="raster", flags="f", name="proc_productHFtr1")
+    run_command("g.remove", type="raster", flags="f", name="techn_pix_comp")
+    run_command("g.remove", type="raster", flags="f", name="technical_surface")
+    run_command("g.remove", type="raster", flags="f", name="tot_dist")
+    run_command("g.remove", type="raster", flags="f", name="total_revenues")
+    run_command("g.remove", type="raster", flags="f", name="total_revenues1")
+    run_command("g.remove", type="raster", flags="f", name="total_revenues2")
+    run_command("g.remove", type="raster", flags="f", name="yield_pix")
+    run_command("g.remove", type="raster", flags="f", name="yield_pix1")
+    run_command("g.remove", type="raster", flags="f", name="yield_pix2")
+    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_deg__")
+
+    for x in range(1,len(pricelist)+1):
+        mapvol1=prf_yield+'_vol_typ'+str(x)+'pix'
+        mapvol2=prf_yield+'_vol_typ'+str(x)+'pix2'
+        run_command("g.remove", type="raster", flags="f", name=mapvol1)
+        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):
+
+
+    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.mapcalc", overwrite=ow,
+            expression='pix_cross = ((ewres()+nsres())/2)/ cos(slope_deg__)')
+
+    run_command("r.mapcalc", overwrite=ow,  
+        expression='yield_pix1 = ('+yield_+'/'+yield_surface+')*((ewres()*nsres())/10000)')
+
+    run_command("r.null", map="yield_pix1", null=0)
+
+    exprmap='frict_surf_extr = pix_cross + if(yield_pix1<=0, 99999)'
+
+
+    if rivers!='':
+        run_command("r.null", map=rivers, null=0)
+        exprmap+='+ if('+rivers+'>=1, 99999)'
+
+    if lakes!='':        
+        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)
+
+    run_command("r.cost", overwrite=ow,
+            input="frict_surf_extr", output="extr_dist",
+            stop_points=vector_forest, start_rast=forest_roads,
+            max_cost=1500)
+
+    CCEXTR = 'cable_crane_extraction = if('+yield_+'>0 && slope__>'+opts['slp_min_cc']+' && slope__<='+opts['slp_max_cc']+' && extr_dist<'+opts['dist_max_cc']+', 1)'
+
+    FWEXTR = 'forwarder_extraction = if('+yield_+'>0 && slope__<='+opts['slp_max_fw']+' && '+management+'==1 && ('+roughness+'==0 || '+roughness+'==1 || '+roughness+'==99999) && extr_dist<'+opts['dist_max_fw']+', 1)'
+    
+    OEXTR = 'other_extraction = if('+yield_+'>0 && slope__<='+opts['slp_max_cop']+' && '+management+'==2 && ('+roughness+'==0 || '+roughness+'==1 || '+roughness+'==99999) && extr_dist<'+opts['dist_max_cop']+', 1)'
+
+
+    run_command("r.mapcalc", overwrite=ow,expression=CCEXTR)
+    run_command("r.mapcalc", overwrite=ow,expression=FWEXTR)
+    run_command("r.mapcalc", overwrite=ow,expression=OEXTR)
+
+
+    run_command("r.null", map="cable_crane_extraction", null=0)
+    run_command("r.null", map="forwarder_extraction", null=0)
+    run_command("r.null", map="other_extraction", null=0)
+
+
+    run_command("r.mapcalc", overwrite=ow,expression='technical_surface = cable_crane_extraction + forwarder_extraction + other_extraction')
+    
+    run_command("r.null", map="technical_surface", null=0)
+
+
+    EHF = 'tech_bioenergyHF = technical_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']+')))'
+
+    ECC = 'tech_bioenergyC = technical_surface*(if('+management+' == 2, yield_pix*'+opts['energy_tops_cop']+'))'
+
+    ET='technical_bioenergy=tech_bioenergyHF+tech_bioenergyC'
+
+    # run_command("r.stats.zonal", overwrite=ow,
+    #             base="compartment", cover="technical_surface", method="sum",
+    #             output="techn_pix_comp")
+
+    # run_command("r.mapcalc", overwrite=ow,
+    #     expression='yield_pix2 = yield/(technical_surface*techn_pix_comp)')   
+    
+    # YPIX = 'yield_pix = yield_pix1*%d + yield_pix2*%d'
+
+    # run_command("r.mapcalc", overwrite=ow,
+    #             expression=YPIX % (1 if flgs['u'] else 0, 0 if flgs['u'] else 1,))
+
+    run_command("r.mapcalc", overwrite=ow,expression="yield_pix=yield_pix1")
+
+    # run_command("r.mapcalc", overwrite=ow,expression=YPIX)
+
+    run_command("r.mapcalc", overwrite=ow,expression=EHF)
+    run_command("r.mapcalc", overwrite=ow,expression=ECC)
+    run_command("r.mapcalc", overwrite=ow,expression=ET)
+
+    run_command("g.remove", type="raster", flags="f", name="tech_bioenergyHF,tech_bioenergyC")
+
+    run_command("r.null", map="technical_bioenergy", null=0)
+
+    tech_bioenergy="technical_bioenergy"
+
+    with RasterRow(tech_bioenergy) as pT:
+        T = np.array(pT)
+    print ("Tech bioenergy stimated (Mwh): %.2f" % np.nansum(T))
+
+
+def revenues(opts, flgs,yield_surface,management,treatment):
+    # Calculate revenues
+    prf_yield = opts['field_prefix']
+
+    
+
+    pricelist=string.split(opts['prices'],',') #trasformo la stringa opts in una lista di stringhe
+
+
+    for x in range(1,len(pricelist)+1):
+        price_field=prf_yield+"_voltyp"+str(x)
+        run_command("r.mapcalc", overwrite=ow,expression=prf_yield+'_vol_typ'+str(x)+'pix = ('+price_field+'/'+yield_surface+')*(ewres()*nsres()/10000)')
+        run_command("r.null", map=prf_yield+'_vol_typ'+str(x)+'pix', null=0)
+
+
+        
+    #prices = '+'.join(["vol_typ%dpix*%f" % (i+1, price) for i, price in enumerate(opts['prices'])])
+    prices = '+'.join([prf_yield+"_vol_typ%dpix*%f" % (i+1, float(price)) for i, price in enumerate(pricelist)])
+
+    #pdb.set_trace()
+
+    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 
+    # (destnated to the wood production) and the residuals (for the energy production) 
+    # so inside the total revenues formula there is vol_typXpix*price + bioenergy*energy_price
+
+    run_command("r.mapcalc", overwrite=ow, expression=TR1)
+    
+    
+    #if there is a value of vol_typxx there must be also the corresponding map 
+    
+
+    #divide the yield only in the yarding surface e not in all the parcel surface
+
+
+    # for x in range(1,len(pricelist)+1):
+    #     price_field=prf_yield+"_voltyp"+str(x)
+    #     #pdb.set_trace()
+    #     run_command("r.mapcalc", overwrite=ow,expression=prf_yield+'_vol_typ'+str(x)+'pix2 = '+price_field+'/(technical_surface*@techn_pix_comp)')
+    #     run_command("r.null", map=prf_yield+'_vol_typ'+str(x)+'pix2', null=0)
+
+    # # price_energy_woodchips=float(opts['price_energy_woodchips'])
+    # run_command("r.mapcalc", overwrite=ow,
+    #             expression='total_revenues2 = technical_surface*(if(management == 1 && treatment==1 || management == 1 && treatment==99999 || management == 2,(%s+(technical_bioenergy*%f)), if(management == 1 && treatment==2, technical_bioenergy*20)))' % (prices, price_energy_woodchips))
+    # run_command("r.mapcalc", overwrite=ow,
+    #             expression='total_revenues = total_revenues1*%d + total_revenues2*%d' % (1 if flgs['u'] else 0, 0 if flgs['u'] else 1))
+
+    run_command("r.mapcalc",overwrite=ow,expression='total_revenues=total_revenues1')
+    #total_revenues1: take into account only the yarding surface inside the parcel  
+    #total_revenues2: take into account the entire parcel sufrace 
+    
+    
+def productivity(opts, flgs,management,treatment,soilp2_map,tree_diam,tree_vol,forest_roads,main_roads):
+
+    if tree_diam == '':
+        tree_diam="99999"
+    if tree_vol == '':
+        tree_vol="9.999"
+    if soilp2_map == '':
+        soilp2_map="99999"
+
+    dhp=opts['dhp']
+
+    # 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))))')
+    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))))')
+    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))))')
+    run_command("r.null", map="fell_proc_productC", null=0)
+    #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))))')
+    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))')
+    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))')
+    run_command("r.null", map="chipp_prodHF", null=0)
+    run_command("r.mapcalc", overwrite=ow,
+                expression='chipp_prodC = if('+management+' ==2, yield_pix/45.9)')
+    run_command("r.null", map="chipp_prodC", null=0)
+    run_command("r.mapcalc", overwrite=ow,
+                expression='chipp_prod = chipp_prodHF + chipp_prodC')
+    run_command("r.null", map="chipp_prod", null=0)
+    run_command("r.mapcalc", overwrite=ow,
+                expression='extr_product_cableHF = if('+management+' ==1, cable_crane_extraction*149.33*(extr_dist^-1.3438)* extr_dist/8*0.75)')
+    run_command("r.null", map="extr_product_cableHF", null=0)
+    run_command("r.mapcalc", overwrite=ow,
+                expression='extr_product_cableC = if('+management+' ==2, cable_crane_extraction*149.33*(extr_dist^-1.3438)* extr_dist/8*0.75)')
+    run_command("r.null", map="extr_product_cableC", null=0)
+    run_command("r.mapcalc", overwrite=ow,
+                expression='extr_product_forw = forwarder_extraction*36.293*(extr_dist^-1.1791)* extr_dist/8*0.6')
+    run_command("r.null", map="extr_product_forw", null=0)
+    run_command("r.mapcalc", overwrite=ow,
+                expression='extr_product_other = other_extraction*36.293*(extr_dist^-1.1791)* extr_dist/8*0.6')
+    run_command("r.null", map="extr_product_other", null=0)
+        
+    #cost of the transport distance
+    #this is becouse the wood must be sell to the collection point
+    #instead the residual must be brung to the heating points
+    
+    run_command("r.mapcalc", overwrite=ow,
+                expression='tot_roads = '+forest_roads+' ||| '+main_roads)
+    run_command("r.null", map="tot_roads", null=0)
+    run_command("r.mapcalc", overwrite=ow,
+                expression='tot_roads_neg = if(tot_roads==1,0,1)')
+    run_command("r.null", map="tot_roads_neg", null=1)
+    run_command("r.mapcalc", overwrite=ow,
+                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,
+                    max_cost=100000)
+        run_command("r.mapcalc", overwrite=ow,
+                    expression='transp_dist = tot_dist -  extr_dist')
+    except:
+        run_command("r.mapcalc", overwrite=ow,
+                    expression='transp_dist = extr_dist')
+
+    run_command("r.mapcalc", overwrite=ow,
+                expression='transport_prod = if(('+treatment+' == 1 ||  '+treatment+' == 99999), ((transp_dist/1000/30)*(yield_pix*1/32)*2), if('+management+' ==1 && '+treatment+' == 2, ((transp_dist/1000/30)*(yield_pix*2.7/32)*2)))')
+
+    #the cost of distance transport derived by the negative of the friction surface
+    #the DHP must be inside the study area and connected with the road network
+
+def costs(opts, flgs):
+    # Calculate costs
+
+    run_command("r.mapcalc", overwrite=ow,
+                expression='fell_costHFtr1 = '+opts['cost_chainsaw']+'/fell_productHFtr1*yield_pix')
+    run_command("r.null", map="fell_costHFtr1", null=0)
+    run_command("r.mapcalc", overwrite=ow,
+                expression='fell_costHFtr2 = '+opts['cost_chainsaw']+'/fell_productHFtr2*yield_pix')
+    run_command("r.null", map="fell_costHFtr2", null=0)
+    run_command("r.mapcalc", overwrite=ow,
+                expression='fell_proc_costC = '+opts['cost_chainsaw']+'/fell_proc_productC*yield_pix')
+    run_command("r.null", map="fell_proc_costC", null=0)
+    run_command("r.mapcalc", overwrite=ow,
+                expression='proc_costHFtr1 = '+opts['cost_processor']+'/proc_productHFtr1*yield_pix')
+    run_command("r.null", map="proc_costHFtr1", null=0)
+    run_command("r.mapcalc", overwrite=ow,
+                expression='fell_proc_costHFtr1 = '+opts['cost_harvester']+'/fell_proc_productHFtr1*yield_pix')
+    run_command("r.null", map="fell_proc_costHFtr1", null=0)
+    run_command("r.mapcalc", overwrite=ow,
+                expression='fell_proc_costHFtr2 = '+opts['cost_harvester']+'/fell_proc_productHFtr2*yield_pix')
+    run_command("r.null", map="fell_proc_costHFtr2", null=0)
+    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')
+    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')
+    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')
+    run_command("r.null", map="extr_cost_forw", null=0)
+    run_command("r.mapcalc", overwrite=ow,
+                expression='extr_cost_other = '+opts['cost_skidder']+'/extr_product_other*yield_pix')
+    run_command("r.null", map="extr_cost_other", null=0)
+    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')
+    run_command("r.mapcalc", overwrite=ow,
+                expression='direction_cost =  prod_costs *0.05')
+    run_command("r.mapcalc", overwrite=ow,
+                expression='administrative_cost =  total_revenues*0.07')
+    run_command("r.mapcalc", overwrite=ow,
+                expression='interests = (prod_costs +  administrative_cost)*0.03/4')
+                
+    
+    #management and administration costs
+    
+    ###########################
+    # patch for solve the absence of some optional maps 
+                
+    map_prodcost=grass.find_file('prod_costs',element='cell')
+    map_admcost=grass.find_file('administrative_cost',element='cell')
+    map_dircost=grass.find_file('direction_cost',element='cell')
+    
+    listcost=''
+    
+    if map_admcost['fullname']!='':
+        listcost+=map_admcost['fullname']
+    if map_dircost['fullname']!='':
+        listcost+="+"+map_dircost['fullname']
+    if map_prodcost['fullname']!='':
+        listcost+="+"+map_prodcost['fullname']  
+        
+    # end of patch
+    ###########################
+    
+    
+    run_command("r.mapcalc", overwrite=ow,
+                expression='total_costs = %s' % listcost)
+
+
+def net_revenues(opts, flgs,management,treatment):
+
+
+
+    output = opts['output_prefix']
+
+    econ_bioenergyHF=output+'_econ_bioenergyHF'
+    econ_bioenergyC=output+'_econ_bioenergyC'
+    econ_bioenergy=output+'_econ_bioenergy'
+
+    
+    # Calculate net revenues and economic biomass
+    run_command("r.mapcalc", overwrite=ow,
+                expression='net_revenues = total_revenues - total_costs')
+    run_command("r.mapcalc", overwrite=ow,
+                expression='positive_net_revenues = if(net_revenues<=0,0,1)')
+    run_command("r.mapcalc", overwrite=ow,
+                expression='net_rev_pos = net_revenues*positive_net_revenues')
+    
+    #per evitare che vi siano pixel con revenues>0 sparsi si riclassifica la mappa
+    #in order to avoid pixel greater than 0 scattered the map must be reclassified
+    #considering only the aree clustered greater than 1 hectares
+
+    
+    run_command("r.reclass.area", overwrite=ow,
+                input="positive_net_revenues",
+                output="economic_surface", value=1, mode="greater")
+
+    ECONHF=econ_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']+')))'
+    ECONC=econ_bioenergyC+'= economic_surface*(if('+management+' == 2, yield_pix*'+opts['energy_tops_cop']+'))'
+    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)
+
+    run_command("r.mapcalc", overwrite=ow, expression=ECONC)
+
+    run_command("r.mapcalc", overwrite=ow, expression=ECONTOT)
+
+
+def main(opts, flgs):
+
+
+    output = opts['output_prefix']
+
+
+    yield_=opts['yield1']
+    management=opts['management']
+    treatment=opts['treatment']
+    yield_surface=opts['yield_surface']
+    roughness=opts['roughness']
+    forest_roads=opts['forest_roads']
+    main_roads=opts['main_roads']
+
+    rivers=opts['rivers']
+    lakes=opts['lakes']
+    mmfeatures=opts['mmfeatures']
+    tree_diam=opts['tree_diam']
+    tree_vol=opts['tree_vol']
+    soilp2_map=opts['soilp2_map']
+
+    prf_yield = opts['field_prefix']
+
+
+    vector_forest = opts['forest']
+
+    econ_bioenergyHF=output+'_econ_bioenergyHF'
+    econ_bioenergyC=output+'_econ_bioenergyC'
+    econ_bioenergy=output+'_econ_bioenergy'
+
+    if roughness=='':
+        run_command("r.mapcalc",overwrite=ow,expression='roughness=0')
+        roughness='roughness'
+
+    if tree_diam=='':
+        run_command("r.mapcalc",overwrite=ow,expression='tree_diam=99999')
+        tree_diam='tree_diam'
+
+    if tree_vol=='':
+        run_command("r.mapcalc",overwrite=ow,expression='tree_vol=9.999')
+        tree_diam='tree_vol'
+
+    if soilp2_map=='':
+        run_command("r.mapcalc",overwrite=ow,expression='soil_map=99999')
+        soilp2_map='soil_map'
+
+    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)
+    
+
+    revenues(opts, flgs,yield_surface,management,treatment)
+    
+    productivity(opts, flgs,management,treatment,soilp2_map,tree_diam,tree_vol,forest_roads,main_roads)
+    costs(opts, flgs)
+    net_revenues(opts, flgs,management,treatment)
+
+    if flgs['r'] == True:
+         remove_map(opts, flgs)
+
+
+    with RasterRow(econ_bioenergy) as pT:
+        T = np.array(pT)
+
+    print "Resulted maps: "+output+"_econ_bioenergyHF, "+output+"_econ_bioenergyC, "+output+"_econ_bioenergy"
+    print ("Total bioenergy stimated (Mwh): %.2f" % np.nansum(T))
+
+
+    
+
+if __name__ == "__main__":
+    main(*parser())


Property changes on: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.economic/r.green.biomassfor.economic.py
___________________________________________________________________
Added: svn:executable
   + *

Added: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.html
===================================================================
Added: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.impact/Makefile
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.impact/Makefile	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.impact/Makefile	2015-02-16 13:28:30 UTC (rev 64648)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../../../..
+
+PGM = r.green.biomassfor.impact
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script


Property changes on: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.impact/Makefile
___________________________________________________________________
Added: svn:executable
   + *


Property changes on: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.impact/r.green.biomassfor.impact.html
___________________________________________________________________
Added: svn:executable
   + *

Added: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.impact/r.green.biomassfor.impact.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.impact/r.green.biomassfor.impact.py	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.impact/r.green.biomassfor.impact.py	2015-02-16 13:28:30 UTC (rev 64648)
@@ -0,0 +1,887 @@
+#!/usr/bin/env python
+# -- coding: utf-8 --
+#
+############################################################################
+#
+# MODULE:      r.green.biomassfor.impact
+# AUTHOR(S):   Sandro Sacchelli, Francesco Geri
+#              Converted to Python by Francesco Geri, reviewed by Marco Ciolli 
+# PURPOSE:     Calculates impacts and multifunctionality values regarding fertility maintenance, 
+#              soil water protection, biodiversity, sustainable bioenergy, 
+#              avoided CO2 emission, fire risk, recreation
+# COPYRIGHT:   (C) 2013 by 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.
+#
+#############################################################################
+#
+#%Module
+#% description: Calculates impact and multifunctionality values
+#% overwrite: yes
+#%End
+#%option G_OPT_V_INPUT
+#% key: forest
+#% type: string
+#% description: Name of vector parcel map
+#% label: Name of vector parcel map
+#% required : yes
+#% guisection: Base
+#%end
+#%option G_OPT_R_INPUT
+#% key: yield1
+#% type: string
+#% description: Map of forest yield (cubic meters)
+#% required : yes
+#% guisection: Base
+#%end
+#%option G_OPT_R_INPUT
+#% key: yield_surface
+#% type: string
+#% description: Map of stand surface (ha)
+#% required : yes
+#% guisection: Base
+#%end
+#%option G_OPT_R_INPUT
+#% key: management
+#% type: string
+#% description: Map of forest management (1: high forest, 2:coppice)
+#% required : yes
+#% guisection: Base
+#%end
+#%option G_OPT_R_INPUT
+#% key: treatment
+#% type: string
+#% description: Map of forest treatment (1: final felling, 2:thinning)
+#% required : yes
+#% guisection: Base
+#%end
+#%option G_OPT_R_INPUT
+#% key: forest_roads
+#% type: string
+#% description: Raster map of forest roads (0, 1)
+#% required : yes
+#% guisection: Base
+#%end
+#%option
+#% key: energy_tops_hf
+#% type: double
+#% description: Energy for tops and branches in high forest in MWh/m³
+#% answer: 0.49
+#% required : yes
+#% guisection: Base
+#%end
+#%option
+#% key: energy_cormometric_vol_hf
+#% type: double
+#% description: Energy for tops and branches for high forest in MWh/m³
+#% answer: 1.97
+#% required : yes
+#% guisection: Base
+#%end
+#%option
+#% key: energy_tops_cop
+#% type: double
+#% description: Energy for tops and branches for Coppices in MWh/m³
+#% answer: 0.55
+#% required : yes
+#% guisection: Base
+#%end
+#%option G_OPT_R_INPUT
+#% key: energy_map
+#% description: Bioenergy map in MWh/m³
+#% required : yes
+#% guisection: Base
+#%end
+#%option G_OPT_V_INPUT
+#% key: dhp
+#% type: string
+#% description: Name of vector district heating points
+#% label: Name of vector district heating points
+#% required : yes
+#% guisection: Base
+#%end
+#%option 
+#% key: output_sw_map
+#% type: string
+#% description: Name for output soil and water reduction bioenergy map
+#% key_desc : name
+#% guisection: Soil and water protection
+#%end
+#%option G_OPT_R_INPUT
+#% key: dtm
+#% type: string
+#% description: Name of Digital terrain model map
+#% required : no
+#% guisection : Soil and water protection
+#%end
+#%option G_OPT_R_INPUT
+#% key: soiltx_map
+#% type: string
+#% description: Soil texture map
+#% required : no
+#% guisection: Soil and water protection
+#%end
+#%option G_OPT_R_INPUT
+#% key: soild_map
+#% type: string
+#% description: Soil depth map
+#% required : no
+#% guisection: Soil and water protection
+#%end
+#%option G_OPT_R_INPUT
+#% key: soilcmp_map
+#% type: string
+#% description: Soil compaction risk map
+#% required : no
+#% guisection: Soil and water protection
+#%end
+#%option 
+#% key: output_co2_map
+#% type: string
+#% description: Name for output CO2 emissions map
+#% key_desc : name
+#% guisection: CO2 Emission
+#%end
+#%option 
+#% key: output_aco2_map
+#% type: string
+#% description: Name for output avoided CO2 emissions map
+#% key_desc : name
+#% guisection: CO2 Emission
+#%end
+#%option 
+#% key: output_netco2_map
+#% type: string
+#% description: Name for output net CO2 emissions map
+#% key_desc : name
+#% guisection: CO2 Emission
+#%end
+#%option G_OPT_R_INPUT
+#% key: dtm2
+#% type: string
+#% description: Name of Digital terrain model map
+#% required : no
+#% guisection : CO2 Emission
+#%end
+#%option G_OPT_R_INPUT
+#% key: roughness
+#% type: string
+#% description: Name of roughness map
+#% required : no
+#% guisection: CO2 Emission
+#%end
+#%option G_OPT_R_INPUT
+#% key: soilp2_map
+#% type: string
+#% description: Soil production map
+#% required : no
+#% guisection: CO2 Emission
+#%end
+#%option G_OPT_R_INPUT
+#% key: tree_diam
+#% type: string
+#% description: Average tree diameter map
+#% required : no
+#% guisection: CO2 Emission
+#%end
+#%option G_OPT_R_INPUT
+#% key: tree_vol
+#% type: string
+#% description: Average tree volume map
+#% required : no
+#% guisection: CO2 Emission
+#%end
+#%option G_OPT_R_INPUT
+#% key: main_roads
+#% type: string
+#% description: Name of raster main roads
+#% label: Name of raster main roads
+#% required : yes
+#% guisection: CO2 Emission
+#%end
+#%option G_OPT_R_INPUT
+#% key: rivers
+#% type: string
+#% description: Raster map of rivers (0, 1)
+#% required : no
+#% guisection: CO2 Emission
+#%end
+#%option G_OPT_R_INPUT
+#% key: lakes
+#% type: string
+#% description: Raster map of lakes (0, 1)
+#% required : no
+#% guisection: CO2 Emission
+#%end
+#%option G_OPT_R_INPUT
+#% key: mmfeatures
+#% type: string
+#% description: Raster map of morphometric features
+#% required : no
+#% guisection: CO2 Emission
+#%end
+#%option
+#% key: slp_min_cc
+#% type: double
+#% description: Percent slope lower limit with Cable Crane
+#% answer: 30.
+#% required : no
+#% guisection: CO2 Emission
+#%end
+#%option
+#% key: slp_max_cc
+#% type: double
+#% description: Percent slope higher limit with Cable Crane
+#% answer: 100.
+#% required : no
+#% guisection: CO2 Emission
+#%end
+#%option
+#% key: dist_max_cc
+#% type: double
+#% description: Maximum distance with Cable Crane
+#% answer: 800.
+#% required : no
+#% guisection: CO2 Emission
+#%end
+#%option
+#% key: slp_max_fw
+#% type: double
+#% description: Percent slope higher limit with Forwarder
+#% answer: 30.
+#% required : no
+#% guisection: CO2 Emission
+#%end
+#%option
+#% key: dist_max_fw
+#% type: double
+#% description: Maximum distance with Forwarder
+#% answer: 600.
+#% required : no
+#% guisection: CO2 Emission
+#%end
+#%option
+#% key: slp_max_cop
+#% type: double
+#% description: Percent slope higher limit with other techniques for Coppices
+#% answer: 30.
+#% required : no
+#% guisection: CO2 Emission
+#%end
+#%option
+#% key: dist_max_cop
+#% type: double
+#% description: Maximum distance with other techniques for Coppices
+#% answer: 600.
+#% required : no
+#% guisection: CO2 Emission
+#%end
+#%option 
+#% key: output_fr_map
+#% type: string
+#% description: Name for output reduction map of fire risk
+#% key_desc : name
+#% guisection: Fire risk
+#%end
+#%option G_OPT_R_INPUT
+#% key: firerisk_map
+#% type: string
+#% description: Fire risk map
+#% required : no
+#% guisection: Fire risk
+#%end
+#%option 
+#% key: output_tot_re_map
+#% type: string
+#% description: Name for output total recreational map
+#% key_desc : name
+#% guisection: Recreational
+#%end
+#%option 
+#% key: output_imp_re_map
+#% type: string
+#% description: Name for output improved recreational map
+#% key_desc : name
+#% guisection: Recreational
+#%end
+#%option G_OPT_R_INPUT
+#% key: touristic_map
+#% type: string
+#% description: Touristic map
+#% required : no
+#% guisection: Recreational
+#%end
+#%option G_OPT_V_INPUT
+#% key: tev
+#% type: string
+#% description: Name of vector Total Economic Value map
+#% label: Name of vector Total Economic Value map
+#% required : no
+#% guisection: TEV
+#%end
+#%option 
+#% key: field_tev
+#% type: string
+#% description: Name of field with TEV value
+#% key_desc : name
+#% guisection: TEV
+#%end
+#%option 
+#% key: area_tev
+#% type: string
+#% description: Area of TEV polygons
+#% key_desc : name
+#% guisection: TEV
+#%end
+#%option 
+#% key: output_tev
+#% type: string
+#% description: TEV result
+#% key_desc : name
+#% guisection: TEV
+#%end
+#%option
+#% key: expl
+#% type: string
+#% gisprompt: old,cell,raster
+#% key_desc: name
+#% description: Exploited areas [Energy/m2]
+#% guisection: TEV
+#%end
+#%option
+#% key: impact
+#% type: double
+#% description: Percentange of the impact
+#% guisection: TEV
+#% answer: 0
+#%end
+#%option
+#% key: base
+#% type: string
+#% gisprompt: old,cell,raster
+#% key_desc: name
+#% description: Map of the reference situation for the impact
+#% guisection: TEV
+#%end
+#%flag
+#% key: r
+#% description: Remove all operational maps
+#%end
+
+import grass.script as grass
+from grass.script.core import run_command, parser,overwrite, read_command
+from grass.pygrass.messages import get_msgr
+import numpy as np
+from grass.pygrass.raster import RasterRow
+import pdb
+
+
+ow = overwrite()
+
+
+
+
+def remove_map(opts, flgs):
+
+
+    run_command("g.remove", type="raster", flags="f", name="tot_roads")
+    run_command("g.remove", type="raster", flags="f", name="tot_roads_neg")
+    run_command("g.remove", type="raster", flags="f", name="frict_surf_tr1")
+    run_command("g.remove", type="raster", flags="f", name="frict_surf_tr")
+    run_command("g.remove", type="raster", flags="f", name="transp_dist")
+    run_command("g.remove", type="raster", flags="f", name="transport_prod")
+    run_command("g.remove", type="raster", flags="f", name="chipp_prod")
+    run_command("g.remove", type="raster", flags="f", name="chipp_prodHF")
+    run_command("g.remove", type="raster", flags="f", name="chipp_prodC")
+    run_command("g.remove", type="raster", flags="f", name="extr_cost_cableC")
+    run_command("g.remove", type="raster", flags="f", name="extr_dist")
+    run_command("g.remove", type="raster", flags="f", name="extr_product_other")
+    run_command("g.remove", type="raster", flags="f", name="extr_cableHF_em")
+    run_command("g.remove", type="raster", flags="f", name="extr_product_cableC")
+    run_command("g.remove", type="raster", flags="f", name="extr_product_cableHF")
+    run_command("g.remove", type="raster", flags="f", name="extr_product_forw")
+    run_command("g.remove", type="raster", flags="f", name="fell_proc_costHFtr1")
+    run_command("g.remove", type="raster", flags="f", name="fell_proc_costHFtr2")
+    run_command("g.remove", type="raster", flags="f", name="fell_proc_productC")
+    run_command("g.remove", type="raster", flags="f", name="fell_proc_productHFtr1")
+    run_command("g.remove", type="raster", flags="f", name="fell_proc_productHFtr2")
+    run_command("g.remove", type="raster", flags="f", name="fell_productHFtr1")
+    run_command("g.remove", type="raster", flags="f", name="fell_productHFtr2")
+    run_command("g.remove", type="raster", flags="f", name="forwarder_extraction")
+    run_command("g.remove", type="raster", flags="f", name="frict_surf_extr")
+    run_command("g.remove", type="raster", flags="f", name="other_extraction")
+    run_command("g.remove", type="raster", flags="f", name="pix_cross")
+    run_command("g.remove", type="raster", flags="f", name="proc_productHFtr1")
+    run_command("g.remove", type="raster", flags="f", name="tot_dist")
+    run_command("g.remove", type="raster", flags="f", name="yield_pix")
+    run_command("g.remove", type="raster", flags="f", name="yield_pix1")
+    run_command("g.remove", type="raster", flags="f", name="yield_pix2")
+    run_command("g.remove", type='raster', flags='f', name='slope__')
+    run_command("g.remove", type='raster', flags='f', name='slope_deg__')
+    run_command("g.remove", type='raster', flags='f', name='fell_HFtr1_em')
+    run_command("g.remove", type='raster', flags='f', name='fell_HFtr2_em')
+    run_command("g.remove", type='raster', flags='f', name='fell_proc_C_em')
+    run_command("g.remove", type='raster', flags='f', name='proc_HFtr1_em')
+    run_command("g.remove", type='raster', flags='f', name='fell_proc_HFtr1_em')
+    run_command("g.remove", type='raster', flags='f', name='fell_proc_HFtr2_em')
+    run_command("g.remove", type='raster', flags='f', name='chipp_em')
+    run_command("g.remove", type='raster', flags='f', name='extr_cableHF_em')
+    run_command("g.remove", type='raster', flags='f', name='extr_cableC_em')
+    run_command("g.remove", type='raster', flags='f', name='extr_forw_em')
+    run_command("g.remove", type='raster', flags='f', name='extr_other_em')
+    run_command("g.remove", type='raster', flags='f', name='transport_em')
+
+
+
+
+def yield_pix_process(opts, flgs):
+
+    #YPIX = 'yield_pix = yield_pix1*%d + yield_pix2*%d'
+    YPIX = ''
+
+    yield_surface=opts['yield_surface']
+
+    expr_surf='analysis_surface='+opts['energy_map']+'>0'
+    run_command('r.mapcalc', overwrite=ow,expression=expr_surf)
+
+    # run_command("r.stats.zonal", overwrite=ow,
+    #             base="compartment", cover="analysis_surface", method="sum",
+    #             output="techn_pix_comp")
+
+    run_command("r.mapcalc", overwrite=ow,  
+        expression='yield_pix1 = (yield/'+yield_surface+')*((ewres()*nsres())/10000)')
+
+
+    run_command("r.null", map="yield_pix1", null=0)
+    # run_command("r.mapcalc", overwrite=ow,
+    #     expression='yield_pix2 = yield/(analysis_surface*techn_pix_comp)')   
+
+
+    # run_command("r.mapcalc", overwrite=ow,
+    #     expression=YPIX % (1 if flgs['u'] else 0, 0 if flgs['u'] else 1,))
+
+    #run_command("r.mapcalc", overwrite=ow,expression=YPIX)
+
+
+    run_command("r.mapcalc", overwrite=ow,expression="yield_pix=yield_pix1")
+
+    #run_command("r.mapcalc",overwrite=ow,expression='yield_pix=yield_pix1*0+yield_pix2*1')
+
+def fertility_maintenance(opts, flgs):
+
+    energy_tops_hf=float(opts['energy_tops_hf'])
+    energy_cormometric_vol_hf=float(opts['energy_cormometric_vol_hf'])  
+    management=opts['management']
+    treatment=opts['treatment']
+
+    yield_pix_process(opts, flgs)
+
+    expr_prodFF='site_prod_bioenergyFF = if(('+management+'==1 || '+management+'==2) && ('+treatment+'==1 || '+treatment+'==99999), '+opts['energy_map']+'*0.9)'
+    expr_prodT='site_prod_bioenergyT = if('+treatment+'==2 && ('+opts['soilp_map']+'==1 || '+opts['soilp_map']+'==2), analysis_surface*yield_pix*%f*0+yield_pix*%f, if('+treatment+'==2 && '+opts['soilp_map']+'>2, analysis_surface*yield_pix*%f*0.7+yield_pix*%f))'
+    # Fertility maintenance
+    run_command("r.mapcalc", overwrite=ow, expression=expr_prodFF)
+    run_command("r.mapcalc", overwrite=ow, expression=expr_prodT % (energy_tops_hf, energy_cormometric_vol_hf, energy_tops_hf, energy_cormometric_vol_hf))
+    
+    listmapsite=''
+    map_site_prod_bioenergyT=grass.find_file('site_prod_bioenergyT',element='cell')  
+    map_site_prod_bioenergyFF=grass.find_file('site_prod_bioenergyFF',element='cell') 
+
+    if map_site_prod_bioenergyT['fullname']!='':
+        listmapsite+=map_site_prod_bioenergyT['fullname']
+        if map_site_prod_bioenergyFF['fullname']!='':
+            listmapsite+=","+map_site_prod_bioenergyFF['fullname']
+    else:
+        if map_site_prod_bioenergyFF['fullname']!='':
+            listmapsite+=map_site_prod_bioenergyFF['fullname']    
+            
+    run_command("r.mapcalc", overwrite=ow,
+                expression=opts['output_fert_map']+'= max(%s)' % listmapsite)
+
+
+def soil_water_protection(opts, flgs):
+
+    energy_tops_hf=float(opts['energy_tops_hf'])
+    energy_cormometric_vol_hf=float(opts['energy_cormometric_vol_hf']) 
+
+    management=opts['management']
+    treatment=opts['treatment']
+    
+
+    run_command("r.slope.aspect", flags="a", overwrite=ow,elevation=opts['dtm'], slope="slope__", format="percent") 
+
+    yield_pix_process(opts, flgs)
+
+    # Soil and water protection
+
+    expr_sw1='S_W_prot_bioenergy1 = if(('+treatment+'==1 || '+treatment+'==99999) && slope__<30,'+opts['energy_map']+'*0.67,if(('+treatment+'==1 || '+treatment+'==99999) && slope__>=30, '+opts['energy_map']+'*1))'
+    expr_sw2='S_W_prot_bioenergy2 = if(('+treatment+'==1 || '+treatment+'==99999) && '+opts['soild_map']+'==1,0,if(('+treatment+'==1 || '+treatment+'==99999) && '+opts['soild_map']+'!=1, '+opts['energy_map']+'*1))'
+    expr_sw3='S_W_prot_bioenergy3 = if(('+treatment+'==1 || '+treatment+'==99999) && '+opts['soiltx_map']+'==3,0,if(('+treatment+'==1 || '+treatment+'==99999) && '+opts['soiltx_map']+'!=3, '+opts['energy_map']+'*1))'
+    expr_sw4='S_W_prot_bioenergy4 = if(('+treatment+'==1 || '+treatment+'==99999) && ('+opts['soilcmp_map']+'==4 || '+opts['soilcmp_map']+'==5),0,if(('+treatment+'==1 || '+treatment+'==99999) && ('+opts['soilcmp_map']+'<4 || '+opts['soilcmp_map']+'>5), '+opts['energy_map']+'*1))'
+
+
+    run_command("r.mapcalc", overwrite=ow,expression=expr_sw1)
+    run_command("r.mapcalc", overwrite=ow,expression=expr_sw2)
+    run_command("r.mapcalc", overwrite=ow,expression=expr_sw3)
+    run_command("r.mapcalc", overwrite=ow,expression=expr_sw4)
+    
+
+
+    string_sw_prot=''
+    list_sw_prot=[]
+    for i in range(1,4):
+        file_sw='S_W_prot_bioenergy%s' % i
+        map_sw=grass.find_file(file_sw,element='cell')
+        if map_sw['fullname']!='':
+            list_sw_prot.append(map_sw['fullname'])
+    string_sw_prot=string.join(list_sw_prot,',')   
+
+    
+    expr_sw5='S_W_prot_bioenergy5 = if('+treatment+'==2 && slope__<30,0,if('+treatment+'==2 && slope__ >=30, '+opts['energy_map']+'*1))'
+    expr_sw6='S_W_prot_bioenergy6 = if('+treatment+'==2 && '+opts['soild_map']+'==1,analysis_surface*(yield_pix*%f*0+yield_pix*%f),if('+treatment+'==2 && '+opts['soild_map']+'!=1, analysis_surface*(yield_pix*%f+yield_pix*%f)))'
+    expr_sw7='S_W_prot_bioenergy7 = if('+treatment+'==2 && '+opts['soiltx_map']+'==3,analysis_surface*(yield_pix*%f*0.35+yield_pix*%f),if('+treatment+'==2 && '+opts['soiltx_map']+'!=3, analysis_surface*(yield_pix*%f+yield_pix*%f)))'
+    expr_sw8='S_W_prot_bioenergy8 = if('+treatment+'==2 && ('+opts['soilcmp_map']+'==4 || '+opts['soilcmp_map']+'==5),analysis_surface*(yield_pix*%f*0+yield_pix*%f),if('+treatment+'==2 && ('+opts['soilcmp_map']+'<4 || '+opts['soilcmp_map']+'>5), analysis_surface*(yield_pix*%f+yield_pix*2.1)))'
+
+    run_command("r.mapcalc", overwrite=ow,
+                expression='S_W_prot_bioenergy_FF = min(%s)' % string_sw_prot)
+    run_command("r.mapcalc", overwrite=ow, expression=expr_sw5)
+    run_command("r.mapcalc", overwrite=ow,
+                expression=expr_sw6 % (energy_tops_hf, energy_cormometric_vol_hf, energy_tops_hf, energy_cormometric_vol_hf))
+    run_command("r.mapcalc", overwrite=ow,
+                expression=expr_sw7  % (energy_tops_hf, energy_cormometric_vol_hf, energy_tops_hf, energy_cormometric_vol_hf))
+    run_command("r.mapcalc", overwrite=ow,
+                expression=expr_sw8 % (energy_tops_hf, energy_cormometric_vol_hf, energy_tops_hf))
+
+    string_sw_prot=''
+    list_sw_prot=[]
+    for i in range(5,8):
+        file_sw='S_W_prot_bioenergy%s' % i
+        map_sw=grass.find_file(file_sw,element='cell')
+        if map_sw['fullname']!='':
+            list_sw_prot.append(map_sw['fullname'])
+    string_sw_prot=string.join(list_sw_prot,',')
+
+    run_command("r.mapcalc", overwrite=ow,
+                expression='S_W_prot_bioenergy_T = min(%s)' % string_sw_prot)
+    run_command("r.mapcalc", overwrite=ow,
+                expression=opts['output_sw_map']+' = max(S_W_prot_bioenergy_FF, S_W_prot_bioenergy_T)')
+
+
+
+
+
+def biodiversity_maintenance(opts, flgs):
+    # Biodiversity maintenance
+    run_command("r.null", map='protected_areas', null=0)
+    run_command("r.mapcalc", overwrite=ow,
+                expression='biodiv_bioenergy = if(protected_areas>0,0,if(protected_areas==0, economic_bioenergy*1))')
+
+
+def sustainable_bioenergy(opts, flgs):
+    # Sustainable bioenergy
+    run_command("r.mapcalc", overwrite=ow,
+                expression='sustainable_bioenergy = min(site_prod_bioenergy,  S_W_prot_bioenergy,  biodiv_bioenergy)')
+
+
+
+
+def avoided_CO2_emission(opts, flgs):
+
+    vector_forest=opts['forest']
+    management=opts['management']
+    treatment=opts['treatment']
+    roughness=opts['roughness']
+    yield_=opts['yield1']
+    tree_diam=opts['tree_diam']
+    tree_vol=opts['tree_vol']
+    soil_prod=opts['soilp2_map']
+    forest_roads=opts['forest_roads']
+    main_roads=opts['main_roads']
+    rivers=opts['rivers']
+    lakes=opts['lakes']
+    mmfeatures=opts['mmfeatures']
+
+
+    if tree_diam == '':
+        tree_diam="99999"
+    if tree_vol == '':
+        tree_vol="9.999"
+    if soil_prod == '':
+        soil_prod="99999"
+
+    dhp=opts['dhp']
+
+    #process the yield_pix map
+    yield_pix_process(opts, flgs)
+
+    #control and process the slope map
+    run_command("r.slope.aspect", flags="a", overwrite=ow,elevation=opts['dtm2'], slope="slope__", format="percent")
+    run_command("r.slope.aspect", overwrite=ow,elevation=opts['dtm2'], slope="slope_deg__")
+
+    #process the preparatory maps
+
+
+    run_command("r.mapcalc", overwrite=ow,
+            expression='pix_cross = ((ewres()+nsres())/2)/ cos(slope_deg__)')
+
+
+
+    if roughness=='':
+        run_command("r.mapcalc",overwrite=ow,expression='roughness=0')
+        roughness='roughness'
+
+    
+    exprmap='frict_surf_extr = pix_cross + if(yield_pix1<=0, 99999)'
+    
+    if rivers!='':
+        run_command("r.null", map=rivers, null=0)
+        exprmap+='+ if('+rivers+'>=1, 99999)'
+
+    if lakes!='':        
+        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)
+
+    run_command("r.cost", overwrite=ow,
+            input="frict_surf_extr", output="extr_dist",
+            stop_points=vector_forest, start_rast="forest_roads",
+            max_cost=1500)
+
+    CCEXTR = 'cable_crane_extraction = if('+yield_+'>0 && slope__>'+opts['slp_min_cc']+' && slope__<='+opts['slp_max_cc']+' && extr_dist<'+opts['dist_max_cc']+', 1)'
+
+    FWEXTR = 'forwarder_extraction = if('+yield_+'>0 && slope__<='+opts['slp_max_fw']+' && '+management+'==1 && ('+roughness+'==0 || '+roughness+'==1 || '+roughness+'==99999) && extr_dist<'+opts['dist_max_fw']+', 1)'
+    
+    OEXTR = 'other_extraction = if('+yield_+'>0 && slope__<='+opts['slp_max_cop']+' && '+management+'==2 && ('+roughness+'==0 || '+roughness+'==1 || '+roughness+'==99999) && extr_dist<'+opts['dist_max_cop']+', 1)'
+
+
+    run_command("r.mapcalc", overwrite=ow,expression=CCEXTR)
+    run_command("r.mapcalc", overwrite=ow,expression=FWEXTR)
+    run_command("r.mapcalc", overwrite=ow,expression=OEXTR)
+
+
+    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))))')
+
+
+    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))))')
+
+
+    run_command("r.mapcalc", overwrite=ow,
+                expression='fell_proc_productC = if('+management+' ==2 && '+soil_prod+' <99999,((0.3-(1.1*'+soil_prod+'))/(-4))*(1-(slope__/100)), if('+management+' ==2 && '+soil_prod+' == 99999,((0.3-(1.1*3))/(-4))*(1-((1000-(90*slope__)/(-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.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))))')
+
+
+    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))')
+
+
+    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))')
+    run_command("r.mapcalc", overwrite=ow,
+                expression='chipp_prodC = if('+management+' ==2, yield_pix/45.9)')
+    run_command("r.mapcalc", overwrite=ow,
+                expression='chipp_prod = chipp_prodHF + chipp_prodC')
+
+    run_command("r.mapcalc", overwrite=ow,
+                expression='extr_product_cableHF = if('+management+' ==1, cable_crane_extraction*149.33*(extr_dist^-1.3438)* extr_dist/8*0.75)')
+
+    run_command("r.mapcalc", overwrite=ow,
+                expression='extr_product_cableC = if('+management+' ==2, cable_crane_extraction*149.33*(extr_dist^-1.3438)* extr_dist/8*0.75)')
+    run_command("r.mapcalc", overwrite=ow,
+                expression='extr_product_forw = forwarder_extraction*36.293*(extr_dist^-1.1791)* extr_dist/8*0.6')
+    run_command("r.mapcalc", overwrite=ow,
+                expression='extr_product_other = other_extraction*36.293*(extr_dist^-1.1791)* extr_dist/8*0.6')
+
+
+
+
+    run_command("r.mapcalc", overwrite=ow,
+                expression='tot_roads = '+forest_roads+' ||| '+main_roads+'')
+    run_command("r.null", map="tot_roads", null=0)
+    run_command("r.mapcalc", overwrite=ow,
+                expression='tot_roads_neg = if(tot_roads==1,0,1)')
+    run_command("r.null", map="tot_roads_neg", null=1)
+    run_command("r.mapcalc", overwrite=ow,
+                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.cost", overwrite=ow, input="frict_surf_tr",
+                output="tot_dist", stop_points=vector_forest, start_points=dhp,
+                max_cost=100000)
+    run_command("r.mapcalc", overwrite=ow,
+                expression='transp_dist = tot_dist -  extr_dist')
+    run_command("r.mapcalc", overwrite=ow,
+                expression='transport_prod = if(('+treatment+' == 1 ||  '+treatment+' == 99999), ((transp_dist/1000/30)*(yield_pix*1/32)*2), if('+management+' ==1 && '+treatment+' == 2, ((transp_dist/1000/30)*(yield_pix*2.7/32)*2)))')
+
+
+
+    # Avoided carbon dioxide emission
+    run_command("r.mapcalc", overwrite=ow,
+                expression='fell_HFtr1_em = yield_pix/fell_productHFtr1*4.725')
+    run_command("r.mapcalc", overwrite=ow,
+                expression='fell_HFtr2_em = yield_pix/fell_productHFtr2*4.725')
+    run_command("r.mapcalc", overwrite=ow,
+                expression='fell_proc_C_em = yield_pix/fell_proc_productC*2.363')
+    run_command("r.mapcalc", overwrite=ow,
+                expression='proc_HFtr1_em =  yield_pix/proc_productHFtr1*37.729')
+    run_command("r.mapcalc", overwrite=ow,
+                expression='fell_proc_HFtr1_em = yield_pix/fell_proc_productHFtr1*36.899')
+    run_command("r.mapcalc", overwrite=ow,
+                expression='fell_proc_HFtr2_em = yield_pix/fell_proc_productHFtr2*36.899')
+    run_command("r.mapcalc", overwrite=ow,
+                expression='chipp_em = chipp_prod*130.599')
+    run_command("r.mapcalc", overwrite=ow,
+                expression='extr_cableHF_em = yield_pix/extr_product_cableHF*20.730')
+    run_command("r.mapcalc", overwrite=ow,
+                expression='extr_cableC_em = yield_pix/extr_product_cableC*12.956')
+    run_command("r.mapcalc", overwrite=ow,
+                expression='extr_forw_em = yield_pix/extr_product_forw*25.394')
+    run_command("r.mapcalc", overwrite=ow,
+                expression='extr_other_em = yield_pix/extr_product_other*15.548')
+    run_command("r.mapcalc", overwrite=ow,
+                expression='transport_em =  transport_prod*24.041')
+    run_command("r.null", map='fell_HFtr1_em', null=0)
+    run_command("r.null", map='fell_HFtr2_em', null=0)
+    run_command("r.null", map='fell_proc_C_em', null=0)
+    run_command("r.null", map='proc_HFtr1_em', null=0)
+    run_command("r.null", map='fell_proc_HFtr1_em', null=0)
+    run_command("r.null", map='fell_proc_HFtr2_em', null=0)
+    run_command("r.null", map='chipp_em', null=0)
+    run_command("r.null", map='extr_cableHF_em', null=0)
+    run_command("r.null", map='extr_cableC_em', null=0)
+    run_command("r.null", map='extr_forw_em', null=0)
+    run_command("r.null", map='extr_other_em', null=0)
+    run_command("r.null", map='transport_em', null=0)
+    run_command("r.mapcalc", overwrite=ow, expression=opts['output_co2_map']+' = (analysis_surface*(fell_HFtr1_em  + fell_HFtr2_em + fell_proc_C_em + proc_HFtr1_em + fell_proc_HFtr1_em + fell_proc_HFtr2_em + chipp_em + extr_cableHF_em + extr_cableC_em + extr_forw_em + extr_other_em + transport_em))/1000')
+    run_command("r.mapcalc", overwrite=ow, expression=opts['output_aco2_map']+' = '+opts['energy_map']+'*320')
+    #run_command("r.mapcalc", overwrite=ow, expression=opts['output_netco2_map']+' = analysis_surface*'+('+opts['output_aco2_map']+' - '+opts['output_co2_map']+')/1000')
+    run_command("r.mapcalc", overwrite=ow, expression=opts['output_netco2_map']+' = analysis_surface*('+opts['output_aco2_map']+' - '+opts['output_co2_map']+')/1000')
+
+    mapco2=opts['output_co2_map']
+    with RasterRow(mapco2) as pT:
+        T = np.array(pT)
+
+    mapaco2=opts['output_netco2_map']
+    with RasterRow(mapaco2) as pT1:
+        A = np.array(pT1)
+   
+    print ("Total emission (Tons): %.2f" % np.nansum(T))
+    print ("Total avoided emission (Tons): %.2f" % np.nansum(A))
+
+
+def fire_risk_reduction(opts, flgs):
+    # Fire risk reduction
+    expr_surf='analysis_surface='+opts['energy_map']+'>0'
+    run_command('r.mapcalc', overwrite=ow,expression=expr_surf)
+    run_command("r.mapcalc", overwrite=ow, expression=opts['output_fr_map']+' = if(analysis_surface==1,'+opts['firerisk_map']+'*0.7, '+opts['firerisk_map']+'*1)')
+
+
+def recreational_improvement(opts, flgs):
+    # Recreational improvement
+    expr_surf='analysis_surface='+opts['energy_map']+'>0'
+    run_command('r.mapcalc', overwrite=ow,expression=expr_surf)
+    run_command("r.mapcalc", overwrite=ow, expression=opts['output_tot_re_map']+' = (ewres()*nsres()/10000)*'+opts['touristic_map'])
+    run_command("r.mapcalc", overwrite=ow, expression=opts['output_imp_re_map']+' = if(analysis_surface==1,(ewres()*nsres()/10000)*'+opts['touristic_map'])
+
+
+def tev(opts,flgs):
+
+
+    TEV = opts['tev']
+    field_tev=opts['field_tev']
+    expl = opts['expl']
+    impact = opts['impact']
+    base = opts['base']
+    res = opts['output_tev']
+    area_tev = opts['area_tev']
+
+
+    forest_split=str.split(TEV,'@')
+
+    fields=str.split(read_command('db.columns', table=forest_split[0]),"\n")
+
+
+    vol_matching = [s for s in fields if field_tev in s]
+
+    vol_matching2 = [s for s in fields if area_tev in s]
+
+    #pdb.set_trace()
+
+    if (len(vol_matching)<1) or (len(vol_matching2<1)) :
+        #get_msgr().fatal("Field in vector TEV map not found")
+        print "Errors in fields of TEV map"
+        return
+
+    run_command("v.to.rast", overwrite=ow, input=TEV,
+                output="tev1", use="attr", attrcolumn=field_tev)
+
+    run_command("v.to.rast", overwrite=ow, input=TEV,
+                output="tev_area", use="attr", attrcolumn=area_tev)
+
+    run_command("r.mapcalc", overwrite=ow, expression='tev_map=(tev1/tev_area)*ewres()*nsres()')
+
+    TEV2="tev_area"
+
+    if base:
+        formula_tev = "%s=if(%s>0, %s-%f*%s/%s*%s)" % (res, expl, TEV2, impact,
+                                                   expl, base, TEV2)
+    else:
+        formula_tev = "%s=if(%s>0, %s-%f*%s)" % (res, expl, TEV2, impact, expl,
+                                             base, TEV2)
+    mapcalc(formula_tev, overwrite=True)
+
+    with RasterRow(TEV2) as pT:
+        T = np.array(pT)
+    with RasterRow(res) as pR:
+        R = np.array(pR)
+
+    print("_________")
+    print("IMPACT")
+    print("_________")
+    print("Total value at the beginning %.2f" % np.nansum(T))
+    print("Total value after the exploitation %.2f" % np.nansum(R))
+
+
+def main(opts, flgs):
+
+    # if(opts['output_fert_map'])!="":
+    #     fertility_maintenance(opts, flgs)
+
+    if(opts['output_sw_map'])!="":
+        soil_water_protection(opts, flgs)
+    
+    # biodiversity_maintenance(opts, flgs)
+    # sustainable_bioenergy(opts, flgs)
+
+    if(opts['output_co2_map'])!="":        
+        avoided_CO2_emission(opts, flgs)
+
+    if(opts['output_fr_map'])!="":        
+        fire_risk_reduction(opts, flgs)
+
+    if(opts['output_tot_re_map'])!="":        
+        recreational_improvement(opts, flgs)
+
+    if(opts['output_tev'])!="":        
+        tev(opts, flgs)
+
+    if flgs['r'] == True:
+         remove_map(opts, flgs)
+
+
+
+if __name__ == "__main__":
+    main(*parser())


Property changes on: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.impact/r.green.biomassfor.impact.py
___________________________________________________________________
Added: svn:executable
   + *

Added: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.legal/Makefile
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.legal/Makefile	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.legal/Makefile	2015-02-16 13:28:30 UTC (rev 64648)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../../../..
+
+PGM = r.green.biomassfor.legal
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script
\ No newline at end of file


Property changes on: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.legal/Makefile
___________________________________________________________________
Added: svn:executable
   + *

Added: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.legal/r.green.biomassfor.legal.html
===================================================================
Added: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.legal/r.green.biomassfor.legal.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.legal/r.green.biomassfor.legal.py	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.legal/r.green.biomassfor.legal.py	2015-02-16 13:28:30 UTC (rev 64648)
@@ -0,0 +1,136 @@
+#!/usr/bin/env python
+# -- coding: utf-8 --
+#
+############################################################################
+#
+# MODULE:      r.green.biomassfor.legal
+# AUTHOR(S):   Sandro Sacchelli, Francesco Geri
+#              Converted to Python by Francesco Geri reviewed by Marco Ciolli
+# PURPOSE:     Calculates the potential Ecological Bioenergy contained in a forest
+# COPYRIGHT:   (C) 2013 by 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.
+#
+#############################################################################
+#%Module
+#% description: Estimates legal bioenergy depending on yield, forest management and forest treatment
+#% overwrite: yes
+#%End
+#%option
+#% key: energy_tops_hf
+#% type: double
+#% description: Energy for tops and branches in high forest in MWh/m³
+#% answer: 0.49
+#% required : yes
+#% guisection: Energy
+#%end
+#%option G_OPT_R_INPUT
+#% key: yield1
+#% type: string
+#% description: Map of forest yield (cubic meters)
+#% required : yes
+#%end
+#%option G_OPT_R_INPUT
+#% key: yield_surface
+#% type: string
+#% description: Map of stand surface (ha)
+#% required : yes
+#%end
+#%option G_OPT_R_INPUT
+#% key: management
+#% type: string
+#% description: Map of forest management (1: high forest, 2:coppice)
+#% required : yes
+#%end
+#%option G_OPT_R_INPUT
+#% key: treatment
+#% type: string
+#% description: Map of forest treatment (1: final felling, 2:thinning)
+#% required : yes
+#%end
+#%option 
+#% key: output_prefix
+#% type: string
+#% description: Prefix for potential bioenergy (HF,CC and total)
+#% key_desc : name
+#% required : yes
+#%end
+#%option
+#% key: energy_cormometric_vol_hf
+#% type: double
+#% description: Energy for the whole tree in high forest (tops, branches and stem) in MWh/m³
+#% answer: 1.97
+#% required : no
+#% guisection: Energy
+#%end
+#%option
+#% key: energy_tops_cop
+#% type: double
+#% description: Energy for tops and branches for Coppices in MWh/m³
+#% answer: 0.55
+#% required : no
+#% guisection: Energy
+#%end
+
+from grass.script.core import run_command, parser, overwrite
+from grass.pygrass.raster import RasterRow
+import numpy as np
+
+
+#ECOCC = 'ecological_bioenergyC = if(management==2, yield_pix1*%f)'
+
+
+def main(opts, flgs):
+    ow = overwrite()
+
+    output = opts['output_prefix']
+
+    yield_=opts['yield1']
+    management=opts['management']
+    treatment=opts['treatment']
+    yield_surface=opts['yield_surface']
+
+    l_bioenergyHF=output+'_l_bioenergyHF'
+    l_bioenergyC=output+'_l_bioenergyC'
+    l_bioenergy=output+'_l_bioenergy'
+
+
+    #import pdb; pdb.set_trace()
+    #treatment=1 final felling, treatment=2 thinning
+    ECOHF = l_bioenergyHF+' = if('+management+'==1 && '+treatment+'==1 || '+management+' == 1 && '+treatment+'==99999, yield_pix1*%f, if('+management+'==1 && '+treatment+'==2, yield_pix1*%f + yield_pix1*%f))'                                     
+
+    #ECOHF = 'ecological_bioenergyHF = if(management==1 && treatment==1 || management == 1 && treatment==99999,yield_pix1*'+opts['energy_tops_hf']+', if(management==1 && treatment==2, yield_pix1*'+opts['energy_tops_hf']+' + yield_pix1*'+opts['energy_cormometric_vol_hf']+'))'
+
+    ECOCC = l_bioenergyC+' = if('+management+'==2, yield_pix1*'+opts['energy_tops_cop']+')'
+
+    ECOT=l_bioenergy+' = ('+l_bioenergyHF+' + '+l_bioenergyC+')'
+
+    run_command("r.mapcalc", overwrite=ow,expression='yield_pix1 = (yield/'+yield_surface+')*((ewres()*nsres())/10000)')
+       
+    run_command("r.mapcalc", overwrite=ow,
+                expression=ECOHF % tuple(map(float, (opts['energy_tops_hf'],
+                                                     opts['energy_tops_hf'],
+                                                     opts['energy_cormometric_vol_hf'])))
+                                                     )
+
+    run_command("r.mapcalc", overwrite=ow,expression=ECOCC)
+
+    run_command("r.mapcalc", overwrite=ow,expression=ECOT)
+
+
+
+    with RasterRow(l_bioenergy) as pT:
+        T = np.array(pT)
+
+
+    print "Resulted maps: "+output+"_l_bioenergyHF, "+output+"_l_bioenergyC, "+output+"_l_bioenergy"
+    print ("Total bioenergy stimated (Mwh): %.2f" % np.nansum(T))
+
+
+
+    #print ECOHF % tuple(map(float, (opts['energy_tops_hf'],opts['energy_tops_hf'],opts['energy_cormometric_vol_hf'])))
+
+if __name__ == "__main__":
+    main(*parser())


Property changes on: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.legal/r.green.biomassfor.legal.py
___________________________________________________________________
Added: svn:executable
   + *

Added: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.recommended/Makefile
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.recommended/Makefile	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.recommended/Makefile	2015-02-16 13:28:30 UTC (rev 64648)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../../../..
+
+PGM = r.green.biomassfor.recommended
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script
\ No newline at end of file


Property changes on: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.recommended/Makefile
___________________________________________________________________
Added: svn:executable
   + *

Added: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.recommended/r.green.biomassfor.recommended.html
===================================================================
Added: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.recommended/r.green.biomassfor.recommended.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.recommended/r.green.biomassfor.recommended.py	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.recommended/r.green.biomassfor.recommended.py	2015-02-16 13:28:30 UTC (rev 64648)
@@ -0,0 +1,240 @@
+#!/usr/bin/env python
+# -- coding: utf-8 --
+#
+############################################################################
+#
+# MODULE:      r.green.biomassfor.recommended
+# AUTHOR(S):   Francesco Geri, Sandro Sacchelli
+#              Converted to Python by Francesco Geri reviewed by Marco Ciolli
+# PURPOSE:     Calculates the potential bioenergy contained in a forest accortding to several constraints
+# COPYRIGHT:   (C) 2013 by 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.
+#
+#############################################################################
+#%Module
+#% description: Estimates potential bioenergy according to environmental restriction
+#% overwrite: yes
+#%End
+#%option G_OPT_R_INPUT
+#% key: hfmap
+#% description: Bioenergy potential map for High Forest in MWh/m³
+#%end
+#%option G_OPT_R_INPUT
+#% key: cmap
+#% type: string
+#% description: Bioenergy potential map for Coppice in MWh/m³
+#% required : yes
+#%end
+#%option 
+#% key: output_prefix
+#% type: string
+#% description: Prefix for final recommended maps of bioenergy (HF,CC and total)
+#% key_desc : name
+#% required : yes
+#%end
+#%option G_OPT_R_INPUT
+#% key: management
+#% type: string
+#% description: Map of forest management (1: high forest, 2:coppice)
+#% required : yes
+#%end
+#%option G_OPT_R_INPUT
+#% key: treatment
+#% type: string
+#% description: Map of forest treatment (1: final felling, 2:thinning)
+#% required : yes
+#%end
+#%option G_OPT_R_INPUTS
+#% key: restrictions
+#% type: string
+#% description: Area with absolute restrictions (protected areas, urban parks etc.)
+#% required : no
+#% guisection: Restrictions
+#%end
+#%option G_OPT_R_INPUT
+#% key: hydro
+#% type: string
+#% description: Rivers network
+#% required : no
+#% guisection: Restrictions
+#%end
+#%option
+#% key: buffer_hydro
+#% type: integer
+#% description: Buffer area for rivers
+#% answer: 0
+#% required : no
+#% guisection: Restrictions
+#%end
+#%option G_OPT_R_INPUT
+#% key: zone_less
+#% type: string
+#% description: Civic use
+#% required : no
+#% guisection: Restrictions
+#%end
+#%option
+#% key: energy_tops_hf
+#% type: double
+#% description: Energy for tops and branches in high forest in MWh/m³
+#% answer: 0.49
+#% guisection: Energy
+#%end
+#%option
+#% key: energy_cormometric_vol_hf
+#% type: double
+#% description: Energy for tops and branches for high forest in MWh/m³
+#% answer: 1.97
+#% guisection: Energy
+#%end
+#%option
+#% key: energy_tops_cop
+#% type: double
+#% description: Energy for tops and branches for Coppices in MWh/m³
+#% answer: 0.55
+#% guisection: Energy
+#%end
+
+from grass.script.core import run_command, parser,overwrite
+from grass.pygrass.raster import RasterRow
+import numpy as np
+import string
+import pdb
+
+#check_var checks the presence/absence of the input maps
+check_var=0
+
+def main(opts, flgs):
+    ow = overwrite()
+
+    output = opts['output_prefix']
+    management = opts['management']
+    treatment = opts['treatment']
+
+    #ouput variables
+    rec_bioenergyHF=output+'_rec_bioenergyHF'
+    rec_bioenergyC=output+'_rec_bioenergyC'
+    rec_bioenergy=output+'_rec_bioenergy'
+
+    #input variables
+    pot_HF=opts['hfmap']
+    pot_C=opts['cmap']
+
+    rivers=opts['hydro']
+
+    buffer_hydro=int(opts['buffer_hydro'])
+
+    zone_less=opts['zone_less']
+
+    check_var=0
+
+
+    #pdb.set_trace()
+
+    #check if the raster of rivers is present with a buffer inserted
+    if (buffer_hydro>0 and rivers==""):
+        print "if the river buffer is greater than zero, the raster map of rivers is required"
+        return
+
+    #recovery of the series of raster constraint maps
+    restr_map=opts['restrictions'].split(',')
+
+    #start the query string
+    expr_map="constraint="
+
+
+    #check if at least 1 constraint map is inserted
+    if opts['restrictions']!="":
+        check_var=1
+        count_map=0
+
+        #cycle with composition of the query string with all the constraint maps
+        for mapr_ in restr_map:
+            mapr1=string.split(mapr_,'@')
+            mapr=mapr1[0]
+
+            if count_map==0:
+                expr_map+="("+mapr
+                convert_bool=mapr+"="+mapr+">0"
+                run_command("r.mapcalc", overwrite=1,expression=convert_bool)
+                run_command("r.null", map=mapr, null=0)
+            else:
+                expr_map+="||"+mapr  
+                convert_bool=mapr+"="+mapr+">0"
+                run_command("r.mapcalc", overwrite=1,expression=convert_bool)
+                run_command("r.null", map=mapr, null=0)
+            count_map+=1
+        expr_map+=")"
+        
+    #if the river buffer is inserted add calculate the buffer and
+    # add the buffer to the constraint map
+    if buffer_hydro>0:
+        run_command("r.null", map=rivers, null=0)
+        run_command("r.buffer", overwrite=ow,
+                input=rivers, output="rivers_buffer",
+                distances=buffer_hydro,flags = 'z')
+        run_command("r.null", map="rivers_buffer", null=0)
+        if check_var==1:
+            expr_map+="|| (rivers || rivers_buffer)"
+        else:
+            expr_map+="rivers || rivers_buffer"
+        check_var=1
+
+    if zone_less!="":
+        check_var=1
+
+
+    if check_var==0:
+        print "Error: At least one constraint map must be inserted"
+        return
+    else:
+        #if at least one contraint is inserted process the potential map
+        run_command("r.mapcalc", overwrite=ow,expression=rec_bioenergyHF+"="+pot_HF)
+        run_command("r.mapcalc", overwrite=ow,expression=rec_bioenergyC+"="+pot_C)
+
+        run_command("r.mapcalc", overwrite=ow,expression=expr_map)
+        run_command("r.mapcalc", overwrite=ow, expression="constraint=constraint<1")
+        run_command("r.null", map="constraint", null=0)
+        
+        constr_HF=rec_bioenergyHF+"="+rec_bioenergyHF+"*constraint"
+        constr_C=rec_bioenergyC+"="+rec_bioenergyC+"*constraint"
+
+        run_command("r.mapcalc", overwrite=ow,expression=constr_HF)
+        run_command("r.mapcalc", overwrite=ow,expression=constr_C) 
+
+    if zone_less!="":
+        run_command("r.mapcalc", overwrite=ow, expression='wood_pix=('+zone_less+'/((ewres()*nsres())*10000))')
+        WHF = 'wood_energyHF= if('+management+'==1 && '+treatment+'==1 || '+management+' == 1 && '+treatment+'==99999, wood_pix*%f, if('+management+'==1 && '+treatment+'==2, wood_pix*%f + wood_pix*%f))' 
+        WCC = 'wood_energyC = if('+management+'==2, wood_pix*'+opts['energy_tops_cop']+')'
+        run_command("r.mapcalc", overwrite=ow,expression=WHF % tuple(map(float, (opts['energy_tops_hf'],opts['energy_tops_hf'],opts['energy_cormometric_vol_hf']))))
+        run_command("r.mapcalc", overwrite=ow, expression=WCC)
+
+        run_command("r.null", map="wood_energyHF", null=0)
+        run_command("r.null", map="wood_energyC", null=0)
+
+        limit_HF=rec_bioenergyHF+"="+rec_bioenergyHF+"-wood_energyHF"
+        limit_C=rec_bioenergyC+"="+rec_bioenergyC+"-wood_energyC"
+
+        run_command("r.mapcalc", overwrite=ow,expression=limit_HF)
+        run_command("r.mapcalc", overwrite=ow,expression=limit_C) 
+
+
+    RECOT=rec_bioenergy+' = ('+rec_bioenergyHF+' + '+rec_bioenergyC+')'
+
+    run_command("r.mapcalc", overwrite=ow,expression=RECOT) 
+
+    with RasterRow(rec_bioenergy) as pT:
+        T = np.array(pT)
+
+    print "Resulted maps: "+output+"_rec_bioenergyHF, "+output+"_rec_bioenergyC, "+output+"_rec_bioenergy"
+    print ("Total bioenergy stimated (Mwh): %.2f" % np.nansum(T))
+
+    #print "Resulted maps: "+output+"_rec_bioenergyHF, "+output+"_rec_bioenergyC, "+output+"_rec_bioenergy"
+
+
+
+if __name__ == "__main__":
+    main(*parser())


Property changes on: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.recommended/r.green.biomassfor.recommended.py
___________________________________________________________________
Added: svn:executable
   + *

Added: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.technical/Makefile
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.technical/Makefile	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.technical/Makefile	2015-02-16 13:28:30 UTC (rev 64648)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../../../..
+
+PGM = r.green.biomassfor.technical
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script
\ No newline at end of file


Property changes on: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.technical/Makefile
___________________________________________________________________
Added: svn:executable
   + *

Added: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.technical/biomasfor.technical.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.technical/biomasfor.technical.py	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.technical/biomasfor.technical.py	2015-02-16 13:28:30 UTC (rev 64648)
@@ -0,0 +1,187 @@
+#!/usr/bin/env python
+# -- coding: utf-8 --
+#
+############################################################################
+#
+# MODULE:      biomasfor.import
+# AUTHOR(S):   Sandro Sacchelli
+#              Converted to Python by Pietro Zambelli, reviewed by Marco Ciolli
+# PURPOSE:     Calculates the technical potential taking into account morphology and operative technical limits
+# COPYRIGHT:   (C) 2013 by 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.
+#
+#############################################################################
+#
+#%Module
+#% description: Assess the technical biomass availability
+#% overwrite: yes
+#%End
+#%option G_OPT_R_INPUT
+#% key: dtm
+#% type: string
+#% description: Name of Digital terrain model map
+#% required : yes
+#%end
+#%option
+#% key: slp_min_cc
+#% type: double
+#% description: Percent slope lower limit with Cable Crane
+#% answer: 30.
+#% required : no
+#% guisection: Cable Crane
+#%end
+#%option
+#% key: slp_max_cc
+#% type: double
+#% description: Percent slope higher limit with Cable Crane
+#% answer: 100.
+#% required : no
+#% guisection: Cable Crane
+#%end
+#%option
+#% key: dist_max_cc
+#% type: double
+#% description: Maximum distance with Cable Crane
+#% answer: 800.
+#% required : no
+#% guisection: Cable Crane
+#%end
+#%option
+#% key: slp_max_fw
+#% type: double
+#% description: Percent slope higher limit with Forwarder
+#% answer: 30.
+#% required : no
+#% guisection: Forwarder
+#%end
+#%option
+#% key: dist_max_fw
+#% type: double
+#% description: Maximum distance with Forwarder
+#% answer: 600.
+#% required : no
+#% guisection: Forwarder
+#%end
+#%option
+#% key: slp_max_cop
+#% type: double
+#% description: Percent slope higher limit with other techniques for Coppices
+#% answer: 30.
+#% required : no
+#% guisection: Other
+#%end
+#%option
+#% key: dist_max_cop
+#% type: double
+#% description: Maximum distance with other techniques for Coppices
+#% answer: 600.
+#% required : no
+#% guisection: Other
+#%end
+#%option
+#% key: energy_tops_hf
+#% type: double
+#% description: Energy for tops and branches in high forest in MWh/m³
+#% answer: 0.49
+#% required : no
+#% guisection: Energy
+#%end
+#%option
+#% key: energy_cormometric_vol_hf
+#% type: double
+#% description: Energy for tops and branches for high forest in MWh/m³
+#% answer: 1.97
+#% required : no
+#% guisection: Energy
+#%end
+#%option
+#% key: energy_tops_cop
+#% type: double
+#% description: Energy for tops and branches for Coppices in MWh/m³
+#% answer: 0.55
+#% required : no
+#% guisection: Energy
+#%end
+#%flag
+#% key: u
+#% description: technical bioenergy can be considered to be spread uniformly over the entire surface or to be concentrated in accessible areas.
+#%end
+from grass.script.core import run_command, parser, overwrite
+
+
+
+#CCEXTR = 'cable_crane_extraction = if(yield>0 && slope>%f && slope<=%f && extr_dist<%f, 1)'
+#FWEXTR = 'forwarder_extraction = if(yield>0 && slope<=%f && management==1 && (roughness==0 || roughness==1 || roughness==99999) && extr_dist<%f, 1)'
+#OEXTR = 'other_extraction = if(yield>0 && slope<=%f && management==2 && (roughness==0 || roughness==1 || roughness==99999) && extr_dist<%f, 1)'
+YPIX = 'yield_pix = yield_pix1*%d + yield_pix2*%d'
+#EHF = 'technical_bioenergyHF = technical_surface*(if(management==1 && treatment==1 || management==1 && treatment==99999, yield_pix*%f, if(management==1 && treatment==2, yield_pix * %f + yield_pix * %f)))'
+#ECC = 'technical_bioenergyC = technical_surface*(if(management == 2, yield_pix*%f))'
+
+
+def main(opts, flgs):
+    ow = overwrite()
+
+    
+    CCEXTR = 'cable_crane_extraction = if(yield>0 && slope>'+opts['slp_min_cc']+' && slope<='+opts['slp_max_cc']+' && extr_dist<'+opts['dist_max_cc']+', 1)'
+
+    FWEXTR = 'forwarder_extraction = if(yield>0 && slope<='+opts['slp_max_fw']+' && management==1 && (roughness==0 || roughness==1 || roughness==99999) && extr_dist<'+opts['dist_max_fw']+', 1)'
+
+    OEXTR = 'other_extraction = if(yield>0 && slope<='+opts['slp_max_cop']+' && management==2 && (roughness==0 || roughness==1 || roughness==99999) && extr_dist<'+opts['dist_max_cop']+', 1)'
+
+    EHF = 'technical_bioenergyHF = technical_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']+')))'
+
+    ECC = 'technical_bioenergyC = technical_surface*(if(management == 2, yield_pix*'+opts['energy_tops_cop']+'))'
+
+
+    
+
+    run_command("r.param.scale", overwrite=ow,
+                input=opts['dtm'], output="morphometric_features",
+                size=3, param="feature")
+    run_command("r.slope.aspect", overwrite=ow,
+                elevation=opts['dtm'], slope="slope_deg")
+    run_command("r.mapcalc", overwrite=ow,
+                expression='pix_cross = ((ewres()+nsres())/2)/ cos(slope_deg)')
+    run_command("r.null", map="yield_pix1", null=0)
+    run_command("r.null", map="lakes", null=0)
+    run_command("r.null", map="rivers", null=0)
+    run_command("r.null", map="morphometric_features", null=0)
+    #morphometric_features==6 -> peaks
+    run_command("r.mapcalc", overwrite=ow,
+                expression='frict_surf_extr = if(morphometric_features==6, 99999) + if(rivers>=1 || lakes>=1, 99999) + if(yield_pix1<=0, 99999) + pix_cross')
+    run_command("r.cost", overwrite=ow,
+                input="frict_surf_extr", output="extr_dist",
+                stop_points="forest", start_rast="forest_roads",
+                max_cost=1500)
+    run_command("r.slope.aspect", flags="a", overwrite=ow,
+                elevation=opts['dtm'], slope="slope", format="percent")
+    run_command("r.mapcalc", overwrite=ow,expression=CCEXTR)
+    run_command("r.mapcalc", overwrite=ow,
+                expression=FWEXTR)
+    run_command("r.mapcalc", overwrite=ow,
+                expression=OEXTR)
+    run_command("r.null", map="cable_crane_extraction", null=0)
+    run_command("r.null", map="forwarder_extraction", null=0)
+    run_command("r.null", map="other_extraction", null=0)
+    run_command("r.mapcalc", overwrite=ow,
+                expression='technical_surface = cable_crane_extraction + forwarder_extraction + other_extraction')
+    run_command("r.statistics", overwrite=ow,
+                base="compartment", cover="technical_surface", method="sum",
+                output="techn_pix_comp")
+    run_command("r.mapcalc", overwrite=ow,
+                expression='yield_pix2 = yield/(technical_surface*@techn_pix_comp)')
+    run_command("r.null", map="yield_pix2", null=0)
+    run_command("r.mapcalc", overwrite=ow,
+                expression=YPIX % (1 if flgs['u'] else 0, 0 if flgs['u'] else 1,))
+    run_command("r.mapcalc", overwrite=ow,expression=EHF)
+    run_command("r.mapcalc", overwrite=ow,
+                expression=ECC)
+    run_command("r.mapcalc", overwrite=ow,
+                expression='technical_bioenergy =  (technical_bioenergyHF +  technical_bioenergyC)')
+
+
+if __name__ == "__main__":
+    main(*parser())


Property changes on: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.technical/biomasfor.technical.py
___________________________________________________________________
Added: svn:executable
   + *


Property changes on: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.technical/r.green.biomassfor.technical.html
___________________________________________________________________
Added: svn:executable
   + *

Added: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.technical/r.green.biomassfor.technical.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.technical/r.green.biomassfor.technical.py	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.technical/r.green.biomassfor.technical.py	2015-02-16 13:28:30 UTC (rev 64648)
@@ -0,0 +1,348 @@
+#!/usr/bin/env python
+# -- coding: utf-8 --
+#
+############################################################################
+#
+# MODULE:      r.green.biomassfor.technical
+# AUTHOR(S):   Sandro Sacchelli, Francesco Geri
+#              Converted to Python by Pietro Zambelli, reviewed by Marco Ciolli
+# PURPOSE:     Calculates the technical potential taking into account morphology and operative technical limits
+# COPYRIGHT:   (C) 2013 by 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.
+#
+#############################################################################
+#
+#%Module
+#% description: Estimates the quantity of woody biomass obtained from a forest surface where extraction is possible given a particular level of mechanisation
+#% overwrite: yes
+#%End
+#%option G_OPT_R_INPUT
+#% key: dtm
+#% type: string
+#% description: Name of Digital terrain model map
+#% required : yes
+#% guisection: Base
+#%end
+#%option G_OPT_V_INPUT
+#% key: forest
+#% type: string
+#% description: Name of vector parcel map
+#% label: Name of vector parcel map
+#% required : yes
+#% guisection: Base
+#%end
+#%option G_OPT_R_INPUT
+#% key: yield1
+#% type: string
+#% description: Map of forest yield (cubic meters)
+#% required : yes
+#% guisection: Base
+#%end
+#%option G_OPT_R_INPUT
+#% key: yield_surface
+#% type: string
+#% description: Map of stand surface (ha)
+#% required : yes
+#% guisection: Base
+#%end
+#%option G_OPT_R_INPUT
+#% key: management
+#% type: string
+#% description: Map of forest management (1: high forest, 2:coppice)
+#% required : yes
+#% guisection: Base
+#%end
+#%option G_OPT_R_INPUT
+#% key: treatment
+#% type: string
+#% description: Map of forest treatment (1: final felling, 2:thinning)
+#% required : yes
+#% guisection: Base
+#%end
+#%option G_OPT_R_INPUT
+#% key: forest_roads
+#% type: string
+#% description: Raster map of forest roads (0, 1)
+#% required : yes
+#% guisection: Base
+#%end
+#%option 
+#% key: output_prefix
+#% type: string
+#% description: Prefix for technical bioenergy (HF,CC and total)
+#% key_desc : name
+#% required : yes
+#% guisection: Base
+#%end
+#%option G_OPT_R_INPUT
+#% key: roughness
+#% type: string
+#% description: Name of roughness map
+#% required : no
+#% guisection: Opt files
+#%end
+#%option G_OPT_R_INPUT
+#% key: rivers
+#% type: string
+#% description: Raster map of rivers (0, 1)
+#% required : no
+#% guisection: Opt files
+#%end
+#%option G_OPT_R_INPUT
+#% key: lakes
+#% type: string
+#% description: Raster map of lakes (0, 1)
+#% required : no
+#% 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
+#% key: slp_min_cc
+#% type: double
+#% description: Percent slope lower limit with Cable Crane
+#% answer: 30.
+#% required : yes
+#% guisection: Cable Crane
+#%end
+#%option
+#% key: slp_max_cc
+#% type: double
+#% description: Percent slope higher limit with Cable Crane
+#% answer: 100.
+#% required : no
+#% guisection: Cable Crane
+#%end
+#%option
+#% key: dist_max_cc
+#% type: double
+#% description: Maximum distance with Cable Crane
+#% answer: 800.
+#% required : no
+#% guisection: Cable Crane
+#%end
+#%option
+#% key: slp_max_fw
+#% type: double
+#% description: Percent slope higher limit with Forwarder
+#% answer: 30.
+#% required : no
+#% guisection: Forwarder
+#%end
+#%option
+#% key: dist_max_fw
+#% type: double
+#% description: Maximum distance with Forwarder
+#% answer: 600.
+#% required : no
+#% guisection: Forwarder
+#%end
+#%option
+#% key: slp_max_cop
+#% type: double
+#% description: Percent slope higher limit with other techniques for Coppices
+#% answer: 30.
+#% required : no
+#% guisection: Other
+#%end
+#%option
+#% key: dist_max_cop
+#% type: double
+#% description: Maximum distance with other techniques for Coppices
+#% answer: 600.
+#% required : no
+#% guisection: Other
+#%end
+#%option
+#% key: energy_tops_hf
+#% type: double
+#% description: Energy for tops and branches in high forest in MWh/m³
+#% answer: 0.49
+#% required : yes
+#% guisection: Energy
+#%end
+#%option
+#% key: energy_cormometric_vol_hf
+#% type: double
+#% description: Energy for the whole tree in high forest (tops, branches and stem) in MWh/m³
+#% answer: 1.97
+#% required : yes
+#% guisection: Energy
+#%end
+#%option
+#% key: energy_tops_cop
+#% type: double
+#% description: Energy for tops and branches for Coppices in MWh/m³
+#% answer: 0.55
+#% required : yes
+#% guisection: Energy
+#%end
+#%flag
+#% key: r
+#% description: Remove all operational maps
+#%end
+
+
+import grass.script as grass
+from grass.script.core import run_command, parser, overwrite, parse_command
+from grass.pygrass.raster import RasterRow
+import numpy as np
+
+
+
+#CCEXTR = 'cable_crane_extraction = if(yield>0 && slope>%f && slope<=%f && extr_dist<%f, 1)'
+#FWEXTR = 'forwarder_extraction = if(yield>0 && slope<=%f && management==1 && (roughness==0 || roughness==1 || roughness==99999) && extr_dist<%f, 1)'
+#OEXTR = 'other_extraction = if(yield>0 && slope<=%f && management==2 && (roughness==0 || roughness==1 || roughness==99999) && extr_dist<%f, 1)'
+YPIX = 'yield_pix = yield_pix1*%d + yield_pix2*%d'
+#EHF = 'technical_bioenergyHF = technical_surface*(if(management==1 && treatment==1 || management==1 && treatment==99999, yield_pix*%f, if(management==1 && treatment==2, yield_pix * %f + yield_pix * %f)))'
+#ECC = 'technical_bioenergyC = technical_surface*(if(management == 2, yield_pix*%f))'
+
+
+def remove_map(opts, flgs):
+
+
+    run_command("g.remove", type="raster", flags="f", name="cable_crane_extraction")
+    run_command("g.remove", type="raster", flags="f", name="forwarder_extraction")
+    run_command("g.remove", type="raster", flags="f", name="other_extraction")
+    run_command("g.remove", type="raster", flags="f", name="technical_surface")
+    run_command("g.remove", type="raster", flags="f", name="frict_surf_extr")
+    run_command("g.remove", type="raster", flags="f", name="extr_dist")
+    run_command("g.remove", type="raster", flags="f", name="yield_pix")
+    run_command("g.remove", type="raster", flags="f", name="yield_pix1")
+    run_command("g.remove", type="raster", flags="f", name="yield_pix2")
+    run_command("g.remove", type="raster", flags="f", name="pix_cross")
+    run_command("g.remove", type="raster", flags="f", name="slope_deg")
+    run_command("g.remove", type="raster", flags="f", name="slope")
+
+
+def main(opts, flgs):
+    ow = overwrite()
+
+    output = opts['output_prefix']
+
+    yield_=opts['yield1']
+    management=opts['management']
+    treatment=opts['treatment']
+    yield_surface=opts['yield_surface']
+    roughness=opts['roughness']
+    forest_roads=opts['forest_roads']
+
+    rivers=opts['rivers']
+    lakes=opts['lakes']
+    mmfeatures=opts['mmfeatures']
+
+    vector_forest=opts['forest']
+
+    tech_bioenergyHF=output+'_tech_bioenergyHF'
+    tech_bioenergyC=output+'_tech_bioenergyC'
+    tech_bioenergy=output+'_tech_bioenergy'
+
+
+    if roughness=='':
+        run_command("r.mapcalc",overwrite=ow,expression='roughness=0')
+        roughness='roughness'
+    
+    CCEXTR = 'cable_crane_extraction = if('+yield_+'>0 && slope>'+opts['slp_min_cc']+' && slope<='+opts['slp_max_cc']+' && extr_dist<'+opts['dist_max_cc']+', 1)'
+
+    FWEXTR = 'forwarder_extraction = if('+yield_+'>0 && slope<='+opts['slp_max_fw']+' && '+management+'==1 && ('+roughness+'==0 || '+roughness+'==1 || '+roughness+'==99999) && extr_dist<'+opts['dist_max_fw']+', 1)'
+
+    OEXTR = 'other_extraction = if('+yield_+'>0 && slope<='+opts['slp_max_cop']+' && '+management+'==2 && ('+roughness+'==0 || '+roughness+'==1 || '+roughness+'==99999) && extr_dist<'+opts['dist_max_cop']+', 1)'
+
+    EHF = tech_bioenergyHF+' = technical_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']+')))'
+
+    ECC = tech_bioenergyC+' = technical_surface*(if('+management+' == 2, yield_pix*'+opts['energy_tops_cop']+'))'
+
+    ET=tech_bioenergy+' = ('+tech_bioenergyC+' + '+tech_bioenergyHF+')'
+    
+
+    run_command("r.param.scale", overwrite=ow,
+                input=opts['dtm'], output="morphometric_features",
+                size=3, param="feature")
+    run_command("r.slope.aspect", overwrite=ow,
+                elevation=opts['dtm'], slope="slope_deg")
+    run_command("r.mapcalc", overwrite=ow,
+                expression='pix_cross = ((ewres()+nsres())/2)/ cos(slope_deg)')
+    run_command("r.mapcalc", overwrite=ow,expression='yield_pix1 = ('+yield_+'/'+yield_surface+')*((ewres()*nsres())/10000)')
+    run_command("r.null", map="yield_pix1", null=0)
+
+
+    
+    exprmap='frict_surf_extr = pix_cross + if(yield_pix1<=0, 99999)'
+
+    if rivers!='':
+        run_command("r.null", map=rivers, null=0)
+        exprmap+='+ if('+rivers+'>=1, 99999)'
+
+    if lakes!='':        
+        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)
+
+     
+    #check the result of command
+
+
+    #test=run_command("r.null", map="rivers", null=0)
+    
+    #print "risultato "+str(test)
+    #morphometric_features==6 -> peaks
+    #run_command("r.mapcalc", overwrite=ow,expression='frict_surf_extr = if(morphometric_features==6, 99999) + if(rivers>=1 || lakes>=1, 99999) + if(yield_pix1<=0, 99999) + pix_cross')
+    run_command("r.mapcalc", overwrite=ow,expression=exprmap)
+    
+    run_command("r.cost", overwrite=ow,
+                input="frict_surf_extr", output="extr_dist",
+                stop_points=vector_forest, start_rast=forest_roads,
+                max_cost=1500)
+    run_command("r.slope.aspect", overwrite=ow,
+                elevation=opts['dtm'], slope="slope", format="percent")
+    run_command("r.mapcalc", overwrite=ow,expression=CCEXTR)
+    run_command("r.mapcalc", overwrite=ow,
+                expression=FWEXTR)
+    run_command("r.mapcalc", overwrite=ow,
+                expression=OEXTR)
+    run_command("r.null", map="cable_crane_extraction", null=0)
+    run_command("r.null", map="forwarder_extraction", null=0)
+    run_command("r.null", map="other_extraction", null=0)
+    run_command("r.mapcalc", overwrite=ow,
+                expression='technical_surface = cable_crane_extraction + forwarder_extraction + other_extraction')
+    # run_command("r.statistics", overwrite=ow,
+    #             base="compartment", cover="technical_surface", method="sum",
+    #             output="techn_pix_comp")
+    # run_command("r.mapcalc", overwrite=ow,
+    #             expression='yield_pix2 = yield/(technical_surface*@techn_pix_comp)')
+    # run_command("r.null", map="yield_pix2", null=0)
+    # run_command("r.mapcalc", overwrite=ow,
+    #             expression=YPIX % (1 if flgs['u'] else 0, 0 if flgs['u'] else 1,))
+
+    run_command("r.mapcalc", overwrite=ow,expression="yield_pix=yield_pix1")
+
+
+    run_command("r.mapcalc", overwrite=ow,expression=EHF)
+    run_command("r.mapcalc", overwrite=ow,expression=ECC)
+    run_command("r.mapcalc", overwrite=ow,expression=ET)
+
+    with RasterRow(tech_bioenergy) as pT:
+        T = np.array(pT)
+
+    print "Resulted maps: "+output+"_tech_bioenergyHF, "+output+"_tech_bioenergyC, "+output+"_tech_bioenergy"
+    print ("Total bioenergy stimated (Mwh): %.2f" % np.nansum(T))
+
+
+    if flgs['r'] == True:
+         remove_map(opts, flgs)
+
+
+
+if __name__ == "__main__":
+    main(*parser())


Property changes on: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.technical/r.green.biomassfor.technical.py
___________________________________________________________________
Added: svn:executable
   + *

Added: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.theoretical/Makefile
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.theoretical/Makefile	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.theoretical/Makefile	2015-02-16 13:28:30 UTC (rev 64648)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../../../..
+
+PGM = r.green.biomassfor.theoretical
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script


Property changes on: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.theoretical/Makefile
___________________________________________________________________
Added: svn:executable
   + *


Property changes on: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.theoretical/r.green.biomassfor.theoretical.html
___________________________________________________________________
Added: svn:executable
   + *

Added: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.theoretical/r.green.biomassfor.theoretical.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.theoretical/r.green.biomassfor.theoretical.py	                        (rev 0)
+++ grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.theoretical/r.green.biomassfor.theoretical.py	2015-02-16 13:28:30 UTC (rev 64648)
@@ -0,0 +1,131 @@
+#!/usr/bin/env python
+# -- coding: utf-8 --
+#
+############################################################################
+#
+# MODULE:      r.green.biomassfor.potential
+# AUTHOR(S):   Sandro Sacchelli, Francesco Geri
+#              Converted to Python by Pietro Zambelli and Francesco Geri, reviewed by Marco Ciolli
+# PURPOSE:     Calculates the potential Ecological Bioenergy contained in a forest
+# COPYRIGHT:   (C) 2013 by 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.
+#
+#############################################################################
+#%Module
+#% description: Estimates potential bioenergy depending on forest increment, forest management and forest treatment
+#% overwrite: yes
+#%End
+#%option
+#% key: energy_tops_hf
+#% type: double
+#% description: Energy for tops and branches in high forest in MWh/m³
+#% answer: 0.49
+#% guisection: Energy
+#%end
+#%option G_OPT_R_INPUT
+#% key: increment
+#% type: string
+#% description: Map of increment
+#% required : yes
+#%end
+#%option G_OPT_R_INPUT
+#% key: yield_surface
+#% type: string
+#% description: Map of stand surface (ha)
+#% required : yes
+#%end
+#%option G_OPT_R_INPUT
+#% key: management
+#% type: string
+#% description: Map of forest management (1: high forest, 2:coppice)
+#% required : yes
+#%end
+#%option G_OPT_R_INPUT
+#% key: treatment
+#% type: string
+#% description: Map of forest treatment (1: final felling, 2:thinning)
+#% required : yes
+#%end
+#%option 
+#% key: output_prefix
+#% type: string
+#% description: Prefix for potential bioenergy (HF,CC and total)
+#% key_desc : name
+#% required : yes
+#%end
+#%option
+#% key: energy_cormometric_vol_hf
+#% type: double
+#% description: Energy for the whole tree in high forest (tops, branches and stem) in MWh/m³
+#% answer: 1.97
+#% required : no
+#% guisection: Energy
+#%end
+#%option
+#% key: energy_tops_cop
+#% type: double
+#% description: Energy for tops and branches for Coppices in MWh/m³
+#% answer: 0.55
+#% required : no
+#% guisection: Energy
+#%end
+
+from grass.script.core import run_command, parser, overwrite
+from grass.pygrass.raster import RasterRow
+import numpy as np
+
+
+
+
+#ECOCC = 'ecological_bioenergyC = if(management==2, yield_pix1*%f)'
+
+
+def main(opts, flgs):
+    ow = overwrite()
+
+    output = opts['output_prefix']
+
+    increment=opts['increment']
+    management=opts['management']
+    treatment=opts['treatment']
+    yield_surface=opts['yield_surface']
+
+    p_bioenergyHF=output+'_p_bioenergyHF'
+    p_bioenergyC=output+'_p_bioenergyC'
+    p_bioenergy=output+'_p_bioenergy'
+
+
+    #import pdb; pdb.set_trace()
+    ECOHF = p_bioenergyHF+' = if('+management+'==1 && '+treatment+'==1 || '+management+' == 1 && '+treatment+'==99999, yield_pixp*%f, if('+management+'==1 && '+treatment+'==2, yield_pixp*%f + yield_pixp*%f))'                                     
+
+    #ECOHF = 'ecological_bioenergyHF = if(management==1 && treatment==1 || management == 1 && treatment==99999,yield_pix1*'+opts['energy_tops_hf']+', if(management==1 && treatment==2, yield_pix1*'+opts['energy_tops_hf']+' + yield_pix1*'+opts['energy_cormometric_vol_hf']+'))'
+
+    ECOCC = p_bioenergyC+' = if('+management+'==2, yield_pixp*'+opts['energy_tops_cop']+')'
+
+    ECOT=p_bioenergy+' = ('+p_bioenergyHF+' + '+p_bioenergyC+')'
+
+    run_command("r.mapcalc", overwrite=ow,expression='yield_pixp = ('+increment+'/'+yield_surface+')*((ewres()*nsres())/10000)')
+       
+    run_command("r.mapcalc", overwrite=ow,
+                expression=ECOHF % tuple(map(float, (opts['energy_tops_hf'],
+                                                     opts['energy_tops_hf'],
+                                                     opts['energy_cormometric_vol_hf'])))
+                                                     )
+
+    run_command("r.mapcalc", overwrite=ow,expression=ECOCC)
+
+    run_command("r.mapcalc", overwrite=ow,expression=ECOT)
+    
+
+    with RasterRow(p_bioenergy) as pT:
+        T = np.array(pT)
+
+
+    print "Resulted maps: "+output+"_p_bioenergyHF, "+output+"_p_bioenergyC, "+output+"_p_bioenergy"
+    print ("Total bioenergy stimated (Mwh): %.2f" % np.nansum(T))
+
+if __name__ == "__main__":
+    main(*parser())


Property changes on: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.theoretical/r.green.biomassfor.theoretical.py
___________________________________________________________________
Added: svn:executable
   + *



More information about the grass-commit mailing list