up [pdf]
from rsf.proj import *

n1=400

Flow('spike',None,'spike n1=%d d1=1 label1=" " ' % n1)

waves = []
for j in range(n1//15,n1,n1//5):
    wave = 'wave%d' % j
    waves.append(wave)
    Flow(wave,'spike',
         '''
         math output="(x1-%(j)d)/%(n1)d" |
         math output="exp(-input*15)*sin(input*0.95*%(j)d)" |
         window f1=%(j)d | pad beg1=%(j)d
         '''
         % {'n1':n1,'j':j})
Flow('in',waves,'add ${SOURCES[1:%d]}' % len(waves))


Flow('flt',None,'spike n1=1 n2=1 mag=-1')
Flow('lag',None,'spike n1=1 | dd type=int')
Flow('pch',None,'spike n1=400 n2=1 mag=0 | dd type=int')

decs = ['in']
labels = 'TVdecon input'
for niter in [1,2,3,4,100]:
    npef = 'npef%d' % niter
    nlag = 'nlag%d' % niter
    tvdec = 'tvdec%d' % niter
    decs.append(tvdec)
    labels = labels + ': iter=%d' % niter

    Flow([npef,nlag],'in flt pch lag',
         '''
         npef epsilon=0 filt=${SOURCES[1]} filt_pch=${SOURCES[2]}
         filt_lag=${SOURCES[3]} lag=${TARGETS[1]}
         a=3 niter=%d
         ''' % niter)
    Flow(tvdec,['in',npef],'nhelicon filt=${SOURCES[1]}')

Result('tvdecon',decs,
       '''
       cat axis=2 ${SOURCES[1:%d]} |
       dots yreverse=1 strings=1 connect=3 labels="%s"
       ''' % (len(decs),labels))

End()

sfspike
sfmath
sfwindow
sfpad
sfadd
sfdd
sfnpef
sfnhelicon
sfcat
sfdots