[GRASS-SVN] r69953 - grass-addons/grass7/raster/r.series.lwr
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Nov 30 05:33:14 PST 2016
Author: mmetz
Date: 2016-11-30 05:33:13 -0800 (Wed, 30 Nov 2016)
New Revision: 69953
Modified:
grass-addons/grass7/raster/r.series.lwr/main.c
grass-addons/grass7/raster/r.series.lwr/r.series.lwr.html
Log:
r.series.lwr: skip large gaps in time
Modified: grass-addons/grass7/raster/r.series.lwr/main.c
===================================================================
--- grass-addons/grass7/raster/r.series.lwr/main.c 2016-11-29 13:34:36 UTC (rev 69952)
+++ grass-addons/grass7/raster/r.series.lwr/main.c 2016-11-30 13:33:13 UTC (rev 69953)
@@ -218,6 +218,7 @@
*weight, /* weighing function */
*fet, /* fit error tolerance */
*ts, /* time steps */
+ *maxgap, /* maximum gap size */
*dod, /* degree of over-determination */
*range, /* range of valid values */
*delta; /* threshold for high amplitudes */
@@ -242,7 +243,7 @@
DCELL *resultn;
int msize;
double **m, **m2, *a, *a2, *B;
- double *ts, weight;
+ double *ts, maxgap, thisgap, prev_ts, next_ts, weight;
double (*weight_func)(double, double, double);
int dod;
int *isnull, n_nulls;
@@ -320,6 +321,11 @@
parm.ts->multiple = YES;
parm.ts->description = _("Time steps of the input maps");
+ parm.maxgap = G_define_option();
+ parm.maxgap->key = "maxgap";
+ parm.maxgap->type = TYPE_DOUBLE;
+ parm.maxgap->description = _("Maximum gap size to be interpolated");
+
parm.delta = G_define_option();
parm.delta->key = "delta";
parm.delta->type = TYPE_DOUBLE;
@@ -493,6 +499,11 @@
}
}
+ maxgap = ts[num_inputs - 1] - ts[0];
+ if (parm.maxgap->answer) {
+ maxgap = atof(parm.maxgap->answer);
+ }
+
/* open output maps */
num_outputs = num_inputs;
@@ -590,10 +601,42 @@
/* LWR */
if (num_inputs - n_nulls >= min_points) {
+
+ thisgap = 0;
+ prev_ts = next_ts = ts[0] - (ts[1] - ts[0]);
for (i = first; i <= last; i++) {
DCELL result;
+ if (isnull[i]) {
+ if (next_ts < ts[i]) {
+ if (i > 0)
+ prev_ts = ts[i] - (ts[i] - ts[i - 1]) / 2.0;
+ else
+ prev_ts = ts[i] - (ts[i + 1] - ts[i]) / 2.0;
+
+ if (i < num_inputs - 1)
+ next_ts = ts[i] + (ts[i + 1] - ts[i]) / 2.0;
+ else
+ next_ts = ts[i] + (ts[i] - ts[i - 1]) / 2.0;
+
+ j = i;
+ while (j < num_inputs - 1 && isnull[j + 1])
+ j++;
+
+ if (j > i)
+ next_ts = ts[j] + (ts[j + 1] - ts[j]) / 2.0;
+ else
+ next_ts = ts[j] + (ts[j] - ts[j - 1]) / 2.0;
+
+ thisgap = next_ts - prev_ts;
+ }
+ if (thisgap > maxgap) {
+ Rast_set_d_null_value(&outputs[i].buf[col], 1);
+ continue;
+ }
+ }
+
/* margin around i */
n_points = 0;
in_lo = in_hi = i;
@@ -618,7 +661,13 @@
break;
}
}
+ if (interp_only && isnull[i] &&
+ (in_lo == i || in_hi == i)) {
+ Rast_set_d_null_value(&outputs[i].buf[col], 1);
+ continue;
+ }
+
tsdiff1 = ts[i] - ts[in_lo];
tsdiff2 = ts[in_hi] - ts[i];
Modified: grass-addons/grass7/raster/r.series.lwr/r.series.lwr.html
===================================================================
--- grass-addons/grass7/raster/r.series.lwr/r.series.lwr.html 2016-11-29 13:34:36 UTC (rev 69952)
+++ grass-addons/grass7/raster/r.series.lwr/r.series.lwr.html 2016-11-30 13:33:13 UTC (rev 69953)
@@ -32,6 +32,17 @@
contains many outliers. A few outliers are handled well with the
default settings.
+<p>
+Gaps in the time series are by default interpolated, as long as the
+time series contains sufficient non-NULL points. Optionally, the
+maximum size of gaps to be interpolated can be set with the
+<em>maxgap</em> option.
+
+<p>
+Extrapolation can be avoided with the <em>-i</em> flag. In this case,
+LWR is performed only from the first non-NULL point to the last
+non-NULL point in the time series.
+
<h2>NOTES</h2>
If the <em>range</em> option is given, any values which fall outside
More information about the grass-commit
mailing list