[GRASS-SVN] r30839 - grass-addons/gipe/i.dn2full.l7

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Apr 1 23:58:10 EDT 2008


Author: ychemin
Date: 2008-04-01 23:58:10 -0400 (Tue, 01 Apr 2008)
New Revision: 30839

Removed:
   grass-addons/gipe/i.dn2full.l7/dn2rad_landsat5.c
   grass-addons/gipe/i.dn2full.l7/l5inread.c
   grass-addons/gipe/i.dn2full.l7/rad2ref_landsat5.c
   grass-addons/gipe/i.dn2full.l7/tempk_landsat5.c
Modified:
   grass-addons/gipe/i.dn2full.l7/Makefile
   grass-addons/gipe/i.dn2full.l7/main.c
Log:
Fixed svn mix between i.dn2full.l5 and i.dn2full.l7

Modified: grass-addons/gipe/i.dn2full.l7/Makefile
===================================================================
--- grass-addons/gipe/i.dn2full.l7/Makefile	2008-04-02 02:59:43 UTC (rev 30838)
+++ grass-addons/gipe/i.dn2full.l7/Makefile	2008-04-02 03:58:10 UTC (rev 30839)
@@ -1,6 +1,6 @@
 MODULE_TOPDIR = ../..
 
-PGM = i.dn2full.l5
+PGM = i.dn2full.l7
 
 LIBES = $(GISLIB)
 DEPENDENCIES = $(GISDEP)

Deleted: grass-addons/gipe/i.dn2full.l7/dn2rad_landsat5.c
===================================================================
--- grass-addons/gipe/i.dn2full.l7/dn2rad_landsat5.c	2008-04-02 02:59:43 UTC (rev 30838)
+++ grass-addons/gipe/i.dn2full.l7/dn2rad_landsat5.c	2008-04-02 03:58:10 UTC (rev 30839)
@@ -1,163 +0,0 @@
-#include<stdio.h>
-#include<math.h>
-#include<stdlib.h>
-
-// Conversion of DN to Radiance for Landsat 5TM
-// yann.chemin at gmail.com - Yann Chemin - GPL>=2, 2008.
-
-double dn2rad_landsat5(int c_year, int c_month, int c_day, int year, int month, int day, int band, int DN )
-{
-	double	result, gain, bias;
-	int	gain_mode;
-	
-	if(c_year<2003){
-		gain_mode=1;
-	} else if (c_year==2003){
-		if(c_month<5){
-			gain_mode=1;
-		} else if(c_month==5){
-			if(c_day<5){
-				gain_mode=1;
-			}else{
-				gain_mode=2;
-			}
-		} else {
-			gain_mode=2;
-		}
-	} else if (c_year>2003&&c_year<2007){
-		gain_mode=2;
-	} else if (c_year==2007){
-		if(c_month<5){
-			gain_mode=2;
-		} else if(year<1992){
-			gain_mode=3;
-		} else {
-			gain_mode=4;
-		}
-	}
-	if (gain_mode==1){
-		if (band==1){
-			gain = 0.602431;
-			bias = -1.52;
-		}
-		if (band==2){
-			gain = 1.175100;
-			bias = -2.84;
-		}
-		if (band==3){
-			gain = 0.805765;
-			bias = -1.17;
-		}
-		if (band==4){
-			gain = 0.814549;
-			bias = -1.51;
-		}
-		if (band==5){
-			gain = 0.108078;
-			bias = -0.37;
-		}
-		if (band==6){
-			gain = 0.055158;
-			bias = 1.2378;
-		}
-		if (band==7){
-			gain = 0.056980;
-			bias = -0.15;
-		}
-	}
-	if (gain_mode==2){
-		if (band==1){
-			gain = 0.762824;
-			bias = -1.52;
-		}
-		if (band==2){
-			gain = 1.442510;
-			bias = -2.84;
-		}
-		if (band==3){
-			gain = 1.039880;
-			bias = -1.17;
-		}
-		if (band==4){
-			gain = 0.872588;
-			bias = -1.51;
-		}
-		if (band==5){
-			gain = 0.119882;
-			bias = -0.37;
-		}
-		if (band==6){
-			gain = 0.055158;
-			bias = 1.2378;
-		}
-		if (band==7){
-			gain = 0.065294;
-			bias = -0.15;
-		}
-	}
-	if (gain_mode==3){
-		if (band==1){
-			gain = 0.668706;
-			bias = -1.52;
-		}
-		if (band==2){
-			gain = 1.317020;
-			bias = -2.84;
-		}
-		if (band==3){
-			gain = 1.039880;
-			bias = -1.17;
-		}
-		if (band==4){
-			gain = 0.872588;
-			bias = -1.51;
-		}
-		if (band==5){
-			gain = 0.119882;
-			bias = -0.37;
-		}
-		if (band==6){
-			gain = 0.055158;
-			bias = 1.2378;
-		}
-		if (band==7){
-			gain = 0.065294;
-			bias = -0.15;
-		}
-	}
-	if (gain_mode==4){
-		if (band==1){
-			gain = 0.762824;
-			bias = -1.52;
-		}
-		if (band==2){
-			gain = 1.442510;
-			bias = -2.84;
-		}
-		if (band==3){
-			gain = 1.039880;
-			bias = -1.17;
-		}
-		if (band==4){
-			gain = 0.872588;
-			bias = -1.51;
-		}
-		if (band==5){
-			gain = 0.119882;
-			bias = -0.37;
-		}
-		if (band==6){
-			gain = 0.055158;
-			bias = 1.2378;
-		}
-		if (band==7){
-			gain = 0.065294;
-			bias = -0.15;
-		}
-	}
-		
-	result 	= gain * (double) DN + bias ;
-
-	return result;
-}
-

