[GRASS-SVN] r69907 - in grass-addons/grass7/raster/r.green/r.green.hydro: r.green.hydro.optimal r.green.hydro.recommended r.green.hydro.technical r.green.hydro.theoretical

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Nov 24 22:54:01 PST 2016


Author: Giulia
Date: 2016-11-24 22:54:01 -0800 (Thu, 24 Nov 2016)
New Revision: 69907

Modified:
   grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.optimal/r.green.hydro.optimal.py
   grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.recommended/r.green.hydro.recommended.py
   grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.technical/r.green.hydro.technical.py
   grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.theoretical/r.green.hydro.theoretical.py
Log:
r.green: add column with energy to the output file

Modified: grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.optimal/r.green.hydro.optimal.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.optimal/r.green.hydro.optimal.py	2016-11-25 06:52:10 UTC (rev 69906)
+++ grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.optimal/r.green.hydro.optimal.py	2016-11-25 06:54:01 UTC (rev 69907)
@@ -172,6 +172,7 @@
     plants = find_segments(river, discharge, elevation, range_plant, distance,
                            p_max)
 
+    # add l_min
     if output_point:
         write_points(plants, output_point, efficiency, p_min)
     write_plants(plants, output_plant, efficiency, p_min)

Modified: grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.recommended/r.green.hydro.recommended.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.recommended/r.green.hydro.recommended.py	2016-11-25 06:52:10 UTC (rev 69906)
+++ grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.recommended/r.green.hydro.recommended.py	2016-11-25 06:54:01 UTC (rev 69907)
@@ -78,6 +78,13 @@
 #% answer: 10.0
 #% required: no
 #%end
+#%option
+#% key: n
+#% type: double
+#% description: Number of operative hours per year [hours/year]
+#% required: no
+#% answer: 3392
+#%end
 
 ##
 ## OPTIONAL INPUTS: LEGAL DISCHARGE
@@ -204,6 +211,7 @@
     set_path('r.green', 'libgreen', os.path.join('..', '..'))
     # finally import the module in the library
     from libgreen.utils import cleanup
+    from libhydro.plant import power2energy
 except ImportError:
     gcore.warning('libgreen and libhydro not in the python path!')
 
@@ -348,7 +356,8 @@
                       len_min=len_min,
                       efficiency=efficiency,
                       p_min=p_min)
-
+    import ipdb; ipdb.set_trace()
+    power2energy(output_plant, 'pot_power', float(options['n']))
     print('r.green.hydro.recommended completed!')
 
 if __name__ == "__main__":

Modified: grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.technical/r.green.hydro.technical.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.technical/r.green.hydro.technical.py	2016-11-25 06:52:10 UTC (rev 69906)
+++ grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.technical/r.green.hydro.technical.py	2016-11-25 06:54:01 UTC (rev 69907)
@@ -161,6 +161,14 @@
 #% guisection: Turbine
 #%end
 #%option
+#% key: n
+#% type: double
+#% description: Number of operative hours per year [hours/year]
+#% required: no
+#% answer: 3392
+#% guisection: Efficiency
+#%end
+#%option
 #% key: efficiency_shaft
 #% type: double
 #% description: Efficiency of the shaft (bearings friction) [-]
@@ -241,6 +249,7 @@
     # finally import the module in the library
     from libgreen.utils import cleanup
     from libhydro.optimal import conv_segpoints
+    from libhydro.plant import power2energy
 except ImportError:
     gcore.warning('libgreen and libhydro not in the python path!')
 
@@ -757,7 +766,9 @@
                         seg.attrs[col] = value
         out.table.conn.commit()
 
+    power2energy(output_plant, 'power', float(options['n']))  
 
+
 if __name__ == "__main__":
     atexit.register(cleanup)
     options, flags = gcore.parser()

Modified: grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.theoretical/r.green.hydro.theoretical.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.theoretical/r.green.hydro.theoretical.py	2016-11-25 06:52:10 UTC (rev 69906)
+++ grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.theoretical/r.green.hydro.theoretical.py	2016-11-25 06:54:01 UTC (rev 69907)
@@ -83,7 +83,7 @@
 #% key: output
 #% type: string
 #% key_desc: name
-#% description: Name of output vector map with basin potential
+#% description: Name of output vector map with basin potential [MWh]
 #% required: yes
 #% guisection: Basin Potential
 #%END
@@ -108,6 +108,7 @@
     # finally import the module in the library
     from libgreen.utils import cleanup
     from libhydro.basin import dtm_corr
+    from libhydro.plant import power2energy
     from libhydro import basin
     from libgreen.utils import check_overlay_rr
     #from libgreen.utils import check_overlay_rv
@@ -178,10 +179,16 @@
 
     perc_overlay = check_overlay_rr(discharge, stream)
     #pdb.set_trace()
-    if float(perc_overlay) < 90:
-        warn = ("Discharge map doesn't overlay all the stream map."
-                "It covers only the %s %% of rivers") % (perc_overlay)
-        msgr.warning(warn)
+    try:
+        p = float(perc_overlay)
+        if p < 90:
+            warn = ("Discharge map doesn't overlay all the stream map."
+                    "It covers only the %s %% of rivers") % (perc_overlay)
+            msgr.warning(warn)
+    except ValueError:
+        msgr.error("Could not convert data to a float")
+    except:
+        msgr.error("Unexpected error")
 
     msgr.message("\Init basins\n")
     #pdb.set_trace()
@@ -216,6 +223,7 @@
     msgr.message("\nWrite results\n")
 
     basin.write_results2newvec(stream, E, basins_tot, inputs)
+    power2energy(E, 'Etot_kW', 8760)
 
 
 if __name__ == "__main__":



More information about the grass-commit mailing list