[GRASS-dev] r.series thresholds?

Hi, I was trying to figure out how to use the r.series threshold=
parameter to make a MASK only where all channels of some Landsat
data were >0 (extant), without needing to use r.null and the extra disk
space to store a NULL file for each of the input bands (the files take up
enough disk space as it is). so something like "output cells contain the
count of input maps with data values >=1". for 6 input bands the output
range would be 0-6, or null and 1-6.

... but I was having a difficult time of understanding how it was
supposed to work. the only mention in the man page has to do with the
range= option.

Remembering there was some discussion about it I just found this:
  http://article.gmane.org/gmane.comp.gis.grass.devel/22002/

.. so was the html part of the patch just never applied? or did things
change since then? ie is it still true that the -n flag makes it ignored?
(perhaps then issue a G_warning()?)

Is threshold= not even related to the method=threshold option?!

how does using multiple floating points work with it? a single threshold
per each input map? would that be a problem if you were eg trying to
match exact integer values? (like >= some bitmask threshold?)

if only 1 value is given is that just applied to the first map in the
series or for all in the series?

slightly confused..

thanks,
Hamish

Hi Hamish,

On Sun, Oct 10, 2010 at 8:42 AM, Hamish <hamish_b@yahoo.com> wrote:

Hi, I was trying to figure out how to use the r.series threshold=
parameter to make a MASK only where all channels of some Landsat
data were >0 (extant),

Perhaps use the count parameter with -n for null propagation?

without needing to use r.null and the extra disk
space to store a NULL file for each of the input bands (the files take up
enough disk space as it is). so something like "output cells contain the
count of input maps with data values >=1". for 6 input bands the output
range would be 0-6, or null and 1-6.

So the sum parameter sounds better.

... but I was having a difficult time of understanding how it was
supposed to work. the only mention in the man page has to do with the
range= option.

Remembering there was some discussion about it I just found this:
http://article.gmane.org/gmane.comp.gis.grass.devel/22002/

.. so was the html part of the patch just never applied? or did things
change since then? ie is it still true that the -n flag makes it ignored?
(perhaps then issue a G_warning()?)

Time to reverse engineer the code :slight_smile:

Is threshold= not even related to the method=threshold option?!

Here a usage example:

# Growing Degree Days maps thresholding, seeking 1350 GDD
r.series in=gdd1,gdd2,gdd3,gdd4,...,gdd365 \
         out=gdd_daynum.thresh1350 threshold=1350 method=threshold

The output is, for eacxh pixel, the map number in which 1350 GDD have
been reached.

I agree that documentation could be better...

Markus

Hamish wrote:

Hi, I was trying to figure out how to use the r.series threshold=
parameter to make a MASK only where all channels of some Landsat
data were >0 (extant), without needing to use r.null and the extra disk
space to store a NULL file for each of the input bands (the files take up
enough disk space as it is). so something like "output cells contain the
count of input maps with data values >=1". for 6 input bands the output
range would be 0-6, or null and 1-6.

... but I was having a difficult time of understanding how it was
supposed to work. the only mention in the man page has to do with the
range= option.

Remembering there was some discussion about it I just found this:
  http://article.gmane.org/gmane.comp.gis.grass.devel/22002/

.. so was the html part of the patch just never applied? or did things
change since then? ie is it still true that the -n flag makes it ignored?
(perhaps then issue a G_warning()?)

Is threshold= not even related to the method=threshold option?!

Ugh. Thanks for bringing this up. r.series was broken with r41667;
quantile= no longer works.

Reverted with r43853.

threshold= an method=threshold no longer exist, so this question is
moot.

--
Glynn Clements <glynn@gclements.plus.com>

Hamish wrote:

> Hi, I was trying to figure out how to use the r.series
> threshold= parameter

(thanks Markus, method=count is what I was looking for)

> ... but I was having a difficult time of understanding
> how it was supposed to work. the only mention in the man page
> has to do with the range= option.

...while the module has threshold=value[,value,...],
method=treshold, and range=lo,hi thresholds available.

...

> Is threshold= not even related to the method=threshold
> option?!

(yes, this was written after looking at the source code, but even
now I'm still not fully understanding all of it: multiple=yes?)

Ugh. Thanks for bringing this up. r.series was broken with
r41667; quantile= no longer works.

Reverted with r43853.

threshold= an method=threshold no longer exist, so this
question is moot.

Not quite moot, it had already been backported to 6.5svn and
in the last month 6.4.1svn as well & so still exists there and
more to be discussed, decided, and resolved before we can move
on.

Hamish

On Wed, Oct 13, 2010 at 9:42 AM, Hamish <hamish_b@yahoo.com> wrote:

Hamish wrote:

...

Ugh. Thanks for bringing this up. r.series was broken with
r41667; quantile= no longer works.

Reverted with r43853.

threshold= an method=threshold no longer exist, so this
question is moot.

Not quite moot, it had already been backported to 6.5svn and
in the last month 6.4.1svn as well & so still exists there and
more to be discussed, decided, and resolved before we can move
on.

I would appreciate to fix the problem rather than a brute force removal.
Thresholding is a task which is needed and which can only be done
with r.series (and not reasonably r.mapcalc).

thanks
Markus (on the road this week)

Hamish wrote:

> > Is threshold= not even related to the method=threshold
> > option?!

(yes, this was written after looking at the source code, but even
now I'm still not fully understanding all of it: multiple=yes?)

output=, method= and quantile= (and the now-removed threshold=) all
accept multiple answers, allowing multiple aggregates to be computed
in a single run, e.g.:

  r.series input=map1,...,mapN \
    output=map.mean,map.stddev \
    method=average,stddev
or:
  r.series input=map1,...,mapN \
    output=map.p10,map.p50,map.p90 \
    method=quantile,quantile,quantile \
    quantile=0.1,0.5,0.9

The same number of values must be provided for all options.

If multiple outputs were commonplace, it might be better to merge
these options, i.e.:

  r.series input=map1,...,mapN \
    output=map.p10,quantile,0.1,map.p50,quantile,0.5,map.p90,quantile,0.9

or even:

  r.series input=map1,...,mapN \
    output=map.p10=quantile(0.1),map.p50=quantile(0.5),map.p90=quantile(0.9)

OTOH, this loses the abilibity to make use of the validation in
G_parser() and type-specific input mechanisms in the GUI. And the
existing interface is more appropriate when you only have one output,
which is probably more common.

> Ugh. Thanks for bringing this up. r.series was broken with
> r41667; quantile= no longer works.
>
> Reverted with r43853.
>
> threshold= an method=threshold no longer exist, so this
> question is moot.

Not quite moot, it had already been backported to 6.5svn and
in the last month 6.4.1svn as well & so still exists there and
more to be discussed, decided, and resolved before we can move
on.

With the introduction of quantile=, the interface to the aggregate
functions was changed so that each function accepts a "closure"
argument. This allows e.g. c_quant() to calculate arbitrary quantiles
rather than needing a separate function for each (fixed) quantile.

But the body of r.series is generic, i.e. the code is the same
regardless of the method(s) used. So it would always pass the
quantile= value to the aggregate, but only c_quant() would pay any
attention to it.

r41667 stomped on this, ignoring the quantile= values and always
passing the threshold= values instead.

Appropriate solutions include:

1. Adding specific code which passes the correct value based upon the
method, or

2. Merging quantile= and threshold= into a generic parameter= option
(but this loses the 0.0-1.0 validity check for quantile values).

--
Glynn Clements <glynn@gclements.plus.com>