Deleted: grass-addons/gipe/i.dn2full.l7/l5inread.c
===================================================================
--- grass-addons/gipe/i.dn2full.l7/l5inread.c	2008-04-02 02:59:43 UTC (rev 30838)
+++ grass-addons/gipe/i.dn2full.l7/l5inread.c	2008-04-02 03:58:10 UTC (rev 30839)
@@ -1,94 +0,0 @@
-#include<stdio.h>
-#include<stdlib.h>
-#include<string.h>
-#include <grass/gis.h>
-#include <grass/glocale.h>
-
-int l5_in_read(char *metfName,int *path, int *row, double *latitude,double *longitude,double *sun_elevation, double *sun_azimuth,int *c_year, int *c_month, int *c_day,int *day, int *month, int *year,double *decimal_hour)
-{
-	FILE 		*f;
-	char 		s[1000], *ptr;
-	int 		i=0;
-	char 		*p;
-	int 		hour, minute;
-	float		second;
-
-	if((f=fopen(metfName,"r"))==NULL){
-		G_fatal_error (_("NLAPS report file [%s] not found, are you in the proper directory?"), metfName);
-	}
-
-	while (fgets(s,1000,f)!=NULL)
-	{
-		ptr = strstr(s, "Strip no.");
-		if (ptr != NULL)
-		{
-			p = strtok(ptr, ":");
-			p = strtok(NULL, " ");
-			*path = atoi(p);
-			p = strtok(NULL, " ");
-			p = strtok(NULL, "Start Row no.:");
-			*row = atoi(p);
-		}
-		ptr = strstr(s, "center lat");
-		if (ptr != NULL)
-		{
-			p = strtok(ptr, ":");
-			p = strtok(NULL, " ");
-			*latitude = atof(p);
-			p = strtok(NULL, " deg");
-			p = strtok(NULL, " Scene center long:");
-			*longitude = atof(p);
-		}
-		ptr = strstr(s, "Sun Elevation");
-		if (ptr != NULL)
-		{
-			p = strtok(ptr, ":");
-			p = strtok(NULL, " ");
-			*sun_elevation = atof(p);
-			p = strtok(NULL, " deg");
-			p = strtok(NULL, "Sun Azimuth:");
-			*sun_azimuth = atof(p);
-		}
-		ptr = strstr(s, "center date");
-		if (ptr != NULL)
-		{
-			p = strtok(ptr, ":");
-			p = strtok(NULL, " ");
-			*year = atoi(p);
-			p = strtok(NULL, " ");
-			*month = atoi(p);
-			p = strtok(NULL, " ");
-			*day = atoi(p);
-			p = strtok(NULL, " Scene center time:");
-			hour = atoi(p);
-			p = strtok(NULL, ":");
-			minute = atoi(p);
-			p = strtok(NULL, ":");
-			second = atof(p);
-		}
-		ptr = strstr(s, "Completion date");
-		if (ptr != NULL)
-		{
-			p = strtok(ptr, ":");
-			p = strtok(NULL, " ");
-			*c_year = atoi(p);
-			p = strtok(NULL, " ");
-			*c_month = atoi(p);
-			p = strtok(NULL, " ");
-			*c_day = atoi(p);
-		}
-	}
-
-//	printf("year = %i\n", year);
-//	printf("month = %i\n", month);
-//	printf("day = %i\n", day);
-
-//	printf("sun azimuth = %f\n", sun_azimuth);
-//	printf("sun elevation = %f\n", sun_elevation);
-
-//	printf("latitude = %f\n", latitude);
-//	printf("longitude = %f\n", longitude);
-
-	(void)fclose(f);
-	return;
-}

