[GRASS-SVN] r32965 - in grass-addons/gipe: i.eb.evapfr i.eb.g0
i.eb.h0 i.eb.h_SEBAL01 i.eb.h_SEBAL95 i.eb.h_iter
i.eb.molength i.eb.netrad i.eb.psi i.eb.rah i.eb.rohair
i.eb.ublend i.eb.ustar i.eb.wetdrypix i.eb.z0m i.eb.z0m0
i.emissivity i.evapo.PT i.evapo.SENAY i.evapo.potrad
i.evapo.time_integration
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Aug 21 07:23:45 EDT 2008
Author: ychemin
Date: 2008-08-21 07:23:44 -0400 (Thu, 21 Aug 2008)
New Revision: 32965
Modified:
grass-addons/gipe/i.eb.evapfr/main.c
grass-addons/gipe/i.eb.evapfr/soilmoisture.c
grass-addons/gipe/i.eb.g0/g0.c
grass-addons/gipe/i.eb.g0/main.c
grass-addons/gipe/i.eb.h0/main.c
grass-addons/gipe/i.eb.h_SEBAL01/main.c
grass-addons/gipe/i.eb.h_SEBAL95/U_0.c
grass-addons/gipe/i.eb.h_SEBAL95/dtair.c
grass-addons/gipe/i.eb.h_SEBAL95/main.c
grass-addons/gipe/i.eb.h_SEBAL95/psi_h.c
grass-addons/gipe/i.eb.h_SEBAL95/psi_m.c
grass-addons/gipe/i.eb.h_SEBAL95/sensi_h.c
grass-addons/gipe/i.eb.h_SEBAL95/u_star.c
grass-addons/gipe/i.eb.h_SEBAL95/zom_0.c
grass-addons/gipe/i.eb.h_iter/main.c
grass-addons/gipe/i.eb.molength/main.c
grass-addons/gipe/i.eb.netrad/main.c
grass-addons/gipe/i.eb.netrad/r_net.c
grass-addons/gipe/i.eb.psi/main.c
grass-addons/gipe/i.eb.rah/main.c
grass-addons/gipe/i.eb.rohair/main.c
grass-addons/gipe/i.eb.ublend/main.c
grass-addons/gipe/i.eb.ublend/ublend.c
grass-addons/gipe/i.eb.ustar/main.c
grass-addons/gipe/i.eb.wetdrypix/main.c
grass-addons/gipe/i.eb.z0m/main.c
grass-addons/gipe/i.eb.z0m/z0m.c
grass-addons/gipe/i.eb.z0m0/main.c
grass-addons/gipe/i.eb.z0m0/zom_0.c
grass-addons/gipe/i.emissivity/emissivity_generic.c
grass-addons/gipe/i.emissivity/main.c
grass-addons/gipe/i.evapo.PT/main.c
grass-addons/gipe/i.evapo.PT/pt_daily_et.c
grass-addons/gipe/i.evapo.PT/pt_delta.c
grass-addons/gipe/i.evapo.PT/pt_ghamma.c
grass-addons/gipe/i.evapo.SENAY/et_pot_day.c
grass-addons/gipe/i.evapo.SENAY/evapfr_senay.c
grass-addons/gipe/i.evapo.SENAY/main.c
grass-addons/gipe/i.evapo.SENAY/r_net_day.c
grass-addons/gipe/i.evapo.SENAY/r_net_day_bandara98.c
grass-addons/gipe/i.evapo.SENAY/solar_day.c
grass-addons/gipe/i.evapo.SENAY/solar_day_3d.c
grass-addons/gipe/i.evapo.potrad/et_pot_day.c
grass-addons/gipe/i.evapo.potrad/main.c
grass-addons/gipe/i.evapo.potrad/r_net_day.c
grass-addons/gipe/i.evapo.potrad/r_net_day_bandara98.c
grass-addons/gipe/i.evapo.potrad/solar_day.c
grass-addons/gipe/i.evapo.potrad/solar_day_3d.c
grass-addons/gipe/i.evapo.time_integration/main.c
Log:
code cleaning, upgrade, standardization
Modified: grass-addons/gipe/i.eb.evapfr/main.c
===================================================================
--- grass-addons/gipe/i.eb.evapfr/main.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.evapfr/main.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -1,7 +1,7 @@
/****************************************************************************
*
* MODULE: i.eb.evapfr
- * AUTHOR(S): Yann Chemin - ychemin at gmail.com
+ * AUTHOR(S): Yann Chemin - yann.chemin at gmail.com
* PURPOSE: Calculates the evaporative fraction
* as seen in Bastiaanssen (1995)
*
@@ -19,29 +19,28 @@
#include <grass/gis.h>
#include <grass/glocale.h>
-
double evap_fr(double r_net, double g0, double h0);
double soilmoisture( double evapfr );
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;
- int makin=0;//Makin Flag for root zone soil moisture output
+ int makin=0;/*Makin Flag for root zone soil moisture output*/
struct GModule *module;
struct Option *input1, *input2, *input3, *output1, *output2;
struct Flag *flag1, *flag2;
- struct History history; //metadata
+ struct History history; /*metadata*/
/************************************/
/* FMEO Declarations*****************/
- char *name; // input raster name
- char *result1, *result2; //output raster name
- //File Descriptors
+ char *name; /* input raster name*/
+ char *result1, *result2; /*output raster name*/
+ /*File Descriptors*/
int infd_rnet, infd_g0, infd_h0;
int outfd1, outfd2;
@@ -160,8 +159,7 @@
DCELL d_g0;
DCELL d_h0;
G_percent(row,nrows,2);
-// printf("row = %i/%i\n",row,nrows);
- /* read soil input maps */
+ /* read input maps */
if(G_get_raster_row(infd_rnet,inrast_rnet,row,data_type_rnet)<0)
G_fatal_error(_("Could not read from <%s>"),rnet);
if(G_get_raster_row(infd_g0,inrast_g0,row,data_type_g0)<0)
Modified: grass-addons/gipe/i.eb.evapfr/soilmoisture.c
===================================================================
--- grass-addons/gipe/i.eb.evapfr/soilmoisture.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.evapfr/soilmoisture.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -2,8 +2,9 @@
#include<math.h>
#include<stdlib.h>
-// soil moisture in the root zone
-// Makin, Molden and Bastiaanssen, 2001
+/* soil moisture in the root zone
+ * Makin, Molden and Bastiaanssen, 2001
+ */
double soilmoisture( double evap_fr )
{
Modified: grass-addons/gipe/i.eb.g0/g0.c
===================================================================
--- grass-addons/gipe/i.eb.g0/g0.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.g0/g0.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -19,10 +19,10 @@
a = (0.0032 * (bbalb/r0_coef) + 0.0062 * (bbalb/r0_coef) * (bbalb/r0_coef));
b = (1 - 0.978 * pow(ndvi,4));
- // Spain (Bastiaanssen, 1995)
+ /* Spain (Bastiaanssen, 1995)*/
result = (rnet * (tempk-273.15) / bbalb) * a * b ;
- // HAPEX-Sahel (Roerink, 1995)
+ /* HAPEX-Sahel (Roerink, 1995)*/
if(roerink){
result = result * 1.430 - 0.0845;
}
Modified: grass-addons/gipe/i.eb.g0/main.c
===================================================================
--- grass-addons/gipe/i.eb.g0/main.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.g0/main.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -25,23 +25,23 @@
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;
- int roerink=0;//Roerink Flag for HAPEX-Sahel conditions
+ int roerink=0;/*Roerink Flag for HAPEX-Sahel conditions*/
struct GModule *module;
struct Option *input1, *input2, *input3, *input4, *input5, *output1;
struct Flag *flag1, *flag2;
- struct History history; //metadata
- struct Colors colors; //metadata
+ struct History history; /*metadata*/
+ struct Colors colors; /*metadata*/
/************************************/
/* FMEO Declarations*****************/
- char *name; // input raster name
- char *result; //output raster name
- //File Descriptors
+ char *name; /* input raster name*/
+ char *result; /*output raster name*/
+ /*File Descriptors*/
int infd_albedo, infd_ndvi, infd_tempk, infd_rnet, infd_time;
int outfd;
@@ -185,8 +185,7 @@
DCELL d_rnet;
DCELL d_time;
G_percent(row,nrows,2);
-// printf("row = %i/%i\n",row,nrows);
- /* read soil input maps */
+ /* read input maps */
if(G_get_raster_row(infd_albedo,inrast_albedo,row,data_type_albedo)<0)
G_fatal_error(_("Could not read from <%s>"),albedo);
if(G_get_raster_row(infd_ndvi,inrast_ndvi,row,data_type_ndvi)<0)
Modified: grass-addons/gipe/i.eb.h0/main.c
===================================================================
--- grass-addons/gipe/i.eb.h0/main.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.h0/main.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -1,12 +1,12 @@
/****************************************************************************
*
* MODULE: i.eb.h0
- * AUTHOR(S): Yann Chemin - ychemin at gmail.com
+ * AUTHOR(S): Yann Chemin - yann.chemin at gmail.com
* PURPOSE: Calculates sensible heat flux
* a flag allows the Bastiaanssen (1995) affine transform
* of surface temperature as used in his SEBAL model.
*
- * COPYRIGHT: (C) 2002-2006 by the GRASS Development Team
+ * COPYRIGHT: (C) 2002-2008 by the GRASS Development Team
*
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
@@ -20,44 +20,44 @@
#include <grass/gis.h>
#include <grass/glocale.h>
-
double h0(double roh_air, double cp, double rah, double dtair);
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;
- int sebal=0;//SEBAL Flag for affine transform of surf. temp.
+ int sebal=0;/*SEBAL Flag for affine transform of surf. temp.*/
struct GModule *module;
struct Option *input1, *input2, *input3, *input4, *input5;
struct Option *input6, *input7, *output1;
struct Flag *flag1, *flag2;
- struct History history; //metadata
+ struct History history; /*metadata*/
/************************************/
/* FMEO Declarations*****************/
- char *name; // input raster name
- char *result; //output raster name
- //File Descriptors
+ char *name; /*input raster name*/
+ char *result; /*output raster name*/
+ /*File Descriptors*/
int infd_rohair, infd_tempk, infd_rah, infd_dtair;
int outfd;
char *rohair,*tempk,*rah,*dtair;
- double cp; //air specific heat
+ double cp; /*air specific heat*/
int i=0,j=0;
- double a,b; //SEBAL slope and intercepts of surf. temp.
+ double a,b; /*SEBAL slope and intercepts of surf. temp.*/
void *inrast_rohair, *inrast_tempk, *inrast_rah, *inrast_dtair;
- unsigned char *outrast;
+ DCELL *outrast;
RASTER_MAP_TYPE data_type_rohair;
RASTER_MAP_TYPE data_type_tempk;
RASTER_MAP_TYPE data_type_rah;
RASTER_MAP_TYPE data_type_dtair;
+ RASTER_MAP_TYPE data_type_output=DCELL_TYPE;
/************************************/
G_gisinit(argv[0]);
@@ -109,9 +109,7 @@
input7->description=_("Value of the intercept of the transform");
output1 = G_define_standard_option(G_OPT_R_OUTPUT) ;
- output1->key =_("h0");
output1->description=_("Name of the output h0 layer");
- output1->answer =_("h0");
flag1 = G_define_flag();
flag1->key = 's';
@@ -196,8 +194,7 @@
DCELL d_affine;
DCELL d_tempk;
G_percent(row,nrows,2);
-// printf("row = %i/%i\n",row,nrows);
- /* read soil input maps */
+ /* read input maps */
if(G_get_raster_row(infd_rohair,inrast_rohair,row,data_type_rohair)<0)
G_fatal_error(_("Could not read from <%s>"),rohair);
if(G_get_raster_row(infd_rah,inrast_rah,row,data_type_rah)<0)
@@ -212,26 +209,18 @@
/*process the data */
for (col=0; col < ncols; col++)
{
- // printf("col=%i/%i ",col,ncols);
d_rohair = ((DCELL *) inrast_rohair)[col];
- // printf("rohair = %5.3f", d_rohair);
d_rah = ((DCELL *) inrast_rah)[col];
- // printf(" rah = %5.3f", d_rah);
if(!sebal){
d_dtair = ((DCELL *) inrast_dtair)[col];
- // printf(" d_dtair = %5.3f", d_dtair);
}else{
d_tempk = ((DCELL *) inrast_tempk)[col];
- // printf("inrast_rnet = %f\n", d_rnet);
}
- if(G_is_d_null_value(&d_rohair)){
- ((DCELL *) outrast)[col] = -999.99;
- }else if(G_is_d_null_value(&d_rah)){
- ((DCELL *) outrast)[col] = -999.99;
- }else if((!sebal)&&G_is_d_null_value(&d_dtair)){
- ((DCELL *) outrast)[col] = -999.99;
- }else if((sebal)&&G_is_d_null_value(&d_tempk)){
- ((DCELL *) outrast)[col] = -999.99;
+ if(G_is_d_null_value(&d_rohair)||
+ G_is_d_null_value(&d_rah)||
+ (!sebal)&&G_is_d_null_value(&d_dtair)||
+ (sebal)&&G_is_d_null_value(&d_tempk)){
+ G_set_d_null_value(&outrast[col],1);
}else {
/************************************/
/* calculate sensible heat flux */
@@ -241,15 +230,10 @@
d_affine=a*d_tempk+b;
d = h0(d_rohair,cp,d_rah,d_affine);
}
- // printf(" || d=%5.3f",d);
- ((DCELL *) outrast)[col] = d;
- // printf(" -> %5.3f\n",d);
+ outrast[col] = d;
}
- // if(row==50){
- // exit(EXIT_SUCCESS);
- // }
}
- if (G_put_raster_row (outfd, outrast, data_type_rah) < 0)
+ if (G_put_raster_row (outfd, outrast, data_type_output) < 0)
G_fatal_error(_("Cannot write to output raster file"));
}
Modified: grass-addons/gipe/i.eb.h_SEBAL01/main.c
===================================================================
--- grass-addons/gipe/i.eb.h_SEBAL01/main.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.h_SEBAL01/main.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -41,7 +41,7 @@
int main(int argc, char *argv[])
{
struct Cell_head cellhd;
- char *mapset; // mapset name
+ char *mapset; /*mapset name*/
/* buffer for in, tmp and out raster */
void *inrast_Rn, *inrast_g0;
@@ -161,7 +161,6 @@
input_col_dry->guisection = _("Parameters");
output = G_define_standard_option(G_OPT_R_OUTPUT) ;
- output->key = "h0";
output->description= _("Name of output sensible heat flux layer [W/m2]");
/* Define the different flags */
@@ -532,7 +531,7 @@
} else {
d_roh1=((1000-4.65)/(d_t0dem*2.87))+(4.65/(d_t0dem*4.61));
}
- if(row==rowDry&&col==colDry){//collect dry pix info
+ if(row==rowDry&&col==colDry){/*collect dry pix info*/
d_rah_dry = d_rah1;
d_roh_dry = d_roh1;
G_message("d_rah_dry=%f d_roh_dry=%f",d_rah_dry,d_roh_dry);
@@ -543,12 +542,12 @@
}
}
DCELL d_dT_dry;
- // Calculate dT_dry
+ /*Calculate dT_dry*/
d_dT_dry = (h_dry*d_rah_dry)/(1004*d_roh_dry);
double a, b;
- // Calculate coefficients for next dT equation
-// a = 1.0/ ((d_dT_dry-0.0) / (d_t0dem_dry-d_t0dem_wet));
-// b = ( a * d_t0dem_wet ) * (-1.0);
+ /*Calculate coefficients for next dT equation*/
+ /*a = 1.0/ ((d_dT_dry-0.0) / (d_t0dem_dry-d_t0dem_wet));*/
+ /*b = ( a * d_t0dem_wet ) * (-1.0);*/
double sumx=d_t0dem_wet+d_t0dem_dry;
double sumy=d_dT_dry+0.0;
@@ -624,7 +623,7 @@
d_psih=2*log((1+pow(d_x,2))/2);
d_u5=(ustar/0.41)*log(5/d_z0m);
d_rah2=(1/(d_u5*pow(0.41,2)))*log((5/d_z0m)-d_psim)*log((5/(d_z0m*0.1))-d_psih);
- if(row==rowDry&&col==colDry){//collect dry pix info
+ if(row==rowDry&&col==colDry){/*collect dry pix info*/
d_rah_dry = d_rah2;
d_h_dry = d_h1;
}
@@ -633,13 +632,13 @@
}
}
- // Calculate dT_dry
+ /*Calculate dT_dry*/
d_dT_dry = (d_h_dry*d_rah_dry)/(1004*d_roh_dry);
- // Calculate coefficients for next dT equation
-// a = (d_dT_dry-0)/(d_t0dem_dry-d_t0dem_wet);
-// b = (-1.0) * ( a * d_t0dem_wet );
-// G_message("d_dT_dry=%f",d_dT_dry);
-// G_message("dT2=%f * t0dem + (%f)", a, b);
+ /*Calculate coefficients for next dT equation*/
+/* a = (d_dT_dry-0)/(d_t0dem_dry-d_t0dem_wet);*/
+/* b = (-1.0) * ( a * d_t0dem_wet );*/
+/* G_message("d_dT_dry=%f",d_dT_dry);*/
+/* G_message("dT2=%f * t0dem + (%f)", a, b);*/
sumx=d_t0dem_wet+d_t0dem_dry;
sumy=d_dT_dry+0.0;
sumx2=pow(d_t0dem_wet,2)+pow(d_t0dem_dry,2);
@@ -714,7 +713,7 @@
d_psih=2*log((1+pow(d_x,2))/2);
d_u5=(ustar/0.41)*log(5/d_z0m);
d_rah3=(1/(d_u5*pow(0.41,2)))*log((5/d_z0m)-d_psim)*log((5/(d_z0m*0.1))-d_psih);
- if(row==rowDry&&col==colDry){//collect dry pix info
+ if(row==rowDry&&col==colDry){/*collect dry pix info*/
d_rah_dry = d_rah2;
d_h_dry = d_h2;
}
@@ -723,13 +722,13 @@
}
}
- // Calculate dT_dry
+ /*Calculate dT_dry*/
d_dT_dry = (d_h_dry*d_rah_dry)/(1004*d_roh_dry);
- // Calculate coefficients for next dT equation
-// a = (d_dT_dry-0)/(d_t0dem_dry-d_t0dem_wet);
-// b = (-1.0) * ( a * d_t0dem_wet );
-// G_message("d_dT_dry=%f",d_dT_dry);
-// G_message("dT3=%f * t0dem + (%f)", a, b);
+ /*Calculate coefficients for next dT equation*/
+/* a = (d_dT_dry-0)/(d_t0dem_dry-d_t0dem_wet);*/
+/* b = (-1.0) * ( a * d_t0dem_wet );*/
+/* G_message("d_dT_dry=%f",d_dT_dry);*/
+/* G_message("dT3=%f * t0dem + (%f)", a, b);*/
sumx=d_t0dem_wet+d_t0dem_dry;
sumy=d_dT_dry+0.0;
sumx2=pow(d_t0dem_wet,2)+pow(d_t0dem_dry,2);
Modified: grass-addons/gipe/i.eb.h_SEBAL95/U_0.c
===================================================================
--- grass-addons/gipe/i.eb.h_SEBAL95/U_0.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.h_SEBAL95/U_0.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -8,8 +8,6 @@
u_0 = u2m*0.41*log10(200/(0.15/7))/(log10(2/(0.15/7))*log10(200/zom_0));
-// printf("u_0 = %5.3f\n", u_0);
-
return (u_0);
}
Modified: grass-addons/gipe/i.eb.h_SEBAL95/dtair.c
===================================================================
--- grass-addons/gipe/i.eb.h_SEBAL95/dtair.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.h_SEBAL95/dtair.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -13,8 +13,6 @@
a = (dtair_desert-0.0)/(tempk_desert-tempk_water);
b = dtair_desert - a * tempk_desert;
result = t0_dem * a + b;
-// printf("__________________________________");
-// printf("dtair=%5.3f * Tempk + (%5.3f)\n",a,b);
return result;
}
Modified: grass-addons/gipe/i.eb.h_SEBAL95/main.c
===================================================================
--- grass-addons/gipe/i.eb.h_SEBAL95/main.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.h_SEBAL95/main.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -23,15 +23,13 @@
#include <grass/gis.h>
#include <math.h>
#include <grass/glocale.h>
-/*#include <omp.h>*/
-
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[])
{
struct Cell_head cellhd;
- char *mapset; // mapset name
+ char *mapset; /* mapset name*/
/* buffer for in out raster */
void *inrast_T,*inrast_ndvi,*inrast_dem, *inrast_u2m;
@@ -159,7 +157,6 @@
input_col_dry->guisection = _("Optional");
output = G_define_standard_option(G_OPT_R_OUTPUT) ;
- output->key = "h0";
output->description= _("Name of output sensible heat flux layer [W/m2]");
/* Define the different flags */
@@ -318,9 +315,6 @@
G_percent (row, nrows, 2);
if (G_get_d_raster_row (infd_ndvi, inrast_ndvi, row) < 0)
G_fatal_error (_("Could not read from <%s>"),ndvi);
- /* #pragma omp for parallel default (shared) \
- shared(ncols,nrows) \
- private (col,row,d_ndvi)*/
for (col=0; col < ncols; col++)
{
switch(data_type_ndvi){
@@ -334,7 +328,6 @@
d_ndvi = (double) ((DCELL *) inrast_ndvi)[col];
break;
}
- //d_ndvi = ((DCELL *) inrast_ndvi)[col];
if(G_is_d_null_value(&d_ndvi)){
/* do nothing */
} else if ((d_ndvi)>d_ndvi_max&&(d_ndvi)<0.999){
@@ -416,20 +409,12 @@
}
average = (double) sum / 400.0;
G_message("Histogram of Temperature map (if it has rogue values to clean)");
- //int peak1, peak2, peak3;
- //int i_peak1, i_peak2, i_peak3;
peak1=0;
peak2=0;
peak3=0;
i_peak1=0;
i_peak2=0;
i_peak3=0;
- //int bottom1a, bottom1b;
- //int bottom2a, bottom2b;
- //int bottom3a, bottom3b;
- //int i_bottom1a, i_bottom1b;
- //int i_bottom2a, i_bottom2b;
- //int i_bottom3a, i_bottom3b;
bottom1a=100000;
bottom1b=100000;
bottom2a=100000;
@@ -511,7 +496,7 @@
G_message("bottom3a: [%i]=>%i\n",i_bottom3a, bottom3a);
G_message("peak3: [%i]=>%i\n",i_peak3, peak3);
G_message("bottom3b: [%i]=>%i\n",i_bottom3b, bottom3b);
- }//END OF FLAG1
+ }/*END OF FLAG1*/
/* End of processing histogram*/
/*******************/
@@ -521,9 +506,6 @@
if(flag2->answer){
/* THREAD 3 */
/* Process tempk min / max pixels */
- /* #pragma omp for parallel default (shared) \
- shared(ncols,nrows) \
- private (col,row,d_albedo,d_tempk,d_dem,d_t0dem,d_Rn,d_g0)*/
/* Internal use only */
DCELL d_Rn_wet;
DCELL d_g0_wet;
@@ -533,8 +515,8 @@
DCELL d_tempk;
DCELL d_dem;
DCELL d_t0dem;
- DCELL d_h0=100.0;//for flag 1
- DCELL d_h0_max=100.0;//for flag 1
+ DCELL d_h0=100.0;/*for flag 1*/
+ DCELL d_h0_max=100.0;/*for flag 1*/
G_percent(row,nrows,2);
if(G_get_raster_row(infd_albedo,inrast_albedo,row,data_type_albedo)<0)
G_fatal_error(_("Could not read from <%s>"),albedo);
@@ -695,7 +677,6 @@
G_message("g0_dry=%f\n",d_g0_dry);
G_message("h0_dry=%f\n",d_Rn_dry-d_g0_dry);
} /* END OF FLAG2 */
- /*MPI_BARRIER*/
/* MANUAL WET/DRY PIXELS */
if(input_row_wet->answer&&input_row_dry->answer&&
@@ -955,7 +936,7 @@
d_t0dem_dry,
d_u2m,
d_dem_dry);
- // G_message(" d_h0=%5.3f",d);
+ /* G_message(" d_h0=%5.3f",d);*/
if (zero->answer && d<0.0){
d=0.0;
}
Modified: grass-addons/gipe/i.eb.h_SEBAL95/psi_h.c
===================================================================
--- grass-addons/gipe/i.eb.h_SEBAL95/psi_h.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.h_SEBAL95/psi_h.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -9,8 +9,6 @@
double result;
double n5_temp, n11_mem, n12_mem;
-// printf("h input to psih() is %5.3f\n",h);
-
if(h != 0.0){
n5_temp = (-1004* roh_air*pow(U_0,3)* t0_dem)/(0.41*9.81* h);
} else {
Modified: grass-addons/gipe/i.eb.h_SEBAL95/psi_m.c
===================================================================
--- grass-addons/gipe/i.eb.h_SEBAL95/psi_m.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.h_SEBAL95/psi_m.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -8,7 +8,6 @@
{
double result;
double n5, n10, n12;
-// printf("h input to psim() is %5.3f\n",h);
if(h != 0.0){
n5 = (-1004* roh_air*pow(ustar,3)* t0_dem)/(0.41*9.81* h);
} else {
Modified: grass-addons/gipe/i.eb.h_SEBAL95/sensi_h.c
===================================================================
--- grass-addons/gipe/i.eb.h_SEBAL95/sensi_h.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.h_SEBAL95/sensi_h.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -1,6 +1,5 @@
/* This is the main loop used in SEBAL */
-/* ychemin at yahoo.com - yann.chemin at ait.ac.th */
-/* GPL >= 2 - April 2004 */
+/* April 2004 */
#include<stdio.h>
#include<math.h>
@@ -37,21 +36,21 @@
printf("ndvi = %5.3f ndvimax = %5.3f\n",ndvi,ndvi_max);
printf("*****************************\n");
}
-// dtair[0] = dt_air_0(t0_dem, tempk_water, tempk_desert);
+/* dtair[0] = dt_air_0(t0_dem, tempk_water, tempk_desert);*/
dtair[0] = 5.0;
-// printf("*****************************dtair = %5.3f\n",dtair[0]);
+/* printf("*****************************dtair = %5.3f\n",dtair[0]);*/
roh_air[0] = roh_air_0(tempk);
-// printf("*****************************rohair=%5.3f\n",roh_air[0]);
+/* printf("*****************************rohair=%5.3f\n",roh_air[0]);*/
roh_air_desert = roh_air_0(tempk_desert);
-// printf("**rohairdesert = %5.3f\n",roh_air_desert);
+/* printf("**rohairdesert = %5.3f\n",roh_air_desert);*/
zom0 = zom_0(ndvi, ndvi_max);
-// printf("*****************************zom = %5.3f\n",zom0);
+/* printf("*****************************zom = %5.3f\n",zom0);*/
u_0 = U_0(zom0, u2m);
-// printf("*****************************u0\n");
+/* printf("*****************************u0\n");*/
rah[0] = rah_0(zom0, u_0);
-// printf("*****************************rah = %5.3f\n",rah[0]);
+/* printf("*****************************rah = %5.3f\n",rah[0]);*/
h[0] = h_0(roh_air[0], rah[0], dtair[0]);
-// printf("*****************************h\n");
+/* printf("*****************************h\n");*/
if(debug==1){
printf("dtair[0] = %5.3f K\n", dtair[0]);
printf("roh_air[0] = %5.3f kg/m3\n", roh_air[0]);
Modified: grass-addons/gipe/i.eb.h_SEBAL95/u_star.c
===================================================================
--- grass-addons/gipe/i.eb.h_SEBAL95/u_star.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.h_SEBAL95/u_star.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -13,13 +13,6 @@
double hv=0.15; /* crop height (m) */
double bh=200; /* blending height (m) */
-// printf("t0dem = %5.3f\n", t0_dem);
-// printf("h = %5.3f\n", h);
-// printf("U_0 = %5.3f\n", U_0);
-// printf("roh_air = %5.3f\n", roh_air);
-// printf("zom = %5.3f\n", zom);
-// printf("u2m = %5.3f\n", u2m);
-
if(h != 0.0){
n5_temp = (-1004* roh_air*pow(ustar,3)* t0_dem)/(0.41*9.81* h);
} else {
@@ -33,7 +26,7 @@
} else {
-// n31_mem = 1.0;
+/* n31_mem = 1.0;*/
n10_mem = -5*2/n5_temp;
}
Modified: grass-addons/gipe/i.eb.h_SEBAL95/zom_0.c
===================================================================
--- grass-addons/gipe/i.eb.h_SEBAL95/zom_0.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.h_SEBAL95/zom_0.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -5,15 +5,14 @@
double zom_0(double ndvi, double ndvi_max)
{
double a, b, zom;
-// double hv_ndvimax=1.5; /* crop vegetation height (m) */
-// double hv_desert=0.002; /* desert base vegetation height (m) */
+ double hv_ndvimax=1.5; /* crop vegetation height (m) */
+ double hv_desert=0.002; /* desert base vegetation height (m) */
-// a = (log(hv_desert)-((log(hv_ndvimax/7)-log(hv_desert))/(ndvi_max-0.02)*0.02));
-// b = ((log(hv_ndvimax/7)-log(hv_desert))/(ndvi_max-0.02)) * ndvi;
-// zom = exp(a+b);
-
-// printf("****************zom = %5.3f\n", zom);
- zom = exp(3.3219*ndvi-3.9939);
+ a = (log(hv_desert)-((log(hv_ndvimax/7)-log(hv_desert))/(ndvi_max-0.02)*0.02));
+ b = ((log(hv_ndvimax/7)-log(hv_desert))/(ndvi_max-0.02)) * ndvi;
+ zom = exp(a+b);
+ /* Greece works and SEBAL01*/
+ /*zom = exp(3.3219*ndvi-3.9939);*/
return (zom);
}
Modified: grass-addons/gipe/i.eb.h_iter/main.c
===================================================================
--- grass-addons/gipe/i.eb.h_iter/main.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.h_iter/main.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -29,41 +29,40 @@
#include <grass/gis.h>
#include <grass/glocale.h>
-
double fixed_deltat(double u2m, double roh_air,double cp,double dt,double disp,double z0m,double z0h,double tempk,double hu,int iteration);
double h0(double roh_air, double cp, double rah, double dtair);
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;
- //If !sebal then use Delta T input file
- int sebal=0;//SEBAL Flag for affine transform of surf. temp.
+ /*If !sebal then use Delta T input file*/
+ int sebal=0;/*SEBAL Flag for affine transform of surf. temp.*/
struct GModule *module;
struct Option *input1, *input2, *input3, *input4, *input5;
struct Option *input6, *input7, *input8, *input9, *input10;
struct Option *input11, *input_hu, *output1;
struct Flag *flag1, *flag2;
- struct History history; //metadata
+ struct History history; /*metadata*/
/************************************/
/* FMEO Declarations*****************/
- char *name; // input raster name
- char *result; //output raster name
- //File Descriptors
+ char *name; /*input raster name*/
+ char *result; /*output raster name*/
+ /*File Descriptors*/
int infd_rohair, infd_tempk, infd_dtair;
int infd_disp, infd_z0m, infd_z0h, infd_u_hu;
int infd_hu, outfd;
char *rohair,*tempk,*dtair, *disp, *z0m, *z0h, *u_hu, *hu;
- double cp; //air specific heat
+ double cp; /*air specific heat*/
int i=0,j=0;
- double a,b; //SEBAL slope and intercepts of surf. temp.
+ double a,b; /*SEBAL slope and intercepts of surf. temp.*/
int iteration;
void *inrast_rohair, *inrast_tempk, *inrast_dtair;
@@ -158,9 +157,7 @@
input11->answer =_("3");
output1 = G_define_standard_option(G_OPT_R_OUTPUT) ;
- output1->key =_("h0");
output1->description=_("Name of the output h0 layer");
- output1->answer =_("h0");
flag1 = G_define_flag();
flag1->key = 's';
Modified: grass-addons/gipe/i.eb.molength/main.c
===================================================================
--- grass-addons/gipe/i.eb.molength/main.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.molength/main.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -1,10 +1,10 @@
/****************************************************************************
*
* MODULE: i.eb.molength
- * AUTHOR(S): Yann Chemin - ychemin at gmail.com
+ * AUTHOR(S): Yann Chemin - yann.chemin at gmail.com
* PURPOSE: Calculates the Monin-Obukov Length
*
- * COPYRIGHT: (C) 2002-2006 by the GRASS Development Team
+ * COPYRIGHT: (C) 2002-2008 by the GRASS Development Team
*
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
@@ -18,39 +18,37 @@
#include <grass/gis.h>
#include <grass/glocale.h>
-
double mo_length(double roh_air, double cp, double ustar, double tempk, double h0);
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;
- int verbose=1;
struct GModule *module;
struct Option *input1, *input2, *input3, *input4, *input5;
struct Option *output1;
struct Flag *flag1;
- struct History history; //metadata
+ struct History history; /*metadata*/
/************************************/
/* FMEO Declarations*****************/
- char *name; // input raster name
- char *result; //output raster name
- //File Descriptors
+ char *name; /*input raster name*/
+ char *result; /*output raster name*/
+ /*File Descriptors*/
int infd_rohair, infd_tempk, infd_ustar, infd_h0;
int outfd;
char *rohair,*tempk,*ustar,*h0;
- double cp; //air specific heat
+ double cp; /*air specific heat*/
int i=0,j=0;
void *inrast_rohair, *inrast_tempk, *inrast_ustar, *inrast_h0;
- unsigned char *outrast;
+ DCELL *outrast;
RASTER_MAP_TYPE data_type_output=DCELL_TYPE;
RASTER_MAP_TYPE data_type_rohair;
@@ -66,13 +64,9 @@
module->description = _("Monin-Obukov Length");
/* Define the different options */
- input1 = G_define_option() ;
+ input1 = G_define_standard_option(G_OPT_R_INPUT) ;
input1->key = _("rohair");
- input1->type = TYPE_STRING;
- input1->required = YES;
- input1->gisprompt =_("old,cell,raster") ;
input1->description=_("Name of the air density map ~[0.9;1.5]");
- input1->answer =_("rohair");
input2 = G_define_option() ;
input2->key =_("cp");
@@ -82,41 +76,21 @@
input2->description=_("Value of the air specific heat [1000.0;1020.0]");
input2->answer =_("1004.0");
- input3 = G_define_option() ;
+ input3 = G_define_standard_option(G_OPT_R_INPUT) ;
input3->key =_("ustar");
- input3->type = TYPE_STRING;
- input3->required = YES;
- input3->gisprompt =_("old,cell,raster");
input3->description=_("Name of the ustar map");
- input3->answer =_("ustar");
- input4 = G_define_option() ;
+ input4 = G_define_standard_option(G_OPT_R_INPUT) ;
input4->key =_("tempk");
- input4->type = TYPE_STRING;
- input4->required = YES;
- input4->gisprompt =_("old,cell,raster");
input4->description=_("Name of the surface skin temperature map [degrees Kelvin]");
- input4->answer =_("tempk");
- input5 = G_define_option() ;
+ input5 = G_define_standard_option(G_OPT_R_INPUT) ;
input5->key =_("h0");
- input5->type = TYPE_STRING;
- input5->required = YES;
- input5->gisprompt =_("new,cell,raster");
input5->description=_("Name of the sensible heat flux map");
- input5->answer =_("h0");
- output1 = G_define_option() ;
- output1->key =_("molength");
- output1->type = TYPE_STRING;
- output1->required = YES;
- output1->gisprompt =_("new,cell,raster");
+ output1 = G_define_standard_option(G_OPT_R_OUTPUT) ;
output1->description=_("Name of the output Monin-Obukov Length layer");
- output1->answer =_("molength");
- flag1 = G_define_flag();
- flag1->key = 'q';
- flag1->description = _("Quiet");
/********************/
if (G_parser(argc, argv))
exit (EXIT_FAILURE);
@@ -128,7 +102,6 @@
h0 = input5->answer;
result = output1->answer;
- verbose = (!flag1->answer);
/***************************************************/
mapset = G_find_cell2(rohair, "");
if (mapset == NULL) {
@@ -189,9 +162,7 @@
DCELL d_ustar;
DCELL d_tempk;
DCELL d_h0;
- if(verbose)
- G_percent(row,nrows,2);
-// printf("row = %i/%i\n",row,nrows);
+ G_percent(row,nrows,2);
/* read input maps */
if(G_get_raster_row(infd_rohair,inrast_rohair,row,data_type_rohair)<0)
G_fatal_error(_("Could not read from <%s>"),rohair);
@@ -204,23 +175,60 @@
/*process the data */
for (col=0; col < ncols; col++)
{
- d_rohair = ((DCELL *) inrast_rohair)[col];
- d_ustar = ((DCELL *) inrast_ustar)[col];
- d_tempk = ((DCELL *) inrast_tempk)[col];
- d_h0 = ((DCELL *) inrast_h0)[col];
- if(G_is_d_null_value(&d_rohair)){
- ((DCELL *) outrast)[col] = -999.99;
- }else if(G_is_d_null_value(&d_ustar)){
- ((DCELL *) outrast)[col] = -999.99;
- }else if(G_is_d_null_value(&d_tempk)){
- ((DCELL *) outrast)[col] = -999.99;
- }else if(G_is_d_null_value(&d_h0)){
- ((DCELL *) outrast)[col] = -999.99;
+ switch(data_type_rohair){
+ case CELL_TYPE:
+ d_rohair = (double) ((CELL *) inrast_rohair)[col];
+ break;
+ case FCELL_TYPE:
+ d_rohair = (double) ((FCELL *) inrast_rohair)[col];
+ break;
+ case DCELL_TYPE:
+ d_rohair = ((DCELL *) inrast_rohair)[col];
+ break;
+ }
+ switch(data_type_ustar){
+ case CELL_TYPE:
+ d_ustar = (double) ((CELL *) inrast_ustar)[col];
+ break;
+ case FCELL_TYPE:
+ d_ustar = (double) ((FCELL *) inrast_ustar)[col];
+ break;
+ case DCELL_TYPE:
+ d_ustar = ((DCELL *) inrast_ustar)[col];
+ break;
+ }
+ switch(data_type_tempk){
+ case CELL_TYPE:
+ d_tempk = (double) ((CELL *) inrast_tempk)[col];
+ break;
+ case FCELL_TYPE:
+ d_tempk = (double) ((FCELL *) inrast_tempk)[col];
+ break;
+ case DCELL_TYPE:
+ d_tempk = ((DCELL *) inrast_tempk)[col];
+ break;
+ }
+ switch(data_type_h0){
+ case CELL_TYPE:
+ d_h0 = (double) ((CELL *) inrast_h0)[col];
+ break;
+ case FCELL_TYPE:
+ d_h0 = (double) ((FCELL *) inrast_h0)[col];
+ break;
+ case DCELL_TYPE:
+ d_h0 = ((DCELL *) inrast_h0)[col];
+ break;
+ }
+ if(G_is_d_null_value(&d_rohair)||
+ G_is_d_null_value(&d_ustar)||
+ G_is_d_null_value(&d_tempk)||
+ G_is_d_null_value(&d_h0)){
+ G_set_d_null_value(&outrast[col],1);
}else {
/************************************/
/* calculate Monin-Obukov Length */
d = mo_length(d_rohair,cp,d_ustar,d_tempk, d_h0);
- ((DCELL *) outrast)[col] = d;
+ outrast[col] = d;
}
}
if (G_put_raster_row (outfd, outrast, data_type_output) < 0)
Modified: grass-addons/gipe/i.eb.netrad/main.c
===================================================================
--- grass-addons/gipe/i.eb.netrad/main.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.netrad/main.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -6,7 +6,7 @@
* as seen in Bastiaanssen (1995) using time of
* satellite overpass.
*
- * COPYRIGHT: (C) 2006-2007 by the GRASS Development Team
+ * COPYRIGHT: (C) 2006-2008 by the GRASS Development Team
*
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
@@ -24,8 +24,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;
@@ -34,13 +34,13 @@
struct Option *input6, *input7, *input8, *input9, *output1;
struct Flag *flag1;
- struct History history; //metadata
- struct Colors colors; //Color rules
+ struct History history; /*metadata*/
+ struct Colors colors; /*Color rules*/
/************************************/
/* FMEO Declarations*****************/
- char *name; // input raster name
- char *result; //output raster name
- //File Descriptors
+ char *name; /*input raster name*/
+ char *result; /*output raster name*/
+ /*File Descriptors*/
int infd_albedo, infd_ndvi, infd_tempk, infd_time, infd_dtair;
int infd_emissivity, infd_tsw, infd_doy, infd_sunzangle;
int outfd;
@@ -283,7 +283,6 @@
/*process the data */
for (col=0; col < ncols; col++)
{
- //printf("row:%d\tcol:%d\n",row,col);
switch(data_type_albedo){
case CELL_TYPE:
d_albedo = (double) ((CELL *) inrast_albedo)[col];
@@ -398,7 +397,6 @@
/* calculate the net radiation */
d = r_net(d_albedo,d_ndvi,d_tempk,d_dtair,d_emissivity,d_tsw,d_doy,d_time,d_sunzangle);
outrast[col] = d;
- // printf(" -> %5.3f\n",d);
}
}
if (G_put_raster_row (outfd, outrast, data_type_output) < 0)
Modified: grass-addons/gipe/i.eb.netrad/r_net.c
===================================================================
--- grass-addons/gipe/i.eb.netrad/r_net.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.netrad/r_net.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -15,36 +15,26 @@
double Kin=0.0, Lin=0.0, Lout=0.0, Lcorr=0.0, result=0.0;
double temp=0.0, ds=0.0, e_atm=0.0, delta=0.0;
- double tsw_for_e_atm=0.7; //Special tsw, consider it a coefficient
+ double tsw_for_e_atm=0.7; /*Special tsw, consider it a coefficient*/
-// printf("**rnet: bbalb = %5.3f\n\tndvi = %5.3f\n\ttempk = %5.3f\n\te0 = %5.3f\n\ttsw = %5.3f\n\tdoy = %f\n\tutc = %5.3f\n\tsunzangle = %5.3f\n\tdtair = %5.3f\n",bbalb,ndvi,tempk,e0,tsw,doy,utc,sunzangle,dtair);
-
- // Atmospheric emissivity (Bastiaanssen, 1995)
+ /* Atmospheric emissivity (Bastiaanssen, 1995)*/
e_atm = 1.08 * pow(-log(tsw),0.265) ;
- // Atmospheric emissivity (Pawan, 2004)
-// e_atm = 0.85 * pow(-log(tsw),0.09);
-// printf("rnet: e_atm = %5.3f\n",e_atm);
+ /* Atmospheric emissivity (Pawan, 2004)*/
+/* e_atm = 0.85 * pow(-log(tsw),0.09);*/
-// ds = 1.0 + 0.01672 * sin(2*PI*(doy-93.5)/365);
+/* ds = 1.0 + 0.01672 * sin(2*PI*(doy-93.5)/365);*/
ds = 1.0/pow((1+0.033*cos(2*PI*doy/365)),2);
-// printf("rnet: ds = %lf\n",ds);
delta = 0.4093*sin((2*PI*doy/365)-1.39);
-// printf("rnet: delta = %5.3f\n",delta);
- // Kin is the shortwave incoming radiation
+ /* Kin is the shortwave incoming radiation*/
Kin = 1358.0 * (cos(sunzangle*PI/180) * tsw / (ds*ds) );
-// printf("rnet: Kin = %5.3f\n",Kin);
- // Lin is incoming longwave radiation
+ /* Lin is incoming longwave radiation*/
Lin = (e_atm) * 5.67 * pow(10,-8) * pow((tempk-dtair),4);
-// printf("rnet: Lin = %5.3f\n",Lin);
- // Lout is surface grey body emission in Longwave spectrum
+ /* Lout is surface grey body emission in Longwave spectrum*/
Lout = e0 * 5.67 * pow(10,-8) * pow(tempk,4);
-// printf("rnet: Lout = %5.3f\n",Lout);
- // Lcorr is outgoing longwave radiation "reflected" by the emissivity
+ /* Lcorr is outgoing longwave radiation "reflected" by the emissivity*/
Lcorr = (1.0 - e0) * Lin;
-// printf("rnet: Lcorr = %5.3f\n",Lcorr);
result = (1.0 - bbalb) * Kin + Lin - Lout - Lcorr ;
-// printf("rnet: result = %5.3f\n",result);
return result;
}
Modified: grass-addons/gipe/i.eb.psi/main.c
===================================================================
--- grass-addons/gipe/i.eb.psi/main.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.psi/main.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -1,11 +1,11 @@
/****************************************************************************
*
* MODULE: i.eb.psi
- * AUTHOR(S): Yann Chemin - ychemin at gmail.com
+ * AUTHOR(S): Yann Chemin - yann.chemin at gmail.com
* PURPOSE: Calculates the psichrometric parameter for heat,
* a flag permits output for momentum.
*
- * COPYRIGHT: (C) 2002-2006 by the GRASS Development Team
+ * COPYRIGHT: (C) 2002-2008 by the GRASS Development Team
*
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
@@ -25,34 +25,33 @@
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;
- int verbose=1;
- int momentum=0;//Flag for psim
+ int momentum=0;/*Flag for psim*/
struct GModule *module;
struct Option *input1, *input2, *input3, *input4, *output1, *output2;
struct Flag *flag1, *flag2;
- struct History history; //metadata
+ struct History history; /*metadata*/
/************************************/
/* FMEO Declarations*****************/
- char *name; // input raster name
- char *result1, *result2; //output raster name
- //File Descriptors
+ char *name; /*input raster name*/
+ char *result1, *result2; /*output raster name*/
+ /*File Descriptors*/
int infd_disp,infd_molength;
int outfd1,outfd2;
char *disp,*molength;
- double height, height_m; //z height for heat and momentum
+ double height, height_m; /*z height for heat and momentum*/
int i=0,j=0;
void *inrast_disp, *inrast_molength;
- unsigned char *outrast1,*outrast2;
+ DCELL *outrast1,*outrast2;
RASTER_MAP_TYPE data_type_output=DCELL_TYPE;
RASTER_MAP_TYPE data_type_disp;
RASTER_MAP_TYPE data_type_molength;
@@ -64,21 +63,13 @@
module->description = _("psichrometric paramters for heat (standard) and momentum (need flag).");
/* Define the different options */
- input1 = G_define_option() ;
+ input1 = G_define_standard_option(G_OPT_R_INPUT) ;
input1->key = _("disp");
- input1->type = TYPE_STRING;
- input1->required = YES;
- input1->gisprompt =_("old,cell,raster") ;
input1->description=_("Name of the displacement height map");
- input1->answer =_("disp");
- input2 = G_define_option() ;
+ input2 = G_define_standard_option(G_OPT_R_INPUT) ;
input2->key =_("molength");
- input2->type = TYPE_STRING;
- input2->required = YES;
- input2->gisprompt =_("old,cell,raster");
input2->description=_("Name of the Monin-Obukov length map");
- input2->answer =_("molength");
input3 = G_define_option() ;
input3->key =_("height");
@@ -96,29 +87,17 @@
input4->description=_("Value of the blending height for momentum (100.0 in Pawan, 2004). Use with flag -m.");
input4->answer =_("100.0");
- output1 = G_define_option() ;
- output1->key =_("psih");
- output1->type = TYPE_STRING;
- output1->required = YES;
- output1->gisprompt =_("new,dcell,raster");
+ output1 = G_define_standard_option(G_OPT_R_OUTPUT) ;
output1->description=_("Name of the output psih layer");
- output1->answer =_("psih");
- output2 = G_define_option() ;
+ output2 = G_define_standard_option(G_OPT_R_OUTPUT) ;
output2->key =_("psim");
- output2->type = TYPE_STRING;
- output2->required = NO;
- output2->gisprompt =_("new,dcell,raster");
output2->description=_("Name of the output psim layer");
- output2->answer =_("psim");
flag1 = G_define_flag();
flag1->key = 'm';
flag1->description = _("Output psim (requires height_m parameter)");
- flag2 = G_define_flag();
- flag2->key = 'q';
- flag2->description = _("Quiet");
/********************/
if (G_parser(argc, argv))
exit (EXIT_FAILURE);
@@ -131,7 +110,6 @@
result1 = output1->answer;
result2 = output2->answer;
momentum = flag1->answer;
- verbose = (!flag2->answer);
/***************************************************/
mapset = G_find_cell2 (disp, "");
if (mapset == NULL) {
@@ -177,9 +155,7 @@
DCELL d_molength;
DCELL d_psih;
DCELL d_psim;
- if(verbose)
- G_percent(row,nrows,2);
-// printf("row = %i/%i\n",row,nrows);
+ G_percent(row,nrows,2);
/* read input maps */
if(G_get_raster_row(infd_disp,inrast_disp,row,data_type_disp)<0)
G_fatal_error(_("Could not read from <%s>"),disp);
@@ -190,24 +166,20 @@
{
d_disp = ((DCELL *) inrast_disp)[col];
d_molength = ((DCELL *) inrast_molength)[col];
- if(G_is_d_null_value(&d_disp)){
- ((DCELL *) outrast1)[col] = -999.99;
+ if(G_is_d_null_value(&d_disp)||
+ G_is_d_null_value(&d_molength)){
+ G_set_d_null_value(&outrast1[col],1);
if(momentum){
- ((DCELL *) outrast2)[col] = -999.99;
+ G_set_d_null_value(&outrast2[col],1);
}
- }else if(G_is_d_null_value(&d_molength)){
- ((DCELL *) outrast1)[col] = -999.99;
- if(momentum){
- ((DCELL *) outrast2)[col] = -999.99;
- }
}else {
/************************************/
/* calculate psih */
d_psih=psi_h(d_disp,d_molength,height);
- ((DCELL *) outrast1)[col] = d_psih;
+ outrast1[col] = d_psih;
if(momentum){
d_psim=psi_m(d_disp,d_molength,height_m);
- ((DCELL *) outrast2)[col] = d_psim;
+ outrast2[col] = d_psim;
}
}
}
Modified: grass-addons/gipe/i.eb.rah/main.c
===================================================================
--- grass-addons/gipe/i.eb.rah/main.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.rah/main.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -1,11 +1,11 @@
/****************************************************************************
*
* MODULE: i.eb.rah
- * AUTHOR(S): Yann Chemin - ychemin at gmail.com
+ * AUTHOR(S): Yann Chemin - yann.chemin at gmail.com
* PURPOSE: Calculates aerodynamic resistance to heat transport
* This has been seen in Pawan (2004).
*
- * COPYRIGHT: (C) 2002-2006 by the GRASS Development Team
+ * COPYRIGHT: (C) 2002-2008 by the GRASS Development Team
*
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
@@ -19,13 +19,12 @@
#include <grass/gis.h>
#include <grass/glocale.h>
-
double ra_h(double disp,double z0h,double psih,double ustar,double hu);
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;
@@ -34,21 +33,21 @@
struct Option *input5, *output1;
struct Flag *flag1;
- struct History history; //metadata
+ struct History history; /*metadata*/
/************************************/
/* FMEO Declarations*****************/
- char *name; // input raster name
- char *result; //output raster name
- //File Descriptors
+ char *name; /*input raster name*/
+ char *result; /*output raster name*/
+ /*File Descriptors*/
int infd_disp, infd_z0h, infd_psih, infd_ustar;
int infd_hu, outfd;
char *disp, *z0h, *psih, *ustar, *hu;
- double cp; //air specific heat
+ double cp; /*air specific heat*/
int i=0,j=0;
- double a,b; //SEBAL slope and intercepts of surf. temp.
+ double a,b; /*SEBAL slope and intercepts of surf. temp.*/
void *inrast_disp, *inrast_z0h, *inrast_psih;
void *inrast_hu, *inrast_ustar;
@@ -70,32 +69,25 @@
input1 = G_define_standard_option(G_OPT_R_INPUT) ;
input1->key = _("disp");
input1->description=_("Name of the displacement height map");
- input1->answer =_("disp");
input2 = G_define_standard_option(G_OPT_R_INPUT) ;
input2->key =_("z0h");
input2->description=_("Name of the height of heat flux roughness length map");
- input2->answer =_("z0h");
input3 = G_define_standard_option(G_OPT_R_INPUT) ;
input3->key =_("psih");
input3->description=_("Name of the psichrometric parameter for heat flux map");
- input3->answer =_("psih");
input4 = G_define_standard_option(G_OPT_R_INPUT) ;
input4->key =_("ustar");
input4->description=_("Name of the nominal wind speed map");
- input4->answer =_("ustar");
input5 = G_define_standard_option(G_OPT_R_INPUT) ;
input5->key =_("hu");
input5->description=_("Name of the height of wind measurement (typically 2 m) map");
- input5->answer =_("hu");
output1 = G_define_standard_option(G_OPT_R_OUTPUT) ;
- output1->key =_("rah");
output1->description=_("Name of the output rah layer");
- output1->answer =_("rah");
/********************/
if (G_parser(argc, argv))
@@ -182,8 +174,7 @@
DCELL d_ustar;
DCELL d_hu;
G_percent(row,nrows,2);
-// printf("row = %i/%i\n",row,nrows);
- /* read soil input maps */
+ /* read input maps */
if(G_get_raster_row(infd_disp,inrast_disp,row,data_type_disp)<0)
G_fatal_error(_("Could not read from <%s>"),disp);
if(G_get_raster_row(infd_z0h,inrast_z0h,row,data_type_z0h)<0)
Modified: grass-addons/gipe/i.eb.rohair/main.c
===================================================================
--- grass-addons/gipe/i.eb.rohair/main.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.rohair/main.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -1,10 +1,10 @@
/****************************************************************************
*
* MODULE: i.eb.rohair
- * AUTHOR(S): Yann Chemin - ychemin at gmail.com
+ * AUTHOR(S): Yann Chemin - yann.chemin at gmail.com
* PURPOSE: Calculates the standard air density as seen in Pawan (2004)
*
- * COPYRIGHT: (C) 2002-2007 by the GRASS Development Team
+ * COPYRIGHT: (C) 2002-2008 by the GRASS Development Team
*
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
@@ -18,26 +18,25 @@
#include <grass/gis.h>
#include <grass/glocale.h>
-
double roh_air(double dem, double tempka);
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 *input1, *input2, *output1;
- struct History history; //metadata
+ struct History history; /*metadata*/
/************************************/
/* FMEO Declarations*****************/
- char *name; // input raster name
- char *result1; //output raster name
- //File Descriptors
+ char *name; /*input raster name*/
+ char *result1; /*output raster name*/
+ /*File Descriptors*/
int infd_dem, infd_tempka;
int outfd1;
@@ -46,7 +45,7 @@
int i=0,j=0;
void *inrast_dem, *inrast_tempka;
- unsigned char *outrast1;
+ DCELL *outrast1;
RASTER_MAP_TYPE data_type_output=DCELL_TYPE;
RASTER_MAP_TYPE data_type_dem;
RASTER_MAP_TYPE data_type_tempka;
@@ -58,29 +57,17 @@
module->description = _("Standard height-based Air Density as seen in Pawan (2004).");
/* Define the different options */
- input1 = G_define_option() ;
+ input1 = G_define_standard_option(G_OPT_R_INPUT) ;
input1->key = _("dem");
- input1->type = TYPE_STRING;
- input1->required = YES;
- input1->gisprompt =_("old,cell,raster") ;
input1->description=_("Name of the DEM map [m]");
- input1->answer =_("dem");
- input2 = G_define_option() ;
+ input2 = G_define_standard_option(G_OPT_R_INPUT) ;
input2->key = _("tempka");
- input2->type = TYPE_STRING;
- input2->required = YES;
- input2->gisprompt =_("old,cell,raster") ;
input2->description=_("Name of the Air Temperature map [K]");
- input2->answer =_("tempka");
- output1 = G_define_option() ;
+ output1 = G_define_standard_option(G_OPT_R_OUTPUT) ;
output1->key =_("rohair");
- output1->type = TYPE_STRING;
- output1->required = YES;
- output1->gisprompt =_("new,dcell,raster");
output1->description=_("Name of the output rohair layer");
- output1->answer =_("rohair");
/********************/
if (G_parser(argc, argv))
@@ -157,15 +144,14 @@
d_tempka = ((DCELL *) inrast_tempka)[col];
break;
}
- if(G_is_d_null_value(&d_dem)){
- ((DCELL *) outrast1)[col] = -999.99;
- } else if (G_is_d_null_value(&d_tempka)){
- ((DCELL *) outrast1)[col] = -999.99;
+ if(G_is_d_null_value(&d_dem)||
+ G_is_d_null_value(&d_tempka)){
+ G_set_d_null_value(&outrast1[col],1);
} else {
/********************/
/* calculate rohair */
d = roh_air(d_dem, d_tempka);
- ((DCELL *) outrast1)[col] = d;
+ outrast1[col] = d;
}
}
if (G_put_raster_row (outfd1, outrast1, data_type_output) < 0)
Modified: grass-addons/gipe/i.eb.ublend/main.c
===================================================================
--- grass-addons/gipe/i.eb.ublend/main.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.ublend/main.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -1,11 +1,11 @@
/****************************************************************************
*
* MODULE: i.eb.ublend
- * AUTHOR(S): Yann Chemin - ychemin at gmail.com
+ * AUTHOR(S): Yann Chemin - yann.chemin at gmail.com
* PURPOSE: Calculates the wind speed at blendiong height
* as seen in Pawan (2004)
*
- * COPYRIGHT: (C) 2002-2006 by the GRASS Development Team
+ * COPYRIGHT: (C) 2002-2008 by the GRASS Development Team
*
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
@@ -19,28 +19,26 @@
#include <grass/gis.h>
#include <grass/glocale.h>
-
double u_blend(double u_hmoment, double disp,double hblend,double z0m, double hmoment);
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;
- int verbose=1;
struct GModule *module;
struct Option *input1, *input2, *input3, *input4, *input5, *output1;
struct Flag *flag1;
- struct History history; //metadata
+ struct History history; /*metadata*/
/************************************/
/* FMEO Declarations*****************/
- char *name; // input raster name
- char *result; //output raster name
- //File Descriptors
+ char *name; /*input raster name*/
+ char *result; /*output raster name*/
+ /*File Descriptors*/
int infd_u_hmoment,infd_disp,infd_z0m;
int outfd;
@@ -50,7 +48,7 @@
int i=0,j=0;
void *inrast_u_hmoment, *inrast_disp, *inrast_z0m;
- unsigned char *outrast;
+ DCELL *outrast;
RASTER_MAP_TYPE data_type_output=DCELL_TYPE;
RASTER_MAP_TYPE data_type_u_hmoment;
RASTER_MAP_TYPE data_type_disp;
@@ -63,13 +61,9 @@
module->description = _("Wind speed at blending height.");
/* Define the different options */
- input1 = G_define_option() ;
+ input1 = G_define_standard_option(G_OPT_R_INPUT) ;
input1->key = _("u_hm");
- input1->type = TYPE_STRING;
- input1->required = YES;
- input1->gisprompt =_("old,cell,raster") ;
input1->description=_("Name of the wind speed at momentum height map (2.0m height in Pawan, 2004)");
- input1->answer =_("u_hm");
input2 = G_define_option() ;
input2->key =_("hmoment");
@@ -79,21 +73,13 @@
input2->description=_("Value of the momentum height (2.0 in Pawan, 2004)");
input2->answer =_("2.0");
- input3 = G_define_option() ;
+ input3 = G_define_standard_option(G_OPT_R_INPUT) ;
input3->key =_("disp");
- input3->type = TYPE_STRING;
- input3->required = YES;
- input3->gisprompt =_("old,cell,raster");
input3->description=_("Name of the displacement height map");
- input3->answer =_("disp");
- input4 = G_define_option() ;
+ input4 = G_define_standard_option(G_OPT_R_INPUT) ;
input4->key =_("z0m");
- input4->type = TYPE_STRING;
- input4->required = YES;
- input4->gisprompt =_("old,cell,raster");
input4->description=_("Name of the surface roughness for momentum map");
- input4->answer =_("z0m");
input5 = G_define_option() ;
input5->key =_("hblend");
@@ -103,17 +89,9 @@
input5->description=_("Value of the blending height (100.0 in Pawan, 2004)");
input5->answer =_("100.0");
- output1 = G_define_option() ;
- output1->key =_("ublend");
- output1->type = TYPE_STRING;
- output1->required = YES;
- output1->gisprompt =_("new,cell,raster");
+ output1 = G_define_standard_option(G_OPT_R_OUTPUT) ;
output1->description=_("Name of the output ublend layer");
- output1->answer =_("ublend");
- flag1 = G_define_flag();
- flag1->key = 'q';
- flag1->description = _("Quiet");
/********************/
if (G_parser(argc, argv))
exit (EXIT_FAILURE);
@@ -125,7 +103,6 @@
hblend = atof(input5->answer);
result = output1->answer;
- verbose = (!flag1->answer);
/***************************************************/
mapset = G_find_cell2 (u_hmoment, "");
if (mapset == NULL) {
@@ -175,9 +152,7 @@
DCELL d_z0m;
DCELL d_u_hmoment;
DCELL d_ublend;
- if(verbose)
- G_percent(row,nrows,2);
-// printf("row = %i/%i\n",row,nrows);
+ G_percent(row,nrows,2);
/* read input maps */
if(G_get_raster_row(infd_u_hmoment,inrast_u_hmoment,row,data_type_u_hmoment)<0)
G_fatal_error(_("Could not read from <%s>"),u_hmoment);
@@ -188,20 +163,48 @@
/*process the data */
for (col=0; col < ncols; col++)
{
- d_u_hmoment = ((DCELL *) inrast_u_hmoment)[col];
- d_disp = ((DCELL *) inrast_disp)[col];
- d_z0m = ((DCELL *) inrast_z0m)[col];
- if(G_is_d_null_value(&d_disp)){
- ((DCELL *) outrast)[col] = -999.99;
- }else if(G_is_d_null_value(&d_z0m)){
- ((DCELL *) outrast)[col] = -999.99;
- }else if(G_is_d_null_value(&d_u_hmoment)){
- ((DCELL *) outrast)[col] = -999.99;
+ switch(data_type_u_hmoment){
+ case CELL_TYPE:
+ d_u_hmoment = (double) ((CELL *) inrast_u_hmoment)[col];
+ break;
+ case FCELL_TYPE:
+ d_u_hmoment = (double) ((FCELL *) inrast_u_hmoment)[col];
+ break;
+ case DCELL_TYPE:
+ d_u_hmoment = ((DCELL *) inrast_u_hmoment)[col];
+ break;
+ }
+ switch(data_type_disp){
+ case CELL_TYPE:
+ d_disp = (double) ((CELL *) inrast_disp)[col];
+ break;
+ case FCELL_TYPE:
+ d_disp = (double) ((FCELL *) inrast_disp)[col];
+ break;
+ case DCELL_TYPE:
+ d_disp = ((DCELL *) inrast_disp)[col];
+ break;
+ }
+ switch(data_type_z0m){
+ case CELL_TYPE:
+ d_z0m = (double) ((CELL *) inrast_z0m)[col];
+ break;
+ case FCELL_TYPE:
+ d_z0m = (double) ((FCELL *) inrast_z0m)[col];
+ break;
+ case DCELL_TYPE:
+ d_z0m = ((DCELL *) inrast_z0m)[col];
+ break;
+ }
+ if(G_is_d_null_value(&d_disp)||
+ G_is_d_null_value(&d_z0m)||
+ G_is_d_null_value(&d_u_hmoment)){
+ G_set_d_null_value(&outrast[col],1);
}else {
/************************************/
/* calculate ustar */
d_ublend=u_blend(d_u_hmoment, d_disp, hblend,d_z0m, d_u_hmoment);
- ((DCELL *) outrast)[col] = d_ublend;
+ outrast[col] = d_ublend;
}
}
if (G_put_raster_row (outfd, outrast, data_type_output) < 0)
Modified: grass-addons/gipe/i.eb.ublend/ublend.c
===================================================================
--- grass-addons/gipe/i.eb.ublend/ublend.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.ublend/ublend.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -2,7 +2,7 @@
#include<stdlib.h>
#include<math.h>
-//Wind speed at blending height
+/*Wind speed at blending height*/
double u_blend(double u_hmoment, double disp,double hblend,double z0m, double hmoment){
double ublend;
Modified: grass-addons/gipe/i.eb.ustar/main.c
===================================================================
--- grass-addons/gipe/i.eb.ustar/main.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.ustar/main.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -1,10 +1,10 @@
/****************************************************************************
*
* MODULE: i.eb.ustar
- * AUTHOR(S): Yann Chemin - ychemin at gmail.com
+ * AUTHOR(S): Yann Chemin - yann.chemin at gmail.com
* PURPOSE: Calculates the nominal wind speed
*
- * COPYRIGHT: (C) 2002-2006 by the GRASS Development Team
+ * COPYRIGHT: (C) 2002-2008 by the GRASS Development Team
*
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
@@ -23,23 +23,22 @@
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;
- int verbose=1;
struct GModule *module;
struct Option *input1, *input2, *input3, *input4, *input5, *output1;
struct Flag *flag1;
- struct History history; //metadata
+ struct History history; /*metadata*/
/************************************/
/* FMEO Declarations*****************/
- char *name; // input raster name
- char *result; //output raster name
- //File Descriptors
+ char *name; /*input raster name*/
+ char *result; /*output raster name*/
+ /*File Descriptors*/
int infd_ublend, infd_disp,infd_z0m,infd_psim;
int outfd;
@@ -49,7 +48,7 @@
int i=0,j=0;
void *inrast_ublend, *inrast_disp, *inrast_z0m, *inrast_psim;
- unsigned char *outrast;
+ DCELL *outrast;
RASTER_MAP_TYPE data_type_output=DCELL_TYPE;
RASTER_MAP_TYPE data_type_ublend;
RASTER_MAP_TYPE data_type_disp;
@@ -63,13 +62,9 @@
module->description = _("Nominal wind speed.");
/* Define the different options */
- input1 = G_define_option() ;
+ input1 = G_define_standard_option(G_OPT_R_INPUT) ;
input1->key = _("ublend");
- input1->type = TYPE_STRING;
- input1->required = YES;
- input1->gisprompt =_("old,cell,raster") ;
- input1->description=_("Name of the wind speed at blending height map");
- input1->answer =_("ublend");
+ input1->description=_("Name of the wind speed at blending height layer");
input2 = G_define_option() ;
input2->key =_("hblend");
@@ -79,41 +74,21 @@
input2->description=_("Value of the blending height (100.0 in Pawan, 2004)");
input2->answer =_("100.0");
- input3 = G_define_option() ;
+ input3 = G_define_standard_option(G_OPT_R_INPUT) ;
input3->key =_("disp");
- input3->type = TYPE_STRING;
- input3->required = YES;
- input3->gisprompt =_("old,cell,raster");
- input3->description=_("Name of the displacement height map");
- input3->answer =_("disp");
+ input3->description=_("Name of the displacement height layer");
- input4 = G_define_option() ;
+ input4 = G_define_standard_option(G_OPT_R_INPUT) ;
input4->key =_("z0m");
- input4->type = TYPE_STRING;
- input4->required = YES;
- input4->gisprompt =_("old,cell,raster");
- input4->description=_("Name of the surface roughness for momentum map");
- input4->answer =_("z0m");
+ input4->description=_("Name of the surface roughness for momentum layer");
- input5 = G_define_option() ;
+ input5 = G_define_standard_option(G_OPT_R_INPUT) ;
input5->key =_("psim");
- input5->type = TYPE_STRING;
- input5->required = YES;
- input5->gisprompt =_("old,cell,raster");
- input5->description=_("Name of the psichrometric parameter for momentum map");
- input5->answer =_("psim");
+ input5->description=_("Name of the psichrometric parameter for momentum layer");
- output1 = G_define_option() ;
- output1->key =_("ustar");
- output1->type = TYPE_STRING;
- output1->required = YES;
- output1->gisprompt =_("new,cell,raster");
+ output1 = G_define_standard_option(G_OPT_R_OUTPUT) ;
output1->description=_("Name of the output ustar layer");
- output1->answer =_("ustar");
- flag1 = G_define_flag();
- flag1->key = 'q';
- flag1->description = _("Quiet");
/********************/
if (G_parser(argc, argv))
exit (EXIT_FAILURE);
@@ -125,7 +100,6 @@
psim = input5->answer;
result = output1->answer;
- verbose = (!flag1->answer);
/***************************************************/
mapset = G_find_cell2 (ublend, "");
if (mapset == NULL) {
@@ -187,9 +161,7 @@
DCELL d_z0m;
DCELL d_psim;
DCELL d_ustar;
- if(verbose)
- G_percent(row,nrows,2);
-// printf("row = %i/%i\n",row,nrows);
+ G_percent(row,nrows,2);
/* read input maps */
if(G_get_raster_row(infd_ublend,inrast_ublend,row,data_type_ublend)<0)
G_fatal_error(_("Could not read from <%s>"),ublend);
@@ -206,19 +178,16 @@
d_disp = ((DCELL *) inrast_disp)[col];
d_z0m = ((DCELL *) inrast_z0m)[col];
d_psim = ((DCELL *) inrast_psim)[col];
- if(G_is_d_null_value(&d_disp)){
- ((DCELL *) outrast)[col] = -999.99;
- }else if(G_is_d_null_value(&d_z0m)){
- ((DCELL *) outrast)[col] = -999.99;
- }else if(G_is_d_null_value(&d_psim)){
- ((DCELL *) outrast)[col] = -999.99;
- }else if(G_is_d_null_value(&d_ublend)){
- ((DCELL *) outrast)[col] = -999.99;
+ if(G_is_d_null_value(&d_disp)||
+ G_is_d_null_value(&d_z0m)||
+ G_is_d_null_value(&d_psim)||
+ G_is_d_null_value(&d_ublend)){
+ G_set_d_null_value(&outrast[col],1);
}else {
/************************************/
/* calculate ustar */
d_ustar=u_star(d_ublend, hblend, d_disp, d_z0m, d_psim);
- ((DCELL *) outrast)[col] = d_ustar;
+ outrast[col] = d_ustar;
}
}
if (G_put_raster_row (outfd, outrast, data_type_output) < 0)
Modified: grass-addons/gipe/i.eb.wetdrypix/main.c
===================================================================
--- grass-addons/gipe/i.eb.wetdrypix/main.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.wetdrypix/main.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -235,20 +235,12 @@
}
}
G_message("Histogram of Temperature map (if it has rogue values to clean)");
- //int peak1, peak2, peak3;
- //int i_peak1, i_peak2, i_peak3;
peak1=0;
peak2=0;
peak3=0;
i_peak1=0;
i_peak2=0;
i_peak3=0;
- //int bottom1a, bottom1b;
- //int bottom2a, bottom2b;
- //int bottom3a, bottom3b;
- //int i_bottom1a, i_bottom1b;
- //int i_bottom2a, i_bottom2b;
- //int i_bottom3a, i_bottom3b;
bottom1a=100000;
bottom1b=100000;
bottom2a=100000;
@@ -568,18 +560,18 @@
d_tempk <= (double) i_peak1+5.0){
c_wet = 1; /* Wet pixel Candidate */
}
- //flag NULL -> 0
+ /*flag NULL -> 0*/
if (zero->answer && c_wet<0){
c_wet = 0;
}
if (zero->answer && c_dry<0){
c_dry = 0;
}
- //results
+ /*results*/
outrast[col] = c_wet;
outrast1[col] = c_dry;
- //clean up
+ /*clean up*/
if(c_wet==-1)
G_set_c_null_value(&outrast[col],1);
if(c_dry==-1)
Modified: grass-addons/gipe/i.eb.z0m/main.c
===================================================================
--- grass-addons/gipe/i.eb.z0m/main.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.z0m/main.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -1,11 +1,11 @@
/****************************************************************************
*
* MODULE: i.eb.z0m
- * AUTHOR(S): Yann Chemin - ychemin at gmail.com
+ * AUTHOR(S): Yann Chemin - yann.chemin at gmail.com
* PURPOSE: Calculates the momentum roughness length
* as seen in Bastiaanssen (1995)
*
- * COPYRIGHT: (C) 2002-2006 by the GRASS Development Team
+ * COPYRIGHT: (C) 2002-2008 by the GRASS Development Team
*
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
@@ -19,28 +19,27 @@
#include <grass/gis.h>
#include <grass/glocale.h>
-
double z_0m(double sa_vi);
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;
- int heat=0;//Flag for surf. roughness for heat transport output
+ int heat=0;/*Flag for surf. roughness for heat transport output*/
struct GModule *module;
struct Option *input1, *input2, *output1, *output2;
struct Flag *flag1, *flag2;
- struct History history; //metadata
+ struct History history; /*metadata*/
/************************************/
/* FMEO Declarations*****************/
- char *name; // input raster name
- char *result1, *result2; //output raster name
- //File Descriptors
+ char *name; /* input raster name*/
+ char *result1, *result2; /*output raster name*/
+ /*File Descriptors*/
int infd_savi;
int outfd1, outfd2;
@@ -64,7 +63,6 @@
input1 = G_define_standard_option(G_OPT_R_INPUT) ;
input1->key = _("savi");
input1->description=_("Name of the SAVI map [-1.0;1.0]");
- input1->answer =_("savi");
input2 = G_define_option() ;
input2->key =_("coef");
@@ -75,15 +73,12 @@
input2->answer =_("0.1");
output1 = G_define_standard_option(G_OPT_R_OUTPUT) ;
- output1->key =_("z0m");
output1->description=_("Name of the output z0m layer");
- output1->answer =_("z0m");
output2 = G_define_standard_option(G_OPT_R_OUTPUT) ;
output2->key =_("z0h");
output2->required = NO;
output2->description=_("Name of the output z0h layer");
- output2->answer =_("z0h");
flag1 = G_define_flag();
flag1->key = 'h';
@@ -131,13 +126,23 @@
DCELL d_savi;
DCELL d_z0h;
G_percent(row,nrows,2);
- /* read soil input maps */
+ /* read input maps */
if(G_get_raster_row(infd_savi,inrast_savi,row,data_type_savi)<0)
G_fatal_error(_("Could not read from <%s>"),savi);
/*process the data */
for (col=0; col < ncols; col++)
{
- d_savi = ((DCELL *) inrast_savi)[col];
+ switch(data_type_savi){
+ case CELL_TYPE:
+ d_savi = (double) ((CELL *) inrast_savi)[col];
+ break;
+ case FCELL_TYPE:
+ d_savi = (double) ((FCELL *) inrast_savi)[col];
+ break;
+ case DCELL_TYPE:
+ d_savi = ((DCELL *) inrast_savi)[col];
+ break;
+ }
if(G_is_d_null_value(&d_savi)){
G_set_d_null_value(&outrast1[col],1);
if(input2->answer&&output2->answer){
Modified: grass-addons/gipe/i.eb.z0m/z0m.c
===================================================================
--- grass-addons/gipe/i.eb.z0m/z0m.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.z0m/z0m.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -2,7 +2,7 @@
#include<stdlib.h>
#include<math.h>
-// Momentum roughness length (z0m) as seen in Pawan (2004)
+/* Momentum roughness length (z0m) as seen in Pawan (2004)*/
double z_0m(double sa_vi)
{
Modified: grass-addons/gipe/i.eb.z0m0/main.c
===================================================================
--- grass-addons/gipe/i.eb.z0m0/main.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.z0m0/main.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -5,7 +5,7 @@
* PURPOSE: Calculates the momentum roughness length
* as seen in Bastiaanssen (1995)
*
- * COPYRIGHT: (C) 2002-2006 by the GRASS Development Team
+ * COPYRIGHT: (C) 2002-2008 by the GRASS Development Team
*
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
@@ -23,24 +23,24 @@
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;
- int heat=0;//Flag for surf. roughness for heat transport output
+ int heat=0;/*Flag for surf. roughness for heat transport output*/
struct GModule *module;
struct Option *input1, *input2, *input3, *input4;
struct Option *output1, *output2;
struct Flag *flag1, *flag2;
- struct History history; //metadata
+ struct History history; /*metadata*/
/************************************/
/* FMEO Declarations*****************/
- char *name; // input raster name
- char *result1, *result2; //output raster name
- //File Descriptors
+ char *name; /*input raster name*/
+ char *result1, *result2; /*output raster name*/
+ /*File Descriptors*/
int infd_ndvi;
int outfd1, outfd2;
@@ -64,7 +64,6 @@
input1 = G_define_standard_option(G_OPT_R_INPUT) ;
input1->key = _("ndvi");
input1->description=_("Name of the NDVI map [-1.0;1.0]");
- input1->answer =_("ndvi");
input2 = G_define_option() ;
input2->key =_("coef");
@@ -91,15 +90,12 @@
input4->answer =_("0.02");
output1 = G_define_standard_option(G_OPT_R_OUTPUT) ;
- output1->key =_("z0m");
output1->description=_("Name of the output z0m layer");
- output1->answer =_("z0m");
output2 = G_define_standard_option(G_OPT_R_OUTPUT) ;
output2->key =_("z0h");
output2->required = NO;
output2->description=_("Name of the output z0h layer");
- output2->answer =_("z0h");
flag1 = G_define_flag();
flag1->key = 'h';
@@ -154,9 +150,6 @@
G_percent (row, nrows, 2);
if (G_get_d_raster_row (infd_ndvi, inrast_ndvi, row) < 0)
G_fatal_error (_("Could not read from <%s>"),ndvi);
- /* #pragma omp for parallel default (shared) \
- shared(ncols,nrows) \
- private (col,row,d_ndvi)*/
for (col=0; col < ncols; col++)
{
switch(data_type_ndvi){
@@ -170,7 +163,6 @@
d_ndvi = (double) ((DCELL *) inrast_ndvi)[col];
break;
}
- //d_ndvi = ((DCELL *) inrast_ndvi)[col];
if(G_is_d_null_value(&d_ndvi)){
/* do nothing */
} else if ((d_ndvi)>d_ndvi_max&&(d_ndvi)<0.98){
@@ -185,7 +177,7 @@
DCELL d;
DCELL d_z0h;
G_percent(row,nrows,2);
- /* read soil input maps */
+ /* read input maps */
if(G_get_raster_row(infd_ndvi,inrast_ndvi,row,data_type_ndvi)<0)
G_fatal_error(_("Could not read from <%s>"),ndvi);
/*process the data */
Modified: grass-addons/gipe/i.eb.z0m0/zom_0.c
===================================================================
--- grass-addons/gipe/i.eb.z0m0/zom_0.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.eb.z0m0/zom_0.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -4,8 +4,8 @@
double zom_0(double ndvi, double ndvi_max, double hv_ndvimax, double hv_desert )
{
double a, b, z0m;
- //double hv_ndvimax=1.5; /* crop vegetation height (m) */
- //double hv_desert=0.002; /* desert base vegetation height (m) */
+ /* hv_ndvimax = crop vegetation height (m) */
+ /* hv_desert=0.002 = desert base vegetation height (m) */
a = (log(hv_desert)-((log(hv_ndvimax/7)-log(hv_desert))/(ndvi_max-0.02)*0.02));
b = (log(hv_ndvimax/7)-log(hv_desert))/(ndvi_max-0.02)* ndvi;
Modified: grass-addons/gipe/i.emissivity/emissivity_generic.c
===================================================================
--- grass-addons/gipe/i.emissivity/emissivity_generic.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.emissivity/emissivity_generic.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -2,9 +2,9 @@
#include<math.h>
#include<stdlib.h>
-// Emissivity Generic mode (Reads directly from NDVI)
-// Estimation in the 8-14 micrometers range for sparse canopy
-// yann.chemin at gmail.com LGPL, Copylefted, 2004.
+/* Emissivity Generic mode (Reads directly from NDVI)
+ * Estimation in the 8-14 micrometers range for sparse canopy
+ */
double emissivity_generic( double ndvi )
{
Modified: grass-addons/gipe/i.emissivity/main.c
===================================================================
--- grass-addons/gipe/i.emissivity/main.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.emissivity/main.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -5,7 +5,7 @@
* PURPOSE: Calculates the emissivity from NDVI (empirical)
* as seen in Caselles and Colles (1997).
*
- * COPYRIGHT: (C) 2007 by the GRASS Development Team
+ * COPYRIGHT: (C) 2002-2008 by the GRASS Development Team
*
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
@@ -19,28 +19,26 @@
#include <grass/gis.h>
#include <grass/glocale.h>
-
double emissivity_generic( double ndvi );
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;
- int verbose=1;
struct GModule *module;
struct Option *input1, *output1;
struct Flag *flag1, *flag2;
- struct History history; //metadata
+ struct History history; /*metadata*/
/************************************/
/* FMEO Declarations*****************/
- char *name; // input raster name
- char *result1; //output raster name
- //File Descriptors
+ char *name; /*input raster name*/
+ char *result1; /*output raster name*/
+ /*File Descriptors*/
int infd_ndvi;
int outfd1;
@@ -49,7 +47,7 @@
int i=0,j=0;
void *inrast_ndvi;
- unsigned char *outrast1;
+ DCELL *outrast1;
RASTER_MAP_TYPE data_type_output=DCELL_TYPE;
RASTER_MAP_TYPE data_type_ndvi;
/************************************/
@@ -60,27 +58,11 @@
module->description = _("Emissivity from NDVI, generic method for spares land.");
/* Define the different options */
- input1 = G_define_option() ;
- input1->key = _("ndvi");
- input1->type = TYPE_STRING;
- input1->required = YES;
- input1->gisprompt =_("old,cell,raster") ;
+ input1 = G_define_standard_option(G_OPT_R_INPUT) ;
input1->description=_("Name of the NDVI map [-]");
- input1->answer =_("ndvi");
- output1 = G_define_option() ;
- output1->key =_("emissivity");
- output1->type = TYPE_STRING;
- output1->required = YES;
- output1->gisprompt =_("new,cell,raster");
+ output1 = G_define_standard_option(G_OPT_R_INPUT) ;
output1->description=_("Name of the output emissivity layer");
- output1->answer =_("e0");
-
-
- flag1 = G_define_flag();
- flag1->key = 'q';
- flag1->description = _("Quiet");
-
/********************/
if (G_parser(argc, argv))
exit (EXIT_FAILURE);
@@ -88,7 +70,6 @@
ndvi = input1->answer;
result1 = output1->answer;
- verbose = (!flag1->answer);
/***************************************************/
mapset = G_find_cell2(ndvi, "");
if (mapset == NULL) {
@@ -113,10 +94,8 @@
{
DCELL d;
DCELL d_ndvi;
- if(verbose)
- G_percent(row,nrows,2);
-// printf("row = %i/%i\n",row,nrows);
- /* read soil input maps */
+ G_percent(row,nrows,2);
+ /* read input maps */
if(G_get_raster_row(infd_ndvi,inrast_ndvi,row,data_type_ndvi)<0)
G_fatal_error(_("Could not read from <%s>"),ndvi);
/*process the data */
@@ -134,13 +113,12 @@
break;
}
if(G_is_d_null_value(&d_ndvi)){
- ((DCELL *) outrast1)[col] = -999.99;
+ G_set_d_null_value(&outrast1[col],1);
} else {
/****************************/
/* calculate emissivity */
d = emissivity_generic(d_ndvi);
-
- ((DCELL *) outrast1)[col] = d;
+ outrast1[col] = d;
}
}
if (G_put_raster_row (outfd1, outrast1, data_type_output) < 0)
Modified: grass-addons/gipe/i.evapo.PT/main.c
===================================================================
--- grass-addons/gipe/i.evapo.PT/main.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.evapo.PT/main.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -1,13 +1,12 @@
/*****************************************************************************
*
* MODULE: i.evapo.PT
-* AUTHOR: Yann Chemin (2007)
-* yann.chemin_AT_gmail.com
+* AUTHOR: Yann Chemin yann.chemin at gmail.com
*
* PURPOSE: To estimate the daily evapotranspiration by means
* of Prestley and Taylor method (1972).
*
-* COPYRIGHT: (C) 2007 by the GRASS Development Team
+* COPYRIGHT: (C) 2007-2008 by the GRASS Development Team
*
* This program is free software under the GNU General Public
* Licence (>=2). Read the file COPYING that comes with GRASS
@@ -23,15 +22,10 @@
#include <grass/raster.h>
#include <grass/glocale.h>
-
-//proto Delta_pt and Ghamma_pt
double pt_delta(double tempka);
double pt_ghamma(double tempka, double p_atm);
-
-//proto ET
double pt_daily_et(double alpha_pt, double delta_pt, double ghamma_pt, double rnet, double g0, double tempka );
-
int main(int argc, char *argv[])
{
/* buffer for input-output rasters */
@@ -112,7 +106,6 @@
input_PT->answer = "1.26";
output = G_define_standard_option(G_OPT_R_OUTPUT) ;
- output->key = "output";
output->key_desc = "[mm/d]";
output->description = _("Name of output Evapotranspiration layer");
@@ -258,11 +251,11 @@
break;
}
- //Delta_pt and Ghamma_pt
+ /*Delta_pt and Ghamma_pt*/
d_pt_delta = pt_delta( d_tempka);
d_pt_ghamma = pt_ghamma(d_tempka, d_pt_patm);
- //Calculate ET
+ /*Calculate ET*/
d_daily_et = pt_daily_et( d_pt_alpha, d_pt_delta, d_pt_ghamma, d_rnet, d_g0, d_tempka );
if (zero->answer && d_daily_et<0)
d_daily_et=0.0;
Modified: grass-addons/gipe/i.evapo.PT/pt_daily_et.c
===================================================================
--- grass-addons/gipe/i.evapo.PT/pt_daily_et.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.evapo.PT/pt_daily_et.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -2,12 +2,12 @@
#include<math.h>
#include<stdlib.h>
-//Prestely and Taylor, 1972.
+/*Prestely and Taylor, 1972. */
double pt_daily_et(double alpha_pt,double delta_pt,double ghamma_pt,double rnet,double g0,double tempka)
{
double result, latentHv, t_celsius;
- double roh_w=1004.15;//mass density of water
+ double roh_w=1004.15;/*mass density of water*/
double vap_slope_ratio;
/*Latent Heat of vaporization (W/m2/d)*/
Modified: grass-addons/gipe/i.evapo.PT/pt_delta.c
===================================================================
--- grass-addons/gipe/i.evapo.PT/pt_delta.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.evapo.PT/pt_delta.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -2,14 +2,15 @@
#include<math.h>
#include<stdlib.h>
-//Prestely and Taylor, 1972.
-//INPUT in Kelvin
+/* Prestely and Taylor, 1972.
+ * INPUT in Kelvin
+ */
double pt_delta(double tempka)
{
double a, b, result;
- tempka -= 273.15;//Celsius
+ tempka -= 273.15;/*Celsius*/
b = tempka + 237.3 ;
a = ( 17.27 * tempka ) / b ;
Modified: grass-addons/gipe/i.evapo.PT/pt_ghamma.c
===================================================================
--- grass-addons/gipe/i.evapo.PT/pt_ghamma.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.evapo.PT/pt_ghamma.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -2,8 +2,9 @@
#include<math.h>
#include<stdlib.h>
-//Prestely and Taylor, 1972.
-//INPUT in Kelvin
+/* Prestely and Taylor, 1972.
+ * INPUT in Kelvin
+ */
double pt_ghamma(double tempka, double patm_pt)
{
Modified: grass-addons/gipe/i.evapo.SENAY/et_pot_day.c
===================================================================
--- grass-addons/gipe/i.evapo.SENAY/et_pot_day.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.evapo.SENAY/et_pot_day.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -2,7 +2,7 @@
#include<math.h>
#include<stdlib.h>
-// Average Diurnal Potential ET after Bastiaanssen (1995)
+/* Average Diurnal Potential ET after Bastiaanssen (1995)*/
double et_pot_day( double rnetd, double tempk, double roh_w )
{
Modified: grass-addons/gipe/i.evapo.SENAY/evapfr_senay.c
===================================================================
--- grass-addons/gipe/i.evapo.SENAY/evapfr_senay.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.evapo.SENAY/evapfr_senay.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -2,7 +2,7 @@
#include<math.h>
#include<stdlib.h>
-// Evaporative fraction from Senay (2007)
+/* Evaporative fraction from Senay (2007)*/
double evapfr_senay( double t_hot, double t_cold, double tempk)
{
Modified: grass-addons/gipe/i.evapo.SENAY/main.c
===================================================================
--- grass-addons/gipe/i.evapo.SENAY/main.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.evapo.SENAY/main.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -28,8 +28,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;
@@ -40,13 +40,13 @@
struct Option *output1, *output2;
struct Flag *flag2, *flag3;
- struct History history; //metadata
- struct Colors colors; //Color rules
+ struct History history; /*metadata*/
+ struct Colors colors; /*Color rules*/
/************************************/
/* FMEO Declarations*****************/
- char *name; // input raster name
- char *result1,*result2; //output raster name
- //File Descriptors
+ char *name; /*input raster name*/
+ char *result1,*result2; /*output raster name*/
+ /*File Descriptors*/
int infd_albedo, infd_tempk, infd_dem;
int infd_lat, infd_doy, infd_tsw;
int infd_slope, infd_aspect;
@@ -93,33 +93,27 @@
/* Define the different options */
input1 = G_define_standard_option(G_OPT_R_INPUT) ;
input1->key = _("albedo");
- input1->description=_("Name of the Albedo map [0.0-1.0]");
- input1->answer =_("albedo");
+ input1->description=_("Name of the Albedo layer [0.0-1.0]");
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->description=_("Name of the temperature layer [Degree Kelvin]");
input3 = G_define_standard_option(G_OPT_R_INPUT) ;
input3->key =_("dem");
- input3->description=_("Name of the elevation map [m]");
- input3->answer =_("dem");
+ input3->description=_("Name of the elevation layer [m]");
input4 = G_define_standard_option(G_OPT_R_INPUT) ;
input4->key =_("lat");
- input4->description=_("Name of the degree latitude map [dd.ddd]");
- input4->answer =_("lat");
+ input4->description=_("Name of the degree latitude layer [dd.ddd]");
input5 = G_define_standard_option(G_OPT_R_INPUT) ;
input5->key =_("doy");
- input5->description=_("Name of the Day of Year map [0.0-366.0]");
- input5->answer =_("doy");
+ input5->description=_("Name of the Day of Year layer [0.0-366.0]");
input6 = G_define_standard_option(G_OPT_R_INPUT) ;
input6->key =_("tsw");
- input6->description=_("Name of the single-way transmissivity map [0.0-1.0]");
- input6->answer =_("tsw");
+ input6->description=_("Name of the single-way transmissivity layer [0.0-1.0]");
input7 = G_define_option() ;
input7->key =_("roh_w");
@@ -131,13 +125,13 @@
input8 = G_define_standard_option(G_OPT_R_INPUT) ;
input8->key =_("slope");
input8->required = NO;
- input8->description=_("Name of the Slope map ~[0-90]");
+ input8->description=_("Name of the Slope layer ~[0-90]");
input8->guisection = _("Optional");
input9 = G_define_standard_option(G_OPT_R_INPUT) ;
input9->key =_("aspect");
input9->required = NO;
- input9->description=_("Name of the Aspect map ~[0-360]");
+ input9->description=_("Name of the Aspect layer ~[0-360]");
input9->guisection = _("Optional");
input10 = G_define_option() ;
@@ -150,24 +144,21 @@
input11 = G_define_standard_option(G_OPT_R_INPUT) ;
input11->key =_("t_air");
input11->required = NO;
- input11->description=_("Name of the Air Temperature map [Kelvin], use with -b");
+ input11->description=_("Name of the Air Temperature layer [Kelvin], use with -b");
input11->guisection = _("Optional");
input12 = G_define_standard_option(G_OPT_R_INPUT) ;
input12->key =_("e0");
input12->required = NO;
- input12->description=_("Name of the Surface Emissivity map [-], use with -b");
+ input12->description=_("Name of the Surface Emissivity layer [-], use with -b");
input12->guisection = _("Optional");
input13 = G_define_standard_option(G_OPT_R_INPUT) ;
input13->key =_("ndvi");
- input13->description=_("Name of the NDVI map [-]");
- input13->answer =_("ndvi");
+ input13->description=_("Name of the NDVI layer [-]");
output1 = G_define_standard_option(G_OPT_R_OUTPUT) ;
- output1->key =_("eta");
output1->description=_("Name of the output Actual ET layer");
- output1->answer =_("eta");
output2 = G_define_standard_option(G_OPT_R_OUTPUT) ;
output2->key =_("evapfr");
@@ -423,12 +414,10 @@
if(d_t0dem<0.0||d_albedo<0.001){
/* do nothing */
} else {
- //if(d_t0dem<t0dem_min){
if(d_tempk<tempk_min&&
d_albedo<0.1){
t0dem_min=d_t0dem;
tempk_min=d_tempk;
- //}else if(d_t0dem>t0dem_max){
}else if(d_tempk>tempk_max&&
d_albedo>0.3){
t0dem_max=d_t0dem;
@@ -448,7 +437,6 @@
DCELL d_lat;
DCELL d_doy;
DCELL d_tsw;
-// DCELL d_roh_w;
DCELL d_solar;
DCELL d_rnetd;
DCELL d_slope;
Modified: grass-addons/gipe/i.evapo.SENAY/r_net_day.c
===================================================================
--- grass-addons/gipe/i.evapo.SENAY/r_net_day.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.evapo.SENAY/r_net_day.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -2,7 +2,7 @@
#include<math.h>
#include<stdlib.h>
-// Average Diurnal Net Radiation after Bastiaanssen (1995)
+/* Average Diurnal Net Radiation after Bastiaanssen (1995)*/
double r_net_day( double bbalb, double solar, double tsw )
{
Modified: grass-addons/gipe/i.evapo.SENAY/r_net_day_bandara98.c
===================================================================
--- grass-addons/gipe/i.evapo.SENAY/r_net_day_bandara98.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.evapo.SENAY/r_net_day_bandara98.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -2,12 +2,12 @@
#include<math.h>
#include<stdlib.h>
-// Average Diurnal Net Radiation after Bandara (1998)
+/* Average Diurnal Net Radiation after Bandara (1998)*/
double r_net_day_bandara98( double surface_albedo, double solar_day, double apparent_atm_emissivity, double surface_emissivity, double air_temperature )
{
double longwave_balance, result;
- double sigma=5.67*pow(10,-8);//Stefann-Boltzmann Constant
+ double sigma=5.67*pow(10,-8);/*Stefann-Boltzmann Constant*/
longwave_balance = (apparent_atm_emissivity-surface_emissivity) * sigma * pow(air_temperature,4) ;
Modified: grass-addons/gipe/i.evapo.SENAY/solar_day.c
===================================================================
--- grass-addons/gipe/i.evapo.SENAY/solar_day.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.evapo.SENAY/solar_day.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -2,8 +2,7 @@
#include<math.h>
#include<stdlib.h>
-// Average Solar Diurnal Radiation after Bastiaanssen (1995)
-// ychemin at gmail.com - Yann Chemin - LGPL, Copylefted, 2004.
+/* Average Solar Diurnal Radiation after Bastiaanssen (1995) */
#define PI 3.1415927
@@ -11,7 +10,6 @@
{
double ws, cosun, latrad, delta, deltarad, ds, result;
-
ds = 1.0 + 0.01672 * sin(2*PI*(doy-93.5)/365.0);
deltarad = 0.4093*sin((2*PI*doy/365)-1.39);
latrad = lat * PI / 180.0;
@@ -22,6 +20,5 @@
result = ( cosun * 1367 * tsw ) / ( PI * ds * ds );
return result;
-
}
Modified: grass-addons/gipe/i.evapo.SENAY/solar_day_3d.c
===================================================================
--- grass-addons/gipe/i.evapo.SENAY/solar_day_3d.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.evapo.SENAY/solar_day_3d.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -2,10 +2,9 @@
#include<math.h>
#include<stdlib.h>
-// Average Solar Diurnal Radiation after Bastiaanssen (1995)
-// Includes Slope and aspect correction
-// yann.chemin at gmail.com - Yann Chemin - LGPL, Copylefted, 2004.
-
+/* Average Solar Diurnal Radiation after Bastiaanssen (1995)
+ * Includes Slope and aspect correction
+ */
#define PI 3.1415927
double solar_day_3d(double lat, double doy, double tsw, double slope, double aspect )
Modified: grass-addons/gipe/i.evapo.potrad/et_pot_day.c
===================================================================
--- grass-addons/gipe/i.evapo.potrad/et_pot_day.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.evapo.potrad/et_pot_day.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -2,7 +2,7 @@
#include<math.h>
#include<stdlib.h>
-// Average Diurnal Potential ET after Bastiaanssen (1995)
+/* Average Diurnal Potential ET after Bastiaanssen (1995)*/
double et_pot_day( double rnetd, double tempk, double roh_w )
{
Modified: grass-addons/gipe/i.evapo.potrad/main.c
===================================================================
--- grass-addons/gipe/i.evapo.potrad/main.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.evapo.potrad/main.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -1,12 +1,12 @@
/****************************************************************************
*
* MODULE: i.evapo.potrad
- * AUTHOR(S): Yann Chemin - ychemin at gmail.com
+ * AUTHOR(S): Yann Chemin - yann.chemin at gmail.com
* PURPOSE: Creates a map of potential evapotranspiration following
* the condition that all net radiation becomes ET
* (thus it can be called a "radiative ET pot")
*
- * COPYRIGHT: (C) 2002-2006 by the GRASS Development Team
+ * COPYRIGHT: (C) 2002-2008 by the GRASS Development Team
*
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
@@ -29,8 +29,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;
@@ -41,13 +41,13 @@
struct Option *output1, *output2;
struct Flag *flag1, *flag2, *flag3, *flag4;
- struct History history; //metadata
- struct Colors colors; //Color rules
+ struct History history; /*metadata*/
+ struct Colors colors; /*Color rules*/
/************************************/
/* FMEO Declarations*****************/
- char *name; // input raster name
- char *result1,*result2; //output raster name
- //File Descriptors
+ char *name; /*input raster name*/
+ char *result1,*result2; /*output raster name*/
+ /*File Descriptors*/
int infd_albedo, infd_tempk, infd_lat, infd_doy, infd_tsw;
int infd_slope, infd_aspect;
int infd_tair, infd_e0;
@@ -83,27 +83,23 @@
/* Define the different options */
input1 = G_define_standard_option(G_OPT_R_INPUT) ;
input1->key = _("albedo");
- input1->description=_("Name of the Albedo map [0.0-1.0]");
- input1->answer =_("albedo");
+ input1->description=_("Name of the Albedo layer [0.0-1.0]");
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->description=_("Name of the temperature layer [Degree Kelvin]");
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->description=_("Name of the degree latitude layer [dd.ddd]");
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->description=_("Name of the Day of Year layer [0.0-366.0]");
input5 = G_define_standard_option(G_OPT_R_INPUT) ;
input5->key =_("tsw");
- input5->description=_("Name of the single-way transmissivity map [0.05-1.0], defaults to 1.0 if no input file");
+ input5->description=_("Name of the single-way transmissivity layer [0.05-1.0], defaults to 1.0 if no input file");
input6 = G_define_option() ;
input6->key =_("roh_w");
@@ -116,13 +112,13 @@
input7 = G_define_standard_option(G_OPT_R_INPUT) ;
input7->key =_("slope");
input7->required = NO;
- input7->description=_("Name of the Slope map ~[0-90]");
+ input7->description=_("Name of the Slope layer ~[0-90]");
input7->guisection = _("Optional");
input8 = G_define_standard_option(G_OPT_R_INPUT) ;
input8->key =_("aspect");
input8->required = NO;
- input8->description=_("Name of the Aspect map ~[0-360]");
+ input8->description=_("Name of the Aspect layer ~[0-360]");
input8->guisection = _("Optional");
input9 = G_define_option() ;
@@ -137,19 +133,17 @@
input10 = G_define_standard_option(G_OPT_R_INPUT) ;
input10->key =_("t_air");
input10->required = NO;
- input10->description=_("Name of the Air Temperature map [Kelvin], use with -b");
+ input10->description=_("Name of the Air Temperature layer [Kelvin], use with -b");
input10->guisection = _("Optional");
input11 = G_define_standard_option(G_OPT_R_INPUT) ;
input11->key =_("e0");
input11->required = NO;
- input11->description=_("Name of the Surface Emissivity map [-], use with -b");
+ input11->description=_("Name of the Surface Emissivity layer [-], use with -b");
input11->guisection = _("Optional");
output1 = G_define_standard_option(G_OPT_R_OUTPUT) ;
- output1->key =_("etpot");
output1->description=_("OUTPUT: Name of the Potential ET layer");
- output1->answer =_("etpot");
output2 = G_define_standard_option(G_OPT_R_OUTPUT) ;
output2->key =_("rnetd");
@@ -317,12 +311,10 @@
DCELL d_lat;
DCELL d_doy;
DCELL d_tsw;
-// DCELL d_roh_w;
DCELL d_solar;
DCELL d_rnetd;
DCELL d_slope;
DCELL d_aspect;
-// DCELL d_e_atm;
DCELL d_tair;
DCELL d_e0;
G_percent(row,nrows,2);
Modified: grass-addons/gipe/i.evapo.potrad/r_net_day.c
===================================================================
--- grass-addons/gipe/i.evapo.potrad/r_net_day.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.evapo.potrad/r_net_day.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -2,7 +2,7 @@
#include<math.h>
#include<stdlib.h>
-// Average Diurnal Net Radiation after Bastiaanssen (1995)
+/* Average Diurnal Net Radiation after Bastiaanssen (1995) */
double r_net_day( double bbalb, double solar, double tsw )
{
Modified: grass-addons/gipe/i.evapo.potrad/r_net_day_bandara98.c
===================================================================
--- grass-addons/gipe/i.evapo.potrad/r_net_day_bandara98.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.evapo.potrad/r_net_day_bandara98.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -2,12 +2,12 @@
#include<math.h>
#include<stdlib.h>
-// Average Diurnal Net Radiation after Bandara (1998)
+/* Average Diurnal Net Radiation after Bandara (1998)*/
double r_net_day_bandara98( double surface_albedo, double solar_day, double apparent_atm_emissivity, double surface_emissivity, double air_temperature )
{
double longwave_balance, result;
- double sigma=5.67*pow(10,-8);//Stefann-Boltzmann Constant
+ double sigma=5.67*pow(10,-8);/*Stefann-Boltzmann Constant*/
longwave_balance = (apparent_atm_emissivity-surface_emissivity) * sigma * pow(air_temperature,4) ;
Modified: grass-addons/gipe/i.evapo.potrad/solar_day.c
===================================================================
--- grass-addons/gipe/i.evapo.potrad/solar_day.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.evapo.potrad/solar_day.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -2,7 +2,7 @@
#include<math.h>
#include<stdlib.h>
-// Average Solar Diurnal Radiation after Bastiaanssen (1995)
+/* Average Solar Diurnal Radiation after Bastiaanssen (1995) */
#define PI 3.1415927
@@ -10,14 +10,14 @@
{
double ws, cosun, latrad, delta, deltarad, ds, result;
- //Sun-Earth Distance (ds; A.U.)
+ /*Sun-Earth Distance (ds; A.U.)*/
ds = 1.0 + 0.01672 * sin(2*PI*(doy-93.5)/365.0);
- //Solar declination (delta; radians)
+ /*Solar declination (delta; radians)*/
deltarad = 0.4093*sin((2*PI*doy/365)-1.39);
- //Convert latitude in radians
+ /*Convert latitude in radians*/
latrad = lat * PI / 180.0;
- //Convert latitude in radians
+ /*Convert latitude in radians*/
ws = acos(-tan(latrad)*tan(deltarad));
cosun = ws*sin(deltarad)*sin(latrad)+cos(deltarad)*cos(latrad)*sin(ws);
Modified: grass-addons/gipe/i.evapo.potrad/solar_day_3d.c
===================================================================
--- grass-addons/gipe/i.evapo.potrad/solar_day_3d.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.evapo.potrad/solar_day_3d.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -2,9 +2,9 @@
#include<math.h>
#include<stdlib.h>
-// Average Solar Diurnal Radiation after Bastiaanssen (1995)
-// Includes Slope and aspect correction
-// yann.chemin at gmail.com - Yann Chemin - LGPL, Copylefted, 2004.
+/* Average Solar Diurnal Radiation after Bastiaanssen (1995)
+ * Includes Slope and aspect correction
+ */
#define PI 3.1415927
Modified: grass-addons/gipe/i.evapo.time_integration/main.c
===================================================================
--- grass-addons/gipe/i.evapo.time_integration/main.c 2008-08-21 11:14:04 UTC (rev 32964)
+++ grass-addons/gipe/i.evapo.time_integration/main.c 2008-08-21 11:23:44 UTC (rev 32965)
@@ -1,7 +1,7 @@
/****************************************************************************
*
* MODULE: i.evapo.time_integration
- * AUTHOR(S): Yann Chemin - ychemin at gmail.com
+ * AUTHOR(S): Yann Chemin - yann.chemin at gmail.com
* PURPOSE: Integrate in time the evapotranspiration from satellite,
* following a daily pattern from meteorological ETo.
*
@@ -24,21 +24,21 @@
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, *input1, *input2, *input3, *output;
- struct History history; //metadata
- struct Colors colors; //Color rules
+ struct History history; /*metadata*/
+ struct Colors colors; /*Color rules*/
/************************************/
/* FMEO Declarations*****************/
- char *name,*name1,*name2; //input raster name
- char *result; //output raster name
- //File Descriptors
+ char *name,*name1,*name2; /*input raster name*/
+ char *result; /*output raster name*/
+ /*File Descriptors*/
int nfiles, nfiles1, nfiles2;
int infd[MAXFILES], infd1[MAXFILES], infd2[MAXFILES];
int outfd;
@@ -77,19 +77,16 @@
/* Define the different options */
- input = G_define_standard_option(G_OPT_R_INPUT) ;
+ input = G_define_standard_option(G_OPT_R_INPUTS) ;
input->key =_("eta");
- input->multiple = YES;
input->description= _("Names of satellite ETa layers [mm/d or cm/d]");
- input1 = G_define_standard_option(G_OPT_R_INPUT) ;
+ input1 = G_define_standard_option(G_OPT_R_INPUTS) ;
input1->key =_("eta_doy");
- input1->multiple = YES;
input1->description= _("Names of satellite ETa Day of Year (DOY) layers [0-400] [-]");
- input2 = G_define_standard_option(G_OPT_R_INPUT) ;
+ input2 = G_define_standard_option(G_OPT_R_INPUTS) ;
input2->key =_("eto");
- input2->multiple = YES;
input2->description= _("Names of meteorological station ETo layers [0-400] [mm/d or cm/d]");
input3 = G_define_option() ;
@@ -386,7 +383,7 @@
G_free (outrast);
G_close_cell (outfd);
- /* Color table from 0.0 to 1.0 */
+ /* Color table from 0.0 to 10.0 */
G_init_colors(&colors);
G_add_color_rule(0.0,0,0,0,10.0,255,255,255,&colors);
/* Metadata */
More information about the grass-commit
mailing list