[GRASS-SVN] r40684 - grass/trunk/imagery/i.sunhours

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jan 26 21:28:55 EST 2010


Author: hamish
Date: 2010-01-26 21:28:54 -0500 (Tue, 26 Jan 2010)
New Revision: 40684

Modified:
   grass/trunk/imagery/i.sunhours/i.sunhours.html
   grass/trunk/imagery/i.sunhours/main.c
Log:
use M_PI instead of custom PI, attempt to document options a little better

Modified: grass/trunk/imagery/i.sunhours/i.sunhours.html
===================================================================
--- grass/trunk/imagery/i.sunhours/i.sunhours.html	2010-01-27 01:49:57 UTC (rev 40683)
+++ grass/trunk/imagery/i.sunhours/i.sunhours.html	2010-01-27 02:28:54 UTC (rev 40684)
@@ -1,9 +1,27 @@
 <H2>DESCRIPTION</H2>
 
-<EM>i.sunhours</EM> creates a sunshine hours map from any map, it considers a perfect clear day. This method follows Iqbal (1983) as found in the AHAS manual (Parodi, 2000).
+<EM>i.sunhours</EM> creates a sunshine hours map from any map, it
+considers a perfect clear day. This method follows Iqbal (1983)
+as found in the AHAS manual (Parodi, 2000).
+
+<!--
+<P>
+The day of year (1-365) raster map can be created with ...?
+  why isn't this just a single integer value?
+-->
+
+<P>
+The latitude input map can be created with the <em>i.latlong</em>
+module, or with <em>r.mapcalc</em>'s <tt>y()</tt> function in a
+latitude-longitude location (possibly reprojected with <em>r.proj</em>.
+
+
 <H2>NOTES</H2>
-Iqbal, M., 1983. An Introduction to Solar Radiation. Iqbal, M., Editorial: Academic Press. Toronto, Canada.
-Parodi, G., 2000. AVHRR Hydrological Analysis System. Algorithms and Theory, Version 1.0. WRES - ITC, The Netherlands.
+
+Iqbal, M., 1983. An Introduction to Solar Radiation. Iqbal, M.,
+ Editorial: Academic Press. Toronto, Canada.
+Parodi, G., 2000. AVHRR Hydrological Analysis System. Algorithms
+ and Theory, Version 1.0. WRES - ITC, The Netherlands.
 <H2>TODO</H2>
 
 

Modified: grass/trunk/imagery/i.sunhours/main.c
===================================================================
--- grass/trunk/imagery/i.sunhours/main.c	2010-01-27 01:49:57 UTC (rev 40683)
+++ grass/trunk/imagery/i.sunhours/main.c	2010-01-27 02:28:54 UTC (rev 40684)
@@ -21,9 +21,8 @@
 #include <grass/gis.h>
 #include <grass/raster.h>
 #include <grass/glocale.h>
-    
-#define PI 3.1415927
 
+
 int main(int argc, char *argv[]) 
 {
     int nrows, ncols;
@@ -52,7 +51,7 @@
     /* Define the different options */ 
     input1 = G_define_standard_option(G_OPT_R_INPUT);
     input1->key = _("doy");
-    input1->description = _("Name of the doy input map");
+    input1->description = _("Name of the day of year input map");
 
     input2 = G_define_standard_option(G_OPT_R_INPUT);
     input2->key = _("lat");
@@ -103,13 +102,13 @@
             d_doy = ((DCELL *) inrast_doy)[col];
             d_lat = ((DCELL *) inrast_lat)[col];
 
-	    d_da = 2 * PI * (d_doy - 1) / 365.0;
+	    d_da = 2 * M_PI * (d_doy - 1) / 365.0;
 	    d_delta = 
 		0.006918 - 0.399912 * cos(d_da) + 0.070257 * sin(d_da) -
 		0.006758 * cos(2 * d_da) + 0.000907 * sin(2 * d_da) -
 		0.002697 * cos(3 * d_da) + 0.00148 * sin(3 * d_da);
-	    d_Ws = acos(-tan(d_lat * PI / 180) * tan(d_delta));
-	    d_N = (360.0 / (15.0 * PI)) * d_Ws;
+	    d_Ws = acos(-tan(d_lat * M_PI / 180) * tan(d_delta));
+	    d_N = (360.0 / (15.0 * M_PI)) * d_Ws;
 	    ((DCELL *) outrast1)[col] = d_N;
         }
 	Rast_put_row(outfd1, outrast1, DCELL_TYPE);
@@ -127,5 +126,3 @@
 
     exit(EXIT_SUCCESS);
 }
-
-



More information about the grass-commit mailing list