[GRASS-dev] Re: r.mapcalc bug/64bit?

Markus Neteler neteler at itc.it
Thu May 11 12:22:22 EDT 2006


Glynn,

Glynn Clements wrote:

>Markus Neteler wrote:
>
>  
>
>>>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.
>>>      
>>>
>
>Sorry, that should have read:
>
>	Thus the output cell will only be NON-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 ?
>>
>>From your simplified table I would also expect this result.
>>    
>>
>
>d+1 is only 2 if d is 1. If d is null, it d+1 is null.
>
>IOW, if c==1 and cp==1 and d==1, then the result is 2. But that's
>three different conditions which have to be met. The other 7 possible
>combinations all result in null. Unless there's at least one cell
>where the non-null portions of all three input maps overlap, the
>output will be all-null.
>
>Try:
>	r.mapcalc 'temp = isnull(condition) + isnull(condition_previous) + isnull(duration)'
>	r.info -r temp
>
>If the minimum value for temp isn't zero, then every cell is null in
>at least one of the three input maps, and thus the output will be
>all-null.
>  
>

I think that it behaves correctly and I found the problem (see below):

>More generally, I find the fact that all of your input maps contain
>only null and 1 rather odd. That, and the fact that you are testing
>whether startday_previous and condition_previous are equal to zero
>suggest that something is using null where you really want zero.
>
>  
>

I guess that I figured out the introduction of NULL:
r.mapcalc 'condition=if(startday - startday_previous > 0 |||
modis_t_a_lst1km20040101.daily_min < -2.0, 1, 0)'

If pixels in the satellite image are covered by clouds, they were set to
NULL in the preprocessing.
Null is propagated and looping over the days it "crashes" the algorithms.

It seems that I have think about this, maybe implement a better "reset"
to 0 if a new frost period
is found.

Markus




More information about the grass-dev mailing list