[GRASS-dev] Re: r.series: threshold/count method?
Markus Neteler
neteler at osgeo.org
Tue Sep 8 03:36:02 EDT 2009
On Tue, Sep 8, 2009 at 8:05 AM, Hamish<hamish_b at yahoo.com> wrote:
> Markus:
>> The problem is the non-linear increase here, I guess: If I
>> would check for 1000 GDD in above example, I have the input
>>
>> ...
>> 193,997.8
>> 194,1008.4
>> ...
>>
>> but get
>> EPSILON = 1e-6
>> > abs(997 - 1000) < EPSILON * 1000
>> [1] FALSE
>> > abs(1008.4 - 1000) < EPSILON * 1000
>> [1] FALSE
>>
>> and still won't find it.
>
> the correct output here is "194", yes?
Yes.
> ie the first day to cross that threshold?
Yes.
> Can you guarantee that the input data array is sorted?
Yes, because it is an accumulation function.
> why worry about EPSILON at all? If sorted:
>
> for(i=0; i < data.n; i++)
> {
> if ( data.val[i] > threshold )
> return data.day[i];
> }
Perhaps you are right...
> If not sorted just run through the whole loop and
>
> first_day=366;
> for (day)
> {
> if ((val > thresh) && (day < first_day))
> first_day = day;
> }
> return first_day;
Since the threshold function should be a generic one, I had
implemented this EPSILON stuff which then effectively causes
problems in this particular case. Maybe you code snippet is more
generic...
Markus
More information about the grass-dev
mailing list