up [pdf]
from rsf.proj import *

ref = (
    (0.09,(0.0,0.3),(0.6,0.3)),
    (0.15,(0.67,0.5),(2.0,0.5)),
    (0.4,(0.0,1.3),(0.93,1.3)),
    (0.4,(1.0,1.5),(2.0,1.5)),
    (0.8,(0.0,2.3),(1.3,2.3)),
    (0.8,(1.37,2.5),(2.0,2.5)),
    (1.0,(0.8,0.9),(0.82,0.9)),
    (2.0,(1.1,1.8),(1.12,1.8)),
    (2.4,(1.18,2.1),(1.2,2.1))
    )
nref = len(ref)

# reflectors
Flow('refs',None,
     '''
     spike n1=%d nsp=%d k1=%s mag=%s |
     spray axis=2 n=2001 d=0.001 o=0 label=Distance unit=m |
     transp 
     ''' % (nref,nref,
            ','.join(map(str,range(1,nref+1))),
            ','.join(map(str,map(lambda x: x[1][1],ref)))))

# reflectivity

refls = []
for r in range(nref):
    refl = 'refl%d' % r
    Flow(refl,'refs',
         '''
         window n2=1 f2=%d |
         spike mag=%g |
         cut max1=%g  |
         cut min1=%g 
         ''' % (r,ref[r][0],
                ref[r][1][0],
                ref[r][2][0]))
    refls.append(refl)
Flow('refl',refls,'cat axis=2 ${SOURCES[1:%d]}' % nref)

Flow('data','refs refl',
     '''
     kirmod nt=600 dt=0.004 vel=2.5 freq=18 refl=${SOURCES[1]}
     ns=101 ds=0.02 s0=0 nh=1 dh=0.02 h0=0 | window |
     put label2=Distance unit2=km
     ''')

Result('data','grey title="Input Data" clip=0.0025')

Result('wdata','data','wiggle poly=y transp=y yreverse=y title="Input Data" ')

pmin=-0.6   # minimum moveout in s/km
pmax=0.6    # maximum moveout in s/km
np=100
dp=(pmax-pmin)/(np-1)

Flow('taup','data','radon np=%d p0=%g dp=%g spk=n' % (np,pmin,dp))

Result('taup',
       '''
       grey label1="Intercept Time" label2=Slope unit2=s/km 
       title="Forward Transform" pclip=99.9
       ''')
Result('wtaup','taup',
       '''
       wiggle poly=y transp=y yreverse=y title="Forward Transform" pclip=99.9
       label1="Intercept Time" label2=Slope unit2=s/km 
       ''')

Flow('back','taup','radon adj=n nx=101 dx=0.02 ox=0')

Result('back','grey title="Inverse Transform" clip=0.0025')

Result('wback','back',
       'wiggle poly=y transp=y yreverse=y title="Inverse Transform" ')


Flow('diff','back data','add scale=1,-1 ${SOURCES[1]}')

Result('diff','grey title="Difference" clip=0.0025')

End()

sfspike
sfspray
sftransp
sfwindow
sfcut
sfcat
sfkirmod
sfput
sfgrey
sfwiggle
sfradon
sfadd