[GRASS-SVN] r44977 - in grass/trunk: gui/wxpython/xml imagery imagery/i.evapo.PT

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jan 11 23:35:12 EST 2011


Author: ychemin
Date: 2011-01-11 20:35:12 -0800 (Tue, 11 Jan 2011)
New Revision: 44977

Added:
   grass/trunk/imagery/i.evapo.PT/
   grass/trunk/imagery/i.evapo.PT/i.evapo.PT.html
Removed:
   grass/trunk/imagery/i.evapo.PT/description.html
Modified:
   grass/trunk/gui/wxpython/xml/menudata.xml
   grass/trunk/imagery/Makefile
   grass/trunk/imagery/i.evapo.PT/main.c
   grass/trunk/imagery/i.evapo.PT/pt_daily_et.c
   grass/trunk/imagery/i.evapo.PT/pt_delta.c
   grass/trunk/imagery/i.evapo.PT/pt_ghamma.c
Log:
Added i.evapo.PT with imagery/Makefile modif and GUI menu item

Modified: grass/trunk/gui/wxpython/xml/menudata.xml
===================================================================
--- grass/trunk/gui/wxpython/xml/menudata.xml	2011-01-12 04:31:54 UTC (rev 44976)
+++ grass/trunk/gui/wxpython/xml/menudata.xml	2011-01-12 04:35:12 UTC (rev 44977)
@@ -2786,6 +2786,13 @@
 	      <handler>OnMenuCmd</handler>
 	      <command>i.evapo.PM</command>
 	    </menuitem>
+	    <menuitem>
+	      <label>Priestley-Taylor Evapotranspiration</label>
+	      <help>reference evapotranspiration (Priestley and Taylor, 1972)</help>
+	      <keywords>imagery,reference evapotranspiration,Priestley-Taylor</keywords>
+	      <handler>OnMenuCmd</handler>
+	      <command>i.evapo.PT</command>
+	    </menuitem>
 	  </items>
 	</menu>
 	<separator />

Modified: grass/trunk/imagery/Makefile
===================================================================
--- grass/trunk/imagery/Makefile	2011-01-12 04:31:54 UTC (rev 44976)
+++ grass/trunk/imagery/Makefile	2011-01-12 04:35:12 UTC (rev 44977)
@@ -13,6 +13,7 @@
 	i.eb.netrad \
 	i.eb.soilheatflux \
 	i.evapo.PM \
+	i.evapo.PT \
 	i.evapo.time_integration \
 	i.emissivity \
 	i.find \

Deleted: grass/trunk/imagery/i.evapo.PT/description.html
===================================================================
--- grass-addons/imagery/gipe/i.evapo.PT/description.html	2011-01-11 18:37:06 UTC (rev 44966)
+++ grass/trunk/imagery/i.evapo.PT/description.html	2011-01-12 04:35:12 UTC (rev 44977)
@@ -1,37 +0,0 @@
-<H2>DESCRIPTION</H2>
-
-<EM>i.evapo.PT</EM> Calculates the diurnal evapotranspiration after Prestley and Taylor (1972). 
-The Priestley-Taylor model (Priestley and Taylor, 1972) is a modification of Penman’s more theoretical equation.
-
-<H2>NOTES</H2>
-RNETD optional output from i.evapo.potrad is giving good results as input for net radiation in this module.
-
-Alpha values:
-1.32 for estimates from vegetated areas as a result of the increase in surface roughness (Morton, 1983; Brutsaert and Stricker, 1979)
-1.26 is applicable in humid climates (De Bruin and Keijman, 1979; Stewart and Rouse, 1976; Shuttleworth and Calder, 1979), and temperate hardwood swamps (Munro, 1979)
-1.74 has been recommended for estimating potential evapotranspiration in more arid regions (ASCE, 1990). This Worked well in Greece with University of Thessaloniki.
-
-Alpha values extracted from:
-http://www.civil.uwaterloo.ca/Watflood/Manual/02_03_1.htm
-
-<H2>TODO</H2>
-
-
-<H2>SEE ALSO</H2>
-
-<em>
-<A HREF="i.evapo.PM.html">i.evapo.PM</A><br>
-<A HREF="i.evapo.potrad.html">i.evapo.potrad</A><br>
-<A HREF="i.eb.netrad.html">i.eb.netrad</A><br>
-<A HREF="i.eb.g0.html">i.eb.g0</A><br>
-<A HREF="i.evapo.TSA.html">i.evapo.TSA</A><br>
-</em>
-
-
-<H2>AUTHORS</H2>
-
-Yann Chemin, GRASS Development team, 2007-08<BR>
-
-
-<p>
-<i>Last changed: $Date$</i>

