[Thread Prev][Thread Next][Index]
Re: [ferret_users] Embedded expressions and @LOC
Hi Steve,
In summary, the errors you faced occurs just because of the
"rounding off" when the value returned from @MAX is used with @LOC.
How to fix it ? (a) Use a very high precision like @LOC:`max_val,p=-10`
(b) Use the idea of masking --> may not be easier for
practical purposes.
Details :
When does the bad value comes ?? Suppose the maximum value is 29.53875.
@MAX (when used as @LOC:`max_val`) will return an approximated value
29.539. Since this value is precisely higher than the maximum value in
the array, @LOC:`max_val` will retrun a bad value.
Where does the decimal places come from ?? Suppose the maximum value is
29.62250. @MAX (when used as @LOC:`max_val`) will return an approximated
value 29.622. Now it is clear that why @LOC returns a cooridnate (Y) value
slightly less than the actual, with decimal points.
Example for (a) and (b) :
use coads_climatology
let xx = 161 ! X=60 for "bad value" case
! X=161 for "decimal" case
let max_val = SST[l=1,x=`xx`,j=@MAX]
let max_loc = SST[l=1,x=`xx`,j=@LOC:`max_val`]
let max_loc_p = SST[l=1,x=`xx`,j=@LOC:`max_val,p=-10`]
let max_mask = IF SST[l=1,x=`xx`] EQ max_val THEN Y[GY=SST]
say " max_val = `max_val`"
say " max_loc = `max_loc`"
say " max_loc_p = `max_loc_p`"
set list/precision=7
list SST[l=1,x=`xx`], max_mask
Hope this helps,
Jaison
On Tue, 12 Sep 2006, Stephen R. Guimond wrote:
> Hello,
> I want to find the maximum value for each time step in an array of
> data, and then find the coordinate position that the maximum value
> occurs at. I have used a loop in a script like this:
>
> repeat/range=1:18:1/name=g (let max_val = lf[l=`g`,j=@MAX];let max_rad
> = lf[l=`g`,j=@LOC:`max_val`];say `max_val`;say `max_rad`;list/l=`g` lf)
>
> However, "max_val" is not finding the precise locations of my maximum
> value. I thought this had to do with precision, so I used
> `max_val,p=-3` in the @LOC statement to specify 3 decimal places, but
> there is still a problem. See the output below. For output 1, the
> @LOC value should be 150, but it comes up as 149.97. For output 2, the
> @LOC value should be 50, but it comes up "bad" even though it has the
> exact same number. Any ideas??
>
> Thanks,
> Steve
>
> OUTPUT.....
>
> result of `max_val,p=-3` = 5.309
> result of @LOC = 149.97
> VARIABLE : LF
> FILENAME : quad_rain_trop.dat
> SUBSET : 20 points (Y)
> TIME : 01-AUG-2004 18:00
> 50 / 1: 3.298
> 100 / 2: 4.598
> 150 / 3: 5.309
> 200 / 4: 3.017
> 250 / 5: 1.740
> 300 / 6: 1.111
> 350 / 7: 0.669
> 400 / 8: 1.114
> 450 / 9: 0.663
> 500 / 10: 0.781
> 550 / 11: 0.900
> 600 / 12: 1.161
> 650 / 13: 1.535
> 700 / 14: 1.620
> 750 / 15: 1.194
> 800 / 16: 1.335
> 850 / 17: 0.660
> 900 / 18: 0.266
> 950 / 19: 0.682
> 1000 / 20: 0.547
>
> result of `max_val,p=-3` = 5.331
> result of @LOC = bad
> VARIABLE : LF
> FILENAME : quad_rain_trop.dat
> SUBSET : 20 points (Y)
> TIME : 02-AUG-2004 18:00
> 50 / 1: 5.331
> 100 / 2: 2.335
> 150 / 3: 2.186
> 200 / 4: 0.892
> 250 / 5: 0.329
> 300 / 6: 0.778
> 350 / 7: 1.785
> 400 / 8: 1.896
> 450 / 9: 1.289
> 500 / 10: 0.792
> 550 / 11: 1.213
> 600 / 12: 1.934
> 650 / 13: 1.697
> 700 / 14: 0.743
> 750 / 15: 0.828
> 800 / 16: 0.818
> 850 / 17: 0.999
> 900 / 18: 1.374
> 950 / 19: 1.599
> 1000 / 20: 2.458
>
>
> =======================================================
> Stephen R. Guimond
> Graduate Research Assistant
> Center for Ocean-Atmospheric Prediction Studies (COAPS)
> Tallahassee, FL 32304
> =======================================================
>
> ----------------------------------------------------------------
>
>
[Thread Prev][Thread Next][Index]
Dept of Commerce /
NOAA /
OAR /
PMEL /
TMAP
Contact Us | Privacy Policy | Disclaimer | Accessibility Statement