[GRASS-SVN] r32909 - in grass-addons/gipe: i.dn2full.l5 i.dn2full.l7

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Aug 19 19:34:53 EDT 2008


Author: ychemin
Date: 2008-08-19 19:34:53 -0400 (Tue, 19 Aug 2008)
New Revision: 32909

Modified:
   grass-addons/gipe/i.dn2full.l5/main.c
   grass-addons/gipe/i.dn2full.l7/main.c
Log:
Clean up, code standardization

Modified: grass-addons/gipe/i.dn2full.l5/main.c
===================================================================
--- grass-addons/gipe/i.dn2full.l5/main.c	2008-08-19 23:06:29 UTC (rev 32908)
+++ grass-addons/gipe/i.dn2full.l5/main.c	2008-08-19 23:34:53 UTC (rev 32909)
@@ -43,8 +43,8 @@
 int
 main(int argc, char *argv[])
 {
-	struct Cell_head cellhd;//region+header info
-	char *mapset; //mapset name
+	struct Cell_head cellhd;/*region+header info*/
+	char *mapset; /*mapset name*/
 	int nrows, ncols;
 	int row,col;
 
@@ -52,18 +52,18 @@
 	struct Option *input, *input1, *output;
 	
 	struct Flag *flag1;
-	struct History history; //metadata
+	struct History history; /*metadata*/
 
 	/************************************/
 	/* FMEO Declarations*****************/
 	char history_buf[200];
-	char *name; //input raster name
-	char *result; //output raster name
-	//Prepare new names for output files
+	char *name; /*input raster name*/
+	char *result; /*output raster name*/
+	/*Prepare new names for output files*/
 	char result1[80], result2[80], result3[80], result4[80];
 	char result5[80], result6[80], result7[80];
 	
-	//File Descriptors
+	/*File Descriptors*/
 	int infd[MAXFILES];
 	int outfd[MAXFILES];
 
@@ -78,21 +78,21 @@
 	RASTER_MAP_TYPE out_data_type = DCELL_TYPE; /* 0=numbers  1=text */
 
 	double		kexo[MAXFILES];
-	//Metfile
-	char		*metfName; //NLAPS report file, header in text format
+	/*Metfile*/
+	char		*metfName; /*NLAPS report file, header in text format*/
 	double 		sun_elevation;
-	double 		sun_azimuth;//not useful here, only for parser()
-	int 		c_day,c_month,c_year;//NLAPS processing date	
+	double 		sun_azimuth;/*not useful here, only for parser()*/
+	int 		c_day,c_month,c_year;/*NLAPS processing date*/	
 	int 		day,month,year;	
 	double 		decimal_hour;	
 	double 		latitude;	
 	double 		longitude;
 	int		l5path, l5row;
-	//EndofMetfile
+	/*EndofMetfile*/
 	int 		doy;
 	char		b1[80],b2[80],b3[80];
 	char		b4[80],b5[80];
-	char		b6[80],b7[80];//Load .tif names
+	char		b6[80],b7[80];/*Load .tif names*/
 	int		temp;
 	/************************************/
 
@@ -129,8 +129,8 @@
 		ptr    	= input1->answers;
 	}
 	result		= output->answer;
-	//******************************************
-	//Fetch parameters for DN2Rad2Ref correction
+	/******************************************/
+	/*Fetch parameters for DN2Rad2Ref correction*/
 	l5_in_read(metfName,&l5path,&l5row,&latitude,&longitude,&sun_elevation,&sun_azimuth,&c_year,&c_month,&c_day,&day,&month,&year,&decimal_hour);
 	G_message("l5path=%i",l5path);
 	G_message("l5row=%i",l5row);
@@ -146,7 +146,7 @@
 	G_message("day=%i",day);
 	G_message("decimal hour=%f",decimal_hour);
 	/********************/
-	//Prepare the input file names 
+	/*Prepare the input file names */
 	/********************/
 	doy = date2doy(day,month,year);
 	G_message("doy=%i",doy);
@@ -194,8 +194,6 @@
 		sprintf(b7, "%s%d%s%d%s%d%d%s","LT5",l5path,"0",l5row,"000",temp,doy,"50_B7.tif");
 		}
 	}
