[GRASS-SVN] r71313 - in grass-addons/grass7/raster/r.green/r.green.gshp: libgshp r.green.gshp.theoretical

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jul 24 22:38:26 PDT 2017


Author: zarch
Date: 2017-07-24 22:38:25 -0700 (Mon, 24 Jul 2017)
New Revision: 71313

Modified:
   grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/gpot.py
   grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.theoretical/r.green.gshp.theoretical.html
   grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.theoretical/r.green.gshp.theoretical.py
Log:
r.green.gshp: add heating season as possible input raster

Modified: grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/gpot.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/gpot.py	2017-07-24 21:59:39 UTC (rev 71312)
+++ grass-addons/grass7/raster/r.green/r.green.gshp/libgshp/gpot.py	2017-07-25 05:38:25 UTC (rev 71313)
@@ -40,9 +40,8 @@
       geo-exchange is evaluated.
 
 """
-from numpy import pi, log, sqrt
+from numpy import log, pi, sqrt
 
-# import grass libraries
 from grass.script import raster as grast
 
 
@@ -106,6 +105,20 @@
     return rcmd
 
 
+def r_tc(out, heating_season, execute=True, **kwargs):
+    """
+    Example
+    -------
+    >>> r_tc('tc', 180, execute=False)
+    'tc = 180 / 365.'
+    """
+    res = ("{out} = {heating_season} / 365.")
+    rcmd = res.format(out=out, heating_season=heating_season)
+    if execute:
+        grast.mapcalc(rcmd, **kwargs)
+    return rcmd
+
+
 def norm_thermal_alteration(tc, uc, us):
     """Normalized thermal alteration
 

Modified: grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.theoretical/r.green.gshp.theoretical.html
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.theoretical/r.green.gshp.theoretical.html	2017-07-24 21:59:39 UTC (rev 71312)
+++ grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.theoretical/r.green.gshp.theoretical.html	2017-07-25 05:38:25 UTC (rev 71313)
@@ -7,9 +7,17 @@
 
 
 <h2>EXAMPLES</h2>
+<div class="code"><pre>
+r.green.gshp.theoretical \
+    ground_conductivity=g_conductivity \
+    heating_season_raster=g_hseason \
+    ground_temp_raster=g_temperature \
+    power=gpot_power \
+    energy=gpot_energy \
+    length=gpot_length --o
+</pre></div><br>
 
 
-
 <h2>SEE ALSO</h2>
 <em>
 <a href="r.green.gshp.technical.html">r.green.hydro.technical</a><br>

Modified: grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.theoretical/r.green.gshp.theoretical.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.theoretical/r.green.gshp.theoretical.py	2017-07-24 21:59:39 UTC (rev 71312)
+++ grass-addons/grass7/raster/r.green/r.green.gshp/r.green.gshp.theoretical/r.green.gshp.theoretical.py	2017-07-25 05:38:25 UTC (rev 71313)
@@ -32,8 +32,17 @@
 ##
 ## OPTIONAL INPUTS
 ##
+
+
+#%option G_OPT_R_INPUT
+#% key: heating_season_raster
+#% description: Raster with the Heating Season [0-365] days
+#% required: no
+#% guisection: Demand
+#%end
+
 #%option
-#% key: heating_season
+#% key: heating_season_value
 #% type: double
 #% key_desc: double
 #% description: Heating Season [0-365] days
@@ -54,7 +63,7 @@
 #%end
 
 #%option G_OPT_R_INPUT
-#% key: ground_capacity_rast
+#% key: ground_capacity_raster
 #% description: Raster with depth-averaged ground thermal capacity ρc  [MJ m-3 K-1]
 #% required: no
 #% guisection: Ground
@@ -72,7 +81,7 @@
 
 
 #%option G_OPT_R_INPUT
-#% key: ground_temp_rast
+#% key: ground_temp_raster
 #% description: Raster with the initial ground temperature T0 [°C]
 #% required: no
 #% guisection: Ground
@@ -199,14 +208,14 @@
 
 from __future__ import print_function
 
+import atexit
 import os
 import sys
-import atexit
 
-# import grass libraries
 from grass.script import core as gcore
-from grass.pygrass.utils import set_path
+from grass.script.utils import set_path
 
+
 try:
     # set python path to the shared r.green libraries
     set_path('r.green', 'libgshp', '..')
@@ -259,16 +268,17 @@
     tmpbase = "tmprgreen_%i" % pid
     atexit.register(cleanup, pattern=(tmpbase + '*'), debug=DEBUG)
 
-    heating_season = float(opts['heating_season']) * 24 * 60 * 60
+    heating_season = rast_or_numb('heating_season_raster',
+                                  'heating_season_value', opts)
     lifetime = float(opts['lifetime']) * 365 * 24 * 60 * 60
 
     # ================================================
     # GROUND
     # get raster or scalar value
     ground_conductivity = opts['ground_conductivity']
-    ground_capacity = rast_or_numb('ground_capacity_rast',
+    ground_capacity = rast_or_numb('ground_capacity_raster',
                                    'ground_capacity_value', opts)
-    ground_temperature = rast_or_numb('ground_temp_rast',
+    ground_temperature = rast_or_numb('ground_temp_raster',
                                       'ground_temp_value', opts)
 
     # ================================================
@@ -300,8 +310,10 @@
                      ground_conductivity, ground_capacity, execute=True,
                      overwrite=OVER)
 
+    tc = tmpbase + '_tc'
+    gpot.r_tc(tc, heating_season)
+
     gmax = tmpbase + '_gmax'
-    tc = heating_season / (365. * 24 * 60 * 60.)
     gpot.r_norm_thermal_alteration(gmax, tc, uc, us, execute=True,
                                    overwrite=OVER)
 



More information about the grass-commit mailing list