[GRASS-SVN] r65938 - grass-addons/grass7/raster/r.sun.daily

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Aug 14 23:30:43 PDT 2015


Author: nikosa
Date: 2015-08-14 23:30:42 -0700 (Fri, 14 Aug 2015)
New Revision: 65938

Modified:
   grass-addons/grass7/raster/r.sun.daily/r.sun.daily.py
Log:
Reverted to r65189, unintentional commit was r65936

Modified: grass-addons/grass7/raster/r.sun.daily/r.sun.daily.py
===================================================================
--- grass-addons/grass7/raster/r.sun.daily/r.sun.daily.py	2015-08-14 22:08:31 UTC (rev 65937)
+++ grass-addons/grass7/raster/r.sun.daily/r.sun.daily.py	2015-08-15 06:30:42 UTC (rev 65938)
@@ -37,39 +37,12 @@
 #%end
 
 #%option
-#% key: aspect_value
-#% key_desc: integer
-#% type: integer
-#% description: A single value of the orientation (aspect), 270 is south
-#% options: 0-360
-#% answer: 270
-#% required : no
-#%end
-
-#% rules
-#%  exclusive: aspect, aspect_value
-#% end
-
-#%option
 #% key: slope
 #% type: string
 #% gisprompt: old,cell,raster
 #% description: Name of the input slope raster map (terrain slope or solar panel inclination) [decimal degrees]
 #%end
 
-#%option
-#% key: slope_value
-#% key_desc: float
-#% type: double
-#% description: A single value of inclination (slope)
-#% answer: 0.0
-#% required : no
-#%end
-
-#% rules
-#%  exclusive: slope, slope_value
-#% end
-
 #%option G_OPT_R_INPUT
 #% key: linke
 #% type: string
@@ -84,6 +57,7 @@
 #% type: double
 #% description: A single value of the Linke atmospheric turbidity coefficient [-]
 #% options: 0.0-7.0
+#% answer: 3.0
 #% required : no
 #%end
 
@@ -95,7 +69,7 @@
 #% key: albedo
 #% type: string
 #% gisprompt: old,cell,raster
-#% description: Name of the ground albedo coefficient input raster map [-]
+#% description: Name of the Linke atmospheric turbidity coefficient input raster map [-]
 #% required : no
 #%end
 
@@ -105,6 +79,7 @@
 #% type: double
 #% description: A single value of the ground albedo coefficient [-]
 #% options: 0.0-1.0
+#% answer: 0.2
 #% required : no
 #%end
 
@@ -128,22 +103,6 @@
 #% required : no
 #%end
 
-#%option G_OPT_R_INPUT
-#% key: coeff_bh
-#% type: string
-#% gisprompt: old,cell,raster
-#% description: Name of real-sky beam radiation coefficient (thick cloud) input raster map [0-1]
-#% required : no
-#%end
-
-#%option G_OPT_R_INPUT
-#% key: coeff_dh
-#% type: string
-#% gisprompt: old,cell,raster
-#% description: Name of real-sky diffues radiation coefficient (haze) input raster map [0-1]
-#% required : no
-#%end
-
 #%option G_OPT_R_BASENAME_INPUT
 #% key: horizon_basename
 #% key_desc: basename
@@ -236,14 +195,6 @@
 #%end
 
 #%option
-#% key: insol_time
-#% type: string
-#% gisprompt: new,cell,raster
-#% description: Output insolation time raster map cumulated for the whole period of time [h]
-#% required: no
-#%end
-
-#%option
 #% key: beam_rad_basename
 #% type: string
 #% label: Base name for output beam irradiation raster maps [Wh.m-2.day-1]
@@ -272,13 +223,6 @@
 #%end
 
 #%option
-#% key: insol_time_basename
-#% type: string
-#% label: Base name for output insolation time raster map [h]
-#% description: Underscore and day number are added to the base name for daily maps
-#%end
-
-#%option
 #% key: nprocs
 #% type: integer
 #% description: Number of r.sun processes to run in parallel
@@ -329,71 +273,49 @@
                                           map_=name)
 
 
-def run_r_sun(elevation, aspect, aspect_value, slope, slope_value, latitude,
-              longitude, linke, linke_value, albedo, albedo_value, coeff_bh,
-              coeff_dh, horizon_basename, horizon_step, day, step, beam_rad,
-              diff_rad, refl_rad, glob_rad, insol_time, suffix):
+def run_r_sun(elevation, aspect, slope, latitude, longitude,
+              linke, linke_value, albedo, albedo_value,
+              horizon_basename, horizon_step,
+              day, step, beam_rad, diff_rad, refl_rad, glob_rad, suffix):
     '''
     Execute r.sun using the provided input options. Except for the required
     parameters, the function updates the list of optional/selected parameters
     to instruct for user requested inputs and outputs.
-
     Optional inputs:
 
-    - aspect_value (if not aspect)
-    - slope_value (if not slope)
     - latitude
     - longitude
     - linke  OR  single linke value
     - albedo  OR  single albedo value
-    - horizon maps (basename AND step)
+    - horizon maps
     '''
     params = {}
