[GRASS-dev] [GRASS GIS] #3296: r.mapcalc: nmedian() unexpected results

#3296: r.mapcalc: nmedian() unexpected results
---------------------------------+---------------------------------
Reporter: sbl | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.2.1
Component: Default | Version: svn-releasebranch72
Keywords: r.mapcalc,nmedian() | CPU: Unspecified
Platform: Unspecified |
---------------------------------+---------------------------------
Seems that the nmedian() function in r.mapcalc for both GRASS 7.0, GRASS
7.2 and trunk gives unexpected results.
The neighborhood modifer I used do not seem to cause the issue...

This:
{{{
g.region -p n=3 s=0 e=3 w=0 res=1
r.mapcalc expression="test=row()*col()" --o
r.mapcalc expression="nbh_test_r=(test[0,-1] - test)^2.0" --o
r.mapcalc expression="nbh_test_l=(test[0,1] - test)^2.0" --o
r.mapcalc expression="nmed_test=nmedian(((test[0,-1] -
test)^2.0,(test[0,1] - test)^2.0))" --o
}}}
should result in a horizontally striped map with values covering 1 (top
row), 4 (middle row, and 9 (bottom row). However, the leftmost column
contains values 0.2, 2.5, 6.5 (from top to bottom).

Yet, here - where values only differ from column to column -
{{{
r.mapcalc expression="test=col()" --o
r.mapcalc expression="nmed_test=nmedian(((test[0,-1] -
test)^2.0,(test[0,1] - test)^2.0))" --o
}}}
only the top-left cell has an odd value of 0.5 while the rest has value 1
as expected...

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

#3296: r.mapcalc: nmedian() unexpected results
--------------------------+---------------------------------
  Reporter: sbl | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.1
Component: Raster | Version: svn-releasebranch72
Resolution: | Keywords: r.mapcalc,nmedian()
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------
Changes (by martinl):

* component: Default => Raster

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

#3296: r.mapcalc: nmedian() unexpected results
--------------------------+---------------------------------
  Reporter: sbl | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.2.1
Component: Raster | Version: svn-releasebranch72
Resolution: fixed | Keywords: r.mapcalc,nmedian()
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------
Changes (by marisn):

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

Comment:

In [changeset:"70674" 70674]:
{{{
#!CommitTicketReference repository="" revision="70674"
Do not calculate median if only one variable is provided.
Fixes #3296
}}}

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

#3296: r.mapcalc: nmedian() unexpected results
--------------------------+---------------------------------
  Reporter: sbl | Owner: grass-dev@…
      Type: defect | Status: reopened
  Priority: normal | Milestone: 7.2.1
Component: Raster | Version: svn-releasebranch72
Resolution: | Keywords: r.mapcalc,nmedian()
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------
Changes (by martinl):

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

Comment:

Milestone set to 7.2.1, backport is needed.

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

#3296: r.mapcalc: nmedian() unexpected results
--------------------------+---------------------------------
  Reporter: sbl | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.2.1
Component: Raster | Version: svn-releasebranch72
Resolution: fixed | Keywords: r.mapcalc,nmedian()
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------
Changes (by marisn):

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

Comment:

In [changeset:"70675" 70675]:
{{{
#!CommitTicketReference repository="" revision="70675"
Do not calculate median if only one variable is provided.
Fixes #3296 (backport of r70674)
}}}

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

#3296: r.mapcalc: nmedian() unexpected results
--------------------------+---------------------------------
  Reporter: sbl | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.2.1
Component: Raster | Version: svn-releasebranch72
Resolution: fixed | Keywords: r.mapcalc,nmedian()
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------

Comment (by marisn):

In [changeset:"70676" 70676]:
{{{
#!CommitTicketReference repository="" revision="70676"
Do not calculate median if only one variable is provided.
Fixes #3296 (backport of r70674)
}}}

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

#3296: r.mapcalc: nmedian() unexpected results
--------------------------+---------------------------------
  Reporter: sbl | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.2.1
Component: Raster | Version: svn-releasebranch72
Resolution: fixed | Keywords: r.mapcalc,nmedian()
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------

Comment (by mmetz):

Replying to [comment:2 marisn]:
> In [changeset:"70674" 70674]:
> {{{
> #!CommitTicketReference repository="" revision="70674"
> Do not calculate median if only one variable is provided.
> Fixes #3296
> }}}

Fixed in trunk r70683. You need to use the actual number of non-NULL
values to set the pointers a1, a2.

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

#3296: r.mapcalc: nmedian() unexpected results
--------------------------+---------------------------------
  Reporter: sbl | Owner: grass-dev@…
      Type: defect | Status: reopened
  Priority: normal | Milestone: 7.2.1
Component: Raster | Version: svn-releasebranch72
Resolution: | Keywords: r.mapcalc,nmedian()
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------
Changes (by neteler):

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

Comment:

Replying to [comment:6 mmetz]:
> Replying to [comment:2 marisn]:
> > In [changeset:"70674" 70674]:
> > {{{
> > #!CommitTicketReference repository="" revision="70674"
> > Do not calculate median if only one variable is provided.
> > Fixes #3296
> > }}}
>
> Fixed in trunk r70683. You need to use the actual number of non-NULL
values to set the pointers a1, a2.

Does(n't) this need to be backported?

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

#3296: r.mapcalc: nmedian() unexpected results
--------------------------+---------------------------------
  Reporter: sbl | Owner: grass-dev@…
      Type: defect | Status: reopened
  Priority: normal | Milestone: 7.2.1
Component: Raster | Version: svn-releasebranch72
Resolution: | Keywords: r.mapcalc,nmedian()
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------

Comment (by mmetz):

Replying to [comment:7 neteler]:
> Replying to [comment:6 mmetz]:
> > Replying to [comment:2 marisn]:
> > > In [changeset:"70674" 70674]:
> > > {{{
> > > #!CommitTicketReference repository="" revision="70674"
> > > Do not calculate median if only one variable is provided.
> > > Fixes #3296
> > > }}}
> >
> > Fixed in trunk r70683. You need to use the actual number of non-NULL
values to set the pointers a1, a2.
>
> Does(n't) this need to be backported?

Already done in r70684 (Feb 2017).

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

#3296: r.mapcalc: nmedian() unexpected results
--------------------------+---------------------------------
  Reporter: sbl | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.2.1
Component: Raster | Version: svn-releasebranch72
Resolution: fixed | Keywords: r.mapcalc,nmedian()
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------
Changes (by neteler):

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

Comment:

OK, thanks. I just saw (further) differences between trunk and relbranch72
in this file..

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

#3296: r.mapcalc: nmedian() unexpected results
--------------------------+---------------------------------
  Reporter: sbl | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.2.1
Component: Raster | Version: svn-releasebranch72
Resolution: fixed | Keywords: r.mapcalc,nmedian()
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------

Comment (by mmetz):

Replying to [comment:9 neteler]:
> OK, thanks. I just saw (further) differences between trunk and
relbranch72 in this file..

These are improvements for trunk.

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