Modified: grass-addons/gipe/i.dn2full.l7/main.c
===================================================================
--- grass-addons/gipe/i.dn2full.l7/main.c	2008-04-02 02:59:43 UTC (rev 30838)
+++ grass-addons/gipe/i.dn2full.l7/main.c	2008-04-02 03:58:10 UTC (rev 30839)
@@ -1,8 +1,8 @@
 /****************************************************************************
  *
- * MODULE:       i.dn2full.l5
+ * MODULE:       i.dn2full.l7
  * AUTHOR(S):    Yann Chemin - ychemin at gmail.com
- * PURPOSE:      Calculate TOA Reflectance&Temperature for Landsat5 from DN.
+ * PURPOSE:      Calculate TOA Reflectance&Temperature for Landsat7 from DN.
  *
  * COPYRIGHT:    (C) 2002 by the GRASS Development Team
  *
@@ -20,7 +20,7 @@
 #include <grass/gis.h>
 #include <grass/glocale.h>
 
-#define MAXFILES 7
+#define MAXFILES 9
 
 //sun exo-atmospheric irradiance
 #define KEXO1 1969.0
@@ -28,17 +28,17 @@
 #define KEXO3 1551.0
 #define KEXO4 1044.0
 #define KEXO5 225.7
-#define KEXO6 00.0//filling only
 #define KEXO7 82.07
+#define KEXO8 1385.64 //to find the real value in the internet
 
 #define PI 3.1415926
 
 
-int l5_in_read(char *metfName, int *path, int *row, double *latitude,double *longitude,double *sun_elevation, double *sun_azimuth,int *c_year, int *c_month, int *c_day, int *day, int *month, int *year,double *decimal_hour);
+int l7_in_read(char *metfName, char *b1, char *b2, char *b3, char *b4, char *b5, char *b61, char *b62, char *b7, char *b8, double *lmin,double *lmax,double *qcalmin,double *qcalmax,double *sun_elevation, double *sun_azimuth,int *day, int *month, int *year);
 int date2doy(int day, int month, int year);
-double dn2rad_landsat5(int c_year, int c_month, int c_day, int year, int month, int day, int band, int DN );
-double rad2ref_landsat5( double radiance, double doy,double sun_elevation, double k_exo );
-double tempk_landsat5( double l6 );
+double dn2rad_landsat7( double Lmin, double LMax, double QCalMax, double QCalmin, int DN );
+double rad2ref_landsat7( double radiance, double doy,double sun_elevation, double k_exo );
+double tempk_landsat7( double l6 );
 
 int
 main(int argc, char *argv[])
@@ -48,6 +48,7 @@
 	int nrows, ncols;
 	int row,col;
 
+	int verbose=1;
 	struct GModule *module;
 	struct Option *input,*output;
 	
@@ -61,7 +62,7 @@
 	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];
+	char result5[80], result61[80], result62[80], result7[80],result8[80] ;
 	
 	//File Descriptors
 	int infd[MAXFILES];
@@ -79,21 +80,19 @@
 
 	double		kexo[MAXFILES];
 	//Metfile
-	char		*metfName; //NLAPS report file, header in text format
+	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
+	double 		lmin[MAXFILES];
+	double 		lmax[MAXFILES];
+	double 		qcalmin[MAXFILES];
+	double 		qcalmax[MAXFILES];
 	double 		sun_elevation;
 	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
 	int 		doy;
-	char		b1[80],b2[80],b3[80];
-	char		b4[80],b5[80];
-	char		b6[80],b7[80];//Load .tif names
-	int		temp;
 	/************************************/
 
 	G_gisinit(argv[0]);
@@ -101,56 +100,56 @@
 	module = G_define_module();
 	module->keywords = _("DN, reflectance, temperature, import");
 	module->description =
-		_("Calculates Top of Atmosphere Reflectance/Temperature from Landsat 5 DN.\n");
+		_("Calculates Top of Atmosphere Reflectance/Temperature from Landsat 7 DN.\n");
 
 	/* Define the different options */
 	input = G_define_option() ;