-	//printf("%f/%f/%i-%i-%i\n",sun_elevation,sun_azimuth,day,month,year);
-	//	exit(1);
 	G_message("b1_in:%s",b1);
 	G_message("b2_in:%s",b2);
 	G_message("b3_in:%s",b3);
@@ -205,7 +203,7 @@
 	G_message("b7_in:%s",b7);
 	
 	/********************/
-	//Prepare the ouput file names 
+	/*Prepare the ouput file names */
 	/********************/
 
 	G_message("result=%s",result);
@@ -225,7 +223,7 @@
 	G_message("%s",result7);
 
 	/********************/
-	//Prepare sun exo-atm irradiance
+	/*Prepare sun exo-atm irradiance*/
 	/********************/
 	
 	kexo[0]=KEXO1;
@@ -233,11 +231,11 @@
 	kexo[2]=KEXO3;
 	kexo[3]=KEXO4;
 	kexo[4]=KEXO5;
-	kexo[5]=KEXO6;//filling only
+	kexo[5]=KEXO6;/*filling only*/
 	kexo[6]=KEXO7;
 	
 	/***************************************************/
-	//Band1
+	/*Band1*/
 	/* find map in mapset */
 	mapset = G_find_cell2 (b1, "");
         if (mapset == NULL){
@@ -258,7 +256,7 @@
 	inrast[0] = G_allocate_raster_buf(in_data_type[0]);
 	/***************************************************/
 	/***************************************************/
-	//Band2
+	/*Band2*/
 	/* find map in mapset */
 	mapset = G_find_cell2 (b2, "");
         if (mapset == NULL){
@@ -279,7 +277,7 @@
 	inrast[1] = G_allocate_raster_buf(in_data_type[1]);
 	/***************************************************/
 	/***************************************************/
-	//Band3
+	/*Band3*/
 	/* find map in mapset */
 	mapset = G_find_cell2 (b3, "");
         if (mapset == NULL){
@@ -300,7 +298,7 @@
 	inrast[2] = G_allocate_raster_buf(in_data_type[2]);
 	/***************************************************/
 	/***************************************************/
-	//Band4
+	/*Band4*/
 	/* find map in mapset */
 	mapset = G_find_cell2 (b4, "");
         if (mapset == NULL){
@@ -321,7 +319,7 @@
 	inrast[3] = G_allocate_raster_buf(in_data_type[3]);
 	/***************************************************/
 	/***************************************************/
-	//Band5
+	/*Band5*/
 	/* find map in mapset */
 	mapset = G_find_cell2 (b5, "");
         if (mapset == NULL){
@@ -342,7 +340,7 @@
 	inrast[4] = G_allocate_raster_buf(in_data_type[4]);
 	/***************************************************/
 	/***************************************************/
-	//Band6
+	/*Band6*/
 	/* find map in mapset */
 	mapset = G_find_cell2 (b6, "");
         if (mapset == NULL){
@@ -363,7 +361,7 @@
 	inrast[5] = G_allocate_raster_buf(in_data_type[5]);
 	/***************************************************/
 	/***************************************************/
-	//Band7
+	/*Band7*/
 	/* find map in mapset */
 	mapset = G_find_cell2 (b7, "");
         if (mapset == NULL){
@@ -435,13 +433,13 @@
 						break;
 				}
 				dout[i]=dn2rad_landsat5(c_year,c_month,c_day,year,month,day,i+1,d[i]);
-				if(i==5){//if band 6, process brightness temperature
+				if(i==5){/*if band 6, process brightness temperature*/
 					if(dout[i]<=0.0){
 						G_set_d_null_value(&dout[i],1);
-					}else{
+					} else {
 						dout[i]=tempk_landsat5(dout[i]);
 					}
-				}else{//process reflectance
+				} else {/*process reflectance*/
 					dout[i]=rad2ref_landsat5(dout[i],doy,sun_elevation,kexo[i]);
 				}
 				outrast[i][col] = dout[i];
@@ -460,36 +458,5 @@
 		G_close_cell (outfd[i]);
 	}
 
-	printf("Make Metadata\n");
-//	G_short_history(result, "raster", &history);
-//	G_command_history(&history);
-//	G_write_history(result,&history);
-
-//	//fill in data source line
-//		printf("1\t");
-//	strncpy(history.datsrc_1,metfName,RECORD_LEN);
-//	sprintf(history_buf,"year=%d",year);
-//		printf("1\t");
-//	strncpy(history.datsrc_1,history_buf,RECORD_LEN);
-//	sprintf(history_buf,"month=%d",month);
-//		printf("1\t");
-//	strncpy(history.datsrc_1,history_buf,RECORD_LEN);
-//	sprintf(history_buf,"day=%d",day);
-//		printf("1\t");
-//	strncpy(history.datsrc_1,history_buf,RECORD_LEN);
-//	sprintf(history_buf,"doy=%d",doy);
-//		printf("1\t");
-//	strncpy(history.datsrc_1,history_buf,RECORD_LEN);
-//	sprintf(history_buf,"sun_elevation=%f",sun_elevation);
-//		printf("1\t");
-//	strncpy(history.datsrc_1,history_buf,RECORD_LEN);
-//	sprintf(history_buf,"sun_azimuth=%f",sun_azimuth);
-//		printf("1\t");
-//	strncpy(history.datsrc_1,history_buf,RECORD_LEN);
-//		printf("1\t");
-//	history.datsrc_1[RECORD_LEN-1]='\0';//strncpy() doesn't null terminate if maxfill
-//		printf("1\t");
-//	G_write_history(result,&history);
-
 	return 0;
 }

Modified: grass-addons/gipe/i.dn2full.l7/main.c
===================================================================
--- grass-addons/gipe/i.dn2full.l7/main.c	2008-08-19 23:06:29 UTC (rev 32908)
+++ grass-addons/gipe/i.dn2full.l7/main.c	2008-08-19 23:34:53 UTC (rev 32909)
@@ -22,14 +22,14 @@
 
 #define MAXFILES 9
 
-//sun exo-atmospheric irradiance
+/*sun exo-atmospheric irradiance*/
 #define KEXO1 1969.0
 #define KEXO2 1840.0
 #define KEXO3 1551.0
 #define KEXO4 1044.0
 #define KEXO5 225.7
 #define KEXO7 82.07
-#define KEXO8 1385.64 //to find the real value in the internet
+#define KEXO8 1385.64 /*to find the real value in the internet*/
 
 #define PI 3.1415926
 
@@ -43,25 +43,25 @@
 int
 main(int argc, char *argv[])
 {
-	struct Cell_head cellhd;//region+header info
-	char *mapset; //mapset name
+	struct Cell_head cellhd;/*region+header info*/
+	char *mapset; /*mapset name*/
 	int nrows, ncols;
 	int row,col;
 
 	struct GModule *module;
 	struct Option *input,*output;
 	
-	struct History history; //metadata
+	struct History history; /*metadata*/
 	/************************************/
 	/* FMEO Declarations*****************/
 	char history_buf[200];
-	char *name; //input raster name
-	char *result; //output raster name
-	//Prepare new names for output files
+	char *name; /*input raster name*/
+	char *result; /*output raster name*/
+	/*Prepare new names for output files*/
 	char result1[80], result2[80], result3[80], result4[80];
 	char result5[80], result61[80], result62[80], result7[80],result8[80] ;
 	
-	//File Descriptors
+	/*File Descriptors*/
 	int infd[MAXFILES];
 	int outfd[MAXFILES];
 
@@ -76,19 +76,19 @@
 	RASTER_MAP_TYPE out_data_type = DCELL_TYPE; /* 0=numbers  1=text */
 
 	double		kexo[MAXFILES];
-	//Metfile
-	char		*metfName; //met file, header in text format
+	/*Metfile*/
+	char		*metfName; /*met file, header in text format*/
 	char		b1[80],b2[80],b3[80];
 	char		b4[80],b5[80],b61[80];
-	char		b62[80],b7[80],b8[80];//Load .tif names
+	char		b62[80],b7[80],b8[80];/*Load .tif names*/
 	double 		lmin[MAXFILES];
 	double 		lmax[MAXFILES];
 	double 		qcalmin[MAXFILES];
 	double 		qcalmax[MAXFILES];
 	double 		sun_elevation;
-	double 		sun_azimuth;//not useful here, only for parser()
+	double 		sun_azimuth;/*not useful here, only for parser()*/
 	int 		day,month,year;	
-	//EndofMetfile
+	/*EndofMetfile*/
 	int 		doy;
 	/************************************/
 
@@ -118,52 +118,25 @@
 	metfName	= input->answer;
 	result		= output->answer;
 
-	//******************************************
-	//Fetch parameters for DN2Rad2Ref correction
+	/******************************************/
+	/*Fetch parameters for DN2Rad2Ref correction*/
 	l7_in_read(metfName,b1,b2,b3,b4,b5,b61,b62,b7,b8,lmin,lmax,qcalmin,qcalmax,&sun_elevation,&sun_azimuth,&day,&month,&year);
-//	printf("%f/%f/%i-%i-%i\n",sun_elevation,sun_azimuth,day,month,year);
-//	for(i=0;i<MAXFILES;i++){
-//		printf("%i=>%f, %f, %f, %f\n",i,lmin[i],lmax[i],qcalmin[i],qcalmax[i]);
-//	}
-//	doy = date2doy(day,month,year);
-//	printf("doy=%i\n",doy);
 	/********************/
-//	printf("b1=%s\n",b1);
-//	printf("b2=%s\n",b2);
-//	printf("b3=%s\n",b3);
-//	printf("b4=%s\n",b4);
-//	printf("b5=%s\n",b5);
-//	printf("b61=%s\n",b61);
-//	printf("b62=%s\n",b62);
-//	printf("b7=%s\n",b7);
-//	printf("b8=%s\n",b8);
-//	exit(1);
+	/*Prepare the ouput file names */
 	/********************/
-	//Prepare the ouput file names 
-	/********************/
 
-//	printf("result=%s\n",result);
 	snprintf(result1, 80, "%s%s",result,".1");
-//	printf("%s\n",result1);
 	snprintf(result2, 80, "%s%s",result,".2");
-//	printf("%s\n",result2);
 	snprintf(result3, 80, "%s%s",result,".3");
-//	printf("%s\n",result3);
 	snprintf(result4, 80, "%s%s",result,".4");
-//	printf("%s\n",result4);
 	snprintf(result5, 80, "%s%s",result,".5");
-//	printf("%s\n",result5);
 	snprintf(result61, 80, "%s%s",result,".61");
-//	printf("%s\n",result61);
 	snprintf(result62, 80, "%s%s",result,".62");
-//	printf("%s\n",result62);
 	snprintf(result7, 80, "%s%s",result,".7");
-//	printf("%s\n",result7);
 	snprintf(result8, 80, "%s%s",result,".8");
-//	printf("%s\n",result8);
 
 	/********************/
-	//Prepare sun exo-atm irradiance
+	/*Prepare sun exo-atm irradiance*/
 	/********************/
 	
 	kexo[0]=KEXO1;
@@ -171,14 +144,13 @@
 	kexo[2]=KEXO3;
 	kexo[3]=KEXO4;
 	kexo[4]=KEXO5;
-	kexo[5]=0.0;//filling
-	kexo[6]=0.0;//filling
+	kexo[5]=0.0;/*filling*/
+	kexo[6]=0.0;/*filling*/
 	kexo[7]=KEXO7;
 	kexo[8]=KEXO8;
 	
-	//******************************************
 	/***************************************************/
-	//Band1
+	/*Band1*/
 	/* find map in mapset */
 	mapset = G_find_cell2 (b1, "");
         if (mapset == NULL){
@@ -199,7 +171,7 @@
 	inrast[0] = G_allocate_raster_buf(in_data_type[0]);
 	/***************************************************/
 	/***************************************************/
-	//Band2
+	/*Band2*/
 	/* find map in mapset */
 	mapset = G_find_cell2 (b2, "");
         if (mapset == NULL){
@@ -220,7 +192,7 @@
 	inrast[1] = G_allocate_raster_buf(in_data_type[1]);
 	/***************************************************/
 	/***************************************************/
-	//Band3
+	/*Band3*/
 	/* find map in mapset */
 	mapset = G_find_cell2 (b3, "");
         if (mapset == NULL){
@@ -241,7 +213,7 @@
 	inrast[2] = G_allocate_raster_buf(in_data_type[2]);
 	/***************************************************/
 	/***************************************************/
-	//Band4
+	/*Band4*/
 	/* find map in mapset */
 	mapset = G_find_cell2 (b4, "");
         if (mapset == NULL){
@@ -262,7 +234,7 @@
 	inrast[3] = G_allocate_raster_buf(in_data_type[3]);
 	/***************************************************/
 	/***************************************************/
-	//Band5
+	/*Band5*/
 	/* find map in mapset */
 	mapset = G_find_cell2 (b5, "");
         if (mapset == NULL){
@@ -283,7 +255,7 @@
 	inrast[4] = G_allocate_raster_buf(in_data_type[4]);
 	/***************************************************/
 	/***************************************************/
-	//Band61
+	/*Band61*/
 	/* find map in mapset */
 	mapset = G_find_cell2 (b61, "");
         if (mapset == NULL){
@@ -304,7 +276,7 @@
 	inrast[5] = G_allocate_raster_buf(in_data_type[5]);
 	/***************************************************/
 	/***************************************************/
-	//Band62
+	/*Band62*/
 	/* find map in mapset */
 	mapset = G_find_cell2 (b62, "");
         if (mapset == NULL){
@@ -325,7 +297,7 @@
 	inrast[6] = G_allocate_raster_buf(in_data_type[6]);
 	/***************************************************/
 	/***************************************************/
-	//Band7
+	/*Band7*/
 	/* find map in mapset */
 	mapset = G_find_cell2 (b7, "");
         if (mapset == NULL){
@@ -346,7 +318,7 @@
 	inrast[7] = G_allocate_raster_buf(in_data_type[7]);
 	/***************************************************/
 	/***************************************************/
-	//Band8
+	/*Band8*/
 	/* find map in mapset */
 	mapset = G_find_cell2 (b8, "");
         if (mapset == NULL){
@@ -412,13 +384,13 @@
 			{
 				d[i] = (double) ((CELL *) inrast[i])[col];
 				dout[i]=dn2rad_landsat7(lmin[i],lmax[i],qcalmax[i],qcalmin[i],d[i]);
-				if(i==5||i==6){//if band 61/62, process brightness temperature
+				if(i==5||i==6){/*if band 61/62, process brightness temperature*/
 					if(dout[i]<=0.0){
 						G_set_d_null_value(&outrast[i][col],1);
 					}else{
 						dout[i]=tempk_landsat7(dout[i]);
 					}
-				}else{//process reflectance
+				}else{/*process reflectance*/
 					dout[i]=rad2ref_landsat7(dout[i],doy,sun_elevation,kexo[i]);
 			}
 			outrast[i][col] = dout[i];
@@ -436,37 +408,5 @@
 		G_free (outrast[i]);
 		G_close_cell (outfd[i]);
 	}
-
-	printf("Make Metadata\n");
-//	G_short_history(result, "raster", &history);
-//	G_command_history(&history);
-//	G_write_history(result,&history);
-
-//	//fill in data source line
-//		printf("1\t");
-//	strncpy(history.datsrc_1,metfName,RECORD_LEN);
-//	sprintf(history_buf,"year=%d",year);
-//		printf("1\t");
-//	strncpy(history.datsrc_1,history_buf,RECORD_LEN);
-//	sprintf(history_buf,"month=%d",month);
-//		printf("1\t");
-//	strncpy(history.datsrc_1,history_buf,RECORD_LEN);
-//	sprintf(history_buf,"day=%d",day);
-//		printf("1\t");
-//	strncpy(history.datsrc_1,history_buf,RECORD_LEN);
-//	sprintf(history_buf,"doy=%d",doy);
-//		printf("1\t");
-//	strncpy(history.datsrc_1,history_buf,RECORD_LEN);
-//	sprintf(history_buf,"sun_elevation=%f",sun_elevation);
-//		printf("1\t");
-//	strncpy(history.datsrc_1,history_buf,RECORD_LEN);
-//	sprintf(history_buf,"sun_azimuth=%f",sun_azimuth);
-//		printf("1\t");
-//	strncpy(history.datsrc_1,history_buf,RECORD_LEN);
-//		printf("1\t");
-//	history.datsrc_1[RECORD_LEN-1]='\0';//strncpy() doesn't null terminate if maxfill
-//		printf("1\t");
-//	G_write_history(result,&history);
-
 	return 0;
 }



More information about the grass-commit mailing list