[GRASS-CVS] [addons] r1249 - in trunk/grassaddons/gipe: . i.sattime script_generator

grass-commit-addons at grass.itc.it grass-commit-addons at grass.itc.it
Thu Dec 6 07:29:12 EST 2007


Author: chemin
Date: 2007-12-06 13:28:44 +0100 (Thu, 06 Dec 2007)
New Revision: 1249

Modified:
   trunk/grassaddons/gipe/i.sattime/main.c
   trunk/grassaddons/gipe/imagery_Makefile
   trunk/grassaddons/gipe/script_generator/l7_in_read.c
Log:
Various bugs fixed

Modified: trunk/grassaddons/gipe/i.sattime/main.c
===================================================================
--- trunk/grassaddons/gipe/i.sattime/main.c	2007-12-05 13:13:53 UTC (rev 1248)
+++ trunk/grassaddons/gipe/i.sattime/main.c	2007-12-06 12:28:44 UTC (rev 1249)
@@ -83,7 +83,7 @@
 	input3->type       = TYPE_STRING;
 	input3->required   = YES;
 	input3->gisprompt  =_("old,cell,raster") ;
-	input3->description=_("Name of the latitude input map");
+	input3->description=_("Name of the longitude input map");
 	input3->answer     =_("longitude");
 
 	input4 = G_define_option() ;
@@ -175,7 +175,8 @@
 	for (row = 0; row < nrows; row++)
 	{
 		DCELL d;
-		DCELL d_da;
+		DCELL d_frac_year;
+		DCELL d_tc_wa;
 		DCELL d_delta;
 		DCELL d_Wa;
 		DCELL d_Wa1;
@@ -191,6 +192,8 @@
 			G_fatal_error(_("Could not read from <%s>"),doy);
 		if(G_get_raster_row(infd_lat,inrast_lat,row,data_type_lat)<0)
 			G_fatal_error(_("Could not read from <%s>"),lat);
+		if(G_get_raster_row(infd_lon,inrast_lon,row,data_type_lon)<0)
+			G_fatal_error(_("Could not read from <%s>"),lon);
 		if(G_get_raster_row(infd_phi,inrast_phi,row,data_type_phi)<0)
 			G_fatal_error(_("Could not read from <%s>"),phi);
 		for (col=0; col < ncols; col++)
@@ -217,6 +220,17 @@
 					d_lat	= ((DCELL *) inrast_lat)[col];
 					break;
 			}
+			switch(data_type_lon){
+				case CELL_TYPE:
+					d_lon = (double) ((CELL *) inrast_lon)[col];
+					break;
+				case FCELL_TYPE:
+					d_lon = (double) ((FCELL *) inrast_lon)[col];
+					break;
+				case DCELL_TYPE:
+					d_lon	= ((DCELL *) inrast_lon)[col];
+					break;
+			}
 			switch(data_type_phi){
 				case CELL_TYPE:
 					d_phi = (double) ((CELL *) inrast_phi)[col];
@@ -230,11 +244,15 @@
 			}
 			//d_da = 2 * 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_delta = 0.4093*sin((2.0*PI/365.0)*d_doy-1.39);
-			d_Wa1=cos(d_phi*PI/180.0)-sin(d_delta)*sin(d_lat*PI/180.0);
-			d_Wa2=cos(d_delta)*cos(d_lat*PI/180.0);
+			//d_delta = 0.4093*sin((2.0*PI/365.0)*d_doy-1.39);
+			d_frac_year = (360.0/365.25) * d_doy;
+			d_delta = 0.396372-22.91327*cos(d_frac_year*PI/180.0)+4.02543*sin(d_frac_year*PI/180.0)-0.387205*cos(2*d_frac_year*PI/180.0)+0.051967*sin(2*d_frac_year*PI/180.0)-0.154527*cos(3*d_frac_year*PI/180.0)+0.084798*sin(3*d_frac_year*PI/180.0);
+			d_tc_wa = 0.004297+0.107029*cos(d_frac_year*PI/180.0)-1.837877*sin(d_frac_year*PI/180.0)-0.837378*cos(2*d_frac_year*PI/180.0)-2.340475*sin(2*d_frac_year*PI/180.0);
+			d_Wa1=cos((90.0-d_phi)*PI/180.0)-sin(d_delta*PI/180.0)*sin(d_lat*PI/180.0);
+			d_Wa2=cos(d_delta*PI/180.0)*cos(d_lat*PI/180.0);
 			d_Wa=acos(d_Wa1/d_Wa2);
