[Thread Prev][Thread Next][Index]

Re: [ferret_users] Searching for local maxima with a running time window. Recursion workarounds



Hi All,


After insightful discussions with Ansley and Steve (Thank you!) I realized that my problem is a special case of computing a running maximum and the solution is reasonably simple using one loop and writing the results to an ascii file. A jnl file is attached to illustrate the type of computation I was searching and the solution.

Cheers,

Paulo
! this script illustrates how to compute
! a running maximum over a time window of length *dl*
!
! *msk* and *wmsk* variables are defined for illustration purposes only

let fun = 10*sin(2*4*atan(1)*l/50)

let lmax = 100
set reg/l=1:`lmax`

let ll = l[g=fun]
let dl = 25

plot/vlim=-12:22 fun

sp \rm running_max.dat
repeat/range=1:`lmax-dl`/name=li (\
 let msk  = if ll eq `li` then 1;\
 let wmsk = if ll ge `li` and ll le `li+dl` then 1;\
 let dif2li = fun-fun[l=`li`];\
 let dif2li_max_in_dl = dif2li[l=`li`:`li+dl`@max];\
 plot/ov/nolab/lin/col=black fun;\
 plot/ov/nolab/lin/col=green fun*wmsk;\
 plot/ov/nolab/sym=1/col=red dif2li_max_in_dl+0*dif2li*msk;\
 save/file=running_max.dat/app/nohead/format=(E15.7) dif2li_max_in_dl;\
 message;\
)

canc viewp 

plot/vlim=-12:22 fun

file/var=max_in_next_dl/grid=fun running_max.dat

plot/ov/col=red max_in_next_dl


[Thread Prev][Thread Next][Index]

Contact Us
Dept of Commerce / NOAA / OAR / PMEL / TMAP

Privacy Policy | Disclaimer | Accessibility Statement