-	input->key        = _("file");
+	input->key        = _("metfile");
 	input->type       = TYPE_STRING;
 	input->required   = YES;
 	input->gisprompt  = _("old_file,file,file");
-	input->description= _("Landsat 5TM NLAPS processing report File (.txt)");
+	input->description= _("Landsat 7ETM+ Header File (.met)");
 
-	output = G_define_standard_option(G_OPT_R_OUTPUT) ;
+	output = G_define_option() ;
 	output->key        = _("output");
+	output->type       = TYPE_STRING;
+	output->required   = YES;
+	output->gisprompt  = _("new,cell,raster");
 	output->description= _("Base name of the output layers (will add .x)");
+
+	/* Define the different flags */
+
+	flag1 = G_define_flag() ;
+	flag1->key         =_('q');
+	flag1->description =_("Quiet");
+
 	/********************/
 	if (G_parser(argc, argv))
 		exit (-1);
 	
 	metfName	= input->answer;
 	result		= output->answer;
+
+	verbose = (!flag1->answer);
 	//******************************************
 	//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);
+	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);
 	/********************/
-	//Prepare the input file names 
-	/********************/
-	doy = date2doy(day,month,year);
-	//printf("doy=%i\n",doy);
-	if(year<2000){
-		temp = year - 1900;
-	} else {
-		temp = year - 2000;
-	}
-	if (temp >=10){
-		sprintf(b1, "%s%d%s%d%s%d%d%s","LT5",l5path,"0",l5row,"00",temp,doy,"50_B1.tif");
-		sprintf(b2, "%s%d%s%d%s%d%d%s","LT5",l5path,"0",l5row,"00",temp,doy,"50_B2.tif");
-		sprintf(b3, "%s%d%s%d%s%d%d%s","LT5",l5path,"0",l5row,"00",temp,doy,"50_B3.tif");
-		sprintf(b4, "%s%d%s%d%s%d%d%s","LT5",l5path,"0",l5row,"00",temp,doy,"50_B4.tif");
-		sprintf(b5, "%s%d%s%d%s%d%d%s","LT5",l5path,"0",l5row,"00",temp,doy,"50_B5.tif");
-		sprintf(b6, "%s%d%s%d%s%d%d%s","LT5",l5path,"0",l5row,"00",temp,doy,"50_B6.tif");
-		sprintf(b7, "%s%d%s%d%s%d%d%s","LT5",l5path,"0",l5row,"00",temp,doy,"50_B7.tif");
-	} else {
-		sprintf(b1, "%s%d%s%d%s%d%d%s","LT5",l5path,"0",l5row,"000",temp,doy,"50_B1.tif");
-		sprintf(b2, "%s%d%s%d%s%d%d%s","LT5",l5path,"0",l5row,"000",temp,doy,"50_B2.tif");
-		sprintf(b3, "%s%d%s%d%s%d%d%s","LT5",l5path,"0",l5row,"000",temp,doy,"50_B3.tif");
-		sprintf(b4, "%s%d%s%d%s%d%d%s","LT5",l5path,"0",l5row,"000",temp,doy,"50_B4.tif");
-		sprintf(b5, "%s%d%s%d%s%d%d%s","LT5",l5path,"0",l5row,"000",temp,doy,"50_B5.tif");
-		sprintf(b6, "%s%d%s%d%s%d%d%s","LT5",l5path,"0",l5row,"000",temp,doy,"50_B6.tif");
-		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);
+//	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 
@@ -167,10 +166,14 @@
 //	printf("%s\n",result4);
 	snprintf(result5, 80, "%s%s",result,".5");
 //	printf("%s\n",result5);
-	snprintf(result6, 80, "%s%s",result,".6");
-//	printf("%s\n",result6);
+	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
@@ -181,9 +184,12 @@
 	kexo[2]=KEXO3;
 	kexo[3]=KEXO4;
 	kexo[4]=KEXO5;
-	kexo[5]=KEXO6;//filling only
-	kexo[6]=KEXO7;
+	kexo[5]=0.0;//filling
+	kexo[6]=0.0;//filling
+	kexo[7]=KEXO7;
+	kexo[8]=KEXO8;
 	
+	//******************************************
 	/***************************************************/
 	//Band1
 	/* find map in mapset */
@@ -290,27 +296,48 @@
 	inrast[4] = G_allocate_raster_buf(in_data_type[4]);
 	/***************************************************/
 	/***************************************************/
-	//Band6
+	//Band61
 	/* find map in mapset */
