[GRASS-dev] [GRASS GIS] #2969: r.series: wrong usage of weights

#2969: r.series: wrong usage of weights
-------------------------------+-------------------------
Reporter: mmetz | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.4
Component: Raster | Version: 7.0.3
Keywords: r.series, weights | CPU: Unspecified
Platform: All |
-------------------------------+-------------------------
A weighted average is calculated with

{{{
avg = sum(w[i] * x[i]) / sum(w[i])
}}}

r.series calculates weighted averages with
{{{
avg = sum(w[i] * x[i]) / count
}}}

r.series should instead behave like r.neighbors and use the corresponding
weighing functions from libstats if available.

Test commands:
{{{
# set the region
g.region -p n=10 s=0 w=0 e=10 res=1
# create identical input maps
r.mapcalc "input1 = 1"
r.mapcalc "input2 = 1"
r.mapcalc "input3 = 1"
r.mapcalc "input4 = 1"
r.mapcalc "input5 = 1"

# average
r.series in=input1,input2,input3,input4,input5 method=average out=avg
# weighted average
r.series in=input1,input2,input3,input4,input5 method=average out=avg_w
weights=0.1,0.2,0.3,0.2,0.1
}}}

Without weights the result is 1, with weights the result is 0.18 instead
of 1. Weights have been added to r.series in r49946. I am going to change
r.series in trunk and relbr70.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2969&gt;
GRASS GIS <https://grass.osgeo.org>

#2969: r.series: wrong usage of weights
--------------------------+-------------------------------
  Reporter: mmetz | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.4
Component: Raster | Version: 7.0.3
Resolution: | Keywords: r.series, weights
       CPU: Unspecified | Platform: All
--------------------------+-------------------------------

Comment (by mmetz):

Fixed in r68124,5 (trunk, relbr70).

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2969#comment:1&gt;
GRASS GIS <https://grass.osgeo.org>

#2969: r.series: wrong usage of weights
--------------------------+-------------------------------
  Reporter: mmetz | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.4
Component: Raster | Version: 7.0.3
Resolution: | Keywords: r.series, weights
       CPU: Unspecified | Platform: All
--------------------------+-------------------------------

Comment (by marisn):

A second candidate for erratum as the wrong result might slip unnoticed
for not so trivial cases?

Affected releases: 7.0.0-7.0.3

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2969#comment:2&gt;
GRASS GIS <https://grass.osgeo.org>

#2969: r.series: wrong usage of weights
--------------------------+-------------------------------
  Reporter: mmetz | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.0.7
Component: Raster | Version: 7.0.3
Resolution: fixed | Keywords: r.series, weights
       CPU: Unspecified | Platform: All
--------------------------+-------------------------------
Changes (by martinl):

* status: new => closed
* resolution: => fixed

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2969#comment:6&gt;
GRASS GIS <https://grass.osgeo.org>