Copied: grass/trunk/imagery/i.evapo.PT/i.evapo.PT.html (from rev 44966, grass-addons/imagery/gipe/i.evapo.PT/description.html)
===================================================================
--- grass/trunk/imagery/i.evapo.PT/i.evapo.PT.html	                        (rev 0)
+++ grass/trunk/imagery/i.evapo.PT/i.evapo.PT.html	2011-01-12 04:35:12 UTC (rev 44977)
@@ -0,0 +1,36 @@
+<H2>DESCRIPTION</H2>
+
+<EM>i.evapo.PT</EM> Calculates the diurnal evapotranspiration after Prestley and Taylor (1972). 
+The Priestley-Taylor model (Priestley and Taylor, 1972) is a modification of Penman’s more theoretical equation.
+
+<H2>NOTES</H2>
+RNETD optional output from i.evapo.potrad is giving good results as input for net radiation in this module.
+
+Alpha values:
+1.32 for estimates from vegetated areas as a result of the increase in surface roughness (Morton, 1983; Brutsaert and Stricker, 1979)
+1.26 is applicable in humid climates (De Bruin and Keijman, 1979; Stewart and Rouse, 1976; Shuttleworth and Calder, 1979), and temperate hardwood swamps (Munro, 1979)
+1.74 has been recommended for estimating potential evapotranspiration in more arid regions (ASCE, 1990). This Worked well in Greece with University of Thessaloniki.
+
+Alpha values extracted from:
+http://www.civil.uwaterloo.ca/Watflood/Manual/02_03_1.htm
+
+<H2>TODO</H2>
+
+
+<H2>SEE ALSO</H2>
+
+<em>
+<A HREF="i.evapo.PM.html">i.evapo.PM</A><br>
+<A HREF="i.evapo.potrad.html">i.evapo.potrad</A><br>
+<A HREF="i.eb.netrad.html">i.eb.netrad</A><br>
+<A HREF="i.eb.g0.html">i.eb.g0</A><br>
+</em>
+
+
+<H2>AUTHORS</H2>
+
+Yann Chemin, GRASS Development team, 2007-08<BR>
+
+
+<p>
+<i>Last changed: $Date$</i>

Modified: grass/trunk/imagery/i.evapo.PT/main.c
===================================================================
--- grass-addons/imagery/gipe/i.evapo.PT/main.c	2011-01-11 18:37:06 UTC (rev 44966)
+++ grass/trunk/imagery/i.evapo.PT/main.c	2011-01-12 04:35:12 UTC (rev 44977)
@@ -1,4 +1,3 @@
-
 /*****************************************************************************
 *
 * MODULE:	i.evapo.PT
@@ -7,7 +6,7 @@
 * PURPOSE:	To estimate the daily evapotranspiration by means
 *		of Prestley and Taylor method (1972).
 *
-* COPYRIGHT:	(C) 2007-2008 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
@@ -24,9 +23,7 @@
 #include <grass/glocale.h>
 
 double pt_delta(double tempka);
-
 double pt_ghamma(double tempka, double p_atm);
-
 double pt_daily_et(double alpha_pt, double delta_pt, double ghamma_pt,
 		   double rnet, double g0, double tempka);
 
@@ -34,12 +31,10 @@
 {
     /* buffer for input-output rasters */
     void *inrast_TEMPKA, *inrast_PATM, *inrast_RNET, *inrast_G0;
-
     DCELL *outrast;
 
     /* pointers to input-output raster files */
     int infd_TEMPKA, infd_PATM, infd_RNET, infd_G0;
-
     int outfd;
 
     /* mapsets for input raster files */
@@ -47,46 +42,26 @@
 
     /* names of input-output raster files */
     char *RNET, *TEMPKA, *PATM, *G0;
-
     char *ETa;
 
     /* input-output cell values */
     DCELL d_tempka, d_pt_patm, d_rnet, d_g0;
-
     DCELL d_pt_alpha, d_pt_delta, d_pt_ghamma, 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_TEMPKA, *input_PATM, *input_G0,
 	*input_PT;
     struct Option *output;
-
     struct Flag *flag1, *zero;
-
     struct Colors color;
-
     struct History history;
 
-    RASTER_MAP_TYPE data_type_output = DCELL_TYPE;
-
-    RASTER_MAP_TYPE data_type_tempka;
-
-    RASTER_MAP_TYPE data_type_patm;
-
-    RASTER_MAP_TYPE data_type_rnet;
-
-    RASTER_MAP_TYPE data_type_g0;
-
-    RASTER_MAP_TYPE data_type_eta;
-
     /* Initialize the GIS calls */
     G_gisinit(argv[0]);
 
@@ -146,129 +121,54 @@
 
     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_TEMPKA = G_find_cell2(TEMPKA, "");
