[GRASS-SVN] r66282 - grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.financial
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Sep 22 05:06:38 PDT 2015
Author: Giulia
Date: 2015-09-22 05:06:38 -0700 (Tue, 22 Sep 2015)
New Revision: 66282
Modified:
grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.financial/r.green.hydro.financial.py
Log:
r.green: put structure input as mandatory
Modified: grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.financial/r.green.hydro.financial.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.financial/r.green.hydro.financial.py 2015-09-22 12:05:02 UTC (rev 66281)
+++ grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.financial/r.green.hydro.financial.py 2015-09-22 12:06:38 UTC (rev 66282)
@@ -26,7 +26,7 @@
#%option G_OPT_V_INPUT
#% key: struct
#% label: Name of the input vector map with the structure of the plants
-#% required: no
+#% required: yes
#%end
#############################################################################
@@ -496,8 +496,6 @@
import os
import atexit
-import random
-
import numpy as np
from grass.script import core as gcore
from grass.exceptions import ParameterError
@@ -585,6 +583,7 @@
slim=slim, width=width, depth=depth),
overwrite=overwrite)
+
def vmapcalc2(vmap, vlayer, cname, ctype, expr, overwrite=False):
v.db_addcolumn(map=vmap, layer=vlayer, columns=[(cname, ctype)],
overwrite=overwrite)
@@ -1009,27 +1008,27 @@
function=max_NPV,
exclude=['intake_id', 'side', 'power',
'gross_head', 'discharge'])
- if opts['output_struct']:
- vec = VectorTopo(opts['output_struct'])
- vec.open('rw')
- vec.table.columns.add('max_NPV','VARCHAR(3)')
-
- list_intakeid=list(set(vec.table.execute('SELECT intake_id FROM %s' %vec.table.name).fetchall()))
-
- for i in range(0,len(list_intakeid)):
- vec.rewind()
- list_npv=list(vec.table.execute('SELECT NPV FROM %s WHERE intake_id=%i;' % (vec.table.name, list_intakeid[i][0])).fetchall())
- npvmax=max(list_npv)[0]
- for line in vec:
- if line.attrs['intake_id'] == list_intakeid[i][0]:
- if line.attrs['NPV'] == npvmax:
- line.attrs['max_NPV']='yes'
- else:
- line.attrs['max_NPV']='no'
+
+ vec = VectorTopo(opts['output_struct'])
+ vec.open('rw')
+ vec.table.columns.add('max_NPV','VARCHAR(3)')
+
+ list_intakeid=list(set(vec.table.execute('SELECT intake_id FROM %s' %vec.table.name).fetchall()))
- vec.table.conn.commit()
- vec.close()
+ for i in range(0,len(list_intakeid)):
+ vec.rewind()
+ list_npv=list(vec.table.execute('SELECT NPV FROM %s WHERE intake_id=%i;' % (vec.table.name, list_intakeid[i][0])).fetchall())
+ npvmax=max(list_npv)[0]
+ for line in vec:
+ if line.attrs['intake_id'] == list_intakeid[i][0]:
+ if line.attrs['NPV'] == npvmax:
+ line.attrs['max_NPV']='yes'
+ else:
+ line.attrs['max_NPV']='no'
+ vec.table.conn.commit()
+ vec.close()
+
if __name__ == "__main__":
main(*parser())
More information about the grass-commit
mailing list