[GRASS-dev] Re: r.series: threshold/count method?
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:
>> The problem is the non-linear increase here, I guess: If I
>> would check for 1000 GDD in above example, I have the input
>> but get
>> EPSILON = 1e-6
>> > abs(997 - 1000) < EPSILON * 1000
>>  FALSE
>> > abs(1008.4 - 1000) < EPSILON * 1000
>>  FALSE
>> and still won't find it.
> the correct output here is "194", yes?
> ie the first day to cross that threshold?
> 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
> 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
More information about the grass-dev