[GRASS-SVN] r31404 - in grass-addons/gipe: i.albedo i.eb.h_SEBAL95 i.evapo.potrad i.vi

svn_grass at osgeo.org svn_grass at osgeo.org
Sat May 17 23:08:39 EDT 2008


Author: ychemin
Date: 2008-05-17 23:08:39 -0400 (Sat, 17 May 2008)
New Revision: 31404

Modified:
   grass-addons/gipe/i.albedo/main.c
   grass-addons/gipe/i.eb.h_SEBAL95/functions.h
   grass-addons/gipe/i.eb.h_SEBAL95/main.c
   grass-addons/gipe/i.eb.h_SEBAL95/sensi_h.c
   grass-addons/gipe/i.evapo.potrad/main.c
   grass-addons/gipe/i.vi/main.c
Log:
minor bug fixing

Modified: grass-addons/gipe/i.albedo/main.c
===================================================================
--- grass-addons/gipe/i.albedo/main.c	2008-05-17 20:29:55 UTC (rev 31403)
+++ grass-addons/gipe/i.albedo/main.c	2008-05-18 03:08:39 UTC (rev 31404)
@@ -40,7 +40,7 @@
 	struct Flag *flag1, *flag2, *flag3;
 	struct Flag *flag4, *flag5, *flag6;
 	struct History history; //metadata
-
+	struct Colors colors; //Color rules
 	/************************************/
 	/* FMEO Declarations*****************/
 	char *name; //input raster name
@@ -410,5 +410,14 @@
 	}
 	G_free (outrast);
 	G_close_cell (outfd);
-	return 0;
+	
+	/* Color table from 0.0 to 1.0 */
+	G_init_colors(&colors);
+	G_add_color_rule(0.0,0,0,0,1.0,255,255,255,&colors);
+	/* Metadata */
+	G_short_history(result,"raster",&history);
+	G_command_history(&history);
+	G_write_history(result,&history);
+
+	exit(EXIT_SUCCESS);
 }

Modified: grass-addons/gipe/i.eb.h_SEBAL95/functions.h
===================================================================
--- grass-addons/gipe/i.eb.h_SEBAL95/functions.h	2008-05-17 20:29:55 UTC (rev 31403)
+++ grass-addons/gipe/i.eb.h_SEBAL95/functions.h	2008-05-18 03:08:39 UTC (rev 31404)
@@ -26,7 +26,7 @@
 double et_pot_day( double bbalb, double solar, double tempk, double tsw );
 
 /* Sensible heat flux functions */
-double sensi_h( double tempk_water, double tempk_desert, double t0_dem, double tempk, double ndvi, double ndvi_max, double dem, double rnet_desert, double g0_desert, double t0_dem_desert, double u2m, double dem_desert);
+double sensi_h( int iteration, double tempk_water, double tempk_desert, double t0_dem, double tempk, double ndvi, double ndvi_max, double dem, double rnet_desert, double g0_desert, double t0_dem_desert, double u2m, double dem_desert);
 double roh_air_0(double tempk);
 double zom_0(double ndvi, double ndvi_max);
 double U_0(double zom_0, double u2m);

Modified: grass-addons/gipe/i.eb.h_SEBAL95/main.c
===================================================================
--- grass-addons/gipe/i.eb.h_SEBAL95/main.c	2008-05-17 20:29:55 UTC (rev 31403)
+++ grass-addons/gipe/i.eb.h_SEBAL95/main.c	2008-05-18 03:08:39 UTC (rev 31404)
@@ -25,7 +25,7 @@
 #include <grass/glocale.h>
 /*#include <omp.h>*/
 
