[GRASS-SVN] r30832 - in grass-addons/gipe: i.albedo r.out.vic_veg
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Apr 1 08:12:37 EDT 2008
Author: ychemin
Date: 2008-04-01 08:12:36 -0400 (Tue, 01 Apr 2008)
New Revision: 30832
Modified:
grass-addons/gipe/i.albedo/main.c
grass-addons/gipe/r.out.vic_veg/main.c
Log:
Various bug fixing
Modified: grass-addons/gipe/i.albedo/main.c
===================================================================
--- grass-addons/gipe/i.albedo/main.c 2008-04-01 10:26:44 UTC (rev 30831)
+++ grass-addons/gipe/i.albedo/main.c 2008-04-01 12:12:36 UTC (rev 30832)
@@ -61,15 +61,13 @@
void *inrast[MAXFILES];
unsigned char *outrast;
int data_format; /* 0=double 1=float 2=32bit signed int 5=8bit unsigned int (ie text) */
- RASTER_MAP_TYPE in_data_type[MAXFILES],out_data_type; /* 0=numbers 1=text */
+ RASTER_MAP_TYPE in_data_type[MAXFILES]; /* 0=numbers 1=text */
+ RASTER_MAP_TYPE out_data_type = DCELL_TYPE;
char *fileName;
#define fileNameLe 8
#define fileNamePosition 3
- FCELL fe;
- FCELL f[MAXFILES];
-
/************************************/
/************************************/
int histogram[100];
@@ -178,7 +176,6 @@
/* Allocate output buffer, use input map data_type */
nrows = G_window_rows();
ncols = G_window_cols();
- out_data_type=FCELL_TYPE;
outrast = G_allocate_raster_buf(out_data_type);
/* Create New raster files */
@@ -192,6 +189,8 @@
histogram[i]=0;
}
if(flag5->answer){
+ DCELL de;
+ DCELL d[MAXFILES];
/****************************/
/* Process pixels histogram */
for (row = 0; row < nrows; row++)
@@ -212,30 +211,30 @@
switch(in_data_type[i])
{
case CELL_TYPE:
- f[i] = (float) ((CELL *) inrast[i])[col];
+ d[i] = (double) ((CELL *) inrast[i])[col];
break;
case FCELL_TYPE:
- f[i] = (float) ((FCELL *) inrast[i])[col];
+ d[i] = (double) ((FCELL *) inrast[i])[col];
break;
case DCELL_TYPE:
- f[i] = (float) ((DCELL *) inrast[i])[col];
+ d[i] = (double) ((DCELL *) inrast[i])[col];
break;
}
}
if(modis){
- fe = bb_alb_modis(f[1],f[2],f[3],f[4],f[5],f[6],f[7]);
+ de = bb_alb_modis(d[1],d[2],d[3],d[4],d[5],d[6],d[7]);
} else if (avhrr){
- fe = bb_alb_noaa(f[1],f[2]);
+ de = bb_alb_noaa(d[1],d[2]);
} else if (landsat){
- fe = bb_alb_landsat(f[1],f[2],f[3],f[4],f[5],f[6]);
+ de = bb_alb_landsat(d[1],d[2],d[3],d[4],d[5],d[6]);
} else if (aster){
- fe = bb_alb_aster(f[1],f[2],f[3],f[4],f[5],f[6],f[7],f[8],f[9]);
+ de = bb_alb_aster(d[1],d[2],d[3],d[4],d[5],d[6],d[7],d[8],d[9]);
}
- if(G_is_f_null_value(&fe)){
+ if(G_is_d_null_value(&de)){
/*Do nothing*/
} else {
int temp;
- temp = (int) (fe*100);
+ temp = (int) (de*100);
if(temp>0){
histogram[temp]=histogram[temp]+1.0;
}
@@ -345,6 +344,8 @@
/* Process pixels */
for (row = 0; row < nrows; row++)
{
+ DCELL de;
+ DCELL d[MAXFILES];
G_percent (row, nrows, 2);
/* read input map */
for (i=1;i<=nfiles;i++)
@@ -361,30 +362,30 @@
switch(in_data_type[i])
{
case CELL_TYPE:
- f[i] = (float) ((CELL *) inrast[i])[col];
+ d[i] = (double) ((CELL *) inrast[i])[col];
break;
case FCELL_TYPE:
- f[i] = (float) ((FCELL *) inrast[i])[col];
+ d[i] = (double) ((FCELL *) inrast[i])[col];
break;
case DCELL_TYPE:
- f[i] = (float) ((DCELL *) inrast[i])[col];
+ d[i] = (double) ((DCELL *) inrast[i])[col];
break;
}
}
if(modis){
- fe = bb_alb_modis(f[1],f[2],f[3],f[4],f[5],f[6],f[7]);
+ de = bb_alb_modis(d[1],d[2],d[3],d[4],d[5],d[6],d[7]);
} else if (avhrr){
- fe = bb_alb_noaa(f[1],f[2]);
+ de = bb_alb_noaa(d[1],d[2]);
} else if (landsat){
- fe = bb_alb_landsat(f[1],f[2],f[3],f[4],f[5],f[6]);
+ de = bb_alb_landsat(d[1],d[2],d[3],d[4],d[5],d[6]);
} else if (aster){
- fe = bb_alb_aster(f[1],f[2],f[3],f[4],f[5],f[6],f[7],f[8],f[9]);
+ de = bb_alb_aster(d[1],d[2],d[3],d[4],d[5],d[6],d[7],d[8],d[9]);
}
if(flag5->answer){
// Post-Process Albedo
- fe = a*fe+b;
+ de = a*de+b;
}
- ((FCELL *) outrast)[col] = fe;
+ ((DCELL *) outrast)[col] = de;
}
if (G_put_raster_row (outfd, outrast, out_data_type) < 0)
G_fatal_error (_("Cannot write to <%s>"),result);
Modified: grass-addons/gipe/r.out.vic_veg/main.c
===================================================================
--- grass-addons/gipe/r.out.vic_veg/main.c 2008-04-01 10:26:44 UTC (rev 30831)
+++ grass-addons/gipe/r.out.vic_veg/main.c 2008-04-01 12:12:36 UTC (rev 30832)
@@ -74,9 +74,7 @@
module = G_define_module();
module->keywords = _("VIC, hydrology, soil");
- module->description = _("creates a vegetation ascii file \
- from land cover map. \
- Optionally LAI data from 12 LAI maps.");
+ module->description = _("creates a vegetation ascii file from land cover map. Optionally LAI data from 12 LAI maps.");
/* Define the different options */
input1 = G_define_standard_option(G_OPT_R_INPUT) ;
@@ -91,8 +89,8 @@
output1 = G_define_option() ;
output1->key =_("output");
- output1->description=_("Name of the output vic vegetation ascii file");
- output1->answer =_("vic_veg.asc");
+ output1->description=_("Name of the output vic soil ascii file");
+ output1->answer =_("vic_soil.asc");
output2 = G_define_option() ;
output2->key =_("veglib");
@@ -186,7 +184,7 @@
/*Extract landcover data*/
switch(data_type_inrast_landcover){
case CELL_TYPE:
- c_landcover= ((CELL *) inrast_landcover)[col];
+ c_landcover= (int) ((CELL *) inrast_landcover)[col];
break;
case FCELL_TYPE:
c_landcover= (int) ((FCELL *) inrast_landcover)[col];
@@ -211,24 +209,28 @@
}
}
}
- /*Print to ascii file*/
- /*Grid cell count and number of classes in that grid cell (=1)*/
- fprintf(f,"%d\t1\n", grid_count);
- /*Class number, percentage that this class covers in the
- * grid cell(=1.0, full grid cell)
- * 3 root zones with depths of 10cm, 10cm and 1.0m
- * for those 3 root zone depths, how much root in each (%)
- * here we have 0.65, 0.50 and 0.25
- * */
- fprintf(f,"\t\t%d\t1.0\t%s\n", c_landcover, dummy_data1);
- /*Load monthly LAI maps data if available*/
- if(input2->answer){
- fprintf(f,"\t\t\t%5.3f\t%5.3f\t%5.3f\t%5.3f\t%5.3f\t%5.3f\t%5.3f\t%5.3f\t%5.3f\t%5.3f\t%5.3f\t%5.3f\n", lai[0], lai[1], lai[2], lai[3], lai[4], lai[5], lai[6], lai[7], lai[8], lai[9], lai[10], lai[11]);
+ if(G_is_c_null_value(&c_landcover)){
+ /* Skip the Null value pixel */
} else {
- fprintf(f,"\t\t\t%s\n", dummy_data2);
-
- }
- grid_count=grid_count+1;
+ /*Print to ascii file*/
+ /*Grid cell count and number of classes in that grid cell (=1)*/
+ fprintf(f,"%d\t1\n", grid_count);
+ /*Class number, percentage that this class covers in the
+ * grid cell(=1.0, full grid cell)
+ * 3 root zones with depths of 10cm, 10cm and 1.0m
+ * for those 3 root zone depths, how much root in each (%)
+ * here we have 0.65, 0.50 and 0.25
+ * */
+ fprintf(f,"\t\t%d\t1.0\t%s\n", c_landcover, dummy_data1);
+ /*Load monthly LAI maps data if available*/
+ if(input2->answer){
+ fprintf(f,"\t\t\t%5.3f\t%5.3f\t%5.3f\t%5.3f\t%5.3f\t%5.3f\t%5.3f\t%5.3f\t%5.3f\t%5.3f\t%5.3f\t%5.3f\n", lai[0], lai[1], lai[2], lai[3], lai[4], lai[5], lai[6], lai[7], lai[8], lai[9], lai[10], lai[11]);
+ } else {
+ fprintf(f,"\t\t\t%s\n", dummy_data2);
+
+ }
+ grid_count=grid_count+1;
+ } /* End of if NULL() statement */
}
}
G_free (inrast_landcover);
More information about the grass-commit
mailing list