-
-    # inputs
-    if aspect:
-        params.update({'aspect': aspect})
-    if aspect_value and not aspect:
-        params.update({'aspect_value': aspect_value})
-    if slope:
-        params.update({'slope': slope})
-    if slope_value and not slope:
-        params.update({'slope_value': slope_value})
+    if beam_rad:
+        params.update({'beam_rad': beam_rad + suffix})
+    if diff_rad:
+        params.update({'diff_rad': diff_rad + suffix})
+    if refl_rad:
+        params.update({'refl_rad': refl_rad + suffix})
+    if glob_rad:
+        params.update({'glob_rad': glob_rad + suffix})
     if linke:
         params.update({'linke': linke})
-    if linke_value and not linke:
+    if linke_value:
         params.update({'linke_value': linke_value})
     if albedo:
         params.update({'albedo': albedo})
-    if albedo_value and not albedo:
+    if albedo_value:
         params.update({'albedo_value': albedo_value})
-    if coeff_bh:
-        params.update({'coeff_bh': coeff_bh})
-    if coeff_dh:
-        params.update({'coeff_dh': coeff_dh})
     if horizon_basename and horizon_step:
         params.update({'horizon_basename': horizon_basename})
         params.update({'horizon_step': horizon_step})
 
-    # outputs
-    if beam_rad:
-        params.update({'beam_rad': beam_rad + suffix})
-    if diff_rad:
-        params.update({'diff_rad': diff_rad + suffix})
-    if refl_rad:
-        params.update({'refl_rad': refl_rad + suffix})
-    if glob_rad:
-        params.update({'glob_rad': glob_rad + suffix})
-    if insol_time:
-        params.update({'insol_time': insol_time + suffix})
+    grass.run_command('r.sun', elevation=elevation, aspect=aspect,
+                      slope=slope, day=day, step=step,
+                      overwrite=core.overwrite(), quiet=True,
+                      **params)
 
-    print "Paramters given:", params
-    print
 
