[GRASS-SVN] r71054 - grass-addons/grass7/raster/r.seasons
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun May 7 12:52:36 PDT 2017
Author: mmetz
Date: 2017-05-07 12:52:36 -0700 (Sun, 07 May 2017)
New Revision: 71054
Modified:
grass-addons/grass7/raster/r.seasons/main.c
grass-addons/grass7/raster/r.seasons/r.seasons.html
Log:
r.seasons: add max_gap option
Modified: grass-addons/grass7/raster/r.seasons/main.c
===================================================================
--- grass-addons/grass7/raster/r.seasons/main.c 2017-05-07 18:13:09 UTC (rev 71053)
+++ grass-addons/grass7/raster/r.seasons/main.c 2017-05-07 19:52:36 UTC (rev 71054)
@@ -50,7 +50,8 @@
}
static int get_season(double *val, char *isnull, double *ts, int i0,
- int n, double threshold, double minlen,
+ int n, double threshold,
+ double minlen, double maxgap,
int *start1, int *start2,
int *end1, int *end2)
{
@@ -113,7 +114,7 @@
else
blenout -= ts[i] - (ts[i + 1] - ts[i]) / 2.0;
- if (blenout >= minlen)
+ if (blenout >= maxgap)
break;
}
}
@@ -159,7 +160,7 @@
else
blenout -= ts[startout] - (ts[startout + 1] - ts[startout]) / 2.0;
- if (blenout >= minlen)
+ if (blenout >= maxgap)
break;
}
}
@@ -177,7 +178,8 @@
*ns, /* number of seasons */
*nsout, /* output map for number of seasons */
*threshold, /* threshold to start/stop a season */
- *min; /* minimum length in time to recognize a start/stop event */
+ *min, /* minimum length in time to recognize a season */
+ *max; /* maximum length in time to separate two seasons */
} parm;
struct
{
@@ -195,7 +197,7 @@
DCELL *values = NULL;
int nrows, ncols;
int row, col;
- double minlen;
+ double minlen, maxgap;
int ns, nsmax, nfound;
double threshold;
double *ts;
@@ -253,12 +255,19 @@
parm.threshold->description = _("Threshold to start/stop a season");
parm.min = G_define_option();
- parm.min->key = "min";
+ parm.min->key = "min_length";
parm.min->type = TYPE_DOUBLE;
parm.min->required = YES;
- parm.min->label = _("Minimum number of time steps");
+ parm.min->label = _("Minimum season length");
parm.min->description = _("A season must be at least min long, otherwise the data are considered as noise");
+ parm.max = G_define_option();
+ parm.max->key = "max_gap";
+ parm.max->type = TYPE_DOUBLE;
+ parm.max->required = NO;
+ parm.max->label = _("Maximum gap length (default: min_length)");
+ parm.max->description = _("A gap must not be longer than max, otherwise the season is terminated");
+
flag.lo = G_define_flag();
flag.lo->key = 'l';
flag.lo->description = _("Stop a season when a value is above threshold (default: below threshold");
@@ -288,6 +297,14 @@
minlen = atof(parm.min->answer);
if (minlen <= 0)
G_fatal_error(_("Minimum season length must be positive"));
+
+ maxgap = minlen;
+ if (parm.max->answer) {
+ maxgap = atof(parm.max->answer);
+ if (maxgap <= 0)
+ G_fatal_error(_("Maximum gap length must be positive"));
+ }
+
threshold = atof(parm.threshold->answer);
if (flag.lo->answer)
@@ -470,7 +487,8 @@
nfound = 0;
i0 = 0;
while (get_season(values, isnull, ts, i0, num_inputs,
- threshold, minlen, &start1, &start2, &end1, &end2)) {
+ threshold, minlen, maxgap,
+ &start1, &start2, &end1, &end2)) {
i0 = end2 + 1;
Modified: grass-addons/grass7/raster/r.seasons/r.seasons.html
===================================================================
--- grass-addons/grass7/raster/r.seasons/r.seasons.html 2017-05-07 18:13:09 UTC (rev 71053)
+++ grass-addons/grass7/raster/r.seasons/r.seasons.html 2017-05-07 19:52:36 UTC (rev 71054)
@@ -1,22 +1,25 @@
<h2>DESCRIPTION</h2>
<em>r.seasons</em> counts the number of seasons in a time series. A
-season is defined as a time period of at least <em>min</em> length
-where no value is below <em>threshold</em> (with the <em>-l</em> flag,
-no value above <em>threshold</em>).
+season is defined as a time period of at least <em>min_length</em>
+length where no value is below <em>threshold</em> (with the <em>-l</em>
+flag, no value above <em>threshold</em>).
<p>
The <em>nout</em> output holds the number of detected seasons. Output
raster maps with the start and end dates of each season are produced
-for at most <em>n</em> number of seasons. For each season, two start
-dates and two end dates are determined. The start date start1 and the
-end date end1 indicate the start and end of the core season, while the
-start date start2 and the end date end2 indicate the start and end of
-the full season including some gaps at the beginning and end of the
-season. Gaps are shorter than <em>min</em>, that is, a season will not
-include gaps equal or longer than <em>min</em>.
+for at most <em>n</em> number of seasons.
+<p>
+For each season, two start dates and two end dates are determined. The
+start date start1 and the end date end1 indicate the start and end of
+the core season, while the start date start2 and the end date end2
+indicate the start and end of the full season including some gaps at
+the beginning and end of the season. Gaps are shorter than
+<em>max_gap</em>, that is, a season will not include gaps equal or
+longer than <em>max_gap</em>.
+
<h2>NOTES</h2>
The maximum number of raster maps that can be processed is given by the
@@ -95,7 +98,7 @@
<div class="code"><pre>
r.seasons input=`g.list rast pat=MOD13* sep=,` prefix=ndvi_season n=3 \
- nout=ndvi_season threshold=3000 min=6
+ nout=ndvi_season threshold=3000 min_length=6
# the outputs are:
g.list type=raster pattern=ndvi_season*
More information about the grass-commit
mailing list