[GRASS-SVN] r51632 - grass-addons/grass7/raster/r.gdd
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed May 16 11:48:08 EDT 2012
Author: mmetz
Date: 2012-05-16 08:48:08 -0700 (Wed, 16 May 2012)
New Revision: 51632
Added:
grass-addons/grass7/raster/r.gdd/r.gdd.html
Removed:
grass-addons/grass7/raster/r.gdd/r.series.html
grass-addons/grass7/raster/r.gdd/test_suite/
Modified:
grass-addons/grass7/raster/r.gdd/Makefile
grass-addons/grass7/raster/r.gdd/main.c
Log:
new r.gdd
Modified: grass-addons/grass7/raster/r.gdd/Makefile
===================================================================
--- grass-addons/grass7/raster/r.gdd/Makefile 2012-05-16 15:45:46 UTC (rev 51631)
+++ grass-addons/grass7/raster/r.gdd/Makefile 2012-05-16 15:48:08 UTC (rev 51632)
@@ -1,10 +1,13 @@
MODULE_TOPDIR = ../..
-PGM = r.series
+PGM = r.gdd
-LIBES = $(STATSLIB) $(RASTERLIB) $(GISLIB)
-DEPENDENCIES = $(STATSDEP) $(RASTERDEP) $(GISDEP)
+LIBES = $(RASTERLIB) $(GISLIB)
+DEPENDENCIES = $(RASTERDEP) $(GISDEP)
+EXTRA_LIBS = $(OMPLIB)
+EXTRA_CFLAGS = $(OMPCFLAGS)
+
include $(MODULE_TOPDIR)/include/Make/Module.make
default: cmd
Modified: grass-addons/grass7/raster/r.gdd/main.c
===================================================================
--- grass-addons/grass7/raster/r.gdd/main.c 2012-05-16 15:45:46 UTC (rev 51631)
+++ grass-addons/grass7/raster/r.gdd/main.c 2012-05-16 15:48:08 UTC (rev 51632)
@@ -1,12 +1,11 @@
/****************************************************************************
*
- * MODULE: r.series
- * AUTHOR(S): Glynn Clements <glynn gclements.plus.com> (original contributor)
- * Hamish Bowman <hamish_b yahoo.com>, Jachym Cepicky <jachym les-ejk.cz>,
- * Martin Wegmann <wegmann biozentrum.uni-wuerzburg.de>
- * PURPOSE:
- * COPYRIGHT: (C) 2002-2008 by the GRASS Development Team
+ * MODULE: r.gdd
+ * AUTHOR(S): Markus Metz
+ * based on r.series
+ * PURPOSE: Calculate Growing Degree Days (GDDs)
+ * COPYRIGHT: (C) 2012 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
@@ -22,235 +21,43 @@
#include <grass/gis.h>
#include <grass/raster.h>
#include <grass/glocale.h>
-#include <grass/stats.h>
-struct menu
-{
- stat_func *method; /* routine to compute new value */
- stat_func_w *method_w; /* routine to compute new value (weighted) */
- int is_int; /* result is an integer */
- char *name; /* method name */
- char *text; /* menu display - full description */
-} menu[] = {
- {c_ave, w_ave, 0, "average", "average value"},
- {c_count, NULL, 1, "count", "count of non-NULL cells"},
- {c_median, w_median, 0, "median", "median value"},
- {c_mode, w_mode, 0, "mode", "most frequently occuring value"},
- {c_min, NULL, 0, "minimum", "lowest value"},
- {c_minx, NULL, 1, "min_raster", "raster with lowest value"},
- {c_max, NULL, 0, "maximum", "highest value"},
- {c_maxx, NULL, 1, "max_raster", "raster with highest value"},
- {c_stddev, w_stddev, 0, "stddev", "standard deviation"},
- {c_range, NULL, 0, "range", "range of values"},
- {c_sum, w_sum, 0, "sum", "sum of values"},
- {c_var, w_var, 0, "variance", "statistical variance"},
- {c_divr, NULL, 1, "diversity", "number of different values"},
- {c_reg_m, NULL, 0, "slope", "linear regression slope"},
- {c_reg_c, NULL, 0, "offset", "linear regression offset"},
- {c_reg_r2, NULL, 0, "detcoeff", "linear regression coefficient of determination"},
- {c_quart1, w_quart1, 0, "quart1", "first quartile"},
- {c_quart3, w_quart3, 0, "quart3", "third quartile"},
- {c_perc90, w_perc90, 0, "perc90", "ninetieth percentile"},
- {c_quant, w_quant, 0, "quantile", "arbitrary quantile"},
- {c_skew, w_skew, 0, "skewness", "skewness"},
- {c_kurt, w_kurt, 0, "kurtosis", "kurtosis"},
- {NULL, NULL, 0, NULL, NULL}
-};
-
-static double f_box(double x)
-{
- return (x > 1) ? 0
- : 1;
-}
-
-static double f_bartlett(double x)
-{
- return (x > 1) ? 0
- : 1 - x;
-}
-
-static double f_hermite(double x)
-{
- return (x > 1) ? 0
- : (2 * x - 3) * x * x + 1;
-}
-
-static double f_gauss(double x)
-{
- return exp(-2 * x * x) * sqrt(2 / M_PI);
-}
-
-static double f_normal(double x)
-{
- return f_gauss(x / 2) / 2;
-}
-
-static double f_sinc(double x)
-{
- return (x == 0) ? 1 : sin(M_PI * x) / (M_PI * x);
-}
-
-static double lanczos(double x, int a)
-{
- return (x > a) ? 0
- : f_sinc(x) * f_sinc(x / a);
-}
-
-static double f_lanczos1(double x)
-{
- return lanczos(x, 1);
-}
-
-static double f_lanczos2(double x)
-{
- return lanczos(x, 2);
-}
-
-static double f_lanczos3(double x)
-{
- return lanczos(x, 3);
-}
-
-static double f_hann(double x)
-{
- return cos(M_PI * x) / 2 + 0.5;
-}
-
-static double f_hamming(double x)
-{
- return 0.46 * cos(M_PI * x) + 0.54;
-}
-
-
-static double f_blackman(double x)
-{
- return cos(M_PI * x) / 2 + 0.08 * cos(2 * M_PI * x) + 0.42;
-}
-
-struct window_type {
- const char *name;
- double (*func)(double);
- int radius;
-} w_menu[] = {
- {"box", f_box, 1},
- {"bartlett", f_bartlett, 1},
- {"gauss", f_gauss, 4},
- {"normal", f_normal, 8},
- {"hermite", f_hermite, 1},
- {"sinc", f_sinc, 0},
- {"lanczos1", f_lanczos1, 1},
- {"lanczos2", f_lanczos2, 2},
- {"lanczos3", f_lanczos3, 3},
- {"hann", f_hann, 0},
- {"hamming", f_hamming, 0},
- {"blackman", f_blackman, 0},
- {NULL},
-};
-
-static char *build_window_list(void)
-{
- char *buf = G_malloc(1024);
- char *p = buf;
- int i;
-
- for (i = 0; w_menu[i].name; i++) {
- const char *q;
-
- if (i)
- *p++ = ',';
- for (q = w_menu[i].name; *q; p++, q++)
- *p = *q;
- }
- *p = '\0';
-
- return buf;
-}
-
-static int find_window(const char *name)
-{
- int i;
-
- for (i = 0; w_menu[i].name; i++)
- if (strcmp(w_menu[i].name, name) == 0)
- return i;
-
- G_fatal_error(_("Unknown window <%s>"), name);
-
- return -1;
-}
-
struct input
{
const char *name;
int fd;
- DCELL *buf;
+ FCELL *buf;
};
struct output
{
const char *name;
int fd;
- DCELL *buf;
- stat_func *method_fn;
- stat_func_w *method_fn_w;
- double quantile;
+ FCELL *buf;
};
-static char *build_method_list(void)
-{
- char *buf = G_malloc(1024);
- char *p = buf;
- int i;
-
- for (i = 0; menu[i].name; i++) {
- char *q;
-
- if (i)
- *p++ = ',';
- for (q = menu[i].name; *q; p++, q++)
- *p = *q;
- }
- *p = '\0';
-
- return buf;
-}
-
-static int find_method(const char *method_name)
-{
- int i;
-
- for (i = 0; menu[i].name; i++)
- if (strcmp(menu[i].name, method_name) == 0)
- return i;
-
- G_fatal_error(_("Unknown method <%s>"), method_name);
-
- return -1;
-}
-
int main(int argc, char *argv[])
{
struct GModule *module;
struct
{
- struct Option *input, *file, *output, *method, *quantile, *range, *weight;
+ struct Option *input, *gdd, *file, *output, *range,
+ *scale, *shift, *baseline, *cutoff;
} parm;
struct
{
- struct Flag *nulls, *lazy, *outlier;
+ struct Flag *nulls, *lazy, *avg;
} flag;
int i;
- int num_inputs;
+ int num_inputs, max_inputs, gdd_in;
struct input *inputs = NULL;
- int num_outputs;
- struct output *outputs = NULL;
+ struct output *out = NULL;
struct History history;
- DCELL *values = NULL, *values_tmp = NULL;
- DCELL (*values_w)[2], (*values_tmp_w)[2]; /* list of neighborhood values and weights */
- double *weights;
+ struct Colors colors;
int nrows, ncols;
int row, col;
- double lo, hi;
+ double lo, hi, tscale, tshift, baseline, cutoff;
+ FCELL fnull;
G_gisinit(argv[0]);
@@ -265,44 +72,57 @@
parm.input = G_define_standard_option(G_OPT_R_INPUTS);
parm.input->required = NO;
+ parm.gdd = G_define_standard_option(G_OPT_R_INPUT);
+ parm.gdd->key = "gdd";
+ parm.gdd->description = _("Existing GDD map to be added to output");
+ parm.gdd->required = NO;
+
parm.file = G_define_standard_option(G_OPT_F_INPUT);
parm.file->key = "file";
parm.file->description = _("Input file with raster map names, one per line");
parm.file->required = NO;
parm.output = G_define_standard_option(G_OPT_R_OUTPUT);
- parm.output->multiple = YES;
+ parm.output->multiple = NO;
- parm.method = G_define_option();
- parm.method->key = "method";
- parm.method->type = TYPE_STRING;
- parm.method->required = YES;
- parm.method->options = build_method_list();
- parm.method->description = _("Aggregate operation");
- parm.method->multiple = YES;
+ parm.scale = G_define_option();
+ parm.scale->key = "scale";
+ parm.scale->type = TYPE_DOUBLE;
+ parm.scale->answer = "1.0";
+ parm.scale->required = NO;
+ parm.scale->description = _("Scale factor for input");
- parm.weight = G_define_option();
- parm.weight->key = "window";
- parm.weight->type = TYPE_STRING;
- parm.weight->required = NO;
- parm.weight->multiple = NO;
- parm.weight->description = _("weighing window");
- parm.weight->options = build_window_list();
+ parm.shift = G_define_option();
+ parm.shift->key = "shift";
+ parm.shift->type = TYPE_DOUBLE;
+ parm.shift->answer = "0.0";
+ parm.shift->required = NO;
+ parm.shift->description = _("Shift factor for input");
- parm.quantile = G_define_option();
- parm.quantile->key = "quantile";
- parm.quantile->type = TYPE_DOUBLE;
- parm.quantile->required = NO;
- parm.quantile->description = _("Quantile to calculate for method=quantile");
- parm.quantile->options = "0.0-1.0";
- parm.quantile->multiple = YES;
+ parm.baseline = G_define_option();
+ parm.baseline->key = "baseline";
+ parm.baseline->type = TYPE_DOUBLE;
+ parm.baseline->required = NO;
+ parm.baseline->answer = "10";
+ parm.baseline->description = _("Baseline temperature");
+ parm.cutoff = G_define_option();
+ parm.cutoff->key = "cutoff";
+ parm.cutoff->type = TYPE_DOUBLE;
+ parm.cutoff->required = NO;
+ parm.cutoff->answer = "30";
+ parm.cutoff->description = _("Cutoff temperature");
+
parm.range = G_define_option();
parm.range->key = "range";
parm.range->type = TYPE_DOUBLE;
parm.range->key_desc = "lo,hi";
parm.range->description = _("Ignore values outside this range");
+ flag.avg = G_define_flag();
+ flag.avg->key = 'a';
+ flag.avg->description = _("Use average instead of min, max");
+
flag.nulls = G_define_flag();
flag.nulls->key = 'n';
flag.nulls->description = _("Propagate NULLs");
@@ -311,36 +131,45 @@
flag.lazy->key = 'z';
flag.lazy->description = _("Don't keep files open");
- flag.outlier = G_define_flag();
- flag.outlier->key = 'o';
- flag.outlier->description = _("Remove outliers");
-
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
+ lo = -1.0 / 0.0;
+ hi = 1.0 / 0.0;
if (parm.range->answer) {
lo = atof(parm.range->answers[0]);
hi = atof(parm.range->answers[1]);
}
+ if (parm.scale->answer)
+ tscale = atof(parm.scale->answer);
+ else
+ tscale = 1.;
+
+ if (parm.shift->answer)
+ tshift = atof(parm.shift->answer);
+ else
+ tshift = 0.;
+
+ baseline = atof(parm.baseline->answer);
+ cutoff = atof(parm.cutoff->answer);
+
if (parm.input->answer && parm.file->answer)
G_fatal_error(_("input= and file= are mutually exclusive"));
if (!parm.input->answer && !parm.file->answer)
G_fatal_error(_("Please specify input= or file="));
-
+ max_inputs = 0;
/* process the input maps from the file */
if (parm.file->answer) {
FILE *in;
- int max_inputs;
in = fopen(parm.file->answer, "r");
if (!in)
G_fatal_error(_("Unable to open input file <%s>"), parm.file->answer);
num_inputs = 0;
- max_inputs = 0;
for (;;) {
char buf[GNAME_MAX];
@@ -364,7 +193,7 @@
p->name = G_store(name);
G_verbose_message(_("Reading raster map <%s>..."), p->name);
- p->buf = Rast_allocate_d_buf();
+ p->buf = Rast_allocate_f_buf();
if (!flag.lazy->answer)
p->fd = Rast_open_old(p->name, "");
}
@@ -389,86 +218,42 @@
p->name = parm.input->answers[i];
G_verbose_message(_("Reading raster map <%s>..."), p->name);
- p->buf = Rast_allocate_d_buf();
+ p->buf = Rast_allocate_f_buf();
if (!flag.lazy->answer)
p->fd = Rast_open_old(p->name, "");
}
+ max_inputs = num_inputs;
}
- /* set the weights */
- if (parm.weight->answer) {
- int method = find_window(parm.weight->answer);
- double (*func)(double) = w_menu[method].func;
- double radius = (num_inputs - 1) / 2.0;
-
- values_w = (DCELL(*)[2]) G_malloc(num_inputs * 2 * sizeof(DCELL));
- values_tmp_w = (DCELL(*)[2]) G_malloc(num_inputs * 2 * sizeof(DCELL));
- weights = (DCELL *) G_malloc(num_inputs * sizeof(DCELL));
+ if (parm.gdd->answer) {
+ struct input *p;
- for (i = 0; i < num_inputs; i++) {
- double x = fabs((i - radius) / radius);
-
- if (w_menu[method].radius > 1)
- x *= w_menu[method].radius;
- weights[i] = (*func)(x);
+ gdd_in = 1;
+ if (num_inputs + 1 >= max_inputs) {
+ max_inputs += 2;
+ inputs = G_realloc(inputs, max_inputs * sizeof(struct input));
}
+ p = &inputs[num_inputs];
+ p->name = parm.gdd->answer;
+ G_verbose_message(_("Reading raster map <%s>..."), p->name);
+ p->buf = Rast_allocate_f_buf();
+ if (!flag.lazy->answer)
+ p->fd = Rast_open_old(p->name, "");
}
- else {
- values_w = NULL;
- values_tmp_w = NULL;
- weights = NULL;
- }
+ else
+ gdd_in = 0;
- /* process the output maps */
- for (i = 0; parm.output->answers[i]; i++)
- ;
- num_outputs = i;
+ out = G_calloc(1, sizeof(struct output));
- for (i = 0; parm.method->answers[i]; i++)
- ;
- if (num_outputs != i)
- G_fatal_error(_("output= and method= must have the same number of values"));
+ out->name = parm.output->answer;
- outputs = G_calloc(num_outputs, sizeof(struct output));
+ out->buf = Rast_allocate_f_buf();
+ out->fd = Rast_open_new(out->name, FCELL_TYPE);
- for (i = 0; i < num_outputs; i++) {
- struct output *out = &outputs[i];
- const char *output_name = parm.output->answers[i];
- const char *method_name = parm.method->answers[i];
- int method = find_method(method_name);
-
- out->name = output_name;
- if (weights) {
- if (menu[method].method_w) {
- out->method_fn = NULL;
- out->method_fn_w = menu[method].method_w;
- }
- else {
- G_warning(_("Method %s not compatible with weighing window, using unweighed version instead"),
- method_name);
-
- out->method_fn = menu[method].method;
- out->method_fn_w = NULL;
- }
- }
- else {
- out->method_fn = menu[method].method;
- out->method_fn_w = NULL;
- }
- out->quantile = (parm.quantile->answer && parm.quantile->answers[i])
- ? atof(parm.quantile->answers[i])
- : 0;
- out->buf = Rast_allocate_d_buf();
- out->fd = Rast_open_new(output_name,
- menu[method].is_int ? CELL_TYPE : DCELL_TYPE);
- }
-
- /* initialise variables */
- values = G_malloc(num_inputs * sizeof(DCELL));
- values_tmp = G_malloc(num_inputs * sizeof(DCELL));
-
nrows = Rast_window_rows();
ncols = Rast_window_cols();
+
+ Rast_set_f_null_value(&fnull, 1);
/* process the data */
G_verbose_message(_("Percent complete..."));
@@ -478,108 +263,100 @@
if (flag.lazy->answer) {
/* Open the files only on run time */
- for (i = 0; i < num_inputs; i++) {
+ for (i = 0; i < num_inputs + gdd_in; i++) {
inputs[i].fd = Rast_open_old(inputs[i].name, "");
- Rast_get_d_row(inputs[i].fd, inputs[i].buf, row);
+ Rast_get_f_row(inputs[i].fd, inputs[i].buf, row);
Rast_close(inputs[i].fd);
}
}
else {
- for (i = 0; i < num_inputs; i++)
- Rast_get_d_row(inputs[i].fd, inputs[i].buf, row);
+ for (i = 0; i < num_inputs + gdd_in; i++)
+ Rast_get_f_row(inputs[i].fd, inputs[i].buf, row);
}
+ #pragma omp for schedule (static) private (col)
+
for (col = 0; col < ncols; col++) {
int null = 0, non_null = 0;
+ FCELL min, max, sum, gdd;
+ min = fnull;
+ max = fnull;
+ sum = 0;
+
for (i = 0; i < num_inputs; i++) {
- DCELL v = inputs[i].buf[col];
+ FCELL v = inputs[i].buf[col];
- if (Rast_is_d_null_value(&v))
+ if (Rast_is_f_null_value(&v))
null = 1;
- else if (parm.range->answer && (v < lo || v > hi)) {
- Rast_set_d_null_value(&v, 1);
- null = 1;
- }
- else
- non_null++;
+ else {
+ v = v * tscale + tshift;
+ if (parm.range->answer && (v < lo || v > hi)) {
+ null = 1;
+ }
+ else {
+ if (v < baseline)
+ v = baseline;
+ if (v > cutoff)
+ v = cutoff;
- if (weights) {
- values_w[i][0] = v;
- values_w[i][1] = weights[i];
+ if (flag.avg->answer)
+ sum += v;
+ else {
+ if (Rast_is_f_null_value(&min) || min > v)
+ min = v;
+ if (Rast_is_f_null_value(&max) || max < v)
+ max = v;
+ }
+ non_null++;
+ }
}
- values[i] = v;
}
- if (flag.outlier->answer && non_null > 5) {
- /* remove outlier */
- /* lower bound = 1st_Quartile - 1.5 * (3rd_Quartile - 1st_Quartile) */
- double quart1, quart3, lower_bound;
+ if (!non_null || (null && flag.nulls->answer)) {
+ if (gdd_in)
+ gdd = inputs[num_inputs].buf[col];
+ else
+ gdd = fnull;
+ }
+ else {
- memcpy(values_tmp, values, num_inputs * sizeof(DCELL));
- c_quart1(&quart1, values_tmp, num_inputs, NULL);
- memcpy(values_tmp, values, num_inputs * sizeof(DCELL));
- c_quart3(&quart3, values_tmp, num_inputs, NULL);
-
- if (quart1 < quart3)
- lower_bound = quart1 - 0.5 * (quart3 - quart1);
+ if (flag.avg->answer)
+ gdd = sum / non_null - baseline;
else
- lower_bound = -1e100;
+ gdd = (min + max) / 2. - baseline;
- for (i = 0; i < num_inputs; i++) {
- DCELL v = values[i];
+ if (gdd < 0.)
+ gdd = 0.;
+ if (gdd_in)
+ gdd += inputs[num_inputs].buf[col];
- if (v <= lower_bound) {
- Rast_set_d_null_value(&v, 1);
- null = 1;
- /* non_null--; */
- values[i] = v;
- if (weights)
- values_w[i][0] = v;
- }
- }
}
-
- for (i = 0; i < num_outputs; i++) {
- struct output *out = &outputs[i];
-
- if (non_null < 2 || (null && flag.nulls->answer))
- Rast_set_d_null_value(&out->buf[col], 1);
- else {
- if (out->method_fn_w) {
- memcpy(values_tmp_w, values_w, num_inputs * 2 * sizeof(DCELL));
- (*out->method_fn_w)(&out->buf[col], values_tmp_w, num_inputs, &out->quantile);
- }
- else {
- memcpy(values_tmp, values, num_inputs * sizeof(DCELL));
- (*out->method_fn)(&out->buf[col], values_tmp, num_inputs, &out->quantile);
- }
- }
- }
+ out->buf[col] = gdd;
}
- for (i = 0; i < num_outputs; i++)
- Rast_put_d_row(outputs[i].fd, outputs[i].buf);
+ Rast_put_f_row(out->fd, out->buf);
}
G_percent(row, nrows, 2);
- /* close output maps */
- for (i = 0; i < num_outputs; i++) {
- struct output *out = &outputs[i];
+ /* close output map */
+ Rast_close(out->fd);
- Rast_close(out->fd);
+ Rast_short_history(out->name, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(out->name, &history);
- Rast_short_history(out->name, "raster", &history);
- Rast_command_history(&history);
- Rast_write_history(out->name, &history);
- }
-
/* Close input maps */
if (!flag.lazy->answer) {
- for (i = 0; i < num_inputs; i++)
+ for (i = 0; i < num_inputs + gdd_in; i++)
Rast_close(inputs[i].fd);
}
+ /* set gdd color table */
+ Rast_init_colors(&colors);
+ Rast_make_colors(&colors, "gdd", 0, 6000);
+ Rast_write_colors(out->name, NULL, &colors);
+
exit(EXIT_SUCCESS);
}
Copied: grass-addons/grass7/raster/r.gdd/r.gdd.html (from rev 51631, grass-addons/grass7/raster/r.gdd/r.series.html)
===================================================================
--- grass-addons/grass7/raster/r.gdd/r.gdd.html (rev 0)
+++ grass-addons/grass7/raster/r.gdd/r.gdd.html 2012-05-16 15:48:08 UTC (rev 51632)
@@ -0,0 +1,99 @@
+<h2>DESCRIPTION</h2>
+
+<em>r.gdd</em> calculates (accumulated) growing degree days (GDDs) from
+several input maps with temperature data for different times of the day.
+<p>
+The formula for calculating GDDs is
+<div class="code"><pre>
+ gdd = (max + min) / 2 - baseline
+</pre></div>
+or using the average from all input maps
+<div class="code"><pre>
+ gdd = average - baseline
+</pre></div>
+with <em>min</em> being the minimum daily temperature, <em>max</em>
+the maximum daily temperature and <em>average</em> the average daily
+temperature. The <em>min</em>, <em>max</em> and <em>average</em> values
+are automatically calculated from the input temperature maps.
+<p>
+Negative GDD values are set to 0 (zero). All (scaled and shifted)
+temperature values above the <em>cutoff</em> value are set to
+<em>cutoff</em>, and all (scaled and shifted) temperature values below
+the <em>baseline</em> value are set to <em>baseline</em>.
+<p>
+If an existing GDD map is provided with the <em>gdd</em> option, the
+values of this GDD map are added to the output, thus accumulating GDDs.
+
+<h2>NOTES</h2>
+
+The <em>scale</em> and <em>shift</em> parameters are used to transform
+input values with
+<div class="code"><pre>
+ new = old * scale + shift
+</pre></div>
+<p>
+With the <em>-n</em> flag, any cell for which any of the
+corresponding input cells are NULL is automatically set to NULL
+(NULL propagation) and the GDD value is not calculated.
+<p>
+Without the <em>-n</em> flag, all non-NULL cells are used to
+calculate the current GDD.
+<p>
+If the <em>range=</em> option is given, any values which fall outside
+that range will be treated as if they were NULL. Note that the range is
+applied to the scaled and shifted input data. The <em>range</em>
+parameter can be set to <em>low,high</em> thresholds:
+values outside of this range are treated as NULL (i.e., they will be
+ignored by most aggregates, or will cause the result to be NULL if -n
+is given). The <em>low,high</em> thresholds are floating point, so use
+<em>-inf</em> or <em>inf</em> for a single threshold (e.g.,
+<em>range=0,inf</em> to ignore negative values, or
+<em>range=-inf,-200.4</em> to ignore values above -200.4).
+<p>
+The number of raster maps to be processed is given by the limit of the
+operating system. For example, both the hard and soft limits are
+typically 1024. The soft limit can be changed with e.g.
+<tt>ulimit -n 1500</tt> (UNIX-based operating systems) but not higher
+than the hard limit. If it is too low, you can as superuser add an
+entry in
+
+<div class="code"><pre>
+/etc/security/limits.conf
+# <domain> <type> <item> <value>
+your_username hard nofile 1500
+</pre></div>
+
+This would raise the hard limit to 1500 file. Be warned that more
+files open need more RAM.
+
+<p>
+Use the <em>file</em> option to analyze large amount of raster maps
+without hitting open files limit and the size limit of command line
+arguments. The computation is slower than the <em>input</em> option
+method. For every sinlge row in the output map(s) all input maps are
+opened and closed. The amount of RAM will rise linear with the
+number of specified input maps. The input and file options are
+mutually exclusive. Input is a text file with a new line separated
+list of raster map names and optional weights. As separator between
+the map name and the weight the charachter | must be used.
+
+<h2>EXAMPLES</h2>
+
+Example with MODIS Land Surface Temperature, transforming values from
+Kelvin * 50 to degrees Celsius:
+<div class="code"><pre>
+r.gdd in=MOD11A1.Day,MOD11A1.Night,MYD11A1.Day,MYD11A1.Night out=MCD11A1.GDD \
+ scale=0.02 shift=-273.15 baseline=10 cutoff=30
+</pre></div>
+
+<h2>SEE ALSO</h2>
+
+<em><a href="r.series.html">r.series</a></em>,
+<em><a href="g.mlist.html">g.mlist</a></em>,
+<em><a href="g.region.html">g.region</a></em>
+
+<h2>AUTHOR</h2>
+
+Glynn Clements
+
+<p><i>Last changed: $Date$</i>
Deleted: grass-addons/grass7/raster/r.gdd/r.series.html
===================================================================
--- grass-addons/grass7/raster/r.gdd/r.series.html 2012-05-16 15:45:46 UTC (rev 51631)
+++ grass-addons/grass7/raster/r.gdd/r.series.html 2012-05-16 15:48:08 UTC (rev 51632)
@@ -1,146 +0,0 @@
-<h2>DESCRIPTION</h2>
-
-<em>r.series</em> makes each output cell value a function of the values
-assigned to the corresponding cells in the input raster map layers.
-Following methods are available:
-
-<ul>
- <li>average: average value
- <li>count: count of non-NULL cells
- <li>median: median value
- <li>mode: most frequently occuring value
- <li>minimum: lowest value
- <li>maximum: highest value
- <li>range: range of values (max - min)
- <li>stddev: standard deviation
- <li>sum: sum of values
- <li>variance: statistical variance
- <li>diversity: number of different values
- <li>slope: linear regression slope
- <li>offset: linear regression offset
- <li>detcoeff: linear regression coefficient of determination
- <li>min_raster: raster map number with the minimum time-series value
- <li>max_raster: raster map number with the maximum time-series value
- </ul>
-
-<h2>NOTES</h2>
-
-With <em>-n</em> flag, any cell for which any of the corresponding input cells are
-NULL is automatically set to NULL (NULL propagation). The aggregate function is not
-called, so all methods behave this way with respect to the <em>-n</em> flag.
-<p>Without <em>-n</em> flag, the complete list of inputs for each cell (including
-NULLs) is passed to the aggregate function. Individual aggregates can
-handle data as they choose. Mostly, they just compute the aggregate
-over the non-NULL values, producing a NULL result only if all inputs
-are NULL.
-<p>The <em>min_raster</em> and <em>max_raster</em> methods generate a map with the
-number of the raster map that holds the minimum/maximum value of the
-time-series. The numbering starts at <em>0</em> up to <em>n</em> for the
-first and the last raster listed in <em>input=</em>, respectively.
-<p>If the <em>range=</em> option is given, any values which fall outside
-that range will be treated as if they were NULL.
-The <em>range</em> parameter can be set to <em>low,high</em> thresholds:
-values outside of this range are treated as NULL (i.e., they will be
-ignored by most aggregates, or will cause the result to be NULL if -n is given).
-The <em>low,high</em> thresholds are floating point, so use <em>-inf</em> or
-<em>inf</em> for a single threshold (e.g., <em>range=0,inf</em> to ignore
-negative values, or <em>range=-inf,-200.4</em> to ignore values above -200.4).
-<p>Linear regression (slope, offset, coefficient of determination) assumes equal time intervals.
-If the data have irregular time intervals, NULL raster maps can be inserted into time series
-to make time intervals equal (see example).
-<p>Number of raster maps to be processed is given by the limit of the
-operating system. For example, both the hard and soft limits are
-typically 1024. The soft limit can be changed with e.g. <tt>ulimit -n
-1500</tt> (UNIX-based operating systems) but not higher than the hard
-limit. If it is too low, you can as superuser add an entry in
-
-<div class="code"><pre>
-/etc/security/limits.conf
-# <domain> <type> <item> <value>
-your_username hard nofile 1500
-</pre></div>
-
-This would raise the hard limit to 1500 file. Be warned that more
-files open need more RAM.
-
-For each map a weighting factor can be specified using the <em>weights</em> option.
-Using weights can be meaningful when computing sum or average of maps with different
-temporal extent. The default weight is 1.0. The number of weights must be identical
-with the number of input maps and must have the same order. Weights can also be specified in the
-input file.
-
-<p>Use the <em>file</em> option to analyze large amount of raster maps without
-hitting open files limit and the size limit of command line arguments.
-The computation is slower than the <em>input</em> option method.
-For every sinlge row in the output map(s)
-all input maps are opened and closed. The amount of RAM will rise linear
-with the number of specified input maps. The input and file options are mutually exclusive.
-Input is a text file with a new line separated list of raster map names and optional weights.
-As separator between the map name and the weight the charachter | must be used.
-
-<h2>EXAMPLES</h2>
-
-Using <em>r.series</em> with wildcards:
-<br>
-<div class="code"><pre>
-r.series input="`g.mlist pattern='insitu_data.*' sep=,`" \
- output=insitu_data.stddev method=stddev
-</pre></div>
-<p>Note the <em>g.mlist</em> script also supports regular expressions for
-selecting map names.
-<p>Using <em>r.series</em> with NULL raster maps:
-<br>
-<div class="code"><pre>
-r.mapcalc "dummy = null()"
-r.series in=map2001,map2002,dummy,dummy,map2005,map2006,dummy,map2008 \
- out=res_slope,res_offset,res_coeff meth=slope,offset,detcoeff
-</pre></div>
-
-<p>Example for multiple aggregates to be computed in one run (3 resulting aggregates
-from two input maps):
-<div class="code"><pre>
-r.series in=one,two out=result_avg,res_slope,result_count meth=sum,slope,count
-</pre></div>
-
-<p>Example to use the file option of r.series:
-<div class="code"><pre>
-cat > input.txt << EOF
-map1
-map2
-map3
-EOF
-
-r.series file=input.txt out=result_sum meth=sum
-</pre></div>
-
-<p>Example to use the file option of r.series including weights. The weight 0.75
-should be assigned to map2. As the other maps do not have weights we can leave it out:
-<div class="code"><pre>
-cat > input.txt << EOF
-map1
-map2|0.75
-map3
-EOF
-
-r.series file=input.txt out=result_sum meth=sum
-</pre></div>
-
-<p>
-Example for counting the number of days above a certain temperature using
-daily average maps ('???' as DOY wildcard):
-<div class="code"><pre>
-r.series input=`g.mlist rast pat="temp_2003_???_avg" sep=,` \
- output=temp_2003_days_over_25deg range=25.0,100.0 method=count
-</pre></div>
-
-
-<h2>SEE ALSO</h2>
-
-<em><a href="g.mlist.html">g.mlist</a></em>,
-<em><a href="g.region.html">g.region</a></em>
-
-<h2>AUTHOR</h2>
-
-Glynn Clements
-
-<p><i>Last changed: $Date$</i>
More information about the grass-commit
mailing list