[GRASS-SVN] r69905 - grass-addons/grass7/raster/r.green/r.green.hydro/libhydro

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Nov 24 22:50:44 PST 2016


Author: Giulia
Date: 2016-11-24 22:50:44 -0800 (Thu, 24 Nov 2016)
New Revision: 69905

Modified:
   grass-addons/grass7/raster/r.green/r.green.hydro/libhydro/plant.py
Log:
r.green: add function to have output in MWh

Modified: grass-addons/grass7/raster/r.green/r.green.hydro/libhydro/plant.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.hydro/libhydro/plant.py	2016-11-24 21:46:59 UTC (rev 69904)
+++ grass-addons/grass7/raster/r.green/r.green.hydro/libhydro/plant.py	2016-11-25 06:50:44 UTC (rev 69905)
@@ -11,6 +11,7 @@
 from grass.pygrass.vector.geometry import Line
 from grass.pygrass.vector.table import Link
 from grass.pygrass import utils
+from grass.script import core as gcore
 
 
 COLS = [(u'cat',       'INTEGER PRIMARY KEY'),
@@ -35,6 +36,16 @@
                          ['intake', 'conduct', 'penstock', 'side'])
 
 
+def power2energy(vect, power, n):
+    """ add a column with energy potential (MWh) given the
+    output file and the name of the column with the power (kW), n is
+    the number of working hours"""
+    new_col = 'E_potMW'
+    gcore.run_command('v.db.addcolumn', map=vect, columns=new_col)
+    gcore.run_command('v.db.update', map=vect, layer=1, column=new_col,
+                      query_column='%s * %f' % (power, n/1000.0))
+
+
 def closest(number, ndigits=0, resolution=None):
     """Round a number defining the number of precision decimal digits and
     the resolution.



More information about the grass-commit mailing list