[GRASS-SVN] r33013 - in grass-addons/gipe: . i.vi r.evapo.PM
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Aug 22 20:10:57 EDT 2008
Author: ychemin
Date: 2008-08-22 20:10:57 -0400 (Fri, 22 Aug 2008)
New Revision: 33013
Added:
grass-addons/gipe/r.evapo.PM/
grass-addons/gipe/r.evapo.PM/Makefile
grass-addons/gipe/r.evapo.PM/description.html
grass-addons/gipe/r.evapo.PM/functions.c
grass-addons/gipe/r.evapo.PM/local_proto.h
grass-addons/gipe/r.evapo.PM/main.c
Removed:
grass-addons/gipe/Makefile.PM
Modified:
grass-addons/gipe/README
grass-addons/gipe/i.vi/main.c
grass-addons/gipe/install_yanns_grass.sh
grass-addons/gipe/readme.gipe
Log:
more updates
Deleted: grass-addons/gipe/Makefile.PM
===================================================================
--- grass-addons/gipe/Makefile.PM 2008-08-22 23:34:16 UTC (rev 33012)
+++ grass-addons/gipe/Makefile.PM 2008-08-23 00:10:57 UTC (rev 33013)
@@ -1,10 +0,0 @@
-MODULE_TOPDIR = ../..
-
-PGM = r.evapo.PM
-
-LIBES = $(GISLIB)
-DEPENDENCIES = $(GISDEP)
-
-include $(MODULE_TOPDIR)/include/Make/Module.make
-
-default: cmd
Modified: grass-addons/gipe/README
===================================================================
--- grass-addons/gipe/README 2008-08-22 23:34:16 UTC (rev 33012)
+++ grass-addons/gipe/README 2008-08-23 00:10:57 UTC (rev 33013)
@@ -1,3 +1,5 @@
gipe (Grass Image Processing Environment)
Yann Chemin
+
+--see readme.gipe for modules names and short description--
Modified: grass-addons/gipe/i.vi/main.c
===================================================================
--- grass-addons/gipe/i.vi/main.c 2008-08-22 23:34:16 UTC (rev 33012)
+++ grass-addons/gipe/i.vi/main.c 2008-08-23 00:10:57 UTC (rev 33013)
@@ -1,906 +1,536 @@
-/****************************************************************************
- *
- * MODULE: i.vi
- * AUTHOR(S): Baburao Kamble baburaokamble at gmail.com
- * Yann Chemin - ychemin at gmail.com
- * PURPOSE: Calculates 14 vegetation indices
- * based on biophysical parameters.
- *
- * COPYRIGHT: (C) 2002-2006 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
- * for details.
- *
- * Remark:
- * These are generic indices that use red and nir for most of them.
- * Those can be any use by standard satellite having V and IR.
- * However arvi uses red, nir and blue;
- * GVI uses B,G,R,NIR, chan5 and chan 7 of landsat;
- * and GARI uses B,G,R and NIR.
- *
- * Changelog: Added EVI on 20080718 (Yann)
- *
+/****************************************************************************
+ *
+ * MODULE: i.vi
+ * AUTHOR(S): Baburao Kamble baburaokamble at gmail.com
+ * Yann Chemin - ychemin at gmail.com
+ * PURPOSE: Calculates 14 vegetation indices
+ * based on biophysical parameters.
+ *
+ * COPYRIGHT: (C) 2002-2006 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
+ * for details.
+ *
+ * Remark:
+ * These are generic indices that use red and nir for most of them.
+ * Those can be any use by standard satellite having V and IR.
+ * However arvi uses red, nir and blue;
+ * GVI uses B,G,R,NIR, chan5 and chan 7 of landsat;
+ * and GARI uses B,G,R and NIR.
+ *
+ * Changelog: Added EVI on 20080718 (Yann)
+ *
*****************************************************************************/
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <grass/gis.h>
-#include <grass/glocale.h>
-
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <grass/gis.h>
+#include <grass/glocale.h>
double s_r(double redchan, double nirchan);
-
double nd_vi(double redchan, double nirchan);
-
double ip_vi(double redchan, double nirchan);
-
double d_vi(double redchan, double nirchan);
-
double e_vi(double bluechan, double redchan, double nirchan);
-
double p_vi(double redchan, double nirchan);
-
double wd_vi(double redchan, double nirchan);
-
double sa_vi(double redchan, double nirchan);
-
double msa_vi(double redchan, double nirchan);
-
double msa_vi2(double redchan, double nirchan);
-
double ge_mi(double redchan, double nirchan);
-
double ar_vi(double redchan, double nirchan, double bluechan);
-
double g_vi(double bluechan, double greenchan, double redchan,
double nirchan, double chan5chan, double chan7chan);
-
double ga_ri(double redchan, double nirchan, double bluechan,
double greenchan);
-
-
-int main(int argc, char *argv[])
+int main(int argc, char *argv[])
{
-
-struct Cell_head cellhd; /*region+header info */
+ struct Cell_head cellhd; /*region+header info */
-
-char *mapset; /*mapset name */
+ char *mapset; /*mapset name */
-
-int nrows, ncols;
+ int nrows, ncols;
-
-int row, col;
+ int row, col;
-
-
-char *viflag; /*Switch for particular index */
+ char *viflag; /*Switch for particular index */
-
-
-struct GModule *module;
+ struct GModule *module;
-
-struct Option *input1, *input2, *input3, *input4, *input5, *input6,
+ struct Option *input1, *input2, *input3, *input4, *input5, *input6,
*input7, *output;
-
-
-struct Flag *flag1;
+ struct Flag *flag1;
-
-struct History history; /*metadata */
+ struct History history; /*metadata */
-
-struct Colors colors; /*Color rules */
+ struct Colors colors; /*Color rules */
-
+
- /************************************/
- /* FMEO Declarations**************** */
+ /************************************/
+ /* FMEO Declarations**************** */
char *name; /*input raster name */
-
-char *result; /*output raster name */
+ char *result; /*output raster name */
-
- /*File Descriptors */
+
+ /*File Descriptors */
int infd_redchan, infd_nirchan, infd_greenchan;
-
-int infd_bluechan, infd_chan5chan, infd_chan7chan;
+ int infd_bluechan, infd_chan5chan, infd_chan7chan;
-
-int outfd;
+ int outfd;
-
-
-char *bluechan, *greenchan, *redchan, *nirchan, *chan5chan, *chan7chan;
+ char *bluechan, *greenchan, *redchan, *nirchan, *chan5chan, *chan7chan;
-
-
-int i = 0, j = 0;
+ int i = 0, j = 0;
-
-
-void *inrast_redchan, *inrast_nirchan, *inrast_greenchan;
+ void *inrast_redchan, *inrast_nirchan, *inrast_greenchan;
-
-void *inrast_bluechan, *inrast_chan5chan, *inrast_chan7chan;
+ void *inrast_bluechan, *inrast_chan5chan, *inrast_chan7chan;
-
-DCELL * outrast;
-
-RASTER_MAP_TYPE data_type_output = DCELL_TYPE;
-
-RASTER_MAP_TYPE data_type_redchan;
-
-RASTER_MAP_TYPE data_type_nirchan;
-
-RASTER_MAP_TYPE data_type_greenchan;
-
-RASTER_MAP_TYPE data_type_bluechan;
-
-RASTER_MAP_TYPE data_type_chan5chan;
-
-RASTER_MAP_TYPE data_type_chan7chan;
-
-
+ DCELL * outrast;
+ RASTER_MAP_TYPE data_type_output = DCELL_TYPE;
+ RASTER_MAP_TYPE data_type_redchan;
+ RASTER_MAP_TYPE data_type_nirchan;
+ RASTER_MAP_TYPE data_type_greenchan;
+ RASTER_MAP_TYPE data_type_bluechan;
+ RASTER_MAP_TYPE data_type_chan5chan;
+ RASTER_MAP_TYPE data_type_chan7chan;
+
- /************************************/
+ /************************************/
G_gisinit(argv[0]);
-
-
-module = G_define_module();
-
-module->keywords = _("vegetation index, biophysical parameters");
-
-module->description =
+ module = G_define_module();
+ module->keywords = _("vegetation index, biophysical parameters");
+ module->description =
_("14 types of vegetation indices from red and nir, and only some requiring additional bands");
-
-
- /* Define the different options */
+
+ /* Define the different options */
input1 = G_define_option();
-
-input1->key = _("viname");
-
-input1->type = TYPE_STRING;
-
-input1->required = YES;
-
-input1->gisprompt = _("Name of VI");
-
-input1->description =
+ input1->key = _("viname");
+ input1->type = TYPE_STRING;
+ input1->required = YES;
+ input1->gisprompt = _("Name of VI");
+ input1->description =
_("Name of VI: sr,ndvi,ipvi,dvi,evi,pvi,wdvi,savi,msavi,msavi2,gemi,arvi,gvi,gari.");
-
-input1->answer = _("ndvi");
-
-
-input2 = G_define_standard_option(G_OPT_R_INPUT);
-
-input2->key = _("red");
-
-input2->description =
+ input1->answer = _("ndvi");
+ input2 = G_define_standard_option(G_OPT_R_INPUT);
+ input2->key = _("red");
+ input2->description =
_("Name of the RED Channel surface reflectance map [0.0;1.0]");
-
-input2->answer = _("redchan");
-
-
-input3 = G_define_standard_option(G_OPT_R_INPUT);
-
-input3->key = _("nir");
-
-input3->description =
+ input2->answer = _("redchan");
+ input3 = G_define_standard_option(G_OPT_R_INPUT);
+ input3->key = _("nir");
+ input3->description =
_("Name of the NIR Channel surface reflectance map [0.0;1.0]");
-
-input3->answer = _("nirchan");
-
-
-input4 = G_define_standard_option(G_OPT_R_INPUT);
-
-input4->key = _("green");
-
-input4->required = NO;
-
-input4->description =
+ input3->answer = _("nirchan");
+ input4 = G_define_standard_option(G_OPT_R_INPUT);
+ input4->key = _("green");
+ input4->required = NO;
+ input4->description =
_("Name of the GREEN Channel surface reflectance map [0.0;1.0]");
-
-
-input5 = G_define_standard_option(G_OPT_R_INPUT);
-
-input5->key = _("blue");
-
-input5->required = NO;
-
-input5->description =
+ input5 = G_define_standard_option(G_OPT_R_INPUT);
+ input5->key = _("blue");
+ input5->required = NO;
+ input5->description =
_("Name of the BLUE Channel surface reflectance map [0.0;1.0]");
-
-
-input6 = G_define_standard_option(G_OPT_R_INPUT);
-
-input6->key = _("chan5");
-
-input6->required = NO;
-
-input6->description =
+ input6 = G_define_standard_option(G_OPT_R_INPUT);
+ input6->key = _("chan5");
+ input6->required = NO;
+ input6->description =
_("Name of the CHAN5 Channel surface reflectance map [0.0;1.0]");
-
-
-input7 = G_define_standard_option(G_OPT_R_INPUT);
-
-input7->key = _("chan7");
-
-input7->required = NO;
-
-input7->description =
+ input7 = G_define_standard_option(G_OPT_R_INPUT);
+ input7->key = _("chan7");
+ input7->required = NO;
+ input7->description =
_("Name of the CHAN7 Channel surface reflectance map [0.0;1.0]");
-
-
-output = G_define_standard_option(G_OPT_R_OUTPUT);
-
-output->key = _("vi");
-
-output->required = YES;
-
-output->description = _("Name of the output vi layer");
-
-output->answer = _("vi");
-
-
+ output = G_define_standard_option(G_OPT_R_OUTPUT);
+ output->key = _("vi");
+ output->required = YES;
+ output->description = _("Name of the output vi layer");
+ output->answer = _("vi");
+
- /********************/
+ /********************/
if (G_parser(argc, argv))
-
-exit(EXIT_FAILURE);
-
-viflag = input1->answer;
-
-redchan = input2->answer;
-
-nirchan = input3->answer;
-
-greenchan = input4->answer;
-
-bluechan = input5->answer;
-
-chan5chan = input6->answer;
-
-chan7chan = input7->answer;
-
-
-result = output->answer;
-
+ exit(EXIT_FAILURE);
+ viflag = input1->answer;
+ redchan = input2->answer;
+ nirchan = input3->answer;
+ greenchan = input4->answer;
+ bluechan = input5->answer;
+ chan5chan = input6->answer;
+ chan7chan = input7->answer;
+ result = output->answer;
+
- /***************************************************/
+ /***************************************************/
mapset = G_find_cell2(redchan, "");
-
-if (mapset == NULL) {
-
-G_fatal_error(_("cell file [%s] not found"), redchan);
-
-}
-
-data_type_redchan = G_raster_map_type(redchan, mapset);
-
-if ((infd_redchan = G_open_cell_old(redchan, mapset)) < 0)
-
-G_fatal_error(_("Cannot open cell file [%s]"), redchan);
-
-if (G_get_cellhd(redchan, mapset, &cellhd) < 0)
-
-G_fatal_error(_("Cannot read file header of [%s])"), redchan);
-
-inrast_redchan = G_allocate_raster_buf(data_type_redchan);
-
+ if (mapset == NULL) {
+ G_fatal_error(_("cell file [%s] not found"), redchan);
+ }
+ data_type_redchan = G_raster_map_type(redchan, mapset);
+ if ((infd_redchan = G_open_cell_old(redchan, mapset)) < 0)
+ G_fatal_error(_("Cannot open cell file [%s]"), redchan);
+ if (G_get_cellhd(redchan, mapset, &cellhd) < 0)
+ G_fatal_error(_("Cannot read file header of [%s])"), redchan);
+ inrast_redchan = G_allocate_raster_buf(data_type_redchan);
+
- /***************************************************/
+ /***************************************************/
mapset = G_find_cell2(nirchan, "");
-
-if (mapset == NULL) {
-
-G_fatal_error(_("cell file [%s] not found"), nirchan);
-
-}
-
-data_type_nirchan = G_raster_map_type(nirchan, mapset);
-
-if ((infd_nirchan = G_open_cell_old(nirchan, mapset)) < 0)
-
-G_fatal_error(_("Cannot open cell file [%s]"), nirchan);
-
-if (G_get_cellhd(nirchan, mapset, &cellhd) < 0)
-
-G_fatal_error(_("Cannot read file header of [%s]"), nirchan);
-
-inrast_nirchan = G_allocate_raster_buf(data_type_nirchan);
-
+ if (mapset == NULL) {
+ G_fatal_error(_("cell file [%s] not found"), nirchan);
+ }
+ data_type_nirchan = G_raster_map_type(nirchan, mapset);
+ if ((infd_nirchan = G_open_cell_old(nirchan, mapset)) < 0)
+ G_fatal_error(_("Cannot open cell file [%s]"), nirchan);
+ if (G_get_cellhd(nirchan, mapset, &cellhd) < 0)
+ G_fatal_error(_("Cannot read file header of [%s]"), nirchan);
+ inrast_nirchan = G_allocate_raster_buf(data_type_nirchan);
+
- /***************************************************/
+ /***************************************************/
if (greenchan) {
-
-mapset = G_find_cell2(greenchan, "");
-
-if (mapset == NULL) {
-
-G_fatal_error(_("cell file [%s] not found"), greenchan);
-
-}
-
-data_type_greenchan = G_raster_map_type(greenchan, mapset);
-
-if ((infd_greenchan = G_open_cell_old(greenchan, mapset)) < 0)
-
-G_fatal_error(_("Cannot open cell file [%s]"), greenchan);
-
-if (G_get_cellhd(greenchan, mapset, &cellhd) < 0)
-
-G_fatal_error(_("Cannot read file header of [%s])"), greenchan);
-
-inrast_greenchan = G_allocate_raster_buf(data_type_greenchan);
-
-}
-
+ mapset = G_find_cell2(greenchan, "");
+ if (mapset == NULL) {
+ G_fatal_error(_("cell file [%s] not found"), greenchan);
+ }
+ data_type_greenchan = G_raster_map_type(greenchan, mapset);
+ if ((infd_greenchan = G_open_cell_old(greenchan, mapset)) < 0)
+ G_fatal_error(_("Cannot open cell file [%s]"), greenchan);
+ if (G_get_cellhd(greenchan, mapset, &cellhd) < 0)
+ G_fatal_error(_("Cannot read file header of [%s])"), greenchan);
+ inrast_greenchan = G_allocate_raster_buf(data_type_greenchan);
+ }
+
- /***************************************************/
+ /***************************************************/
if (bluechan) {
-
-mapset = G_find_cell2(bluechan, "");
-
-if (mapset == NULL) {
-
-G_fatal_error(_("cell file [%s] not found"), bluechan);
-
-}
-
-data_type_bluechan = G_raster_map_type(bluechan, mapset);
-
-if ((infd_bluechan = G_open_cell_old(bluechan, mapset)) < 0)
-
-G_fatal_error(_("Cannot open cell file [%s]"), bluechan);
-
-if (G_get_cellhd(bluechan, mapset, &cellhd) < 0)
-
-G_fatal_error(_("Cannot read file header of [%s])"), bluechan);
-
-inrast_bluechan = G_allocate_raster_buf(data_type_bluechan);
-
-}
-
+ mapset = G_find_cell2(bluechan, "");
+ if (mapset == NULL) {
+ G_fatal_error(_("cell file [%s] not found"), bluechan);
+ }
+ data_type_bluechan = G_raster_map_type(bluechan, mapset);
+ if ((infd_bluechan = G_open_cell_old(bluechan, mapset)) < 0)
+ G_fatal_error(_("Cannot open cell file [%s]"), bluechan);
+ if (G_get_cellhd(bluechan, mapset, &cellhd) < 0)
+ G_fatal_error(_("Cannot read file header of [%s])"), bluechan);
+ inrast_bluechan = G_allocate_raster_buf(data_type_bluechan);
+ }
+
- /***************************************************/
+ /***************************************************/
if (chan5chan) {
-
-mapset = G_find_cell2(chan5chan, "");
-
-if (mapset == NULL) {
-
-G_fatal_error(_("cell file [%s] not found"), chan5chan);
-
-}
-
-data_type_chan5chan = G_raster_map_type(chan5chan, mapset);
-
-if ((infd_chan5chan = G_open_cell_old(chan5chan, mapset)) < 0)
-
-G_fatal_error(_("Cannot open cell file [%s]"), chan5chan);
-
-if (G_get_cellhd(chan5chan, mapset, &cellhd) < 0)
-
-G_fatal_error(_("Cannot read file header of [%s])"), chan5chan);
-
-inrast_chan5chan = G_allocate_raster_buf(data_type_chan5chan);
-
-}
-
+ mapset = G_find_cell2(chan5chan, "");
+ if (mapset == NULL) {
+ G_fatal_error(_("cell file [%s] not found"), chan5chan);
+ }
+ data_type_chan5chan = G_raster_map_type(chan5chan, mapset);
+ if ((infd_chan5chan = G_open_cell_old(chan5chan, mapset)) < 0)
+ G_fatal_error(_("Cannot open cell file [%s]"), chan5chan);
+ if (G_get_cellhd(chan5chan, mapset, &cellhd) < 0)
+ G_fatal_error(_("Cannot read file header of [%s])"), chan5chan);
+ inrast_chan5chan = G_allocate_raster_buf(data_type_chan5chan);
+ }
+
- /***************************************************/
+ /***************************************************/
if (chan7chan) {
-
-mapset = G_find_cell2(chan7chan, "");
-
-if (mapset == NULL) {
-
-G_fatal_error(_("cell file [%s] not found"), chan7chan);
-
-}
-
-data_type_chan7chan = G_raster_map_type(chan7chan, mapset);
-
-if ((infd_chan7chan = G_open_cell_old(chan7chan, mapset)) < 0)
-
-G_fatal_error(_("Cannot open cell file [%s]"), chan7chan);
-
-if (G_get_cellhd(chan7chan, mapset, &cellhd) < 0)
-
-G_fatal_error(_("Cannot read file header of [%s])"), chan7chan);
-
-inrast_chan7chan = G_allocate_raster_buf(data_type_chan7chan);
-
-}
-
+ mapset = G_find_cell2(chan7chan, "");
+ if (mapset == NULL) {
+ G_fatal_error(_("cell file [%s] not found"), chan7chan);
+ }
+ data_type_chan7chan = G_raster_map_type(chan7chan, mapset);
+ if ((infd_chan7chan = G_open_cell_old(chan7chan, mapset)) < 0)
+ G_fatal_error(_("Cannot open cell file [%s]"), chan7chan);
+ if (G_get_cellhd(chan7chan, mapset, &cellhd) < 0)
+ G_fatal_error(_("Cannot read file header of [%s])"), chan7chan);
+ inrast_chan7chan = G_allocate_raster_buf(data_type_chan7chan);
+ }
+
- /***************************************************/
-
-G_debug(3, "number of rows %d", cellhd.rows);
-
-nrows = G_window_rows();
-
-ncols = G_window_cols();
-
-outrast = G_allocate_raster_buf(data_type_output);
-
- /* Create New raster files */
+ /***************************************************/
+ G_debug(3, "number of rows %d", cellhd.rows);
+ nrows = G_window_rows();
+ ncols = G_window_cols();
+ outrast = G_allocate_raster_buf(data_type_output);
+
+ /* Create New raster files */
if ((outfd = G_open_raster_new(result, data_type_output)) < 0)
-
-G_fatal_error(_("Could not open <%s>"), result);
-
- /* Process pixels */
+ G_fatal_error(_("Could not open <%s>"), result);
+
+ /* Process pixels */
for (row = 0; row < nrows; row++)
-
- {
-
-DCELL d;
-
-DCELL d_bluechan;
-
-DCELL d_greenchan;
-
-DCELL d_redchan;
-
-DCELL d_nirchan;
-
-DCELL d_chan5chan;
-
-DCELL d_chan7chan;
-
-G_percent(row, nrows, 2);
-
-if (G_get_raster_row
+ {
+ DCELL d;
+ DCELL d_bluechan;
+ DCELL d_greenchan;
+ DCELL d_redchan;
+ DCELL d_nirchan;
+ DCELL d_chan5chan;
+ DCELL d_chan7chan;
+ G_percent(row, nrows, 2);
+ if (G_get_raster_row
(infd_redchan, inrast_redchan, row, data_type_redchan) < 0)
-
-G_fatal_error(_("Could not read from <%s>"), redchan);
-
-if (G_get_raster_row
+ G_fatal_error(_("Could not read from <%s>"), redchan);
+ if (G_get_raster_row
(infd_nirchan, inrast_nirchan, row, data_type_nirchan) < 0)
-
-G_fatal_error(_("Could not read from <%s>"), nirchan);
-
-if (greenchan) {
-
-if (G_get_raster_row
+ G_fatal_error(_("Could not read from <%s>"), nirchan);
+ if (greenchan) {
+ if (G_get_raster_row
(infd_greenchan, inrast_greenchan, row,
data_type_greenchan) < 0)
-
-G_fatal_error(_("Could not read from <%s>"), greenchan);
-
-}
-
-if (bluechan) {
-
-if (G_get_raster_row
+ G_fatal_error(_("Could not read from <%s>"), greenchan);
+ }
+ if (bluechan) {
+ if (G_get_raster_row
(infd_bluechan, inrast_bluechan, row,
data_type_bluechan) < 0)
-
-G_fatal_error(_("Could not read from <%s>"), bluechan);
-
-}
-
-if (chan5chan) {
-
-if (G_get_raster_row
+ G_fatal_error(_("Could not read from <%s>"), bluechan);
+ }
+ if (chan5chan) {
+ if (G_get_raster_row
(infd_chan5chan, inrast_chan5chan, row,
data_type_chan5chan) < 0)
-
-G_fatal_error(_("Could not read from <%s>"), chan5chan);
-
-}
-
-if (chan7chan) {
-
-if (G_get_raster_row
+ G_fatal_error(_("Could not read from <%s>"), chan5chan);
+ }
+ if (chan7chan) {
+ if (G_get_raster_row
(infd_chan7chan, inrast_chan7chan, row,
data_type_chan7chan) < 0)
-
-G_fatal_error(_("Could not read from <%s>"), chan7chan);
-
-}
-
- /*process the data */
+ G_fatal_error(_("Could not read from <%s>"), chan7chan);
+ }
+
+ /*process the data */
for (col = 0; col < ncols; col++)
-
- {
-
-switch (data_type_redchan) {
-
-case CELL_TYPE:
-
-d_redchan = (double)((CELL *) inrast_redchan)[col];
-
-break;
-
-case FCELL_TYPE:
-
-d_redchan = (double)((FCELL *) inrast_redchan)[col];
-
-break;
-
-case DCELL_TYPE:
-
-d_redchan = ((DCELL *) inrast_redchan)[col];
-
-break;
-
-}
-
-switch (data_type_nirchan) {
-
-case CELL_TYPE:
-
-d_nirchan = (double)((CELL *) inrast_nirchan)[col];
-
-break;
-
-case FCELL_TYPE:
-
-d_nirchan = (double)((FCELL *) inrast_nirchan)[col];
-
-break;
-
-case DCELL_TYPE:
-
-d_nirchan = ((DCELL *) inrast_nirchan)[col];
-
-break;
-
-}
-
-if (greenchan) {
-
-switch (data_type_greenchan) {
-
-case CELL_TYPE:
-
-d_greenchan = (double)((CELL *) inrast_greenchan)[col];
-
-break;
-
-case FCELL_TYPE:
-
-d_greenchan = (double)((FCELL *) inrast_greenchan)[col];
-
-break;
-
-case DCELL_TYPE:
-
-d_greenchan = ((DCELL *) inrast_greenchan)[col];
-
-break;
-
-}
-
-}
-
-if (bluechan) {
-
-switch (data_type_bluechan) {
-
-case CELL_TYPE:
-
-d_bluechan = (double)((CELL *) inrast_bluechan)[col];
-
-break;
-
-case FCELL_TYPE:
-
-d_bluechan = (double)((FCELL *) inrast_bluechan)[col];
-
-break;
-
-case DCELL_TYPE:
-
-d_bluechan = ((DCELL *) inrast_bluechan)[col];
-
-break;
-
-}
-
-}
-
-if (chan5chan) {
-
-switch (data_type_chan5chan) {
-
-case CELL_TYPE:
-
-d_chan5chan = (double)((CELL *) inrast_chan5chan)[col];
-
-break;
-
-case FCELL_TYPE:
-
-d_chan5chan = (double)((FCELL *) inrast_chan5chan)[col];
-
-break;
-
-case DCELL_TYPE:
-
-d_chan5chan = ((DCELL *) inrast_chan5chan)[col];
-
-break;
-
-}
-
-}
-
-if (chan7chan) {
-
-switch (data_type_chan7chan) {
-
-case CELL_TYPE:
-
-d_chan7chan = (double)((CELL *) inrast_chan7chan)[col];
-
-break;
-
-case FCELL_TYPE:
-
-d_chan7chan = (double)((FCELL *) inrast_chan7chan)[col];
-
-break;
-
-case DCELL_TYPE:
-
-d_chan7chan = ((DCELL *) inrast_chan7chan)[col];
-
-break;
-
-}
-
-}
-
-if (G_is_d_null_value(&d_redchan) ||
-
-G_is_d_null_value(&d_nirchan) ||
-((greenchan) &&
+ {
+ switch (data_type_redchan) {
+ case CELL_TYPE:
+ d_redchan = (double)((CELL *) inrast_redchan)[col];
+ break;
+ case FCELL_TYPE:
+ d_redchan = (double)((FCELL *) inrast_redchan)[col];
+ break;
+ case DCELL_TYPE:
+ d_redchan = ((DCELL *) inrast_redchan)[col];
+ break;
+ }
+ switch (data_type_nirchan) {
+ case CELL_TYPE:
+ d_nirchan = (double)((CELL *) inrast_nirchan)[col];
+ break;
+ case FCELL_TYPE:
+ d_nirchan = (double)((FCELL *) inrast_nirchan)[col];
+ break;
+ case DCELL_TYPE:
+ d_nirchan = ((DCELL *) inrast_nirchan)[col];
+ break;
+ }
+ if (greenchan) {
+ switch (data_type_greenchan) {
+ case CELL_TYPE:
+ d_greenchan = (double)((CELL *) inrast_greenchan)[col];
+ break;
+ case FCELL_TYPE:
+ d_greenchan = (double)((FCELL *) inrast_greenchan)[col];
+ break;
+ case DCELL_TYPE:
+ d_greenchan = ((DCELL *) inrast_greenchan)[col];
+ break;
+ }
+ }
+ if (bluechan) {
+ switch (data_type_bluechan) {
+ case CELL_TYPE:
+ d_bluechan = (double)((CELL *) inrast_bluechan)[col];
+ break;
+ case FCELL_TYPE:
+ d_bluechan = (double)((FCELL *) inrast_bluechan)[col];
+ break;
+ case DCELL_TYPE:
+ d_bluechan = ((DCELL *) inrast_bluechan)[col];
+ break;
+ }
+ }
+ if (chan5chan) {
+ switch (data_type_chan5chan) {
+ case CELL_TYPE:
+ d_chan5chan = (double)((CELL *) inrast_chan5chan)[col];
+ break;
+ case FCELL_TYPE:
+ d_chan5chan = (double)((FCELL *) inrast_chan5chan)[col];
+ break;
+ case DCELL_TYPE:
+ d_chan5chan = ((DCELL *) inrast_chan5chan)[col];
+ break;
+ }
+ }
+ if (chan7chan) {
+ switch (data_type_chan7chan) {
+ case CELL_TYPE:
+ d_chan7chan = (double)((CELL *) inrast_chan7chan)[col];
+ break;
+ case FCELL_TYPE:
+ d_chan7chan = (double)((FCELL *) inrast_chan7chan)[col];
+ break;
+ case DCELL_TYPE:
+ d_chan7chan = ((DCELL *) inrast_chan7chan)[col];
+ break;
+ }
+ }
+ if (G_is_d_null_value(&d_redchan) ||
+ G_is_d_null_value(&d_nirchan) || ((greenchan) &&
G_is_d_null_value
(&d_greenchan)) ||
-
-((bluechan) && G_is_d_null_value(&d_bluechan)) ||
-
-((chan5chan) && G_is_d_null_value(&d_chan5chan)) ||
-
-((chan7chan) && G_is_d_null_value(&d_chan7chan))) {
-
-G_set_d_null_value(&outrast[col], 1);
-
-}
+ ((bluechan) && G_is_d_null_value(&d_bluechan)) ||
+ ((chan5chan) && G_is_d_null_value(&d_chan5chan)) ||
+ ((chan7chan) && G_is_d_null_value(&d_chan7chan))) {
+ G_set_d_null_value(&outrast[col], 1);
+ }
else {
-
+
- /************************************/
- /*calculate simple_ratio */
+ /************************************/
+ /*calculate simple_ratio */
if (!strcoll(viflag, "sr")) {
-
-d = s_r(d_redchan, d_nirchan);
-
-((DCELL *) outrast)[col] = d;
-
-}
-
- /*calculate ndvi */
+ d = s_r(d_redchan, d_nirchan);
+ ((DCELL *) outrast)[col] = d;
+ }
+
+ /*calculate ndvi */
if (!strcoll(viflag, "ndvi")) {
-
-if (d_redchan + d_nirchan < 0.001) {
-
-G_set_d_null_value(&outrast[col], 1);
-
-}
+ if (d_redchan + d_nirchan < 0.001) {
+ G_set_d_null_value(&outrast[col], 1);
+ }
else {
-
-d = nd_vi(d_redchan, d_nirchan);
-
-((DCELL *) outrast)[col] = d;
-
-}
-
-}
-
- /*calculate ipvi */
+ d = nd_vi(d_redchan, d_nirchan);
+ ((DCELL *) outrast)[col] = d;
+ }
+ }
+
+ /*calculate ipvi */
if (!strcoll(viflag, "ipvi")) {
-
-d = ip_vi(d_redchan, d_nirchan);
-
-((DCELL *) outrast)[col] = d;
-
-}
-
- /*calculate dvi */
+ d = ip_vi(d_redchan, d_nirchan);
+ ((DCELL *) outrast)[col] = d;
+ }
+
+ /*calculate dvi */
if (!strcoll(viflag, "dvi")) {
-
-d = d_vi(d_redchan, d_nirchan);
-
-((DCELL *) outrast)[col] = d;
-
-}
-
- /*calculate evi */
+ d = d_vi(d_redchan, d_nirchan);
+ ((DCELL *) outrast)[col] = d;
+ }
+
+ /*calculate evi */
if (!strcoll(viflag, "evi")) {
-
-d = e_vi(d_bluechan, d_redchan, d_nirchan);
-
-((DCELL *) outrast)[col] = d;
-
-}
-
- /*calculate pvi */
+ d = e_vi(d_bluechan, d_redchan, d_nirchan);
+ ((DCELL *) outrast)[col] = d;
+ }
+
+ /*calculate pvi */
if (!strcoll(viflag, "pvi")) {
-
-d = p_vi(d_redchan, d_nirchan);
-
-((DCELL *) outrast)[col] = d;
-
-}
-
- /*calculate wdvi */
+ d = p_vi(d_redchan, d_nirchan);
+ ((DCELL *) outrast)[col] = d;
+ }
+
+ /*calculate wdvi */
if (!strcoll(viflag, "wdvi")) {
-
-d = wd_vi(d_redchan, d_nirchan);
-
-((DCELL *) outrast)[col] = d;
-
-}
-
- /*calculate savi */
+ d = wd_vi(d_redchan, d_nirchan);
+ ((DCELL *) outrast)[col] = d;
+ }
+
+ /*calculate savi */
if (!strcoll(viflag, "savi")) {
-
-d = sa_vi(d_redchan, d_nirchan);
-
-((DCELL *) outrast)[col] = d;
-
-}
-
- /*calculate msavi */
+ d = sa_vi(d_redchan, d_nirchan);
+ ((DCELL *) outrast)[col] = d;
+ }
+
+ /*calculate msavi */
if (!strcoll(viflag, "msavi")) {
-
-d = msa_vi(d_redchan, d_nirchan);
-
-((DCELL *) outrast)[col] = d;
-
-}
-
- /*calculate msavi2 */
+ d = msa_vi(d_redchan, d_nirchan);
+ ((DCELL *) outrast)[col] = d;
+ }
+
+ /*calculate msavi2 */
if (!strcoll(viflag, "msavi2")) {
-
-d = msa_vi2(d_redchan, d_nirchan);
-
-((DCELL *) outrast)[col] = d;
-
-}
-
- /*calculate gemi */
+ d = msa_vi2(d_redchan, d_nirchan);
+ ((DCELL *) outrast)[col] = d;
+ }
+
+ /*calculate gemi */
if (!strcoll(viflag, "gemi")) {
-
-d = ge_mi(d_redchan, d_nirchan);
-
-((DCELL *) outrast)[col] = d;
-
-}
-
- /*calculate arvi */
+ d = ge_mi(d_redchan, d_nirchan);
+ ((DCELL *) outrast)[col] = d;
+ }
+
+ /*calculate arvi */
if (!strcoll(viflag, "arvi")) {
-
-d = ar_vi(d_redchan, d_nirchan, d_bluechan);
-
-((DCELL *) outrast)[col] = d;
-
-}
-
- /*calculate gvi */
+ d = ar_vi(d_redchan, d_nirchan, d_bluechan);
+ ((DCELL *) outrast)[col] = d;
+ }
+
+ /*calculate gvi */
if (!strcoll(viflag, "gvi")) {
-
-d = g_vi(d_bluechan, d_greenchan, d_redchan, d_nirchan,
+ d = g_vi(d_bluechan, d_greenchan, d_redchan, d_nirchan,
d_chan5chan, d_chan7chan);
-
-((DCELL *) outrast)[col] = d;
-
-}
-
- /*calculate gari */
+ ((DCELL *) outrast)[col] = d;
+ }
+
+ /*calculate gari */
if (!strcoll(viflag, "gari")) {
-
-d = ga_ri(d_redchan, d_nirchan, d_bluechan, d_greenchan);
-
-((DCELL *) outrast)[col] = d;
-
-}
-
-}
-
-}
-
-if (G_put_raster_row(outfd, outrast, data_type_output) < 0)
-
-G_fatal_error(_("Cannot write to output raster file"));
-
-}
-
-
-
-G_free(inrast_redchan);
-
-G_close_cell(infd_redchan);
-
-G_free(inrast_nirchan);
-
-G_close_cell(infd_nirchan);
-
-if (greenchan) {
-
-G_free(inrast_greenchan);
-
-G_close_cell(infd_greenchan);
-
-}
-
-if (bluechan) {
-
-G_free(inrast_bluechan);
-
-G_close_cell(infd_bluechan);
-
-}
-
-if (chan5chan) {
-
-G_free(inrast_chan5chan);
-
-G_close_cell(infd_chan5chan);
-
-}
-
-if (chan7chan) {
-
-G_free(inrast_chan7chan);
-
-G_close_cell(infd_chan7chan);
-
-}
-
-G_free(outrast);
-
-G_close_cell(outfd);
-
-
- /* Color from -1.0 to +1.0 in grey */
+ d = ga_ri(d_redchan, d_nirchan, d_bluechan, d_greenchan);
+ ((DCELL *) outrast)[col] = d;
+ }
+ }
+ }
+ if (G_put_raster_row(outfd, outrast, data_type_output) < 0)
+ G_fatal_error(_("Cannot write to output raster file"));
+ }
+ G_free(inrast_redchan);
+ G_close_cell(infd_redchan);
+ G_free(inrast_nirchan);
+ G_close_cell(infd_nirchan);
+ if (greenchan) {
+ G_free(inrast_greenchan);
+ G_close_cell(infd_greenchan);
+ }
+ if (bluechan) {
+ G_free(inrast_bluechan);
+ G_close_cell(infd_bluechan);
+ }
+ if (chan5chan) {
+ G_free(inrast_chan5chan);
+ G_close_cell(infd_chan5chan);
+ }
+ if (chan7chan) {
+ G_free(inrast_chan7chan);
+ G_close_cell(infd_chan7chan);
+ }
+ G_free(outrast);
+ G_close_cell(outfd);
+
+ /* Color from -1.0 to +1.0 in grey */
G_init_colors(&colors);
-
-G_add_color_rule(-1.0, 0, 0, 0, 1.0, 255, 255, 255, &colors);
-
-G_short_history(result, "raster", &history);
-
-G_command_history(&history);
-
-G_write_history(result, &history);
-
-
-exit(EXIT_SUCCESS);
-
+ G_add_color_rule(-1.0, 0, 0, 0, 1.0, 255, 255, 255, &colors);
+ G_short_history(result, "raster", &history);
+ G_command_history(&history);
+ G_write_history(result, &history);
+ exit(EXIT_SUCCESS);
}
-
-
+
Modified: grass-addons/gipe/install_yanns_grass.sh
===================================================================
--- grass-addons/gipe/install_yanns_grass.sh 2008-08-22 23:34:16 UTC (rev 33012)
+++ grass-addons/gipe/install_yanns_grass.sh 2008-08-23 00:10:57 UTC (rev 33013)
@@ -10,7 +10,7 @@
# This Assumes you start in GIPE directory
GIPEDIR=$ADDONSVNDIR/gipe
-HFDIR=$ADDONSVNDIR/HydroFOSS
+#HFDIR=$ADDONSVNDIR/HydroFOSS
RSTDIR=$ADDONSVNDIR/raster
#INSTALL MODULES
@@ -21,18 +21,18 @@
cp -rf $GIPEDIR/$directory $GRASSCVSDIR/raster/
done
-cd $HFDIR/
-for directory in r.*
-do
- cp -rf $HFDIR/$directory $GRASSCVSDIR/raster/
-done
-cp -rf $GIPEDIR/Makefile.PM $GRASSCVSDIR/raster/r.evapo.PM/Makefile
+#cd $HFDIR/
+#for directory in r.*
+#do
+# cp -rf $HFDIR/$directory $GRASSCVSDIR/raster/
+#done
+#cp -rf $GIPEDIR/Makefile.PM $GRASSCVSDIR/raster/r.evapo.PM/Makefile
-cd $RSTDIR/
-for directory in r.inund.fluv*
-do
- cp -rf $RSTDIR/$directory $GRASSCVSDIR/raster/
-done
+#cd $RSTDIR/
+#for directory in r.inund.fluv*
+#do
+# cp -rf $RSTDIR/$directory $GRASSCVSDIR/raster/
+#done
cp -f $GIPEDIR/Makefile.raster $GRASSCVSDIR/raster/Makefile.gipe
cd $GRASSCVSDIR/raster/
@@ -64,10 +64,10 @@
#END IMAGERY STUFF
#Install m.gem in /scripts
-cp -rf $GIPEDIR/m.gem $GRASSCVSDIR/scripts/
-cp -f $GIPEDIR/Makefile.scripts $GRASSCVSDIR/scripts/Makefile.gipe
-cd $GRASSCVSDIR/scripts/
-make -f Makefile.scripts
+#cp -rf $GIPEDIR/m.gem $GRASSCVSDIR/scripts/
+#cp -f $GIPEDIR/Makefile.scripts $GRASSCVSDIR/scripts/Makefile.gipe
+#cd $GRASSCVSDIR/scripts/
+#make -f Makefile.scripts
#Install GUI stuff
cp -rf $GIPEDIR/gmmenu.tcl $GRASSCVSDIR/gui/tcltk/gis.m/
Added: grass-addons/gipe/r.evapo.PM/Makefile
===================================================================
--- grass-addons/gipe/r.evapo.PM/Makefile (rev 0)
+++ grass-addons/gipe/r.evapo.PM/Makefile 2008-08-23 00:10:57 UTC (rev 33013)
@@ -0,0 +1,10 @@
+MODULE_TOPDIR = ../..
+
+PGM = r.evapo.PM
+
+LIBES = $(GISLIB)
+DEPENDENCIES = $(GISDEP)
+
+include $(MODULE_TOPDIR)/include/Make/Module.make
+
+default: cmd
Added: grass-addons/gipe/r.evapo.PM/description.html
===================================================================
--- grass-addons/gipe/r.evapo.PM/description.html (rev 0)
+++ grass-addons/gipe/r.evapo.PM/description.html 2008-08-23 00:10:57 UTC (rev 33013)
@@ -0,0 +1,167 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<title>r.evapo.PM</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<link rel="stylesheet" href="grassdocs.css" type="text/css">
+</head>
+<body bgcolor="white">
+
+<img src="grass.smlogo.gif" alt="GRASS logo"><hr align=center size=6 noshade>
+
+<H2>NAME</H2> <B><I>r.evapo.PM </I></B>- computation of <i>potential evapotranspiration</i> [mm/h] for hourly time step.
+
+<P><I>(GRASS Raster Program)</I>
+
+<H2>SYNOPSIS</H2>
+<B>r.evapo.PM</B>
+<BR>
+<B>r.evapo.PM</B> help</br>
+<BR>
+
+<B>r.evapo.PM</b> <b>[ -qzn ]</b>
+
+<b>DEM</b>=name
+<b>T</b>=name
+<b>RH</b>=name
+<b>WS</b>=name
+<b>NSR</b>=name
+<b>Vh</b>=name
+<b>ETP</b>=name
+
+<H2>DESCRIPTION</H2>
+
+<p><EM>r.evapo.PM</EM> given the vegetation height (hc), humidity (RU),
+wind speed at two meters height (WS), temperature (T), digital terrain model (DEM),
+and net radiation (NSR) raster input maps,
+calculates the potential evapotranspiration map (EPo).
+
+<p>Optionally the user can activate a flag (-z)
+that allows him setting to zero all of the negative evapotranspiration cells;
+in fact these negative values motivated by the condensation of the air water
+vapour content, are sometime undesired because they can produce computational
+problems. The usage of the flag -n detect that the module is run in night hours
+and the appropriate soil heat flux is calculated.
+
+<p>The algorithm implements well known approaches: the hourly Penman-Monteith method as presented in Allen et al. (1998) for land surfaces and the Penman method (Penman, 1948) for water surfaces.<br>
+
+<p>Land and water surfaces are idenfyied by Vh:<br>
+- where Vh>0 vegetation is present and evapotranspiration is calculated;<br>
+- where Vh=0 bare ground is present and evapotranspiration is calculated;<br>
+- where Vh<0 water surface is present and evaporation is calculated;<br>
+
+<p>For more details on the algorithms see [1,2,3].
+
+
+<H2>OPTIONS</H2>
+
+The program will run non-interactively if the user specifies program
+arguments and flag settings on the command line using the following
+form:
+
+<P><B>r.evapo.PM</b> <b>[ -qzd ]</b>
+<b>DEM</b>=name
+<b>T</b>=name
+<b>RH</b>=name
+<b>WS</b>=name
+<b>NSR</b>=name
+<b>Vh</b>=name
+<b>ETP</b>=name
+
+
+
+<P>Alternatively, the user can simply type <EM>r.evapo.PM</EM> on the
+command line and the program will ask for parameter values and flag
+settings interactively, using the standard GRASS parser interface.
+
+
+<H3>Flags:</H3>
+<dl>
+ <dt><B>-q</B>
+ <dd>Run quietly (do not display status messages). By default
+ <EM>r.evapo.PM</EM> is run verbosely.
+ <dt><B>-z</B>
+ <dd>Set negative calculated evapotranspiration values to zero.
+ <dt><B>-n</B>
+ <dd>Calculate soil heat flux for night time. By default
+ <EM>r.evapo.PM</EM> calculate it for day time.
+</dl>
+
+
+<H3>Parameters:</H3>
+<dl>
+ <dt><B>DEM</B>=<I>name</I>
+ <dd>Input elevation raster [m a.s.l.]. Required.</dd>
+
+ <dt><b>T</b>=<I>name</I>
+ <dd>Input temperature raster [°C]. Required.</dd>
+
+ <dt><b>RH</b> =<I>name</I>
+ <dd>Input relative humidity raster [%]. Required.</dd>
+
+ <dt><b>WS</b> =<I>name</I>
+ <dd>Input wind speed at two meters raster [m/s]. Required.</dd>
+
+ <dt><b>NSR</b> =<I>name</I>
+ <dd>Input net solar radiation raster [MJ/(m2*h)]. Required.</dd>
+
+ <dt><b>Vh</b> =<I>name</I>
+ <dd>Input vegetation heigth raster [m]. Required.</dd>
+
+ <dt><b>ETP</b> =<I>name</I>
+ <dd>Output evapotranspiration raster [mm/h]. Required.</dd>
+
+</dl>
+
+
+<H2>NOTES</H2>
+
+<p>Net solar radiation map in MJ/(m2*h) can be computed from the combination of the r.sun ,
+run in mode 1, and the r.mapcalc commands.
+
+<p>The sum of the three radiation components outputted by r.sun (beam, diffuse, and reflected)
+multiplied by the Wh->Mj conversion factor (0.0036) and optionally by a
+clear sky factor [0-1] allows the generation of a map to be used as
+an NSR input for the <EM>r.evapo.PM</EM> command.
+<dt>example:
+<br><dd>r.sun -s elevin=dem aspin=aspect slopein=slope lin=2 albedo=alb_Mar incidout=out beam_rad=beam diff_rad=diffuse refl_rad=reflected day=73 time=13:00 dist=100;
+<br><dd>r.mapcalc 'NSR=0.0036*(beam+diffuse+reflected)';
+
+
+<H2>SEE ALSO</H2>
+<ul>
+ <li>The <a href="http://istgis.ist.supsi.ch:8001/geomatica/">HydroFOSS</a>
+project at IST-SUPSI (Institute of Earth Sciences - University school of applied science for the Southern Switzerland)
+
+ <li><a href=r.sun.html>r.sun</a>,
+ <a href=r.mapcalc.html>r.mapcal</a>
+</ul>
+
+
+
+<H2>AUTHORS</H2>
+
+ <p>Original version of program: The <a href="http://istgis.ist.supsi.ch:8001/geomatica/index.php?id=1">HydroFOSS</a> project, 2006, IST-SUPSI. (http://istgis.ist.supsi.ch:8001/geomatica/index.php?id=1)
+ <i>
+ <br>Massimiliano Cannata, Scuola Universitaria Professionale della Svizzera Italiana - Istituto Scienze della Terra
+ <br>Maria A. Brovelli, Politecnico di Milano - Polo regionale di Como
+ </i>
+
+ <p>Contact: <a href="mailto:massimiliano.cannata at supsi.ch"> Massimiliano Cannata</a>
+
+
+<H2>REFERENCES</H2>
+
+ <p>[1] Cannata M., 2006. <A HREF="http://istgis.ist.supsi.ch:8001/geomatica/index.php?id=1">
+ GIS embedded approach for Free & Open Source Hydrological Modelling</A>. PhD thesis, Department of Geodesy and Geomatics, Polytechnic of Milan, Italy.
+
+ <p>[2] Allen, R.G., L.S. Pereira, D. Raes, and M. Smith. 1998.
+ Crop Evapotranspiration: Guidelines for computing crop water requirements.
+ Irrigation and Drainage Paper 56, Food and Agriculture Organization of the
+ United Nations, Rome, pp. 300
+ <p>[3] Penman, H. L. 1948. Natural evaporation from open water,
+ bare soil and grass. Proc. Roy. Soc. London, A193, pp. 120-146.
+
+<p><i>Last changed: $Date: 2007/07/29 19:30:00 $</i>
+</body>
+</html>
Property changes on: grass-addons/gipe/r.evapo.PM/description.html
___________________________________________________________________
Name: svn:executable
+ *
Added: grass-addons/gipe/r.evapo.PM/functions.c
===================================================================
--- grass-addons/gipe/r.evapo.PM/functions.c (rev 0)
+++ grass-addons/gipe/r.evapo.PM/functions.c 2008-08-23 00:10:57 UTC (rev 33013)
@@ -0,0 +1,164 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <grass/gis.h>
+#include <math.h>
+#include "local_proto.h"
+
+extern CELL f_c(CELL);
+
+extern FCELL f_f(FCELL);
+
+extern DCELL f_d(DCELL);
+
+
+/* constant definition */
+/*#define k_sb 4.903 [MJ/m2*h] Stefan Bolzman constant */
+#define cp 1.013 /*[kJ/kg*°C] specific heat of moist air */
+#define epsilon 0.622 /*[-] ratio of molecular weigth of water to dry air */
+#define Po 101.3 /*[kPa] atmospheric pressure at sea level */
+#define Tko 293.16 /*[K] reference temperature at sea level */
+#define eta 0.0065 /*[K/m] constant lapse rate */
+#define Ao 0 /*[m] altitude at sea level */
+#define g 9.81 /*[m/s] gravitational accelleration */
+#define R 287 /*[J/kg*K] specific gas constant */
+#define Zw 2 /*[m] height of wind measurements */
+#define Zh 2 /*[m] height of humidity measurements */
+#define k 0.41 /*[-] Von Karman constant */
+
+
+
+DCELL calc_ETp(DCELL T, DCELL Z, DCELL u2, DCELL Rn, int night, DCELL Rh,
+ DCELL hc)
+{
+
+ DCELL ea, delta, gamma, gstar, lambda;
+
+ DCELL P, ra, d, Zom, Zoh, G, ETrad, u10, rs, ed, Tkv, rho, ETaero, ETp;
+
+ /* calculus: mean saturation vapoure pressure [KPa] */
+ ea = 0.61078 * exp((17.27 * T) / (T + 237.3));
+
+ /* calculus: slope of vapoure pressure curve [KPa/°C] */
+ delta = (4098 * ea) / pow((237.3 + T), 2);
+
+ /* calculus: latent heat vapourisation [MJ/kg] */
+ lambda = 2.501 - (0.002361 * T);
+
+ /* calculus: atmospheric pressure [KPa] */
+ P = Po * pow(((Tko - eta * (Z - Ao)) / Tko), (g / (eta * R)));
+
+ /* calculus: psichiometric constant [kPa/°C] */
+ gamma = ((cp * P) / (epsilon * lambda)) * 0.001;
+
+ /* calculus: aerodynamic resistance [s/m] */
+ if (hc < 2) {
+ d = (2 / 3) * hc;
+ Zom = 0.123 * hc;
+ Zoh = 0.1 * Zom;
+ ra = (log((Zw - d) / Zom) * log((Zh - d) / Zoh)) / (k * k * u2);
+ }
+ else {
+ u10 = u2 * (log((67.8 * 10) - 5.42)) / 4.87;
+ ra = 94 / u10;
+ }
+
+ /* calculus: surface resistance [s/m] */
+ rs = 100 / (0.5 * 24 * hc);
+
+ /*calculus: modified psichiometric constant [kPa/°C] */
+ gstar = gamma * (1 + (rs / ra));
+
+ /*calculus: net radiation [MJ/m2*d] */
+ /*Rn derived from r.sun */
+
+ /*calculus: soil heat flux [MJ/m2*d] */
+ if (night == FALSE)
+ G = 0.1 * Rn;
+ else
+ G = 0.5 * Rn;
+
+ /* calculus: radiation term [mm/h] */
+ /* ETrad = (delta/(delta+gstar))*((Rn-G)/(lambda*1000000)); */
+ ETrad = (delta / (delta + gstar)) * ((Rn - G) / lambda); /* torna da analisi dimensionale */
+
+ /* calculus: actual vapoure pressure [kPa] */
+ ed = Rh * ea / 100;
+
+ /* calculus: virtual temperature [°C] */
+ Tkv = (T + 273.15) / (1 - (0.378 * ed / P));
+
+ /* calculus: atmospheric density [Kg/m^3] */
+ rho = P / (Tkv * R / 100);
+
+ /* calculus: aerodynamic term [mm/h] */
+ /* ETaero = (0.001/lambda)*(1/(delta+gstar))*(rho*cp/ra)*(ea-ed); */
+ ETaero = (3.6 / lambda) * (1 / (delta + gstar)) * (rho * cp / ra) * (ea - ed); /* torna da analisi dimensionale */
+
+ /* calculus: potential evapotranspiration [mm/h] */
+ ETp = ETrad + ETaero;
+
+ return ETp;
+
+}
+
+DCELL calc_openwaterETp(DCELL T, DCELL Z, DCELL u2, DCELL Rn, int day,
+ DCELL Rh, DCELL hc)
+{
+ DCELL ea, delta, gamma, lambda;
+
+ DCELL P, ed, ETaero, ETp;
+
+ /* calculus: mean saturation vapoure pressure [KPa] */
+ ea = 0.61078 * exp((17.27 * T) / (T + 237.3));
+
+ /* calculus: slope of vapoure pressure curve [KPa/°C] */
+ delta = (4098 * ea) / pow((237.3 + T), 2);
+
+ /* calculus: latent heat vapourisation [MJ/kg] */
+ lambda = 2.501 - (0.002361 * T);
+
+ /* calculus: atmospheric pressure [KPa] */
+ P = Po * pow(((Tko - eta * (Z - Ao)) / Tko), (g / (eta * R)));
+
+ /* calculus: di psichiometric constant [kPa/°C] */
+ gamma = ((cp * P) / (epsilon * lambda)) * 0.001;
+
+ /*calculus: net radiation [MJ/m2*h] */
+ /*Rn derived from r.sun */
+
+ /*calculus: actual vapoure pressure [kPa] */
+ ed = Rh * ea / 100;
+
+ /*calculus: aerodynamic term [mm/h] */
+ /*ETaero = 0.35*(0.5+(0.621375*u2/100))*7.500638*(ea-ed); */
+ /*to convert mm/d to mm/h it results: */
+ ETaero =
+ (0.35 / 24) * (0.5 + (0.621375 * u2 / 100)) * 7.500638 * (ea - ed);
+
+ /*calculus: potential evapotranspiration [mm/h] */
+ ETp = (((Rn * delta) / lambda) + (gamma * ETaero)) / (delta + gamma);
+
+ return ETp;
+
+}
+
+/*
+ DCELL calc_ETp_WaSiM(){
+
+ //calculus of saturation vapour pressure at the temperature T: es[hPa]
+ //with T[°C]
+ es = 6.1078*exp((17.27*T)/(237.3+T);
+
+ //tangent of the saturated vapour pressure curve: D[hPa/K] with T[°C]
+ D = (25029/pow((273.3+T),2))*exp((17.27*T)/(237.3+T);
+
+ //air pressure at level hM
+ P = 1013*exp(-hM/(7991+29.33*Tv));
+
+ //calculus of lambda [KJ/Kg] with T[°C]
+ lambda = 2500.8 - 2.372*T;
+
+ //calculus psichiometric constant gamma [hPa/°C] with cp=1.005[KJ/(Kg*K)]
+ gamma = ((1.005*P)/(0.622*lambda))*0.001;
+ */
Added: grass-addons/gipe/r.evapo.PM/local_proto.h
===================================================================
--- grass-addons/gipe/r.evapo.PM/local_proto.h (rev 0)
+++ grass-addons/gipe/r.evapo.PM/local_proto.h 2008-08-23 00:10:57 UTC (rev 33013)
@@ -0,0 +1,15 @@
+/* function.c */
+DCELL calc_Delta(DCELL T);
+
+DCELL calc_g(DCELL Z);
+
+DCELL calc_Eo(DCELL T);
+
+DCELL calc_Ea(DCELL Eo, DCELL RH);
+
+DCELL calc_G(DCELL Rn, int t);
+
+DCELL calc_ETp(DCELL T, DCELL Z, DCELL u2, DCELL Rn, int day, DCELL Rh,
+ DCELL hc);
+DCELL calc_openwaterETp(DCELL T, DCELL Z, DCELL u2, DCELL Rn, int day,
+ DCELL Rh, DCELL hc);
Added: grass-addons/gipe/r.evapo.PM/main.c
===================================================================
--- grass-addons/gipe/r.evapo.PM/main.c (rev 0)
+++ grass-addons/gipe/r.evapo.PM/main.c 2008-08-23 00:10:57 UTC (rev 33013)
@@ -0,0 +1,333 @@
+/* Created by Anjuta version 1.0.2 */
+/* This file will not be overwritten */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <grass/gis.h>
+#include <math.h>
+#include "local_proto.h"
+#include <grass/glocale.h>
+
+
+int main(int argc, char *argv[])
+{
+ struct Cell_head cellhd;
+
+ /* buffer for in out raster */
+ void *inrast_T, *inrast_RH, *inrast_u2, *inrast_Rn, *inrast_DEM,
+ *inrast_hc;
+ DCELL *outrast;
+
+ char *EPo;
+
+ int nrows, ncols;
+
+ int row, col;
+
+ int infd_T, infd_RH, infd_u2, infd_Rn, infd_DEM, infd_hc;
+
+ int outfd;
+
+ char *mapset_T, *mapset_RH, *mapset_u2, *mapset_Rn, *mapset_DEM,
+ *mapset_hc;
+ char *T, *RH, *u2, *Rn, *DEM, *hc;
+
+ DCELL d_T, d_RH, d_u2, d_Rn, d_Z, d_hc;
+
+ DCELL d_EPo;
+
+ int d_night;
+
+ struct History history;
+
+ struct GModule *module;
+
+ struct Option *input_DEM, *input_T, *input_RH, *input_u2, *input_Rn,
+ *input_hc, *output;
+ struct Flag *flag1, *day, *zero;
+
+ RASTER_MAP_TYPE data_type_output = DCELL_TYPE;
+
+ RASTER_MAP_TYPE data_type_DEM;
+
+ RASTER_MAP_TYPE data_type_T;
+
+ RASTER_MAP_TYPE data_type_RH;
+
+ RASTER_MAP_TYPE data_type_u2;
+
+ RASTER_MAP_TYPE data_type_Rn;
+
+ RASTER_MAP_TYPE data_type_hc;
+
+ G_gisinit(argv[0]);
+
+ module = G_define_module();
+ module->description =
+ _("Potontial Evapotranspiration Calculation with hourly Penman-Monteith");
+
+ /* Define different options */
+ input_DEM = G_define_standard_option(G_OPT_R_INPUT);
+ input_DEM->key = "DEM";
+ input_DEM->description = _("Name of DEM raster map [m a.s.l.]");
+
+ input_T = G_define_standard_option(G_OPT_R_INPUT);
+ input_T->key = "T";
+ input_T->description = _("Name of Temperature raster map [°C]");
+
+ input_RH = G_define_standard_option(G_OPT_R_INPUT);
+ input_RH->key = "RU";
+ input_RH->description = _("Name of Relative Umidity raster map [%]");
+
+ input_u2 = G_define_standard_option(G_OPT_R_INPUT);
+ input_u2->key = "WS";
+ input_u2->description = _("Name of Wind Speed raster map [m/s]");
+
+ input_Rn = G_define_standard_option(G_OPT_R_INPUT);
+ input_Rn->key = "NSR";
+ input_Rn->description =
+ _("Name of Net Solar Radiation raster map [MJ/m2/h]");
+
+ input_hc = G_define_standard_option(G_OPT_R_INPUT);
+ input_hc->key = "Vh";
+ input_hc->description = _("Name of crop height raster map [m]");
+
+ output = G_define_standard_option(G_OPT_R_OUTPUT);
+ output->key = "EPo";
+ output->description =
+ _("Name of output Reference Potential Evapotranspiration layer [mm/h]");
+
+ /* Define the different flags */
+
+ zero = G_define_flag();
+ zero->key = 'z';
+ zero->description = _("set negative evapo to zero");
+
+ day = G_define_flag();
+ day->key = 'n';
+ day->description = _("night-time");
+
+ if (G_parser(argc, argv))
+ exit(EXIT_FAILURE);
+
+ /* get entered parameters */
+ T = input_T->answer;
+ RH = input_RH->answer;
+ u2 = input_u2->answer;
+ Rn = input_Rn->answer;
+ DEM = input_DEM->answer;
+ hc = input_hc->answer;
+
+ EPo = output->answer;
+
+ if (day->answer) {
+ d_night = TRUE;
+ }
+ else {
+ d_night = FALSE;
+ }
+
+ /* find maps in mapset */
+ mapset_T = G_find_cell2(T, "");
+ if (mapset_T == NULL)
+ G_fatal_error(_("cell file [%s] not found"), T);
+ mapset_RH = G_find_cell2(RH, "");
+ if (mapset_RH == NULL)
+ G_fatal_error(_("cell file [%s] not found"), RH);
+ mapset_u2 = G_find_cell2(u2, "");
+ if (mapset_u2 == NULL)
+ G_fatal_error(_("cell file [%s] not found"), u2);
+ mapset_Rn = G_find_cell2(Rn, "");
+ if (mapset_Rn == NULL)
+ G_fatal_error(_("cell file [%s] not found"), Rn);
+ mapset_DEM = G_find_cell2(DEM, "");
+ if (mapset_DEM == NULL)
+ G_fatal_error(_("cell file [%s] not found"), DEM);
+ mapset_hc = G_find_cell2(hc, "");
+ if (mapset_hc == NULL)
+ G_fatal_error(_("cell file [%s] not found"), hc);
+
+ /* check legal output name */
+ if (G_legal_filename(EPo) < 0)
+ G_fatal_error(_("[%s] is an illegal name"), EPo);
+
+ /* determine the input map type (CELL/FCELL/DCELL) */
+ data_type_T = G_raster_map_type(T, mapset_T);
+ data_type_RH = G_raster_map_type(RH, mapset_RH);
+ data_type_u2 = G_raster_map_type(u2, mapset_u2);
+ data_type_Rn = G_raster_map_type(Rn, mapset_Rn);
+ data_type_DEM = G_raster_map_type(DEM, mapset_DEM);
+ data_type_hc = G_raster_map_type(hc, mapset_hc);
+
+ if ((infd_T = G_open_cell_old(T, mapset_T)) < 0)
+ G_fatal_error(_("Cannot open cell file [%s]"), T);
+ if ((infd_RH = G_open_cell_old(RH, mapset_RH)) < 0)
+ G_fatal_error(_("Cannot open cell file [%s]"), RH);
+ if ((infd_u2 = G_open_cell_old(u2, mapset_u2)) < 0)
+ G_fatal_error(_("Cannot open cell file [%s]"), u2);
+ if ((infd_Rn = G_open_cell_old(Rn, mapset_Rn)) < 0)
+ G_fatal_error(_("Cannot open cell file [%s]"), Rn);
+ if ((infd_DEM = G_open_cell_old(DEM, mapset_DEM)) < 0)
+ G_fatal_error(_("Cannot open cell file [%s]"), DEM);
+ if ((infd_hc = G_open_cell_old(hc, mapset_hc)) < 0)
+ G_fatal_error(_("Cannot open cell file [%s]"), hc);
+
+ if (G_get_cellhd(T, mapset_T, &cellhd) < 0)
+ G_fatal_error(_("Cannot read file header of [%s]"), T);
+ if (G_get_cellhd(RH, mapset_RH, &cellhd) < 0)
+ G_fatal_error(_("Cannot read file header of [%s]"), RH);
+ if (G_get_cellhd(u2, mapset_u2, &cellhd) < 0)
+ G_fatal_error(_("Cannot read file header of [%s]"), u2);
+ if (G_get_cellhd(Rn, mapset_Rn, &cellhd) < 0)
+ G_fatal_error(_("Cannot read file header of [%s]"), Rn);
+ if (G_get_cellhd(DEM, mapset_DEM, &cellhd) < 0)
+ G_fatal_error(_("Cannot read file header of [%s]"), DEM);
+ if (G_get_cellhd(hc, mapset_hc, &cellhd) < 0)
+ G_fatal_error(_("Cannot read file header of [%s]"), hc);
+
+ /* Allocate input buffer */
+ inrast_T = G_allocate_raster_buf(data_type_T);
+ inrast_RH = G_allocate_raster_buf(data_type_RH);
+ inrast_u2 = G_allocate_raster_buf(data_type_u2);
+ inrast_Rn = G_allocate_raster_buf(data_type_Rn);
+ inrast_DEM = G_allocate_raster_buf(data_type_DEM);
+ inrast_hc = G_allocate_raster_buf(data_type_hc);
+
+ /* Allocate output buffer */
+ nrows = G_window_rows();
+ ncols = G_window_cols();
+ outrast = G_allocate_raster_buf(data_type_output);
+
+ if ((outfd = G_open_raster_new(EPo, data_type_output)) < 0)
+ G_fatal_error(_("Could not open <%s>"), T);
+
+ for (row = 0; row < nrows; row++) {
+ /* read a line input maps into buffers */
+ if (G_get_raster_row(infd_T, inrast_T, row, data_type_output) < 0)
+ G_fatal_error(_("Could not read from <%s>"), T);
+ if (G_get_raster_row(infd_RH, inrast_RH, row, data_type_output) < 0)
+ G_fatal_error(_("Could not read from <%s>"), RH);
+ if (G_get_raster_row(infd_u2, inrast_u2, row, data_type_output) < 0)
+ G_fatal_error(_("Could not read from <%s>"), u2);
+ if (G_get_raster_row(infd_Rn, inrast_Rn, row, data_type_output) < 0)
+ G_fatal_error(_("Could not read from <%s>"), Rn);
+ if (G_get_raster_row(infd_DEM, inrast_DEM, row, data_type_output) < 0)
+ G_fatal_error(_("Could not read from <%s>"), DEM);
+ if (G_get_raster_row(infd_hc, inrast_hc, row, data_type_output) < 0)
+ G_fatal_error(_("Could not read from <%s>"), hc);
+
+ /* read every cell in the line buffers */
+ for (col = 0; col < ncols; col++) {
+ switch (data_type_T) {
+ case CELL_TYPE:
+ d_T = (double)((CELL *) inrast_T)[col];
+ break;
+ case FCELL_TYPE:
+ d_T = (double)((FCELL *) inrast_T)[col];
+ break;
+ case DCELL_TYPE:
+ d_T = ((DCELL *) inrast_T)[col];
+ break;
+ }
+ switch (data_type_RH) {
+ case CELL_TYPE:
+ d_RH = (double)((CELL *) inrast_RH)[col];
+ break;
+ case FCELL_TYPE:
+ d_RH = (double)((FCELL *) inrast_RH)[col];
+ break;
+ case DCELL_TYPE:
+ d_RH = ((DCELL *) inrast_RH)[col];
+ break;
+ }
+ switch (data_type_u2) {
+ case CELL_TYPE:
+ d_u2 = (double)((CELL *) inrast_u2)[col];
+ break;
+ case FCELL_TYPE:
+ d_u2 = (double)((FCELL *) inrast_u2)[col];
+ break;
+ case DCELL_TYPE:
+ d_u2 = ((DCELL *) inrast_u2)[col];
+ break;
+ }
+ switch (data_type_Rn) {
+ case CELL_TYPE:
+ d_Rn = (double)((CELL *) inrast_Rn)[col];
+ break;
+ case FCELL_TYPE:
+ d_Rn = (double)((FCELL *) inrast_Rn)[col];
+ break;
+ case DCELL_TYPE:
+ d_Rn = ((DCELL *) inrast_Rn)[col];
+ break;
+ }
+ switch (data_type_DEM) {
+ case CELL_TYPE:
+ d_Z = (double)((CELL *) inrast_DEM)[col];
+ break;
+ case FCELL_TYPE:
+ d_Z = (double)((FCELL *) inrast_DEM)[col];
+ break;
+ case DCELL_TYPE:
+ d_Z = ((DCELL *) inrast_DEM)[col];
+ break;
+ }
+ switch (data_type_hc) {
+ case CELL_TYPE:
+ d_hc = (double)((CELL *) inrast_hc)[col];
+ break;
+ case FCELL_TYPE:
+ d_hc = (double)((FCELL *) inrast_hc)[col];
+ break;
+ case DCELL_TYPE:
+ d_hc = ((DCELL *) inrast_hc)[col];
+ break;
+ }
+
+ /*calculate evapotranspiration */
+ if (d_hc < 0) {
+ /*calculate evaporation */
+ d_EPo =
+ calc_openwaterETp(d_T, d_Z, d_u2, d_Rn, d_night, d_RH,
+ d_hc);
+ }
+ else {
+ /*calculate evapotranspiration */
+ d_EPo = calc_ETp(d_T, d_Z, d_u2, d_Rn, d_night, d_RH, d_hc);
+ }
+
+ if (zero->answer && d_EPo < 0)
+ d_EPo = 0;
+
+ outrast[col] = d_EPo;
+ }
+
+ if (G_put_d_raster_row(outfd, outrast) < 0)
+ G_fatal_error(_("Cannot write to <%s>"), EPo);
+
+ }
+ G_free(inrast_T);
+ G_free(inrast_RH);
+ G_free(inrast_u2);
+ G_free(inrast_Rn);
+ G_free(inrast_DEM);
+ G_free(inrast_hc);
+ G_free(outrast);
+ G_close_cell(infd_T);
+ G_close_cell(infd_RH);
+ G_close_cell(infd_u2);
+ G_close_cell(infd_Rn);
+ G_close_cell(infd_DEM);
+ G_close_cell(infd_hc);
+ G_close_cell(outfd);
+
+ /* add command line incantation to history file */
+ G_short_history(EPo, "raster", &history);
+ G_command_history(&history);
+ G_write_history(EPo, &history);
+
+ exit(EXIT_SUCCESS);
+}
Modified: grass-addons/gipe/readme.gipe
===================================================================
--- grass-addons/gipe/readme.gipe 2008-08-22 23:34:16 UTC (rev 33012)
+++ grass-addons/gipe/readme.gipe 2008-08-23 00:10:57 UTC (rev 33013)
@@ -12,6 +12,7 @@
20080820-22: // -> /**/ Done, code standardization, new coding practices updated on older modules.
20080822: grass_indent.sh on all but i.vi.grid, r.hydro.CASC2D, r.evapo.PM.
20080822: Contacted Massimiliano (HydroFOSS) to permit me to copy r.evapo.PM in GIPE for grass_indent.sh parsing+eventual cleaning.
+20080822: Massimiliano granted me to prepare r.evapo.PM and include it in GIPE for public consideration to include in GRASS main.
Imagery modules
---------------
@@ -75,12 +76,18 @@
Raster modules
--------------
+r.hydro.CASC2D: (ported from GRASS 5.x): hydrological model
+r.out.vic: Creates input files to VIC Hydrological model
+
+-----EVAPOTRANSPIRATION reference, potential, ET data assimilation--
r.evapo.MH: Calculates the Evapotranspiration from Hargreaves and modified versions.
r.evapo.PM: (from HydroFOSS) Calculates the Evapotranspiration from Penman-Monteith (1972)
r.gaswap.serial: RS ETa data assimilation of SWAP agro-hydrological model
-r.hydro.CASC2D: (ported from GRASS 5.x): hydrological model
-r.out.vic: Creates input files to VIC Hydrological model
+-------------------------------------------------------------------------------------
+
+-----USLE K factor, R factor, soil texture and soil properties convertors--
r.soiltex2prop: Converts soil texture to porosity, saturated hydraulic conductivity, wetting front suction after Rawls et al (1990)
r.soilusda2tex: Converts USDA soil classes to soil texture layers (sand, silt, clay)
r.uslek: USLE K factor calculation from soil texture layers
r.usler: USLE R factor calculation (4 methods)
+-------------------------------------------------------------------------------------
More information about the grass-commit
mailing list