-			d_time = 12.0*(d_Wa+1.0)/PI + d_lon*(24.0/360.0);
+			d_time = ((d_Wa-(d_lon*PI/180.0)-d_tc_wa)/15.0)+12.0;
+			//d_time = 12.0*(d_Wa+1.0)/PI + d_lon*(24.0/360.0);
 			((DCELL *) outrast1)[col] = d_time;
 		}
 		if (G_put_raster_row (outfd1, outrast1, data_type_output) < 0)

Modified: trunk/grassaddons/gipe/imagery_Makefile
===================================================================
--- trunk/grassaddons/gipe/imagery_Makefile	2007-12-05 13:13:53 UTC (rev 1248)
+++ trunk/grassaddons/gipe/imagery_Makefile	2007-12-06 12:28:44 UTC (rev 1249)
@@ -37,6 +37,7 @@
 	i.group \
 	i.his.rgb \
 	i.latitude \
+	i.longitude \
 	i.landsat.dehaze \
 	i.maxlik \
 	i.ortho.photo \

Modified: trunk/grassaddons/gipe/script_generator/l7_in_read.c
===================================================================
--- trunk/grassaddons/gipe/script_generator/l7_in_read.c	2007-12-05 13:13:53 UTC (rev 1248)
+++ trunk/grassaddons/gipe/script_generator/l7_in_read.c	2007-12-06 12:28:44 UTC (rev 1249)
@@ -600,7 +600,7 @@
 	/*Calculate ETPOT (and Rnetd for future ETa calculations)*/
 	system("echo \"\" >> temp.txt");
 	system("echo \"#ETPOT\" >> temp.txt");
-	snprintf(sys_5,1000,"echo \"i.evapo.potrad -r -d albedo=%s.albedo tempk=%s.61 lat=%s.latitude doy=%s.doy tsw=%s.tsw slope=%s.slope aspect=%s.aspect etpot=%s.etpot rnetd=%s.rnetd --overwrite ; r.null map=%s.rnetd setnull=-999.99 \" >> temp.txt", basedate, basedate, basedate, basedate, basedate, basedate, basedate, basedate, basedate, basedate);
+	snprintf(sys_5,1000,"echo \"i.evapo.potrad -r albedo=%s.albedo tempk=%s.61 lat=%s.latitude doy=%s.doy tsw=%s.tsw etpot=%s.etpot rnetd=%s.rnetd --overwrite ; r.null map=%s.rnetd setnull=-999.99 \" >> temp.txt", basedate, basedate, basedate, basedate, basedate, basedate, basedate, basedate, basedate, basedate);
 	system(sys_5);
 	snprintf(sys_7,1000,"echo \"r.colors map=%s.etpot color=grey ; r.null map=%s.etpot setnull=-999.99\" >> temp.txt", basedate, basedate);
 	system(sys_7);
@@ -675,7 +675,7 @@
 	sprintf(sys_31,"echo \"i.eb.h_iter rohair=%s.rohair cp=1004.16 dtair=%s.delta tempk=%s.61 disp=%s.disp z0m=%s.z0m z0h=%s.z0h u2m=u2 h0=%s.h0 --overwrite; r.null map=%s.h0 setnull=-999.99 \" >> temp.txt",basedate,basedate,basedate,basedate,basedate,basedate,basedate,basedate);
 	system(sys_31);
 	system("echo \"\" >> temp.txt");
-	sprintf(sys_32,"echo \"i.eb.evapfr -m rnet=%s.rnet g0=%s.g0 h0=%s.h0 evapfr=%s.evapfr theta=%s.theta --overwrite ; r.null map=%s.evapfr setnull=-999.99 ; r.null map=%s.theta setnull=-999.99 \" >> temp.txt",basedate,basedate,basedate,basedate,basedate,basedate,basedate);
+	sprintf(sys_32,"echo \"i.eb.evapfr -m rnet=%s.rnet g0=%s.g0 h0=%s.h0 evapfr=%s.evapfr theta=%s.theta --overwrite ; r.null map=%s.evapfr setnull=-999.99 ; r.null map=%s.theta setnull=-999.99 ; r.colors map=%s.theta color=grey1.0 ; r.colors map=%s.evapfr color=grey1.0 \" >> temp.txt",basedate,basedate,basedate,basedate,basedate,basedate,basedate,basedate,basedate);
 	system(sys_32);
 	system("echo \"\" >> temp.txt");
 	sprintf(sys_33,"echo \"i.eb.eta rnetday=%s.rnetd evapfr=%s.evapfr tempk=%s.61 eta=%s.eta --overwrite ; r.null map=%s.eta setnull=-999.99 \" >> temp.txt",basedate,basedate,basedate,basedate,basedate);



More information about the grass-commit mailing list