[GRASS-SVN] r30757 - grass-addons/gipe/i.albedo
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Mar 27 09:56:08 EDT 2008
Author: ychemin
Date: 2008-03-27 09:56:08 -0400 (Thu, 27 Mar 2008)
New Revision: 30757
Modified:
grass-addons/gipe/i.albedo/bb_alb_aster.c
grass-addons/gipe/i.albedo/bb_alb_landsat.c
grass-addons/gipe/i.albedo/bb_alb_modis.c
grass-addons/gipe/i.albedo/bb_alb_noaa.c
grass-addons/gipe/i.albedo/main.c
Log:
Bug fixing, new coding standard
Modified: grass-addons/gipe/i.albedo/bb_alb_aster.c
===================================================================
--- grass-addons/gipe/i.albedo/bb_alb_aster.c 2008-03-27 13:18:43 UTC (rev 30756)
+++ grass-addons/gipe/i.albedo/bb_alb_aster.c 2008-03-27 13:56:08 UTC (rev 30757)
@@ -1,20 +1,10 @@
-#include<stdio.h>
-#include<math.h>
-#include<stdlib.h>
-#include"functions.h"
+// Broadband albedo Aster
-// Broadband albedo Aster (Careful the DN multiplier! Here it is 1000.0, output range should be [0-1])
-// yann.chemin at ait.ac.th LGPL, Copylefted, 2004.
-
double bb_alb_aster( double greenchan, double redchan, double nirchan, double swirchan1, double swirchan2, double swirchan3, double swirchan4, double swirchan5, double swirchan6 )
{
double result;
- if( greenchan < 0 || redchan < 0 || nirchan < 0 || swirchan1 < 0 || swirchan2 < 0 || swirchan3 < 0 || swirchan4 < 0 || swirchan5 < 0 || swirchan6 < 0 ){
- result = -1.0;
- } else {
- result = ( 0.09*greenchan + 0.06*redchan + 0.1*nirchan + 0.092*swirchan1 + 0.035*swirchan2 + 0.04*swirchan3 + 0.047*swirchan4 + 0.07*swirchan5 + 0.068*swirchan6 ) / ((0.09+0.06+0.1+0.092+0.035+0.04+0.047+0.07+0.068)*1000.0);
- }
+ result = ( 0.09*greenchan + 0.06*redchan + 0.1*nirchan + 0.092*swirchan1 + 0.035*swirchan2 + 0.04*swirchan3 + 0.047*swirchan4 + 0.07*swirchan5 + 0.068*swirchan6 ) / ((0.09+0.06+0.1+0.092+0.035+0.04+0.047+0.07+0.068)*1000.0);
return result;
}
Modified: grass-addons/gipe/i.albedo/bb_alb_landsat.c
===================================================================
--- grass-addons/gipe/i.albedo/bb_alb_landsat.c 2008-03-27 13:18:43 UTC (rev 30756)
+++ grass-addons/gipe/i.albedo/bb_alb_landsat.c 2008-03-27 13:56:08 UTC (rev 30757)
@@ -1,20 +1,12 @@
#include<stdio.h>
-#include<math.h>
-#include<stdlib.h>
-#include"functions.h"
// Broadband albedo Landsat 5TM and 7ETM+ (maybe others too but not sure)
-// yann.chemin at ait.ac.th LGPL, Copylefted, 2004.
double bb_alb_landsat( double bluechan, double greenchan, double redchan, double nirchan, double chan5, double chan7 )
{
double result;
- if( bluechan < 0 || greenchan < 0 || redchan < 0 || nirchan < 0 || chan5 < 0 || chan7 < 0){
- result = -1.0;
- } else {
- result = ( 0.293*bluechan + 0.274*greenchan + 0.233*redchan + 0.156*nirchan + 0.033*chan5 + 0.011*chan7 ) ;
- }
+ result = (0.293*bluechan+ 0.274*greenchan+ 0.233*redchan+ 0.156*nirchan+ 0.033*chan5+ 0.011*chan7 ) ;
return result;
}
Modified: grass-addons/gipe/i.albedo/bb_alb_modis.c
===================================================================
--- grass-addons/gipe/i.albedo/bb_alb_modis.c 2008-03-27 13:18:43 UTC (rev 30756)
+++ grass-addons/gipe/i.albedo/bb_alb_modis.c 2008-03-27 13:56:08 UTC (rev 30757)
@@ -1,19 +1,10 @@
-#include<stdio.h>
-#include<math.h>
-#include<stdlib.h>
-
// Broadband albedo MODIS
-// yann.chemin at ait.ac.th LGPL, Copylefted, 2004.
double bb_alb_modis( double redchan, double nirchan, double chan3, double chan4, double chan5, double chan6, double chan7 )
{
double result;
- if( nirchan < 0 || redchan < 0 || chan3 < 0 || chan4 < 0 || chan5 < 0 || chan6 < 0 || chan7 < 0){
- result = -1.0;
- } else {
- result = ((0.22831*redchan + 0.15982*nirchan + 0.09132*(chan3+chan4+chan5) + 0.10959*chan6 + 0.22831*chan7 ) / 10000.0 ) ;
- }
+ result =(0.22831*redchan+ 0.15982*nirchan+ 0.09132*(chan3+chan4+chan5)+ 0.10959*chan6+ 0.22831*chan7);
return result;
}
Modified: grass-addons/gipe/i.albedo/bb_alb_noaa.c
===================================================================
--- grass-addons/gipe/i.albedo/bb_alb_noaa.c 2008-03-27 13:18:43 UTC (rev 30756)
+++ grass-addons/gipe/i.albedo/bb_alb_noaa.c 2008-03-27 13:56:08 UTC (rev 30757)
@@ -1,20 +1,10 @@
-#include<stdio.h>
-#include<math.h>
-#include<stdlib.h>
-#include"functions.h"
-
// Broadband albedo NOAA AVHRR 14 (maybe others too but not sure)
-// yann.chemin at ait.ac.th LGPL, Copylefted, 2004.
double bb_alb_noaa( double redchan, double nirchan )
{
double result;
- if( nirchan < 0 || redchan < 0 ){
- result = -1.0;
- } else {
- result = (( 0.035+ 0.545*nirchan - 0.32*redchan) / 10000.0 ) ;
- }
+ result = ( 0.035+ 0.545*nirchan - 0.32*redchan) ;
return result;
}
Modified: grass-addons/gipe/i.albedo/main.c
===================================================================
--- grass-addons/gipe/i.albedo/main.c 2008-03-27 13:18:43 UTC (rev 30756)
+++ grass-addons/gipe/i.albedo/main.c 2008-03-27 13:56:08 UTC (rev 30757)
@@ -20,12 +20,14 @@
#include <grass/glocale.h>
#include "functions.h"
-
-
#define MAXFILES 10
//extern FCELL f_f(FCELL);
+double bb_alb_aster( double greenchan, double redchan, double nirchan, double swirchan1, double swirchan2, double swirchan3, double swirchan4, double swirchan5, double swirchan6 );
+double bb_alb_landsat( double bluechan, double greenchan, double redchan, double nirchan, double chan5, double chan7 );
+double bb_alb_noaa( double redchan, double nirchan );
+double bb_alb_modis( double redchan, double nirchan, double chan3, double chan4, double chan5, double chan6, double chan7 );
int
main(int argc, char *argv[])
@@ -82,19 +84,11 @@
/* Define the different options */
- input = G_define_option() ;
- input->key = _("input");
- input->type = TYPE_STRING;
- input->required = YES;
+ input = G_define_standard_option(G_OPT_R_INPUT) ;
input->multiple = YES;
- input->gisprompt = _("old,cell,raster");
input->description= _("Names of surface reflectance layers");
- output = G_define_option() ;
- output->key = _("output");
- output->type = TYPE_STRING;
- output->required = YES;
- output->gisprompt = _("new,cell,raster");
+ output = G_define_standard_option(G_OPT_R_OUTPUT) ;
output->description= _("Name of the BB_Albedo layer");
/* Define the different flags */
@@ -244,16 +238,16 @@
switch(in_data_type[i])
{
case CELL_TYPE:
- f[i] = (float) ((CELL *) inrast[i])[col];
-// printf("CELL: f[%i] = %f\n",i,f[i]);
+// f[i] = (float) ((CELL *) inrast[i])[col];
+ printf("CELL: f[%i] = %f\n",i,f[i]);
break;
case FCELL_TYPE:
- f[i] = (float) ((FCELL *) inrast[i])[col];
-// printf("FCELL: f[%i] = %f\n",i,f[i]);
+// f[i] = (float) ((FCELL *) inrast[i])[col];
+ printf("FCELL: f[%i] = %f\n",i,f[i]);
break;
case DCELL_TYPE:
- f[i] = (float) ((DCELL *) inrast[i])[col];
-// printf("DCELL: f[%i] = %f\n",i,f[i]);
+// f[i] = (float) ((DCELL *) inrast[i])[col];
+ printf("DCELL: f[%i] = %f\n",i,f[i]);
break;
}
}
More information about the grass-commit
mailing list