[GRASS5] r.mapcalc bug/64bit?
Markus Neteler
neteler at itc.it
Wed May 3 19:03:49 EDT 2006
On Wed, May 03, 2006 at 09:20:05PM +0100, Glynn Clements wrote:
> Markus Neteler wrote:
> > thanks for submitting the new operators. Here the test report:
> > - the first condition works fine (for me) now
> >
> >
> > + r.info -r modis_t_a_lst1km20040102.daily_min
> > min=-24.290000
> > max=-16.510000
> > + r.info -r startday_previous
> > min=1
> > max=1
> > + r.info -r condition_previous
> > min=1
> > max=1
> > + r.info -r duration
> > min=1
> > max=1
> > + r.mapcalc 'startday=if(modis_t_a_lst1km20040102.daily_min < -2.0 &&& (startday_previous == 0 ||| condition_previous == 0), 2, startday_previous)'
> > 100%
> > + r.info -r startday
> > min=1
> > max=1
> >
> >
> > ... but here I am not sure if it is right (program continues):
> >
> >
> > + r.info -r startday_previous
> > min=1
> > max=1
> > + r.mapcalc 'condition=if(startday - startday_previous > 0 ||| modis_t_a_lst1km20040102.daily_min < -2.0, 1, 0)'
> > 100%
> > + r.info -r condition
> > min=1
> > max=1
> > + r.mapcalc 'duration=if(condition == 1, if(condition_previous == 1 &&& condition == 1, duration + 1, 1), duration)'
> > 100%
> > + r.info -r duration
> > min=-2147483648
> > max=-2147483648
>
> It depends upon the contents of the input files. If any of
> condition_previous, condition, or duration contain nulls, you will get
> them in the output. Whether the output is all-null depends upon which
> cells are null in the inputs.
>
> The exact logic of the last expression is:
>
> cp=N cp=1 cp=?
> c=N N N N
> c=1 N d+1 1
> c=? d d d
>
> where c = condition, cp = condition_previous, d = duration, N = null,
> ? = anything other than null or 1.
>
> Note that "condition_previous == 1 &&& condition == 1" can be
> simplified to just "condition_previous == 1", as the expression is
> only evaluated if "condition == 1" is true.
Yes, agreed.
> Also note that the r.info commands indicates that condition and
> condition_previous only contain 1 or null, so the logic can be
> simplified to:
>
> cp=N cp=1
> c=N N N
> c=1 N d+1
>
> Thus the output cell will only be null if all three input cells are
> non-null.
The last sentence I don't understand (sorry for being slow on this).
If all input is 1, I expect to get 2 as result (at least that's my
wish).
Simplified:
r.mapcalc 'duration=if(condition == 1, if(condition_previous == 1, duration + 1, 1), duration)'
So: if c==1 and cp==1, why not d=d+1=2 ?
More information about the grass-dev
mailing list