[GRASS-SVN] r42450 - grass-addons/raster/r.wf
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jun 2 19:57:32 EDT 2010
Author: epifanio
Date: 2010-06-02 19:57:30 -0400 (Wed, 02 Jun 2010)
New Revision: 42450
Modified:
grass-addons/raster/r.wf/description.html
grass-addons/raster/r.wf/r.wf.py
Log:
changed a flag, update description
Modified: grass-addons/raster/r.wf/description.html
===================================================================
--- grass-addons/raster/r.wf/description.html 2010-06-02 22:03:29 UTC (rev 42449)
+++ grass-addons/raster/r.wf/description.html 2010-06-02 23:57:30 UTC (rev 42450)
@@ -1,37 +1,73 @@
-<h2>DESCRIPTION</h2>
-
-
-<em><b>r.wf</b></em> outputs the Width function from the outlet distance map (r.stream.distance output) and print out percentiles.
-
-
-<h2>NOTES</h2>
-
-The width function defined as the number of pixels having equal
-metric distance from the closing section measured by following the directions of drainage.
-They are calculated as a synthesis of the first 4 statistical moments (mean, variance, skewness,
-kurtosis) and percentiles, or the percentage of pixels within a certain distance from section
-closure (5%, 15%, 30%, 40%, 50%, 60%, 70%, 85%, 95%).
-
-<h2>EXAMPLE</h2>
-
-
-<div class="code"><pre>
-r.wf.py map=dst2out image=path/to/output/prefix
-</pre></div>
-<p>
-
-
-<h2>REFERENCES</h2>
-
-Fractal River Basins - Chance and self organization ( Igatio Rodriguez-Iturbe & Andrea Rinaldo ).
-
-<h2>SEE ALSO</h2>
-
-<em><a HREF="r.ipso.html">r.ipso.py</a></em>
-
-<h2>AUTHOR</h2>
-
-Massimo Di Stefano, Francesco Di Stefano , Margherita Di Leo <br>
-
-
-<p><i>Last changed: $Date: 2010-02-07 00:45:10 +0200 (Mon, 7 Feb 2010) $</i>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<HTML>
+<HEAD>
+ <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
+ <TITLE></TITLE>
+ <META NAME="GENERATOR" CONTENT="OpenOffice.org 2.4 (Unix)">
+ <META NAME="CREATED" CONTENT="0;0">
+ <META NAME="CHANGEDBY" CONTENT="Margherita">
+ <META NAME="CHANGED" CONTENT="20100516;20582200">
+ <META NAME="CHANGEDBY" CONTENT="Margherita">
+ <STYLE TYPE="text/css">
+ <!--
+ @page { size: 8.5in 11in }
+ H2.western { font-family: "Albany", sans-serif; font-size: 14pt; font-style: italic }
+ H2.cjk { font-family: "HG Mincho Light J"; font-size: 14pt; font-style: italic }
+ H2.ctl { font-family: "Arial Unicode MS"; font-size: 14pt; font-style: italic }
+ H4.western { font-family: "Albany", sans-serif; font-size: 11pt; font-style: italic }
+ H4.cjk { font-family: "HG Mincho Light J"; font-size: 11pt; font-style: italic }
+ H4.ctl { font-family: "Arial Unicode MS"; font-size: 11pt; font-style: italic }
+ -->
+ </STYLE>
+</HEAD>
+<BODY LANG="en-US" DIR="LTR">
+<H2 CLASS="western"></H2>
+<HR SIZE=5 NOSHADE>
+<H2 CLASS="western"><FONT COLOR="#00ae00">DESCRIPTION</FONT></H2>
+<P><EM><SPAN STYLE="font-style: normal">The module produces the Width
+Function of a basin. The Width
+Function W(x) gives the number of the
+cells in a basin at a
+flow distance x from the outlet (it is also
+referred as distance-area function)
+. It is important to underline
+the fact that the distance is not the euclidean one, but it is
+measured along the flowpath towards the outlet.</SPAN></EM></P>
+<H2 CLASS="western" STYLE="page-break-after: avoid"><FONT COLOR="#00ae00"><FONT FACE="Albany, sans-serif">KEYWORDS</FONT></FONT></H2>
+<P><EM><SPAN STYLE="font-style: normal">Raster</SPAN></EM></P>
+<H2 CLASS="western" STYLE="page-break-after: avoid"><FONT COLOR="#00ae00"><FONT FACE="Albany, sans-serif">INPUT</FONT></FONT></H2>
+<DL>
+ <DT><EM>Distance to outlet map</EM>
+ </DT><DD STYLE="margin-bottom: 0.2in">
+ Input map, required: This map is obtained by r.stream.distance (with
+ the option: distance to outlet, flag -o)
+ </DD><DT>
+ <EM>output plot</EM>
+ </DT><DD STYLE="margin-bottom: 0.2in">
+ Path and name of the plot</DD></DL>
+<H2 CLASS="western" STYLE="page-break-after: avoid">
+<FONT COLOR="#00ae00"><FONT FACE="Albany, sans-serif">OUTPUT</FONT></FONT></H2>
+<H4 CLASS="western">Parameters
+</H4>
+<P><SPAN STYLE="background: #ffffff">It provides the quantiles of the
+distance distribution</SPAN></P>
+<H4 CLASS="western" STYLE="page-break-after: avoid"><FONT FACE="Albany, sans-serif"><SPAN STYLE="background: #ffffff">Plots</SPAN></FONT></H4>
+<P><SPAN STYLE="background: #ffffff">Width Function. In x axis is the
+length and in y axis is the area.</SPAN></P>
+<H4 CLASS="western"><FONT FACE="Albany, sans-serif">Dependencies </FONT>
+</H4>
+<DL>
+ <DD STYLE="margin-left: 0in; margin-bottom: 0.2in; font-style: normal; font-weight: medium">
+ matplotlib</DD></DL>
+<H2 CLASS="western" STYLE="page-break-after: avoid">
+<FONT COLOR="#00ae00"><FONT FACE="Albany, sans-serif">SEE ALSO</FONT></FONT></H2>
+<P><EM><FONT COLOR="#000080"><U><SPAN STYLE="font-weight: medium">r.stream.distance</SPAN></U></FONT></EM></P>
+<H2 CLASS="western"><FONT COLOR="#00ae00">REFERENCES</FONT></H2>
+<P>Rodriguez-Iturbe I., Rinaldo A., Fractal River Basins, Chance and
+Self – Organization. Cambridge Press (2001)</P>
+<H2 CLASS="western"><FONT COLOR="#00ae00">AUTHORS</FONT></H2>
+<P>Margherita Di Leo, Massimo Di Stefano, Francesco Di Stefano</P>
+<P><I>Last changed: $Date: 2010-05-16 20:55:06 +0100 (Sun, 16 May
+2010) $</I></P>
+</BODY>
+</HTML>
\ No newline at end of file
Modified: grass-addons/raster/r.wf/r.wf.py
===================================================================
--- grass-addons/raster/r.wf/r.wf.py 2010-06-02 22:03:29 UTC (rev 42449)
+++ grass-addons/raster/r.wf/r.wf.py 2010-06-02 23:57:30 UTC (rev 42450)
@@ -3,10 +3,12 @@
#
# MODULE: r.wf.py
#
-# AUTHOR(S): Massimo Di Stefano, Francesco Di Stefano , Margherita Di Leo 2010-02-7
+# AUTHOR(S): Massimo Di Stefano, Francesco Di Stefano, Margherita Di Leo
#
#
-# PURPOSE: Output a Width function graph
+# PURPOSE: The module produces the Width Function of a basin. The Width
+# Function W(x) gives the number of the cells in a basin at a
+# flow distance x from the outlet (distance-area function)
#
# COPYRIGHT: (c) 2010 by the GRASS Development Team
#
@@ -28,7 +30,7 @@
#% type: string
#% gisprompt: old,raster,raster
#% key_desc: name
-#% description: Name of raster map
+#% description: Distance to outlet map (from r.stream.distance)
#% required: yes
#%end
#%option
@@ -36,9 +38,9 @@
#% type: string
#% gisprompt: new_file,file,input
#% key_desc: image
-#% description: output graph
+#% description: output plot
#% required: yes
-#%end
+#%END
import sys
@@ -48,27 +50,38 @@
import numpy as np
def main():
- stats = grass.read_command('r.stats', input = options['map'], fs = 'space', nv = '*', nsteps = '255', flags = 'inc').split('\n')[:-1]
- res = float(grass.read_command('g.region', rast = options['map'], flags = 'm').strip().split('\n')[4].split('=')[1])
+ stats = grass.read_command('r.stats', input = options['map'], fs = 'space', nv = '*', nsteps = '255', flags = 'Anc').split('\n')[:-1]
+
+ # res = cellsize
+ res = float(grass.read_command('g.region', rast = options['map'], flags = 'm').strip().split('\n')[4].split('=')[1])
zn = np.zeros((len(stats),4),float)
kl = np.zeros((len(stats),2),float)
prc = np.zeros((9,2),float)
-
+
for i in range(len(stats)):
if i == 0:
- zn[i,0], zn[i, 1] = map(float, stats[i].split(' '))
+ zn[i,0], zn[i,1] = map(float, stats[i].split(' '))
zn[i,1] = zn[i,1]
zn[i,2] = zn[i,1] * res
if i != 0:
- zn[i,0], zn[i, 1] = map(float, stats[i].split(' '))
- zn[i,2] = zn[i,1] + zn[i-1,2]
+ zn[i,0], zn[i,1] = map(float, stats[i].split(' '))
+ zn[i,2] = zn[i,1] + zn[i-1,2]
zn[i,3] = zn[i,1] * (res**2)
+
totcell = sum(zn[:,1])
+ print "Tot. cells", totcell
+ totarea = totcell * (res**2)
+ print "Tot. area", totarea
+ maxdist = max(zn[:,0])
+ print "Max distance", maxdist
+
for i in range(len(stats)):
- kl[i,0] = zn[i,0]
- kl[i,1] = 1 - (zn[i,2] / totcell)
- prc[0,0] , prc[0,1] = findint(kl,0.05) , 0.05
- prc[1,0] , prc[1,1] = findint(kl,0.15) , 0.15
+ kl[i,0] = zn[i,0]
+ kl[i,1] = zn[i,2] / totcell
+
+ # quantiles
+ prc[0,0] , prc[0,1] = findint(kl,0.05) , 0.05
+ prc[1,0] , prc[1,1] = findint(kl,0.15) , 0.15
prc[2,0] , prc[2,1] = findint(kl,0.3) , 0.3
prc[3,0] , prc[3,1] = findint(kl,0.4) , 0.4
prc[4,0] , prc[4,1] = findint(kl,0.5) , 0.5
@@ -76,9 +89,24 @@
prc[6,0] , prc[6,1] = findint(kl,0.7) , 0.7
prc[7,0] , prc[7,1] = findint(kl,0.85) , 0.85
prc[8,0] , prc[8,1] = findint(kl,0.95) , 0.95
- plotImage(zn[:,0], zn[:,3],options['image']+'_width_function.png','-','L [m]','A [m^2]','Width Function')
- print prc
+
+ # plot
+ plotImage(zn[:,0], zn[:,3], options['image']+'_width_function.png','-','x','W(x)','Width Function')
+ print "==========================="
+ print "Whidth Function | quantiles"
+ print "==========================="
+ print '%.0f' %findint(kl,0.05) , "|", 0.05
+ print '%.0f' %findint(kl,0.15) , "|", 0.15
+ print '%.0f' %findint(kl,0.3) , "|", 0.3
+ print '%.0f' %findint(kl,0.4) , "|", 0.4
+ print '%.0f' %findint(kl,0.5) , "|", 0.5
+ print '%.0f' %findint(kl,0.6) , "|", 0.6
+ print '%.0f' %findint(kl,0.7) , "|", 0.7
+ print '%.0f' %findint(kl,0.85) , "|", 0.85
+ print '%.0f' %findint(kl,0.95) , "|", 0.95
+ print '\n'
+ print 'Done!'
def plotImage(x,y,image,type,xlabel,ylabel,title):
plt.plot(x, y, type)
More information about the grass-commit
mailing list