[GRASSLIST:5810] create new map of TS with min value month

Hello,

I have a time series and I want to create a map containing the information
which decade has the annual minimum value.

e.g.:

values for one pixel

jan 1 = 10
jan 2 = 11
jan 3 = 18
feb 1 = 9
feb 2 = 3
feb 3 = 5
.....

output = 22 or 5 (either 2= feb ; 2=2. decade OR 5th decade)

The ouput map would hold the information for each pixel which decade has the
annual minimum value.

I tried a few approaches with
r.mapcalc (if(map_x==map_annual_min,x,null()) )
r.mapcalc (if(map_y==map_annual_min,y,null()) )

and r.patch for all raster maps

however before I start writing a script with a if condition for each decade
map I would like to know if somebody knows a more straight forward method.

cheers Martin

P.S.: would be a nice extra functionality for r.series ,-)

--
Dipl.-Biol. Martin Wegmann

DLR - German Aerospace Center
German Remote Sensing Data Center
@
Dept.of Geography
Remote Sensing and Biodiversity Unit
University of Wuerzburg
Am Hubland
97074 Würzburg

phone: +49-(0)931 - 888 4797
fax: +49-(0)931 - 888 4961
http://www.biota-africa.org
http://www.biogis.de

Martin Wegmann wrote:

I have a time series and I want to create a map containing the information
which decade has the annual minimum value.

e.g.:

values for one pixel

jan 1 = 10
jan 2 = 11
jan 3 = 18
feb 1 = 9
feb 2 = 3
feb 3 = 5
.....

output = 22 or 5 (either 2= feb ; 2=2. decade OR 5th decade)

The ouput map would hold the information for each pixel which decade has the
annual minimum value.

however before I start writing a script with a if condition for each decade
map I would like to know if somebody knows a more straight forward method.

Add it to r.series, i.e.:

1. Copy c_min.c to e.g. c_minx.c.
2. Change the copy to return the x value instead of the y (see below).
3. Search for all occurrences of c_min in the files in the r.series
   directory and add equivalents for c_minx.
4. Repeat for c_max while you're at it.
5. Re-compile.

It's likely to be simpler than writing a script.

Sample (untested) c_minx implementation:

  void c_minx(DCELL *result, DCELL *values, int n)
  {
    DCELL min, minx;
    int i;
  
    G_set_d_null_value(&min, 1);
    G_set_d_null_value(&minx, 1);
  
    for (i = 0; i < n; i++)
    {
      if (G_is_d_null_value(&values[i]))
        continue;
  
      if (G_is_d_null_value(&min) || min > values[i])
      {
        min = values[i];
        minx = i;
      }
    }
  
    if (G_is_d_null_value(&minx))
      G_set_d_null_value(result, 1);
    else
      *result = minx;
  }

Note: you're stuck with DCELL; r.series only generates DCELL maps. Use
r.mapcalc afterwards if you really need CELL.

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