Browse Source

use M_PI instead of custom PI, attempt to document options a little better

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@40684 15284696-431f-4ddb-bdfa-cd5b030d7da7
Hamish Bowman 15 years ago
parent
commit
a5b13357bf
2 changed files with 26 additions and 11 deletions
  1. 21 3
      imagery/i.sunhours/i.sunhours.html
  2. 5 8
      imagery/i.sunhours/main.c

+ 21 - 3
imagery/i.sunhours/i.sunhours.html

@@ -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>
 
 

+ 5 - 8
imagery/i.sunhours/main.c

@@ -21,8 +21,7 @@
 #include <grass/gis.h>
 #include <grass/raster.h>
 #include <grass/glocale.h>
-    
-#define PI 3.1415927
+
 
 int main(int argc, char *argv[]) 
 {
@@ -52,7 +51,7 @@ int main(int argc, char *argv[])
     /* 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 @@ int main(int argc, char *argv[])
             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 @@ int main(int argc, char *argv[])
 
     exit(EXIT_SUCCESS);
 }
-
-