-	mapset = G_find_cell2 (b6, "");
+	mapset = G_find_cell2 (b61, "");
         if (mapset == NULL){
-		G_fatal_error (_("cell file [%s] not found"), b6);
+		G_fatal_error (_("cell file [%s] not found"), b61);
 	}
-	if (G_legal_filename (b6) < 0){
-		G_fatal_error (_("[%s] is an illegal name"), b6);
+	if (G_legal_filename (b61) < 0){
+		G_fatal_error (_("[%s] is an illegal name"), b61);
 	}
-	infd[5] = G_open_cell_old (b6, mapset);
+	infd[5] = G_open_cell_old (b61, mapset);
 	/* Allocate input buffer */
-	in_data_type[5] = G_raster_map_type(b6, mapset);
-	if( (infd[5] = G_open_cell_old(b6,mapset)) < 0){
-		G_fatal_error(_("Cannot open cell file [%s]"), b6);
+	in_data_type[5] = G_raster_map_type(b61, mapset);
+	if( (infd[5] = G_open_cell_old(b61,mapset)) < 0){
+		G_fatal_error(_("Cannot open cell file [%s]"), b61);
 	}
-	if( (G_get_cellhd(b6,mapset,&cellhd)) < 0){
-		G_fatal_error(_("Cannot read file header of [%s]"), b6);
+	if( (G_get_cellhd(b61,mapset,&cellhd)) < 0){
+		G_fatal_error(_("Cannot read file header of [%s]"), b61);
 	}
 	inrast[5] = G_allocate_raster_buf(in_data_type[5]);
 	/***************************************************/
 	/***************************************************/
+	//Band62
+	/* find map in mapset */
+	mapset = G_find_cell2 (b62, "");
+        if (mapset == NULL){
+		G_fatal_error (_("cell file [%s] not found"), b62);
+	}
+	if (G_legal_filename (b62) < 0){
+		G_fatal_error (_("[%s] is an illegal name"), b62);
+	}
+	infd[6] = G_open_cell_old (b62, mapset);
+	/* Allocate input buffer */
+	in_data_type[6] = G_raster_map_type(b62, mapset);
+	if( (infd[6] = G_open_cell_old(b62,mapset)) < 0){
+		G_fatal_error(_("Cannot open cell file [%s]"), b62);
+	}
+	if( (G_get_cellhd(b62,mapset,&cellhd)) < 0){
+		G_fatal_error(_("Cannot read file header of [%s]"), b62);
+	}
+	inrast[6] = G_allocate_raster_buf(in_data_type[6]);
+	/***************************************************/
+	/***************************************************/
 	//Band7
 	/* find map in mapset */
 	mapset = G_find_cell2 (b7, "");
@@ -320,18 +347,39 @@
 	if (G_legal_filename (b7) < 0){
 		G_fatal_error (_("[%s] is an illegal name"), b7);
 	}
-	infd[6] = G_open_cell_old (b7, mapset);
+	infd[7] = G_open_cell_old (b7, mapset);
 	/* Allocate input buffer */
-	in_data_type[6] = G_raster_map_type(b7, mapset);
-	if( (infd[6] = G_open_cell_old(b7,mapset)) < 0){
+	in_data_type[7] = G_raster_map_type(b7, mapset);
+	if( (infd[7] = G_open_cell_old(b7,mapset)) < 0){
 		G_fatal_error(_("Cannot open cell file [%s]"), b7);
 	}
 	if( (G_get_cellhd(b7,mapset,&cellhd)) < 0){
 		G_fatal_error(_("Cannot read file header of [%s]"), b7);
 	}
-	inrast[6] = G_allocate_raster_buf(in_data_type[6]);
+	inrast[7] = G_allocate_raster_buf(in_data_type[7]);
 	/***************************************************/
 	/***************************************************/
+	//Band8
+	/* find map in mapset */
+	mapset = G_find_cell2 (b8, "");
+        if (mapset == NULL){
+		G_fatal_error (_("cell file [%s] not found"), b8);
+	}
+	if (G_legal_filename (b8) < 0){
+		G_fatal_error (_("[%s] is an illegal name"), b8);
+	}
+	infd[8] = G_open_cell_old (b8, mapset);
+	/* Allocate input buffer */
+	in_data_type[8] = G_raster_map_type(b8, mapset);
+	if( (infd[8] = G_open_cell_old(b8,mapset)) < 0){
+		G_fatal_error(_("Cannot open cell file [%s]"), b8);
+	}
+	if( (G_get_cellhd(b8,mapset,&cellhd)) < 0){
+		G_fatal_error(_("Cannot read file header of [%s]"), b8);
+	}
+	inrast[8] = G_allocate_raster_buf(in_data_type[8]);
+	/***************************************************/
+	/***************************************************/
 	/* Allocate output buffer, use input map data_type */
 	nrows = G_window_rows();
 	ncols = G_window_cols();
@@ -349,16 +397,22 @@
 		G_fatal_error (_("Could not open <%s>"),result4);
 	if ( (outfd[4] = G_open_raster_new (result5,1)) < 0)
 		G_fatal_error (_("Could not open <%s>"),result5);
-	if ( (outfd[5] = G_open_raster_new (result6,1)) < 0)
-		G_fatal_error (_("Could not open <%s>"),result6);
-	if ( (outfd[6] = G_open_raster_new (result7,1)) < 0)
+	if ( (outfd[5] = G_open_raster_new (result61,1)) < 0)
+		G_fatal_error (_("Could not open <%s>"),result61);
+	if ( (outfd[6] = G_open_raster_new (result62,1)) < 0)
+		G_fatal_error (_("Could not open <%s>"),result62);
+	if ( (outfd[7] = G_open_raster_new (result7,1)) < 0)
 		G_fatal_error (_("Could not open <%s>"),result7);
+	if ( (outfd[8] = G_open_raster_new (result8,1)) < 0)
+		G_fatal_error (_("Could not open <%s>"),result8);
 	/* Process pixels */
 	DCELL dout[MAXFILES];
 	DCELL d[MAXFILES];
 	for (row = 0; row < nrows; row++)
 	{
-		G_percent (row, nrows, 2);
+		if (verbose){
+			G_percent (row, nrows, 2);
+		}
 		/* read input map */
 		for (i=0;i<MAXFILES;i++)
 		{
@@ -372,15 +426,15 @@
 			for(i=0;i<MAXFILES;i++)
 			{
 				d[i] = (double) ((CELL *) inrast[i])[col];
-				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
+				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(dout[i]<=0.0){
 						dout[i]=-999.990;
 					}else{
-						dout[i]=tempk_landsat5(dout[i]);
+						dout[i]=tempk_landsat7(dout[i]);
 					}
 				}else{//process reflectance
-					dout[i]=rad2ref_landsat5(dout[i],doy,sun_elevation,kexo[i]);
+					dout[i]=rad2ref_landsat7(dout[i],doy,sun_elevation,kexo[i]);
 			}
 			((DCELL *) outrast[i])[col] = dout[i];
  			}

Deleted: grass-addons/gipe/i.dn2full.l7/rad2ref_landsat5.c
===================================================================
--- grass-addons/gipe/i.dn2full.l7/rad2ref_landsat5.c	2008-04-02 02:59:43 UTC (rev 30838)
+++ grass-addons/gipe/i.dn2full.l7/rad2ref_landsat5.c	2008-04-02 03:58:10 UTC (rev 30839)
@@ -1,19 +0,0 @@
-#include<stdio.h>
-#include<math.h>
-#include<stdlib.h>
-
-#define PI 3.1415926
-
-// Conversion of Radiance to Reflectance for Landsat 5TM 
-// ychemin at gmail.com - Yann Chemin - GPL>=2, 2008.
-
-double rad2ref_landsat5( double radiance, double doy,double sun_elevation, double k_exo )
-{
-	double	result, ds;
-	
-	ds = (1+0.01672*sin(2*PI*(doy-93.5)/365));
-	result = (radiance/((cos((90-sun_elevation)*PI/180)/(PI*ds*ds))*k_exo));
-	
-	return result;
-}
-

Deleted: grass-addons/gipe/i.dn2full.l7/tempk_landsat5.c
===================================================================
--- grass-addons/gipe/i.dn2full.l7/tempk_landsat5.c	2008-04-02 02:59:43 UTC (rev 30838)
+++ grass-addons/gipe/i.dn2full.l7/tempk_landsat5.c	2008-04-02 03:58:10 UTC (rev 30839)
@@ -1,16 +0,0 @@
-#include<stdio.h>
-#include<math.h>
-#include<stdlib.h>
-
-// Surface temperature for Landsat 5TM 
-// Schneider and Mauser, 1996
-
-double tempk_landsat5( double l6 )
-{
-	double	result;
-	
-	result = 1260.56 / (log ((607.76 / (l6)) + 1.0)) ;
-	
-	return result;
-}
-



More information about the grass-commit mailing list