[Thread Prev][Thread Next][Index]

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



Hi all,

I'm trying to circumvent the recursion problem by storing intermediate calculations on an external file. However, it seems that ferret keeps increasing the virtual memory used and the process stops at some point depending on system load.
I've tried to issue a cancel mem/all at each time step but it doesn't solve the problem.

A jnl file to reproduce the type of calculation I want is attached. Any hints to workaround this problem or on how to make this time window search without using external files will be appreciated.

Paulo
\canc mode verif 

def sym iinf  test_xp

!==================================================================== ... build time series...
def ax/t="15-jul-2006":"15-sep-2006":10/unit=min/t0=15-jul-2006 t10m
let pi = 4*atan(1)
let xp_top0 =  lsl_lowpass(1000*sin(t[gt=t10m]*2*pi/60000)+5000*randu(t[gt=t10m]), `6*6`,`6*6`)
let xp_top  = if xp_top0 then xp_top0 else xp_top0[t=@ave]
save/clobber/file=($iinf).cdf xp_top
canc var/all; canc ax/all; canc mem/all
!===============================================================================================

!---------------------------- search max dif between each sample and the next ($delT) samples (running window)
!                             assign the result to the first time step of the running window 
def sym delT  432
def sym outf  test_xp_max432

use ($iinf)
                                   !............. just to see whats going on ....................
                                   set viewp upper; plot xp_top
                                   set viewp lower; plot/sym=dot/vlim=0:`xp_top[t=@max]` 0*xp_top

def sym lend `xp_top,ret=lend`

let ll = l[g=xp_top[d=($iinf)]]

let xp_dif_top_max_0 = 0*xp_top
 save/quiet/clob/file=($outf)_lprev.cdf xp_dif_top_max_0
 canc var xp_dif_top_max_0

SET MODE STUPID

let lprev = 0
sp \rm ($outf).cdf
repeat/range=1:`($lend)-($delT)`:1/name=li ( \
 if `mod(li,100) eq 1` then say `li`;\
 let msk = if ll eq li then 1 else 0;\
 use ($outf)_lprev.cdf;\
  let last_xp_dif_top_max = xp_dif_top_max_`lprev`[d=($outf)_lprev];\
  let xp_dif_top     = xp_top[d=($iinf)] - xp_top[d=($iinf),l=`li`];\
  let xp_dif_top_max = xp_dif_top[d=($iinf),l=`li`:`li+($delT)`@max]*msk + last_xp_dif_top_max;\
 plot/nolab/ov/sym=dot/col=red xp_dif_top_max;\
 save/quiet/clob/file=($outf).cdf xp_dif_top_max;\
  let xp_dif_top_max_`li` = xp_dif_top_max;\
 save/quiet/clob/file=($outf)_`li`.cdf xp_dif_top_max_`li`;\
 canc var msk, last_xp_dif_top_max, xp_dif_top, xp_dif_top_max, xp_dif_top_max_`li`, lprev;\
 canc data ($outf)_lprev.cdf;\
 sp mv ($outf)_`li`.cdf ($outf)_lprev.cdf;\
 let lprev = `li`;\
)
      
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                 
  335 pbo       20   0  234m 108m 3932 R 90.6 10.8   0:14.78 ferret                          
  335 pbo       20   0  349m 200m 2464 D 42.6 20.0   0:34.82 ferret
  335 pbo       20   0  497m 225m 2472 D 73.3 22.5   1:01.32 ferret
  335 pbo       20   0  582m 252m 2484 D 47.7 25.2   1:23.58 ferret 
  335 pbo       20   0  582m 260m 1584 R 55.8 26.0   1:42.16 ferret                  
  335 pbo       20   0  889m 241m 2436 R 12.6 24.1   2:55.29 ferret                  
  335 pbo       20   0 1122m 248m 2436 R 25.2 24.8   3:39.25 ferret                  
  335 pbo       20   0 1375m 238m 2436 S 13.6 23.8   4:27.87 ferret                  
  335 pbo       20   0 1398m 199m 2492 D 30.5 19.9   4:32.25 ferret                  







[Thread Prev][Thread Next][Index]

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

Privacy Policy | Disclaimer | Accessibility Statement