-    if (mapset_TEMPKA == NULL)
-	G_fatal_error(_("cell file [%s] not found"), TEMPKA);
-    mapset_PATM = G_find_cell2(PATM, "");
-    if (mapset_PATM == NULL)
-	G_fatal_error(_("cell file [%s] not found"), PATM);
-    mapset_G0 = G_find_cell2(G0, "");
-    if (mapset_G0 == NULL)
-	G_fatal_error(_("cell file [%s] not found"), G0);
-
     /* 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_tempka = G_raster_map_type(TEMPKA, mapset_TEMPKA);
-    data_type_patm = G_raster_map_type(PATM, mapset_PATM);
-    data_type_g0 = G_raster_map_type(G0, mapset_G0);
-
     /* 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_TEMPKA = G_open_cell_old(TEMPKA, mapset_TEMPKA)) < 0)
-	G_fatal_error(_("Cannot open cell file [%s]"), TEMPKA);
-    if ((infd_PATM = G_open_cell_old(PATM, mapset_PATM)) < 0)
-	G_fatal_error(_("Cannot open cell file [%s]"), PATM);
-    if ((infd_G0 = G_open_cell_old(G0, mapset_G0)) < 0)
-	G_fatal_error(_("Cannot open cell file [%s]"), G0);
+    infd_RNET = Rast_open_old(RNET, "");
+    infd_TEMPKA = Rast_open_old(TEMPKA, "");
+    infd_PATM = Rast_open_old(PATM, "");
+    infd_G0 = Rast_open_old(G0, "");
 
     /* 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(TEMPKA, mapset_TEMPKA, &cellhd) < 0)
-	G_fatal_error(_("Cannot read file header of [%s]"), TEMPKA);
-    if (G_get_cellhd(PATM, mapset_PATM, &cellhd) < 0)
-	G_fatal_error(_("Cannot read file header of [%s]"), PATM);
-    if (G_get_cellhd(G0, mapset_G0, &cellhd) < 0)
-	G_fatal_error(_("Cannot read file header of [%s]"), G0);
+    Rast_get_cellhd(RNET, "", &cellhd);
+    Rast_get_cellhd(TEMPKA, "", &cellhd);
+    Rast_get_cellhd(PATM, "", &cellhd);
+    Rast_get_cellhd(G0, "", &cellhd);
 
     /* Allocate input buffer */
-    inrast_RNET = G_allocate_raster_buf(data_type_rnet);
-    inrast_TEMPKA = G_allocate_raster_buf(data_type_tempka);
-    inrast_PATM = G_allocate_raster_buf(data_type_patm);
-    inrast_G0 = G_allocate_raster_buf(data_type_g0);
+    inrast_RNET = Rast_allocate_d_buf();
+    inrast_TEMPKA = Rast_allocate_d_buf();
+    inrast_PATM = Rast_allocate_d_buf();
+    inrast_G0 = 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_TEMPKA, inrast_TEMPKA, row, data_type_tempka) < 0)
-	    G_fatal_error(_("Could not read from <%s>"), TEMPKA);
-	if (G_get_raster_row(infd_PATM, inrast_PATM, row, data_type_patm) < 0)
-	    G_fatal_error(_("Could not read from <%s>"), PATM);
-	if (G_get_raster_row(infd_G0, inrast_G0, row, data_type_g0) < 0)
-	    G_fatal_error(_("Could not read from <%s>"), G0);
+	Rast_get_d_row(infd_RNET, inrast_RNET, row);
+	Rast_get_d_row(infd_TEMPKA, inrast_TEMPKA, row);
+	Rast_get_d_row(infd_PATM, inrast_PATM, row);
+	Rast_get_d_row(infd_G0, inrast_G0, 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_tempka) {
-	    case CELL_TYPE:
-		d_tempka = (double)((CELL *) inrast_TEMPKA)[col];
-		break;
-	    case FCELL_TYPE:
-		d_tempka = (double)((FCELL *) inrast_TEMPKA)[col];
-		break;
-	    case DCELL_TYPE:
-		d_tempka = ((DCELL *) inrast_TEMPKA)[col];
-		break;
-	    }
-	    switch (data_type_patm) {
-	    case CELL_TYPE:
-		d_pt_patm = (double)((CELL *) inrast_PATM)[col];
-		break;
-	    case FCELL_TYPE:
-		d_pt_patm = (double)((FCELL *) inrast_PATM)[col];
-		break;
-	    case DCELL_TYPE:
-		d_pt_patm = ((DCELL *) inrast_PATM)[col];
-		break;
-	    }
-	    switch (data_type_g0) {
-	    case CELL_TYPE:
-		d_g0 = (double)((CELL *) inrast_G0)[col];
-		break;
-	    case FCELL_TYPE:
-		d_g0 = (double)((FCELL *) inrast_G0)[col];
-		break;
-	    case DCELL_TYPE:
-		d_g0 = ((DCELL *) inrast_G0)[col];
-		break;
-	    }
+            d_rnet = ((DCELL *) inrast_RNET)[col];
+            d_tempka = ((DCELL *) inrast_TEMPKA)[col];
+            d_pt_patm = ((DCELL *) inrast_PATM)[col];
+            d_g0 = ((DCELL *) inrast_G0)[col];
 
 	    /*Delta_pt and Ghamma_pt */
 	    d_pt_delta = pt_delta(d_tempka);
