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

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Nov 20 12:08:00 PST 2013


Author: wenzeslaus
Date: 2013-11-20 12:08:00 -0800 (Wed, 20 Nov 2013)
New Revision: 58259

Modified:
   grass-addons/grass7/raster/r.sun.daily/r.sun.daily.py
   grass-addons/grass7/raster/r.sun.daily/test.r.sun.daily.sh
Log:
r.sun.daily: report error when cumulative maps are requested together with day step higher then 1

Modified: grass-addons/grass7/raster/r.sun.daily/r.sun.daily.py
===================================================================
--- grass-addons/grass7/raster/r.sun.daily/r.sun.daily.py	2013-11-20 11:46:05 UTC (rev 58258)
+++ grass-addons/grass7/raster/r.sun.daily/r.sun.daily.py	2013-11-20 20:08:00 UTC (rev 58259)
@@ -74,28 +74,28 @@
 #% type: string
 #% gisprompt: new,cell,raster
 #% key: beam_rad
-#% description: Output beam irradiation raster map [Wh.m-2.day-1]
+#% description: Output beam irradiation raster map cumulated for the whole period of time [Wh.m-2.day-1]
 #% required: no
 #%end
 #%option
 #% type: string
 #% gisprompt: new,cell,raster
 #% key: diff_rad
-#% description: Output diffuse irradiation raster map [Wh.m-2.day-1]
+#% description: Output diffuse irradiation raster map cumulated for the whole period of time [Wh.m-2.day-1]
 #% required: no
 #%end
 #%option
 #% type: string
 #% gisprompt: new,cell,raster
 #% key: refl_rad
-#% description: Output ground reflected irradiation raster map [Wh.m-2.day-1]
+#% description: Output ground reflected irradiation raster map cumulated for the whole period of time [Wh.m-2.day-1]
 #% required: no
 #%end
 #%option
 #% type: string
 #% gisprompt: new,cell,raster
 #% key: glob_rad
-#% description: Output global (total) irradiance/irradiation raster map [Wh.m-2.day-1]
+#% description: Output global (total) irradiance/irradiation raster map cumulated for the whole period of time [Wh.m-2.day-1]
 #% required: no
 #%end
 #%option
@@ -250,6 +250,28 @@
                 refl_rad_basename, glob_rad_basename]):
         grass.fatal(_("No output specified."))
 
+    start_day = int(options['start_day'])
+    end_day = int(options['end_day'])
+    day_step = int(options['day_step'])
+
+    if day_step > 1 and (beam_rad or diff_rad or refl_rad or glob_rad):
+        grass.fatal(_("Day step higher then 1 would produce"
+                      " meaningless cumulative maps."))
+
+    # check: start < end
+    if start_day > end_day:
+        grass.fatal(_("Start day is after end day."))
+    if day_step >= end_day - start_day:
+        grass.fatal(_("Day step is too big."))
+
+    step = float(options['step'])
+
+    nprocs = int(options['nprocs'])
+
+    temporal = flags['t']
+    if not is_grass_7() and temporal:
+        grass.warning(_("Flag t has effect only in GRASS 7"))
+
     if beam_rad and not beam_rad_basename:
         beam_rad_basename = create_tmp_map_name('beam_rad')
         MREMOVE.append(beam_rad_basename)
@@ -263,24 +285,6 @@
         glob_rad_basename = create_tmp_map_name('glob_rad')
         MREMOVE.append(glob_rad_basename)
 
-    start_day = int(options['start_day'])
-    end_day = int(options['end_day'])
-    day_step = int(options['day_step'])
-
-    step = float(options['step'])
-
-    nprocs = int(options['nprocs'])
-
-    temporal = flags['t']
-    if not is_grass_7() and temporal:
-        grass.warning(_("Flag t has effect only in GRASS 7"))
-
-    # check: start < end
-    if start_day > end_day:
-        grass.fatal(_("Start day is after end day."))
-    if day_step >= end_day - start_day:
-        grass.fatal(_("Day step is too big."))
-
     # here we check all the days
     if not grass.overwrite():
         check_daily_map_names(beam_rad_basename, grass.gisenv()['MAPSET'],

Modified: grass-addons/grass7/raster/r.sun.daily/test.r.sun.daily.sh
===================================================================
--- grass-addons/grass7/raster/r.sun.daily/test.r.sun.daily.sh	2013-11-20 11:46:05 UTC (rev 58258)
+++ grass-addons/grass7/raster/r.sun.daily/test.r.sun.daily.sh	2013-11-20 20:08:00 UTC (rev 58259)
@@ -29,6 +29,7 @@
 
 map_names_file=`g.tempfile pid=$$`
 created_map_names_file=`g.tempfile pid=$$`
+should_not_be_created_map="test_r_sun_should_not_be_created_map"
 
 cat > "${map_names_file}" << EOF
 ${map_basename}_026
@@ -44,13 +45,17 @@
 echo "$NAME: r.sun.daily returned: $? (expecting 1)"
 
 NAME="Wrong start and end day parameter values test (module should fail)"
-r.sun.daily elev_in=terrain start_day=82 end_day=37 day_step=3 reflrad_basename=${map_basename}
+r.sun.daily elev_in=terrain start_day=82 end_day=37 day_step=3 reflrad_basename=${should_not_be_created_map}
 echo "$NAME: r.sun.daily returned: $? (expecting 1)"
 
 NAME="Wrong day step parameter values test (module should fail)"
-r.sun.daily elev_in=terrain start_day=82 end_day=85 day_step=9 reflrad_basename=${map_basename}
+r.sun.daily elev_in=terrain start_day=82 end_day=85 day_step=9 reflrad_basename=${should_not_be_created_map}
 echo "$NAME: r.sun.daily returned: $? (expecting 1)"
 
+NAME="Wrong day step parameter and cumulative parameters values test (module should fail)"
+r.sun.daily elev_in=terrain start_day=1 end_day=85 day_step=9 refl_rad=${should_not_be_created_map}
+echo "$NAME: r.sun.daily returned: $? (expecting 1)"
+
 NAME="Map creation test"
 r.sun.daily elev_in=terrain start_day=26 end_day=37 day_step=3 reflrad_basename=${map_basename}
 



More information about the grass-commit mailing list