[GRASS-SVN] r44979 - in grass/trunk: gui/wxpython/xml imagery
imagery/i.evapo.MH
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jan 12 00:28:39 EST 2011
Author: ychemin
Date: 2011-01-11 21:28:39 -0800 (Tue, 11 Jan 2011)
New Revision: 44979
Added:
grass/trunk/imagery/i.evapo.MH/
grass/trunk/imagery/i.evapo.MH/i.evapo.MH.html
Removed:
grass/trunk/imagery/i.evapo.MH/description.html
Modified:
grass/trunk/gui/wxpython/xml/menudata.xml
grass/trunk/imagery/Makefile
grass/trunk/imagery/i.evapo.MH/Makefile
grass/trunk/imagery/i.evapo.MH/main.c
grass/trunk/imagery/i.evapo.MH/mh_eto.c
grass/trunk/imagery/i.evapo.MH/mh_original.c
grass/trunk/imagery/i.evapo.MH/mh_samani.c
Log:
Added i.evapo.MH with updated imagery/Makefile and menu item
Modified: grass/trunk/gui/wxpython/xml/menudata.xml
===================================================================
--- grass/trunk/gui/wxpython/xml/menudata.xml 2011-01-12 05:24:37 UTC (rev 44978)
+++ grass/trunk/gui/wxpython/xml/menudata.xml 2011-01-12 05:28:39 UTC (rev 44979)
@@ -2780,6 +2780,13 @@
</menuitem>
<separator />
<menuitem>
+ <label>Hargreaves methods Evapotranspiration</label>
+ <help>reference evapotranspiration (Hargreaves, modified-H, H and Samani)</help>
+ <keywords>imagery,reference evapotranspiration,Hargreaves,Samani</keywords>
+ <handler>OnMenuCmd</handler>
+ <command>i.evapo.MH</command>
+ </menuitem>
+ <menuitem>
<label>Penman-Monteith Evapotranspiration</label>
<help>reference evapotranspiration (FAO 56 and Penman, 1972)</help>
<keywords>imagery,reference evapotranspiration,FAO56,Penman-Monteith,HydroFOSS</keywords>
Modified: grass/trunk/imagery/Makefile
===================================================================
--- grass/trunk/imagery/Makefile 2011-01-12 05:24:37 UTC (rev 44978)
+++ grass/trunk/imagery/Makefile 2011-01-12 05:28:39 UTC (rev 44979)
@@ -12,6 +12,7 @@
i.eb.h_SEBAL01 \
i.eb.netrad \
i.eb.soilheatflux \
+ i.evapo.MH \
i.evapo.PM \
i.evapo.PT \
i.evapo.time_integration \
Modified: grass/trunk/imagery/i.evapo.MH/Makefile
===================================================================
--- grass-addons/imagery/gipe/r.evapo.MH/Makefile 2011-01-11 18:37:06 UTC (rev 44966)
+++ grass/trunk/imagery/i.evapo.MH/Makefile 2011-01-12 05:28:39 UTC (rev 44979)
@@ -1,6 +1,6 @@
MODULE_TOPDIR = ../..
-PGM = r.evapo.MH
+PGM = i.evapo.MH
LIBES = $(VECTLIB) $(RASTERLIB) $(GISLIB)
DEPENDENCIES= $(VECTDEP) $(GISDEP) $(DISPLAYDEP) $(RASTERDEP)
Deleted: grass/trunk/imagery/i.evapo.MH/description.html
===================================================================
--- grass-addons/imagery/gipe/r.evapo.MH/description.html 2011-01-11 18:37:06 UTC (rev 44966)
+++ grass/trunk/imagery/i.evapo.MH/description.html 2011-01-12 05:28:39 UTC (rev 44979)
@@ -1,34 +0,0 @@
-<H2>DESCRIPTION</H2>
-
-<EM>r.evapo.MH</EM> Calculates the reference ET after Hargreaves (1985) and Modified Hargreaves (2001).
-
-<H2>NOTES</H2>
-Hargreaves GL, Hargreaves GH, Riley JP, 1985. Agricultural benefits for Senegal River Basin. Journal of Irrigation and Drainange Engineering, ASCE, 111(2):113-124.
-
-Droogers P, Allen RG, 2002. Towards a simplified global reference evapotranspiration equation. Irrigation Science.
-Droogers, P., and R.G. Allen. 2002. Estimating reference evapotranspiration under inaccurate data conditions. Irrigation and Drainage Systems 16: 33-45.
-
-Hargreaves and Samani, 1985.
-
-<H2>TODO</H2>
-
-
-<H2>SEE ALSO</H2>
-
-<em>
-<A HREF="i.evapo.PT.html">i.evapo.PT</A><br>
-<A HREF="r.evapo.PM.html">i.evapo.PM</A><br>
-<A HREF="i.evapo.TSA.html">i.evapo.TSA</A><br>
-<A HREF="i.evapo.potrad.html">i.evapo.potrad</A><br>
-<A HREF="r.sun.html">r.sun</A><br>
-
-</em>
-
-
-<H2>AUTHORS</H2>
-
-Yann Chemin, GRASS Development team, 2007<BR>
-
-
-<p>
-<i>Last changed: $Date$</i>
Copied: grass/trunk/imagery/i.evapo.MH/i.evapo.MH.html (from rev 44966, grass-addons/imagery/gipe/r.evapo.MH/description.html)
===================================================================
--- grass/trunk/imagery/i.evapo.MH/i.evapo.MH.html (rev 0)
+++ grass/trunk/imagery/i.evapo.MH/i.evapo.MH.html 2011-01-12 05:28:39 UTC (rev 44979)
@@ -0,0 +1,33 @@
+<H2>DESCRIPTION</H2>
+
+<EM>i.evapo.MH</EM> Calculates the reference ET after Hargreaves (1985) and Modified Hargreaves (2001).
+
+<H2>NOTES</H2>
+Hargreaves GL, Hargreaves GH, Riley JP, 1985. Agricultural benefits for Senegal River Basin. Journal of Irrigation and Drainange Engineering, ASCE, 111(2):113-124.
+
+Droogers P, Allen RG, 2002. Towards a simplified global reference evapotranspiration equation. Irrigation Science.
+Droogers, P., and R.G. Allen. 2002. Estimating reference evapotranspiration under inaccurate data conditions. Irrigation and Drainage Systems 16: 33-45.
+
+Hargreaves and Samani, 1985.
+
+<H2>TODO</H2>
+
+
+<H2>SEE ALSO</H2>
+
+<em>
+<A HREF="i.evapo.PT.html">i.evapo.PT</A><br>
+<A HREF="i.evapo.PM.html">i.evapo.PM</A><br>
+<A HREF="i.evapo.potrad.html">i.evapo.potrad</A><br>
+<A HREF="r.sun.html">r.sun</A><br>
+
+</em>
+
+
+<H2>AUTHORS</H2>
+
+Yann Chemin, GRASS Development team, 2007-2011<BR>
+
+
+<p>
+<i>Last changed: $Date$</i>
Modified: grass/trunk/imagery/i.evapo.MH/main.c
===================================================================
--- grass-addons/imagery/gipe/r.evapo.MH/main.c 2011-01-11 18:37:06 UTC (rev 44966)
+++ grass/trunk/imagery/i.evapo.MH/main.c 2011-01-12 05:28:39 UTC (rev 44979)
@@ -1,7 +1,6 @@
-
/*****************************************************************************
*
-* MODULE: r.evapo.MH
+* MODULE: i.evapo.MH
* AUTHOR: Yann Chemin yann.chemin at gmail.com
*
* PURPOSE: To estimate the reference evapotranspiration by means
@@ -9,7 +8,7 @@
* Also has a switch for original Hargreaves (1985),
* and for Hargreaves-Samani (1985).
*
-* COPYRIGHT: (C) 2007 by the GRASS Development Team
+* COPYRIGHT: (C) 2007-2011 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
@@ -28,7 +27,6 @@
double mh_original(double ra, double tavg, double tmax, double tmin,
double p);
double mh_eto(double ra, double tavg, double tmax, double tmin, double p);
-
double mh_samani(double ra, double tavg, double tmax, double tmin);
int main(int argc, char *argv[])
@@ -36,12 +34,10 @@
/* buffer for input-output rasters */
void *inrast_TEMPKAVG, *inrast_TEMPKMIN, *inrast_TEMPKMAX, *inrast_RNET,
*inrast_P;
-
DCELL *outrast;
/* pointers to input-output raster files */
int infd_TEMPKAVG, infd_TEMPKMIN, infd_TEMPKMAX, infd_RNET, infd_P;
-
int outfd;
/* mapsets for input raster files */
@@ -50,51 +46,26 @@
/* names of input-output raster files */
char *RNET, *TEMPKAVG, *TEMPKMIN, *TEMPKMAX, *P;
-
char *ETa;
/* input-output cell values */
DCELL d_tempkavg, d_tempkmin, d_tempkmax, d_rnet, d_p;
-
DCELL d_daily_et;
-
/* region informations and handler */
struct Cell_head cellhd;
-
int nrows, ncols;
-
int row, col;
/* parser stuctures definition */
struct GModule *module;
-
struct Option *input_RNET, *input_TEMPKAVG, *input_TEMPKMIN;
-
struct Option *input_TEMPKMAX, *input_P;
-
struct Option *output;
-
struct Flag *zero, *original, *samani;
-
struct Colors color;
-
struct History history;
- RASTER_MAP_TYPE data_type_output = DCELL_TYPE;
-
- RASTER_MAP_TYPE data_type_tempkavg;
-
- RASTER_MAP_TYPE data_type_tempkmin;
-
- RASTER_MAP_TYPE data_type_tempkmax;
-
- RASTER_MAP_TYPE data_type_rnet;
-
- RASTER_MAP_TYPE data_type_p;
-
- RASTER_MAP_TYPE data_type_eta;
-
/* Initialize the GIS calls */
G_gisinit(argv[0]);
@@ -160,165 +131,69 @@
ETa = output->answer;
- /* find maps in mapset */
- mapset_RNET = G_find_cell2(RNET, "");
- if (mapset_RNET == NULL)
- G_fatal_error(_("cell file [%s] not found"), RNET);
- mapset_TEMPKAVG = G_find_cell2(TEMPKAVG, "");
- if (mapset_TEMPKAVG == NULL)
- G_fatal_error(_("cell file [%s] not found"), TEMPKAVG);
- mapset_TEMPKMIN = G_find_cell2(TEMPKMIN, "");
- if (mapset_TEMPKMIN == NULL)
- G_fatal_error(_("cell file [%s] not found"), TEMPKMIN);
- mapset_TEMPKMAX = G_find_cell2(TEMPKMAX, "");
- if (mapset_TEMPKMAX == NULL)
- G_fatal_error(_("cell file [%s] not found"), TEMPKMAX);
- if (!original->answer) {
- mapset_P = G_find_cell2(P, "");
- if (mapset_P == NULL)
- G_fatal_error(_("cell file [%s] not found"), P);
- }
/* check legal output name */
if (G_legal_filename(ETa) < 0)
G_fatal_error(_("[%s] is an illegal name"), ETa);
- /* determine the input map type (CELL/FCELL/DCELL) */
- data_type_rnet = G_raster_map_type(RNET, mapset_RNET);
- data_type_tempkavg = G_raster_map_type(TEMPKAVG, mapset_TEMPKAVG);
- data_type_tempkmin = G_raster_map_type(TEMPKMIN, mapset_TEMPKMIN);
- data_type_tempkmax = G_raster_map_type(TEMPKMAX, mapset_TEMPKMAX);
- if (!original->answer) {
- data_type_p = G_raster_map_type(P, mapset_P);
- }
/* open pointers to input raster files */
- if ((infd_RNET = G_open_cell_old(RNET, mapset_RNET)) < 0)
- G_fatal_error(_("Cannot open cell file [%s]"), RNET);
- if ((infd_TEMPKAVG = G_open_cell_old(TEMPKAVG, mapset_TEMPKAVG)) < 0)
- G_fatal_error(_("Cannot open cell file [%s]"), TEMPKAVG);
- if ((infd_TEMPKMIN = G_open_cell_old(TEMPKMIN, mapset_TEMPKMIN)) < 0)
- G_fatal_error(_("Cannot open cell file [%s]"), TEMPKMIN);
- if ((infd_TEMPKMAX = G_open_cell_old(TEMPKMAX, mapset_TEMPKMAX)) < 0)
- G_fatal_error(_("Cannot open cell file [%s]"), TEMPKMAX);
+ infd_RNET = Rast_open_old(RNET, "");
+ infd_TEMPKAVG = Rast_open_old(TEMPKAVG, "");
+ infd_TEMPKMIN = Rast_open_old(TEMPKMIN, "");
+ infd_TEMPKMAX = Rast_open_old(TEMPKMAX, "");
if (!original->answer) {
- if ((infd_P = G_open_cell_old(P, mapset_P)) < 0)
- G_fatal_error(_("Cannot open cell file [%s]"), P);
+ infd_P = Rast_open_old(P, "");
}
/* read headers of raster files */
- if (G_get_cellhd(RNET, mapset_RNET, &cellhd) < 0)
- G_fatal_error(_("Cannot read file header of [%s]"), RNET);
- if (G_get_cellhd(TEMPKAVG, mapset_TEMPKAVG, &cellhd) < 0)
- G_fatal_error(_("Cannot read file header of [%s]"), TEMPKAVG);
- if (G_get_cellhd(TEMPKMIN, mapset_TEMPKMIN, &cellhd) < 0)
- G_fatal_error(_("Cannot read file header of [%s]"), TEMPKMIN);
- if (G_get_cellhd(TEMPKMAX, mapset_TEMPKMAX, &cellhd) < 0)
- G_fatal_error(_("Cannot read file header of [%s]"), TEMPKMAX);
+ Rast_get_cellhd(RNET, "", &cellhd);
+ Rast_get_cellhd(TEMPKAVG, "", &cellhd);
+ Rast_get_cellhd(TEMPKMIN, "", &cellhd);
+ Rast_get_cellhd(TEMPKMAX, "", &cellhd);
if (!original->answer) {
- if (G_get_cellhd(P, mapset_P, &cellhd) < 0)
- G_fatal_error(_("Cannot read file header of [%s]"), P);
+ Rast_get_cellhd(P, "", &cellhd);
}
/* Allocate input buffer */
- inrast_RNET = G_allocate_raster_buf(data_type_rnet);
- inrast_TEMPKAVG = G_allocate_raster_buf(data_type_tempkavg);
- inrast_TEMPKMIN = G_allocate_raster_buf(data_type_tempkmin);
- inrast_TEMPKMAX = G_allocate_raster_buf(data_type_tempkmax);
+ inrast_RNET = Rast_allocate_d_buf();
+ inrast_TEMPKAVG = Rast_allocate_d_buf();
+ inrast_TEMPKMIN = Rast_allocate_d_buf();
+ inrast_TEMPKMAX = Rast_allocate_d_buf();
if (!original->answer) {
- inrast_P = G_allocate_raster_buf(data_type_p);
+ inrast_P = Rast_allocate_d_buf();
}
/* get rows and columns number of the current region */
- nrows = G_window_rows();
- ncols = G_window_cols();
+ nrows = Rast_window_rows();
+ ncols = Rast_window_cols();
/* allocate output buffer */
- outrast = G_allocate_raster_buf(data_type_output);
+ outrast = Rast_allocate_d_buf();
/* open pointers to output raster files */
- if ((outfd = G_open_raster_new(ETa, data_type_output)) < 0)
- G_fatal_error(_("Could not open <%s>"), ETa);
+ outfd = Rast_open_new(ETa, DCELL_TYPE);
-
/* start the loop through cells */
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
/* read input raster row into line buffer */
- 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_TEMPKAVG, inrast_TEMPKAVG, row, data_type_tempkavg) < 0)
- G_fatal_error(_("Could not read from <%s>"), TEMPKAVG);
- if (G_get_raster_row
- (infd_TEMPKMIN, inrast_TEMPKMIN, row, data_type_tempkmin) < 0)
- G_fatal_error(_("Could not read from <%s>"), TEMPKMIN);
- if (G_get_raster_row
- (infd_TEMPKMAX, inrast_TEMPKMAX, row, data_type_tempkmax) < 0)
- G_fatal_error(_("Could not read from <%s>"), TEMPKMAX);
+ Rast_get_d_row(infd_RNET, inrast_RNET, row);
+ Rast_get_d_row(infd_TEMPKAVG, inrast_TEMPKAVG, row);
+ Rast_get_d_row(infd_TEMPKMIN, inrast_TEMPKMIN, row);
+ Rast_get_d_row(infd_TEMPKMAX, inrast_TEMPKMAX, row);
if (!original->answer) {
- if (G_get_raster_row(infd_P, inrast_P, row, data_type_p) < 0)
- G_fatal_error(_("Could not read from <%s>"), P);
+ Rast_get_d_row(infd_P, inrast_P, row);
}
for (col = 0; col < ncols; col++) {
/* read current cell from line buffer */
- switch (data_type_rnet) {
- case CELL_TYPE:
- d_rnet = (double)((CELL *) inrast_RNET)[col];
- break;
- case FCELL_TYPE:
- d_rnet = (double)((FCELL *) inrast_RNET)[col];
- break;
- case DCELL_TYPE:
- d_rnet = ((DCELL *) inrast_RNET)[col];
- break;
- }
- switch (data_type_tempkavg) {
- case CELL_TYPE:
- d_tempkavg = (double)((CELL *) inrast_TEMPKAVG)[col];
- break;
- case FCELL_TYPE:
- d_tempkavg = (double)((FCELL *) inrast_TEMPKAVG)[col];
- break;
- case DCELL_TYPE:
- d_tempkavg = ((DCELL *) inrast_TEMPKAVG)[col];
- break;
- }
- switch (data_type_tempkmin) {
- case CELL_TYPE:
- d_tempkmin = (double)((CELL *) inrast_TEMPKMIN)[col];
- break;
- case FCELL_TYPE:
- d_tempkmin = (double)((FCELL *) inrast_TEMPKMIN)[col];
- break;
- case DCELL_TYPE:
- d_tempkmin = ((DCELL *) inrast_TEMPKMIN)[col];
- break;
- }
- switch (data_type_tempkmax) {
- case CELL_TYPE:
- d_tempkmax = (double)((CELL *) inrast_TEMPKMAX)[col];
- break;
- case FCELL_TYPE:
- d_tempkmax = (double)((FCELL *) inrast_TEMPKMAX)[col];
- break;
- case DCELL_TYPE:
- d_tempkmax = ((DCELL *) inrast_TEMPKMAX)[col];
- break;
- }
+ d_rnet = ((DCELL *) inrast_RNET)[col];
+ d_tempkavg = ((DCELL *) inrast_TEMPKAVG)[col];
+ d_tempkmin = ((DCELL *) inrast_TEMPKMIN)[col];
+ d_tempkmax = ((DCELL *) inrast_TEMPKMAX)[col];
if (!original->answer) {
- switch (data_type_p) {
- case CELL_TYPE:
- d_p = (double)((CELL *) inrast_P)[col];
- break;
- case FCELL_TYPE:
- d_p = (double)((FCELL *) inrast_P)[col];
- break;
- case DCELL_TYPE:
d_p = ((DCELL *) inrast_P)[col];
- break;
- }
}
- if (G_is_d_null_value(&d_rnet) ||
- G_is_d_null_value(&d_tempkavg) ||
- G_is_d_null_value(&d_tempkmin) ||
- G_is_d_null_value(&d_tempkmax) || G_is_d_null_value(&d_p)) {
- G_set_d_null_value(&outrast[col], 1);
+ if (Rast_is_d_null_value(&d_rnet) ||
+ Rast_is_d_null_value(&d_tempkavg) ||
+ Rast_is_d_null_value(&d_tempkmin) ||
+ Rast_is_d_null_value(&d_tempkmax) || Rast_is_d_null_value(&d_p)) {
+ Rast_set_d_null_value(&outrast[col], 1);
}
else {
if (original->answer) {
@@ -341,12 +216,8 @@
outrast[col] = d_daily_et;
}
}
-
-
/* write output line buffer to output raster file */
- if (G_put_raster_row(outfd, outrast, data_type_output) < 0)
- G_fatal_error(_("Cannot write to <%s>"), ETa);
-
+ Rast_put_d_row(outfd, outrast);
}
/* free buffers and close input maps */
@@ -357,24 +228,24 @@
if (!original->answer) {
G_free(inrast_P);
}
- G_close_cell(infd_RNET);
- G_close_cell(infd_TEMPKAVG);
- G_close_cell(infd_TEMPKMIN);
- G_close_cell(infd_TEMPKMAX);
+ Rast_close(infd_RNET);
+ Rast_close(infd_TEMPKAVG);
+ Rast_close(infd_TEMPKMIN);
+ Rast_close(infd_TEMPKMAX);
if (!original->answer) {
- G_close_cell(infd_P);
+ Rast_close(infd_P);
}
/* generate color table between -20 and 20 */
- G_make_rainbow_colors(&color, -20, 20);
- G_write_colors(ETa, G_mapset(), &color);
+ Rast_make_rainbow_colors(&color, -20, 20);
+ Rast_write_colors(ETa, G_mapset(), &color);
- G_short_history(ETa, "raster", &history);
- G_command_history(&history);
- G_write_history(ETa, &history);
+ Rast_short_history(ETa, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(ETa, &history);
/* free buffers and close output map */
G_free(outrast);
- G_close_cell(outfd);
+ Rast_close(outfd);
- return 0;
+ return(EXIT_SUCCESS);
}
Modified: grass/trunk/imagery/i.evapo.MH/mh_eto.c
===================================================================
--- grass-addons/imagery/gipe/r.evapo.MH/mh_eto.c 2011-01-11 18:37:06 UTC (rev 44966)
+++ grass/trunk/imagery/i.evapo.MH/mh_eto.c 2011-01-12 05:28:39 UTC (rev 44979)
@@ -2,9 +2,9 @@
#include<math.h>
#include<stdlib.h>
- /*Droogers and Allen, 2001. */
- /*p is [mm/month] */
-double mh_eto(double ra, double tavg, double tmax, double tmin, double p)
+ /*Droogers and Allen, 2001. */
+ /*p is [mm/month] */
+double mh_eto(double ra, double tavg, double tmax, double tmin, double p)
{
double td, result;
@@ -17,5 +17,3 @@
0.0013 * 0.408 * ra * (tavg + 17.0) * pow((td - 0.0123 * p), 0.76);
return result;
}
-
-
Modified: grass/trunk/imagery/i.evapo.MH/mh_original.c
===================================================================
--- grass-addons/imagery/gipe/r.evapo.MH/mh_original.c 2011-01-11 18:37:06 UTC (rev 44966)
+++ grass/trunk/imagery/i.evapo.MH/mh_original.c 2011-01-12 05:28:39 UTC (rev 44979)
@@ -2,9 +2,8 @@
#include<math.h>
#include<stdlib.h>
- /*Hargreaves et al, 1985. */
-double mh_original(double ra, double tavg, double tmax, double tmin,
- double p)
+ /*Hargreaves et al, 1985. */
+double mh_original(double ra, double tavg, double tmax, double tmin, double p)
{
double td, result;
@@ -16,5 +15,3 @@
result = 0.0023 * 0.408 * ra * (tavg + 17.8) * pow(td, 0.5);
return result;
}
-
-
Modified: grass/trunk/imagery/i.evapo.MH/mh_samani.c
===================================================================
--- grass-addons/imagery/gipe/r.evapo.MH/mh_samani.c 2011-01-11 18:37:06 UTC (rev 44966)
+++ grass/trunk/imagery/i.evapo.MH/mh_samani.c 2011-01-12 05:28:39 UTC (rev 44979)
@@ -2,8 +2,8 @@
#include<math.h>
#include<stdlib.h>
- /*Hargreaves-Samani, 1985. */
-double mh_samani(double ra, double tavg, double tmax, double tmin)
+ /*Hargreaves-Samani, 1985. */
+double mh_samani(double ra, double tavg, double tmax, double tmin)
{
double td, result;
@@ -17,5 +17,3 @@
0.5) * ((tmax + tmin) / 2 + 17.8) / 2.45;
return result;
}
-
-
More information about the grass-commit
mailing list