-double sensi_h( double tempk_water, double tempk_desert, double t0_dem, double tempk, double ndvi, double ndvi_max, double dem, double rnet_desert, double g0_desert, double t0_dem_desert, double u2m, double dem_desert);
+double sensi_h( int iteration, double tempk_water, double tempk_desert, double t0_dem, double tempk, double ndvi, double ndvi_max, double dem, double rnet_desert, double g0_desert, double t0_dem_desert, double u2m, double dem_desert);
 
 int main(int argc, char *argv[])
 {	
@@ -54,6 +54,7 @@
 	struct Option *input_Rn, *input_g0, *input_albedo, *output;
 	struct Option *input_row_wet, *input_col_wet;
 	struct Option *input_row_dry, *input_col_dry;
+	struct Option *input_iter;
 	struct Flag *flag1, *day, *zero;
 	/*******************************/
 	RASTER_MAP_TYPE data_type_T;
@@ -65,8 +66,9 @@
 	RASTER_MAP_TYPE data_type_albedo;
 	RASTER_MAP_TYPE data_type_output=DCELL_TYPE;
 	/*******************************/
+	int iteration = 10; /*SEBAL95 loop number*/
 	/********************************/
-	/* Stats for Senay equation	*/
+	/* Stats for dry/wet pixels	*/
 	double t0dem_min=400.0,t0dem_max=200.0;
 	double tempk_min=400.0,tempk_max=200.0;
 	/********************************/
@@ -112,6 +114,14 @@
 	input_albedo->description = _("With Flag \"-a\": Name of Albedo input map [-]");
 	input_albedo->guisection = _("Optional");
 	
+	input_iter 		= G_define_option();
+	input_iter->key		= "iteration";
+	input_iter->type	= TYPE_INTEGER;
+	input_iter->required 	= NO;
+	input_iter->gisprompt 	= "old,value";
+	input_iter->description	= _("Value of the number of SEBAL95 loops (default is 10)");
+	input_iter->guisection	= _("Optional");
+	
 	input_row_wet 			= G_define_option();
 	input_row_wet->key		= "row_wet";
 	input_row_wet->type 		= TYPE_INTEGER;
@@ -171,6 +181,9 @@
 	albedo	= input_albedo->answer;
 	h0	= output->answer;
 
+	if(input_iter->answer){
+		iteration=atoi(input_iter->answer);
+	}
 	if(input_row_wet->answer){
 		row_wet = atoi(input_row_wet->answer);
 		col_wet = atoi(input_col_wet->answer);
@@ -549,7 +562,7 @@
 				G_message("****InLoop d_dem=%5.3f",d_dem);
 				G_message("****InLoop d_tempk=%5.3f",d_tempk);*/
 				/* Calculate sensible heat flux */
-				d = sensi_h(d_tempk_wet,d_tempk_dry,d_t0dem,d_tempk,d_ndvi,d_ndvi_max,d_dem,d_Rn_dry,d_g0_dry,d_t0dem_dry,d_u2m,d_dem_dry);
+				d = sensi_h(iteration,d_tempk_wet,d_tempk_dry,d_t0dem,d_tempk,d_ndvi,d_ndvi_max,d_dem,d_Rn_dry,d_g0_dry,d_t0dem_dry,d_u2m,d_dem_dry);
 				if (zero->answer && d<0.0){
 					d=0.0;
 				}

Modified: grass-addons/gipe/i.eb.h_SEBAL95/sensi_h.c
===================================================================
--- grass-addons/gipe/i.eb.h_SEBAL95/sensi_h.c	2008-05-17 20:29:55 UTC (rev 31403)
+++ grass-addons/gipe/i.eb.h_SEBAL95/sensi_h.c	2008-05-18 03:08:39 UTC (rev 31404)
@@ -8,9 +8,9 @@
 #include "functions.h"
 
 /* Arrays Declarations */
-#define ITER_MAX 3
+#define ITER_MAX 10
 
-double sensi_h( double tempk_water, double tempk_desert, double t0_dem, double tempk, double ndvi, double ndvi_max, double dem, double rnet_desert, double g0_desert, double t0_dem_desert, double u2m, double dem_desert)
+double sensi_h( int iteration, double tempk_water, double tempk_desert, double t0_dem, double tempk, double ndvi, double ndvi_max, double dem, double rnet_desert, double g0_desert, double t0_dem_desert, double u2m, double dem_desert)
 {
 	/* Arrays Declarations */
 	double dtair[ITER_MAX], roh_air[ITER_MAX], rah[ITER_MAX];
@@ -26,6 +26,11 @@
 	double psih;
 	double result;
 
+	/* Fat-free junk food */
+	if (iteration>ITER_MAX){
+		iteration=ITER_MAX;
+	}
+
 	if(debug==1){
 		printf("*****************************\n");
 		printf("t0_dem = %5.3f\n",t0_dem);
@@ -60,7 +65,7 @@
 /*----------------------------------------------------------------*/
 /*Main iteration loop of SEBAL*/
 	zom[0] = zom0;
-	for(ic=1;ic<ITER_MAX+1;ic++){
+	for(ic=1;ic<iteration+1;ic++){
 		if(debug==1){
 			printf("\n ******** ITERATION %i *********\n",ic);
 		}
@@ -102,6 +107,6 @@
 			printf("h[%i] 		= %5.3f W/m2\n",ic, h[ic]);
 		}
 	}
-	return h[ITER_MAX];
+	return h[iteration];
 }
  

Modified: grass-addons/gipe/i.evapo.potrad/main.c
===================================================================
--- grass-addons/gipe/i.evapo.potrad/main.c	2008-05-17 20:29:55 UTC (rev 31403)
+++ grass-addons/gipe/i.evapo.potrad/main.c	2008-05-18 03:08:39 UTC (rev 31404)
@@ -42,7 +42,7 @@
 	
 	struct Flag *flag1, *flag2, *flag3, *flag4;	
 	struct History history; //metadata
-	
+	struct Colors colors; //Color rules	
 	/************************************/
 	/* FMEO Declarations*****************/
 	char *name;   // input raster name
@@ -85,31 +85,25 @@
 	input1->key	   = _("albedo");
 	input1->description=_("Name of the Albedo map [0.0-1.0]");
 	input1->answer     =_("albedo");
-	input1->guisection = _("Required");
 
 	input2 = G_define_standard_option(G_OPT_R_INPUT) ;
 	input2->key        =_("tempk");
 	input2->description=_("Name of the temperature map [Degree Kelvin]");
 	input2->answer     =_("tempk");
-	input2->guisection = _("Required");
 
 	input3 = G_define_standard_option(G_OPT_R_INPUT) ;
 	input3->key        =_("lat");
 	input3->description=_("Name of the degree latitude map [dd.ddd]");
 	input3->answer     =_("lat");
-	input3->guisection = _("Required");
 
 	input4 = G_define_standard_option(G_OPT_R_INPUT) ;
 	input4->key        =_("doy");
 	input4->description=_("Name of the Day of Year map [0.0-366.0]");
 	input4->answer     =_("doy");
-	input4->guisection = _("Required");
 
 	input5 = G_define_standard_option(G_OPT_R_INPUT) ;
 	input5->key        =_("tsw");
-	input5->required   = NO;
 	input5->description=_("Name of the single-way transmissivity map [0.05-1.0], defaults to 1.0 if no input file");
-	input5->guisection = _("Optional");
 
 	input6 = G_define_option() ;
 	input6->key        =_("roh_w");
@@ -118,7 +112,6 @@
 	input6->gisprompt  =_("value, parameter");
 	input6->description=_("Value of the density of fresh water ~[1000-1020]");
 	input6->answer     =_("1005.0");
-	input6->guisection = _("Required");
 
 	input7 = G_define_standard_option(G_OPT_R_INPUT) ;
 	input7->key        =_("slope");
@@ -157,7 +150,6 @@
 	output1->key        =_("etpot");
 	output1->description=_("OUTPUT: Name of the Potential ET layer");
 	output1->answer     =_("etpot");
-	output1->guisection = _("Required");
 
 	output2 = G_define_standard_option(G_OPT_R_OUTPUT) ;
 	output2->key        =_("rnetd");
@@ -239,18 +231,16 @@
 		G_fatal_error(_("Cannot read file header of [%s]"), doy);
 	inrast_doy = G_allocate_raster_buf(data_type_doy);
 	/***************************************************/
-	if(input5->answer){
-		mapset = G_find_cell2 (tsw, "");
-		if (mapset == NULL) {
-			G_fatal_error(_("Cell file [%s] not found"), tsw);
-		}
-		data_type_tsw = G_raster_map_type(tsw,mapset);
-		if ( (infd_tsw = G_open_cell_old (tsw,mapset)) < 0)
-			G_fatal_error(_("Cannot open cell file [%s]"), tsw);
-		if (G_get_cellhd (tsw, mapset, &cellhd) < 0)
-			G_fatal_error(_("Cannot read file header of [%s]"), tsw);
-		inrast_tsw = G_allocate_raster_buf(data_type_tsw);
+	mapset = G_find_cell2 (tsw, "");
+	if (mapset == NULL) {
+		G_fatal_error(_("Cell file [%s] not found"), tsw);
 	}
+	data_type_tsw = G_raster_map_type(tsw,mapset);
+	if ( (infd_tsw = G_open_cell_old (tsw,mapset)) < 0)
+		G_fatal_error(_("Cannot open cell file [%s]"), tsw);
+	if (G_get_cellhd (tsw, mapset, &cellhd) < 0)
+		G_fatal_error(_("Cannot read file header of [%s]"), tsw);
+	inrast_tsw = G_allocate_raster_buf(data_type_tsw);
 	/***************************************************/
 	if(flag2->answer){
 		mapset = G_find_cell2 (slope, "");
@@ -326,7 +316,7 @@
 		DCELL d_tempk;
 		DCELL d_lat;
 		DCELL d_doy;
-		DCELL d_tsw=0.7;
+		DCELL d_tsw;
 //		DCELL d_roh_w;
 		DCELL d_solar;
 		DCELL d_rnetd;
@@ -345,10 +335,8 @@
 			G_fatal_error(_("Could not read from <%s>"),lat);
 		if(G_get_raster_row(infd_doy,inrast_doy,row,data_type_doy)<0)
 			G_fatal_error(_("Could not read from <%s>"),doy);
-		if(input5->answer){
-			if(G_get_raster_row(infd_tsw,inrast_tsw,row,data_type_tsw)<0)
-				G_fatal_error(_("Could not read from <%s>"),tsw);
-		}
+		if(G_get_raster_row(infd_tsw,inrast_tsw,row,data_type_tsw)<0)
+			G_fatal_error(_("Could not read from <%s>"),tsw);
 		if(flag2->answer){
 			if(G_get_raster_row(infd_slope,inrast_slope,row,data_type_slope)<0)
 				G_fatal_error(_("Could not read from <%s>"),slope);
@@ -408,18 +396,16 @@
 					d_doy = (double) ((DCELL *) inrast_doy)[col];
 					break;
 			}
-			if(input5->answer){
-				switch(data_type_tsw){
-					case CELL_TYPE:
-						d_tsw = (double) ((CELL *) inrast_tsw)[col];
-						break;
-					case FCELL_TYPE:
-						d_tsw = (double) ((FCELL *) inrast_tsw)[col];
-						break;
-					case DCELL_TYPE:
-						d_tsw = (double) ((DCELL *) inrast_tsw)[col];
-						break;
-				}
+			switch(data_type_tsw){
+				case CELL_TYPE:
+					d_tsw = (double) ((CELL *) inrast_tsw)[col];
+					break;
+				case FCELL_TYPE:
+					d_tsw = (double) ((FCELL *) inrast_tsw)[col];
+					break;
+				case DCELL_TYPE:
+					d_tsw = (double) ((DCELL *) inrast_tsw)[col];
+					break;
 			}
 			if(flag2->answer){
 				switch(data_type_slope){
@@ -479,7 +465,7 @@
 				G_set_d_null_value(&outrast1[col],1);
 				if (result2)
 					G_set_d_null_value(&outrast2[col],1);
-			}else {
+			} else {
 				if(flag2->answer){
 					d_solar = solar_day_3d(d_lat,d_doy,d_tsw,d_slope,d_aspect);
 				}else {
@@ -488,20 +474,13 @@
 				if(flag3->answer){
 					d_rnetd = r_net_day_bandara98(d_albedo, d_solar,e_atm, d_e0, d_tair);
 				} else {
-					if(input5->answer){
-						/*do nothing, there is tsw input*/
-					} else {
-						d_tsw = 1.0;
-					}
 					d_rnetd = r_net_day(d_albedo,d_solar,d_tsw);
 				}
 				if(result2){
 					outrast2[col] = d_rnetd;
 				}
 				d = et_pot_day(d_rnetd,d_tempk,roh_w);
-				if(input5->answer&&flag3->answer){
-					d = d * d_tsw;
-				}
+				d = d * d_tsw;
 				outrast1[col] = d;
 			}
 		}
@@ -522,10 +501,8 @@
 	G_close_cell (infd_lat);
 	G_close_cell (infd_doy);
 
-	if (input5->answer){
-		G_free (inrast_tsw);
-		G_close_cell (infd_tsw);
-	}	
+	G_free (inrast_tsw);
+	G_close_cell (infd_tsw);
 	if (flag3->answer){
 		G_free (inrast_tair);
 		G_close_cell (infd_tair);
@@ -538,11 +515,20 @@
 	if (result2){
 		G_free (outrast2);
 		G_close_cell (outfd2);
+		/* Color rule */
+		G_init_colors(&colors);
+		G_add_color_rule(0,0,0,0,400,255,255,255,&colors);
+		/* Metadata */
 		G_short_history(result2, "raster", &history);
 		G_command_history(&history);
 		G_write_history(result2,&history);
 	}
 
+	/* Color rule */
+	G_init_colors(&colors);
+	G_add_color_rule(0,0,0,0,10,255,255,255,&colors);
+
+	/* Metadata */
 	G_short_history(result1, "raster", &history);
 	G_command_history(&history);
 	G_write_history(result1,&history);

Modified: grass-addons/gipe/i.vi/main.c
===================================================================
--- grass-addons/gipe/i.vi/main.c	2008-05-17 20:29:55 UTC (rev 31403)
+++ grass-addons/gipe/i.vi/main.c	2008-05-18 03:08:39 UTC (rev 31404)
@@ -48,8 +48,6 @@
 	int nrows, ncols;
 	int row,col;
 
-	int verbose=1;
-
 	char *viflag;// Switch for particular index
 	
 	struct GModule *module;
@@ -57,7 +55,7 @@
 	
 	struct Flag *flag1;	
 	struct History history; //metadata
-	
+	struct Colors colors; //Color rules	
 	/************************************/
 	/* FMEO Declarations*****************/
 	char *name;   // input raster name
@@ -71,7 +69,7 @@
 	int i=0,j=0;
 	
 	void *inrast_redchan, *inrast_nirchan, *inrast_greenchan, *inrast_bluechan, *inrast_chan5chan, *inrast_chan7chan;
-	unsigned char *outrast;
+	DCELL *outrast;
 	RASTER_MAP_TYPE data_type_output=DCELL_TYPE;
 	RASTER_MAP_TYPE data_type_redchan;
 	RASTER_MAP_TYPE data_type_nirchan;
@@ -152,10 +150,6 @@
 	output->description=_("Name of the output vi layer");
 	output->answer     =_("vi");
 
-	flag1 = G_define_flag();
-	flag1->key = 'q';
-	flag1->description = _("Quiet");
-
 	/********************/
 	if (G_parser(argc, argv))
 		exit (EXIT_FAILURE);
@@ -168,7 +162,6 @@
 	chan7chan	= input7->answer;
 
 	result  = output->answer;
-	verbose = (!flag1->answer);
 	/***************************************************/
 	mapset = G_find_cell2(redchan, "");
 	if (mapset == NULL) {
@@ -262,8 +255,7 @@
 		DCELL d_nirchan;
 		DCELL d_chan5chan;
 		DCELL d_chan7chan;
-		if(verbose)
-			G_percent(row,nrows,2);
+		G_percent(row,nrows,2);
 //		printf("row = %i/%i\n",row,nrows);
 		/* read soil input maps */	
 		if(G_get_raster_row(infd_redchan,inrast_redchan,row,data_type_redchan)<0)
@@ -365,115 +357,85 @@
 			}
 			//	printf("col=%i/%i ",col,ncols);
 		// to change to multiple to output files.
-			if(G_is_d_null_value(&d_redchan)){
-				((DCELL *) outrast)[col] = -999.99;
-			}else if(G_is_d_null_value(&d_nirchan)){
-				((DCELL *) outrast)[col] = -999.99;
-			}else if((greenchan)&&G_is_d_null_value(&d_greenchan)){
-				((DCELL *) outrast)[col] = -999.99;
-			}else if((bluechan)&&G_is_d_null_value(&d_bluechan)){
-				((DCELL *) outrast)[col] = -999.99;
-			}else if((chan5chan)&&G_is_d_null_value(&d_chan5chan)){
-				((DCELL *) outrast)[col] = -999.99;
-			}else if((chan7chan)&&G_is_d_null_value(&d_chan7chan)){
-				((DCELL *) outrast)[col] = -999.99;
+			if(G_is_d_null_value(&d_redchan)||
+			G_is_d_null_value(&d_nirchan)||
+			((greenchan)&&G_is_d_null_value(&d_greenchan))||
+			((bluechan)&&G_is_d_null_value(&d_bluechan))||
+			((chan5chan)&&G_is_d_null_value(&d_chan5chan))||
+			((chan7chan)&&G_is_d_null_value(&d_chan7chan))){
+				G_set_d_null_value(&outrast[col],1);
 			} else {
 				/************************************/
 				/*calculate simple_ratio        */
 				if (!strcoll(viflag,"sr")){		
 					d =  s_r(d_redchan,d_nirchan );
-					//printf(" || d=%5.3f",d);
 					((DCELL *) outrast)[col] = d;
-					//printf(" -> %5.3f\n",d);
 				}
 				/*calculate ndvi	            */
 				if (!strcoll(viflag,"ndvi")){
-					d =  nd_vi(d_redchan,d_nirchan );
-					//printf(" || d=%5.3f",d);
-					((DCELL *) outrast)[col] = d;
-					//printf(" -> %5.3f\n",d);
+					if(d_redchan+d_nirchan<0.001){
+						G_set_d_null_value(&outrast[col],1);
+					} else {
+						d =  nd_vi(d_redchan,d_nirchan );
+						((DCELL *) outrast)[col] = d;
+					}
 				}
 				/*calculate ipvi	            */
 				if (!strcoll(viflag,"ipvi")){
 					d =  ip_vi(d_redchan,d_nirchan );
-					//printf(" || d=%5.3f",d);
 					((DCELL *) outrast)[col] = d;
-					//printf(" -> %5.3f\n",d);
 				}
 				/*calculate dvi	            */
 				if (!strcoll(viflag,"dvi")){
 					d =  d_vi(d_redchan,d_nirchan );
-					//printf(" || d=%5.3f",d);
 					((DCELL *) outrast)[col] = d;
-					//printf(" -> %5.3f\n",d);
 				}
 				/*calculate pvi	            */
 				if (!strcoll(viflag,"pvi")){
 					d =  p_vi(d_redchan,d_nirchan );
-					//printf(" || d=%5.3f",d);
 					((DCELL *) outrast)[col] = d;
-					//printf(" -> %5.3f\n",d);
 				}
 				/*calculate wdvi	            */
 				if (!strcoll(viflag,"wdvi")){
 					d =  wd_vi(d_redchan,d_nirchan );
-					//printf(" || d=%5.3f",d);
 					((DCELL *) outrast)[col] = d;
-					//printf(" -> %5.3f\n",d);
 				}
 				/*calculate savi	            */
 				if (!strcoll(viflag,"savi")){
 					d =  sa_vi(d_redchan,d_nirchan );
-					//printf(" || d=%5.3f",d);
 					((DCELL *) outrast)[col] = d;
-					//printf(" -> %5.3f\n",d);
 				}
 				/*calculate msavi	            */
 				if (!strcoll(viflag,"msavi")){
 					d =  msa_vi(d_redchan,d_nirchan );
-					//printf(" || d=%5.3f",d);
 					((DCELL *) outrast)[col] = d;
-					//printf(" -> %5.3f\n",d);
 				}
 				/*calculate msavi2            */
 				if (!strcoll(viflag,"msavi2")){
 					d =  msa_vi2(d_redchan,d_nirchan );
-					//printf(" || d=%5.3f",d);
 					((DCELL *) outrast)[col] = d;
-					//printf(" -> %5.3f\n",d);
 				}
 				/*calculate gemi	            */
 				if (!strcoll(viflag,"gemi")){
 					d =  ge_mi(d_redchan,d_nirchan );
-					//printf(" || d=%5.3f",d);
 					((DCELL *) outrast)[col] = d;
-					//printf(" -> %5.3f\n",d);
 				}
 				/*calculate arvi	            */
 				if (!strcoll(viflag,"arvi")){
 					d =  ar_vi(d_redchan,d_nirchan,d_bluechan );
-					//printf(" || d=%5.3f",d);
 					((DCELL *) outrast)[col] = d;
-					//printf(" -> %5.3f\n",d);
 				}
 				/*calculate gvi            */
 				if (!strcoll(viflag,"gvi")){
 					d =  g_vi(d_bluechan,d_greenchan,d_redchan,d_nirchan,d_chan5chan,d_chan7chan);
-				//printf(" || d=%5.3f",d);
 					((DCELL *) outrast)[col] = d;
-				//printf(" -> %5.3f\n",d);
 				}
 				/*calculate gari	            */
 				if (!strcoll(viflag,"gari")){
 					d =  ga_ri(d_redchan,d_nirchan,d_bluechan,d_greenchan );
-					//printf(" || d=%5.3f",d);
 					((DCELL *) outrast)[col] = d;
-					//printf(" -> %5.3f\n",d);
 				}
 			}
-		//	if(row==50){
-		//		exit(EXIT_SUCCESS);
-		//	}
 		}
 		if (G_put_raster_row (outfd, outrast, data_type_output) < 0)
 			G_fatal_error(_("Cannot write to output raster file"));
@@ -502,7 +464,10 @@
 	}
 	G_free(outrast);
 	G_close_cell(outfd);
-	
+
+	/* Color from -1.0 to +1.0 in grey */
+	G_init_colors(&colors);
+	G_add_color_rule(-1.0,0,0,0,1.0,255,255,255,&colors);
 	G_short_history(result, "raster", &history);
 	G_command_history(&history);
 	G_write_history(result,&history);



More information about the grass-commit mailing list