-    grass.run_command('r.sun', elevation=elevation, day=day, step=step,
-                      overwrite=core.overwrite(), quiet=True, **params)
-
-
 def set_color_table(rasters):
     """
     Set 'gyr' color tables for raster maps
@@ -444,20 +366,9 @@
 
     # required
     elevation_input = options['elevation']
-
     aspect_input = options['aspect']
-    print "Aspect:", aspect_input
-
-    aspect_value = options['aspect_value']
-    print "Aspect value:", aspect_value
-
     slope_input = options['slope']
-    print "Slope:", slope_input
-    
-    slope_value = options['slope_value']
-    print "Slope value:", slope_value
 
-
     # optional
     latitude = options['lat']
     longitude = options['long']
@@ -465,8 +376,6 @@
     linke_value = options['linke_value']
     albedo_input = options['albedo']
     albedo_value = options['albedo_value']
-    coeff_bh = options['coeff_bh']
-    coeff_dh = options['coeff_dh']
     horizon_basename = options['horizon_basename']
     horizon_step = options['horizon_step']
 
@@ -475,17 +384,15 @@
     diff_rad = options['diff_rad']
     refl_rad = options['refl_rad']
     glob_rad = options['glob_rad']
-    insol_time = options['insol_time']
     beam_rad_basename = beam_rad_basename_user = options['beam_rad_basename']
     diff_rad_basename = diff_rad_basename_user = options['diff_rad_basename']
     refl_rad_basename = refl_rad_basename_user = options['refl_rad_basename']
     glob_rad_basename = glob_rad_basename_user = options['glob_rad_basename']
-    insol_time_basename = insol_time_basename_user = options['insol_time_basename']
 
     # missing output?
-    if not any([beam_rad, diff_rad, refl_rad, glob_rad, insol_time,
+    if not any([beam_rad, diff_rad, refl_rad, glob_rad,
                 beam_rad_basename, diff_rad_basename,
-                refl_rad_basename, glob_rad_basename, insol_time_basename]):
+                refl_rad_basename, glob_rad_basename]):
         grass.fatal(_("No output specified."))
 
     start_day = int(options['start_day'])
@@ -518,9 +425,6 @@
     if glob_rad and not glob_rad_basename:
         glob_rad_basename = create_tmp_map_name('glob_rad')
         MREMOVE.append(glob_rad_basename)
-    if insol_time and not insol_time_basename:
-        insol_time_basename = create_tmp_map_name('insol_time')
-        MREMOVE.append(insol_time_basename)
 
     # check for existing identical map names
     if not grass.overwrite():
@@ -532,22 +436,15 @@
                               start_day, end_day, day_step)
         check_daily_map_names(glob_rad_basename, grass.gisenv()['MAPSET'],
                               start_day, end_day, day_step)
-        check_daily_map_names(insol_time_basename, grass.gisenv()['MAPSET'],
-                              start_day, end_day, day_step)
 
     # check for slope/aspect
-    if not aspect_value or not slope_value:
-
+    if not aspect_input or not slope_input:
         params = {}
-
-        if not aspect_input and not aspect_value:
-            print "Will produce Aspect"
+        if not aspect_input:
             aspect_input = create_tmp_map_name('aspect')
             params.update({'aspect': aspect_input})
             REMOVE.append(aspect_input)
-
-        if not slope_input and not slope_value:
-            print "Will produce Slope"
+        if not slope_input:
             slope_input = create_tmp_map_name('slope')
             params.update({'slope': slope_input})
             REMOVE.append(slope_input)
@@ -564,8 +461,6 @@
         grass.mapcalc('{refl} = 0'.format(refl=refl_rad), quiet=True)
     if glob_rad:
         grass.mapcalc('{glob} = 0'.format(glob=glob_rad), quiet=True)
-    if insol_time:
-        grass.mapcalc('{insol} = 0'.format(insol=insol_time), quiet=True)
 
     grass.info(_("Running r.sun in a loop..."))
     count = 0
@@ -584,19 +479,16 @@
         suffix = '_' + format_order(day)
         proc_list.append(Process(target=run_r_sun,
                                  args=(elevation_input,
-                                       aspect_input, aspect_value,
-                                       slope_input, slope_value,
+                                       aspect_input, slope_input,
                                        latitude, longitude,
                                        linke_input, linke_value,
                                        albedo_input, albedo_value,
-                                       coeff_bh, coeff_dh,
                                        horizon_basename, horizon_step,
                                        day, step,
                                        beam_rad_basename,
                                        diff_rad_basename,
                                        refl_rad_basename,
                                        glob_rad_basename,
-                                       insol_time_basename,
                                        suffix)))
 
         proc_list[proc_count].start()
@@ -622,8 +514,6 @@
                 sum_maps(refl_rad, refl_rad_basename, suffixes)
             if glob_rad:
                 sum_maps(glob_rad, glob_rad_basename, suffixes)
-            if insol_time:
-                sum_maps(insol_time, insol_time_basename, suffixes)
 
             # Empty process list
             proc_list = []
@@ -641,12 +531,9 @@
         set_color_table([refl_rad])
     if glob_rad:
         set_color_table([glob_rad])
-    if insol_time:
-        set_color_table([insol_time])
 
     if not any([beam_rad_basename_user, diff_rad_basename_user,
-                refl_rad_basename_user, glob_rad_basename_user,
-                insol_time_basename_user]):
+                refl_rad_basename_user, glob_rad_basename_user]):
         return 0
 
     # add timestamps and register to spatio-temporal raster data set
@@ -663,7 +550,7 @@
             maps = ','.join([basename + suf + '@' + mapset for suf in suffixes])
             tgis.open_new_stds(basename, type='strds', temporaltype='relative',
                                title=title, descr=desc, semantic='sum',
-                               dbif=None,  overwrite=grass.overwrite())
+                               dbif=None, overwrite=grass.overwrite())
 
             tgis.register_maps_in_space_time_dataset(type='rast',
                                                      name=basename, maps=maps,
@@ -694,10 +581,6 @@
             registerToTemporal(glob_rad_basename, suffixes_all, mapset,
                                start_day, day_step, title="Total irradiation",
                                desc="Output total irradiation raster maps [Wh.m-2.day-1]")
-        if insol_time_basename_user:
-            registerToTemporal(insol_time_basename, suffixes_all, mapset,
-                               start_day, day_step, title="Insolation time",
-                               desc="Output insolation time raster maps [h]")
 
     # just add timestamps, don't register
     else:
@@ -710,8 +593,6 @@
                 set_time_stamp(refl_rad_basename + suffixes_all[i], day=day)
             if glob_rad_basename_user:
                 set_time_stamp(glob_rad_basename + suffixes_all[i], day=day)
-            if insol_time_basename_user:
-                set_time_stamp(insol_time_basename + suffixes_all[i], day=day)
 
     # set color table for daily maps
     if beam_rad_basename_user:
@@ -726,9 +607,6 @@
     if glob_rad_basename_user:
         maps = [glob_rad_basename + suf for suf in suffixes_all]
         set_color_table(maps)
-    if insol_time_basename_user:
-        maps = [insol_time_basename + suf for suf in suffixes_all]
-        set_color_table(maps)
 
 
 if __name__ == "__main__":



More information about the grass-commit mailing list