[GRASS-SVN] r33590 - grass-addons/raster/r.sun_horizon/r.sun2

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Sep 29 06:15:49 EDT 2008


Author: neteler
Date: 2008-09-29 06:15:49 -0400 (Mon, 29 Sep 2008)
New Revision: 33590

Modified:
   grass-addons/raster/r.sun_horizon/r.sun2/description.html
   grass-addons/raster/r.sun_horizon/r.sun2/main.c
Log:
Thomas Huld: catch missing horizonstep parameter; bugfix for horangle map name scheme

Modified: grass-addons/raster/r.sun_horizon/r.sun2/description.html
===================================================================
--- grass-addons/raster/r.sun_horizon/r.sun2/description.html	2008-09-29 09:18:16 UTC (rev 33589)
+++ grass-addons/raster/r.sun_horizon/r.sun2/description.html	2008-09-29 10:15:49 UTC (rev 33590)
@@ -118,8 +118,7 @@
 <p>The maps' history files are generated containing the following listed 
 parameters used in the computation: <br>
 - Solar constant 1367 W.m-2 <br>
-- Extraterrestrial irradiance on a plane perpendicular to the solar beam
-[W.m-2] <br>
+- Extraterrestrial irradiance on a plane perpendicular to the solar beam [W.m-2] <br>
 - Day of the year <br>
 - Declination [radians] <br>
 - Decimal hour (Alternative 1 only) <br>
@@ -187,8 +186,9 @@
 
 Spearfish example (without considering cast shadows):
 <div class="code"><pre>
-r.horizon elevation.dem step=30 e_buff=20 horizon=horangle dist=0.7 maxdistance=2000
-r.sun2  elevation.dem horizon=horangle aspin=aspect slopein=slope glob_rad=global_rad day=180 time=14
+g.region rast=elevation.dem -p
+r.horizon elevation.dem step=30 e_buff=20 horizon=horangle dist=0.7 maxdistance=4000
+r.sun2 -s elevation.dem horizon=horangle horizonstep=30 aspin=aspect slopein=slope glob_rad=global_rad day=180 time=14
 </pre></div>
 
 <h2>SEE ALSO</h2>
@@ -229,7 +229,7 @@
 research and technology, 11, 4, 153-163. </p>
 <p>
 Neteler, M., Mitasova, H. (2002): Open Source GIS: A GRASS GIS Approach, Kluwer
-Academic Publishers. </p>
+Academic Publishers/Springer. </p>
 <p>
 Page, J. ed. (1986). Prediction of solar radiation on inclined surfaces. Solar
 energy R&amp;D in the European Community, series F &#8211; Solar radiation data,

Modified: grass-addons/raster/r.sun_horizon/r.sun2/main.c
===================================================================
--- grass-addons/raster/r.sun_horizon/r.sun2/main.c	2008-09-29 09:18:16 UTC (rev 33589)
+++ grass-addons/raster/r.sun_horizon/r.sun2/main.c	2008-09-29 10:15:49 UTC (rev 33590)
@@ -6,7 +6,7 @@
 See manual pages for details.
 (C) 2002 Copyright Jaro Hofierka, Gresaka 22, 085 01 Bardejov, Slovakia, 
               and GeoModel, s.r.o., Bratislava, Slovakia
-email: hofierka at geomodel.sk,marcel.suri at jrc.it,suri at geomodel.sk
+email: hofierka at geomodel.sk,marcel.suri at jrc.it,suri at geomodel.sk Thomas.Huld at jrc.it
 *******************************************************************************/
 /*
  * This program is free software; you can redistribute it and/or
@@ -569,14 +569,21 @@
     if (parm.horizonstep->answer != NULL) {
 	if (sscanf(parm.horizonstep->answer, "%lf", &horizonStep) != 1)
 	    G_fatal_error(_("Error reading horizon step size"));
-	setHorizonInterval(deg2rad * horizonStep);
+	if(horizonStep > 0.)
+	    setHorizonInterval(deg2rad * horizonStep);
+	else
+	    G_fatal_error(_("The horizon step size must be greater than 0."));
+
     }
+	else if(useHorizonData()) {
+		G_fatal_error(_("If you use the horizon option you must also set the 'horizonstep' parameter."));
+	     }
 
 
     tt = parm.ltime->answer;
     if (parm.ltime->answer != NULL) {
 	if (insol_time != NULL)
-	    G_fatal_error(_("time and insol_time are incompatible options"));
+	    G_fatal_error(_("Time and insol_time are incompatible options"));
 	G_message(_("Mode 1: instantaneous solar incidence angle & irradiance using a set local time"));
 	sscanf(parm.ltime->answer, "%lf", &timo);
     }
@@ -746,6 +753,7 @@
 {
     int finalRow, rowrevoffset;
     int numRows;
+    int numDigits;
     FCELL *cell1 = NULL, *cell2 = NULL;
     FCELL *cell3 = NULL, *cell4 = NULL, *cell5 = NULL, *cell6 = NULL, *cell7 =
 	NULL;
@@ -758,6 +766,7 @@
     int fr1 = -1, fr2 = -1;
     int l, i, j;
     char shad_filename[256];
+    char formatString[10];
 
     finalRow = m - offset - m / numPartitions;
     if (finalRow < 0) {
@@ -926,9 +935,11 @@
 	 * else
 	 * {
 	 */
+	numDigits = (int)(log10(1. * arrayNumInt)) + 1;
+	sprintf(formatString, "%%s_%%0%dd", numDigits);
 	for (i = 0; i < arrayNumInt; i++) {
-	    horizonbuf[i] = G_allocate_f_raster_buf();
-	    sprintf(shad_filename, "%s_%03d", horizon, i);
+		horizonbuf[i] = G_allocate_f_raster_buf();
+	    sprintf(shad_filename, formatString, horizon, i);
 	    if ((mapset = G_find_cell(shad_filename, "")) == NULL)
 		printf("Horizon file no. %d not found\n", i);
 
@@ -1751,8 +1762,6 @@
 	(diff_rad != NULL) || (refl_rad != NULL) || (glob_rad != NULL);
 
 
-    fprintf(stderr, "\n\n");
-
     if (incidout != NULL) {
 	lumcl = (float **)malloc(sizeof(float *) * (m));
 	for (l = 0; l < m; l++) {
@@ -2006,7 +2015,6 @@
 	arrayOffset++;
 
     }
-    fprintf(stderr, "\n");
 
     /* re-use &hist, but try all to initiate it for any case */
     /*   note this will result in incorrect map titles       */



More information about the grass-commit mailing list