@@ -286,9 +186,7 @@
 	}
 
 	/* 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 */
 
@@ -296,22 +194,22 @@
     G_free(inrast_TEMPKA);
     G_free(inrast_PATM);
     G_free(inrast_G0);
-    G_close_cell(infd_RNET);
-    G_close_cell(infd_TEMPKA);
-    G_close_cell(infd_PATM);
-    G_close_cell(infd_G0);
+    Rast_close(infd_RNET);
+    Rast_close(infd_TEMPKA);
+    Rast_close(infd_PATM);
+    Rast_close(infd_G0);
 
     /* 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.PT/pt_daily_et.c
===================================================================
--- grass-addons/imagery/gipe/i.evapo.PT/pt_daily_et.c	2011-01-11 18:37:06 UTC (rev 44966)
+++ grass/trunk/imagery/i.evapo.PT/pt_daily_et.c	2011-01-12 04:35:12 UTC (rev 44977)
@@ -2,29 +2,23 @@
 #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 rnet, double g0, double tempka)
 {
     double result, latentHv, t_celsius;
-
     double roh_w = 1004.15;	/*mass density of water */
-
     double vap_slope_ratio;
 
-    
-	/*Latent Heat of vaporization (W/m2/d) */ 
-	t_celsius = tempka - 273.15;
+    /*Latent Heat of vaporization (W/m2/d) */
+    t_celsius = tempka - 273.15;
     latentHv = 86400 / ((2.501 - 0.002361 * t_celsius) * pow(10, 6));
-    
-	/* Ratio of slope of saturation-vapour pressure Vs Temperature */ 
-	/* ghamma_pt = psychrometric constant */ 
-	vap_slope_ratio = delta_pt / (delta_pt + ghamma_pt);
-    
-	/*(Rn-g0)/latentHv returns [-] */ 
-	result =
-	(alpha_pt / roh_w) * vap_slope_ratio * (rnet - g0) / latentHv;
-    return result;
-}
 
+    /* Ratio of slope of saturation-vapour pressure Vs Temperature */
+    /* ghamma_pt = psychrometric constant */
+    vap_slope_ratio = delta_pt / (delta_pt + ghamma_pt);
 
+    /*(Rn-g0)/latentHv returns [-] */
+    result = (alpha_pt / roh_w) * vap_slope_ratio * (rnet - g0) / latentHv;
+    return result;
+}

Modified: grass/trunk/imagery/i.evapo.PT/pt_delta.c
===================================================================
--- grass-addons/imagery/gipe/i.evapo.PT/pt_delta.c	2011-01-11 18:37:06 UTC (rev 44966)
+++ grass/trunk/imagery/i.evapo.PT/pt_delta.c	2011-01-12 04:35:12 UTC (rev 44977)
@@ -2,10 +2,10 @@
 #include<math.h>
 #include<stdlib.h>
 
-    /* Prestely and Taylor, 1972. 
-     * INPUT in Kelvin
-     */ 
-double pt_delta(double tempka) 
+/* Prestely and Taylor, 1972. 
+ * INPUT in Kelvin
+ */
+double pt_delta(double tempka)
 {
     double a, b, result;
 
@@ -15,5 +15,3 @@
     result = 2504.0 * exp(a) / pow(b, 2);
     return result;
 }
-
-

Modified: grass/trunk/imagery/i.evapo.PT/pt_ghamma.c
===================================================================
--- grass-addons/imagery/gipe/i.evapo.PT/pt_ghamma.c	2011-01-11 18:37:06 UTC (rev 44966)
+++ grass/trunk/imagery/i.evapo.PT/pt_ghamma.c	2011-01-12 04:35:12 UTC (rev 44977)
@@ -2,13 +2,12 @@
 #include<math.h>
 #include<stdlib.h>
 
-    /* Prestely and Taylor, 1972. 
-     * INPUT in Kelvin
-     */ 
-double pt_ghamma(double tempka, double patm_pt) 
+/* Prestely and Taylor, 1972. 
+ * INPUT in Kelvin
+ */
+double pt_ghamma(double tempka, double patm_pt)
 {
     double a, result;
-
     double Cp = 1004.16;
 
     tempka -= 273.15;
@@ -16,5 +15,3 @@
     result = Cp * patm_pt / a;
     return result;
 }
-
-



More information about the grass-commit mailing list