[GRASS-SVN] r43814 - grass-addons/raster/r.univar.zonal
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Oct 7 06:45:22 EDT 2010
Author: mmetz
Date: 2010-10-07 10:45:22 +0000 (Thu, 07 Oct 2010)
New Revision: 43814
Modified:
grass-addons/raster/r.univar.zonal/globals.h
grass-addons/raster/r.univar.zonal/r.univar.zonal.html
grass-addons/raster/r.univar.zonal/r.univar_main.c
grass-addons/raster/r.univar.zonal/r3.univar.zonal.html
grass-addons/raster/r.univar.zonal/r3.univar_main.c
grass-addons/raster/r.univar.zonal/stats.c
Log:
sync to trunk
Modified: grass-addons/raster/r.univar.zonal/globals.h
===================================================================
--- grass-addons/raster/r.univar.zonal/globals.h 2010-10-07 10:30:11 UTC (rev 43813)
+++ grass-addons/raster/r.univar.zonal/globals.h 2010-10-07 10:45:22 UTC (rev 43814)
@@ -53,7 +53,7 @@
/* command line options are the same for raster and raster3d maps */
typedef struct
{
- struct Option *inputfile, *zonefile, *percentile, *output_file;
+ struct Option *inputfile, *zonefile, *percentile, *output_file, *separator;
struct Flag *shell_style, *extended, *table;
} param_type;
Modified: grass-addons/raster/r.univar.zonal/r.univar.zonal.html
===================================================================
--- grass-addons/raster/r.univar.zonal/r.univar.zonal.html 2010-10-07 10:30:11 UTC (rev 43813)
+++ grass-addons/raster/r.univar.zonal/r.univar.zonal.html 2010-10-07 10:45:22 UTC (rev 43814)
@@ -24,6 +24,9 @@
extended statistics flag is used with a very large region setting. If the
region is too large the module should exit gracefully with a memory allocation
error. Basic statistics can be calculated using any size input region.
+<p>
+Without a <b>zones</b> input raster, the <em>r.quantile</em> module will
+be significantly more efficient for calculating percentiles with large maps.
<h2>EXAMPLE</h2>
@@ -107,17 +110,16 @@
<em>
<a href="g.region.html">g.region</a><br>
<a href="r3.univar.html">r3.univar</a><br>
-<a href="r.univar.sh.html">r.univar.sh</a><br>
<a href="r.average.html">r.average</a><br>
<a href="r.median.html">r.median</a><br>
<a href="r.mode.html">r.mode</a><br>
+<a href="r.quantile.html">r.quantile</a><br>
<a href="r.sum.html">r.sum</a><br>
<a href="r.series.html">r.series</a><br>
<a href="r.stats.html">r.stats</a><br>
<a href="v.rast.stats.html">v.rast.stats</a><br>
<a href="r.statistics.html">r.statistics</a><br>
<a href="v.univar.html">v.univar</a><br>
-<a href="v.univar.sh.html">v.univar.sh</a><br>
</em>
Modified: grass-addons/raster/r.univar.zonal/r.univar_main.c
===================================================================
--- grass-addons/raster/r.univar.zonal/r.univar_main.c 2010-10-07 10:30:11 UTC (rev 43813)
+++ grass-addons/raster/r.univar.zonal/r.univar_main.c 2010-10-07 10:45:22 UTC (rev 43814)
@@ -50,6 +50,9 @@
param.percentile->description =
_("Percentile to calculate (requires extended statistics flag)");
+ param.separator = G_define_standard_option(G_OPT_F_SEP);
+ param.separator->description = _("Special characters: space, comma, tab");
+
param.shell_style = G_define_flag();
param.shell_style->key = 'g';
param.shell_style->description =
@@ -87,7 +90,6 @@
struct Range zone_range;
char *mapset, *name;
-
G_gisinit(argv[0]);
module = G_define_module();
@@ -112,11 +114,19 @@
rows = region.rows;
cols = region.cols;
- /* TODO: make table field separator an option */
- zone_info.sep = "|";
+ /* table field separator */
+ zone_info.sep = param.separator->answer;
+ if (strcmp(zone_info.sep, "\\t") == 0)
+ zone_info.sep = "\t";
+ if (strcmp(zone_info.sep, "tab") == 0)
+ zone_info.sep = "\t";
+ if (strcmp(zone_info.sep, "space") == 0)
+ zone_info.sep = " ";
+ if (strcmp(zone_info.sep, "comma") == 0)
+ zone_info.sep = ",";
- zone_info.min = 0.0 / 0.0; /*set to nan as default */
- zone_info.max = 0.0 / 0.0; /*set to nan as default */
+ zone_info.min = 0.0 / 0.0; /* set to nan as default */
+ zone_info.max = 0.0 / 0.0; /* set to nan as default */
zone_info.n_zones = 0;
fdz = -1;
Modified: grass-addons/raster/r.univar.zonal/r3.univar.zonal.html
===================================================================
--- grass-addons/raster/r.univar.zonal/r3.univar.zonal.html 2010-10-07 10:30:11 UTC (rev 43813)
+++ grass-addons/raster/r.univar.zonal/r3.univar.zonal.html 2010-10-07 10:45:22 UTC (rev 43814)
@@ -25,6 +25,11 @@
region is too large the module should exit gracefully with a memory allocation
error. Basic statistics can be calculated using any size input region.
+<!-- no rast3D support?
+<p>
+The <em>r.quantile</em> module will be significantly more efficient for
+calculating percentiles with large maps.
+-->
<h2>TODO</h2>
@@ -37,16 +42,15 @@
<em>
<a href="g.region.html">g.region</a><br>
<a href="r.univar.html">r.univar</a><br>
-<a href="r.univar.sh.html">r.univar.sh</a><br>
<a href="r.average.html">r.average</a><br>
<a href="r.median.html">r.median</a><br>
<a href="r.mode.html">r.mode</a><br>
+<a href="r.quantile.html">r.quantile</a><br>
<a href="r.sum.html">r.sum</a><br>
<a href="r.series.html">r.series</a><br>
<a href="r.stats.html">r.stats</a><br>
<a href="r.statistics.html">r.statistics</a><br>
<a href="v.univar.html">v.univar</a><br>
-<a href="v.univar.sh.html">v.univar.sh</a><br>
</em>
Modified: grass-addons/raster/r.univar.zonal/r3.univar_main.c
===================================================================
--- grass-addons/raster/r.univar.zonal/r3.univar_main.c 2010-10-07 10:30:11 UTC (rev 43813)
+++ grass-addons/raster/r.univar.zonal/r3.univar_main.c 2010-10-07 10:45:22 UTC (rev 43814)
@@ -51,6 +51,9 @@
param.percentile->description =
_("Percentile to calculate (requires extended statistics flag)");
+ param.separator = G_define_standard_option(G_OPT_F_SEP);
+ param.separator->description = _("Special characters: space, comma, tab");
+
param.shell_style = G_define_flag();
param.shell_style->key = 'g';
param.shell_style->description =
@@ -107,10 +110,10 @@
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
- /*Set the defaults */
+ /* Set the defaults */
G3d_initDefaults();
- /*get the current region */
+ /* get the current region */
G3d_getWindow(®ion);
cols = region.cols;
@@ -124,13 +127,21 @@
}
}
- /* TODO: make table field separator an option */
- zone_info.sep = "|";
+ /* table field separator */
+ zone_info.sep = param.separator->answer;
+ if (strcmp(zone_info.sep, "\\t") == 0)
+ zone_info.sep = "\t";
+ if (strcmp(zone_info.sep, "tab") == 0)
+ zone_info.sep = "\t";
+ if (strcmp(zone_info.sep, "space") == 0)
+ zone_info.sep = " ";
+ if (strcmp(zone_info.sep, "comma") == 0)
+ zone_info.sep = ",";
- dmin = 0.0 / 0.0; /*set to nan as default */
- dmax = 0.0 / 0.0; /*set to nan as default */
- zone_info.min = 0.0 / 0.0; /*set to nan as default */
- zone_info.max = 0.0 / 0.0; /*set to nan as default */
+ dmin = 0.0 / 0.0; /* set to nan as default */
+ dmax = 0.0 / 0.0; /* set to nan as default */
+ zone_info.min = 0.0 / 0.0; /* set to nan as default */
+ zone_info.max = 0.0 / 0.0; /* set to nan as default */
zone_info.n_zones = 0;
/* open 3D zoning raster with default region */
@@ -174,7 +185,7 @@
use_zone = 1;
}
- /*Open 3D input raster with default region */
+ /* Open 3D input raster with default region */
infile = param.inputfile->answer;
if (NULL == G_find_grid3(infile, ""))
@@ -200,7 +211,7 @@
}
}
- for (z = 0; z < depths; z++) { /*From the bottom to the top */
+ for (z = 0; z < depths; z++) { /* From the bottom to the top */
if (!(param.shell_style->answer))
G_percent(z, depths - 1, 10);
for (y = 0; y < rows; y++) {
Modified: grass-addons/raster/r.univar.zonal/stats.c
===================================================================
--- grass-addons/raster/r.univar.zonal/stats.c 2010-10-07 10:30:11 UTC (rev 43813)
+++ grass-addons/raster/r.univar.zonal/stats.c 2010-10-07 10:45:22 UTC (rev 43814)
@@ -113,7 +113,7 @@
char sum_str[100];
double mean, variance, stdev, var_coef;
- /*for extendet stats */
+ /* for extendet stats */
double quartile_25 = 0.0, quartile_75 = 0.0, *quartile_perc;
double median = 0.0;
unsigned int i;
@@ -123,7 +123,6 @@
if (stats[z].n == 0)
continue;
-
/* all these calculations get promoted to doubles, so any DIV0 becomes nan */
mean = stats[z].sum / stats[z].n;
variance = (stats[z].sumsq - stats[z].sum * stats[z].sum / stats[z].n) / stats[z].n;
@@ -145,8 +144,9 @@
}
if (param.shell_style->answer) {
- fprintf(stdout, "non_null_cells=%d\n", stats[z].n);
+ fprintf(stdout, "n=%d\n", stats[z].n);
fprintf(stdout, "null_cells=%d\n", stats[z].size - stats[z].n);
+ fprintf(stdout, "cells=%d\n", stats->size);
fprintf(stdout, "min=%.15g\n", stats[z].min);
fprintf(stdout, "max=%.15g\n", stats[z].max);
fprintf(stdout, "range=%.15g\n", stats[z].max - stats[z].min);
More information about the grass-commit
mailing list