up [pdf]
from rsf.proj import *

# Download one CMP gather (with mute)
Fetch('cmp.HH','viking')

Flow('cmp','cmp.HH','dd form=native')
Plot('cmp','grey title="CMP Gather" clip=8.66')

prog = Program('hradon.c')
hradon = str(prog[0])

Flow('rad',['cmp',hradon],
     './${SOURCES[1]} adj=y np=101 dp=0.01 op=0')
Plot('rad',
     '''
     grey title="Hyperbolic Radon Transform" 
     label2=Slowness unit2=s/km
     ''')

Flow('adj',['rad',hradon],
     './${SOURCES[1]} adj=n nx=60 dx=0.05 ox=0.287')
Plot('adj','grey title="Adjoint Hyperbolic Radon Transform" ')

Result('adj','cmp rad adj','SideBySideAniso')

Flow('inv',['cmp',hradon,'rad'],
     '''
     conjgrad ./${SOURCES[1]} mod=${SOURCES[2]} 
     np=101 dp=0.01 op=0 nx=60 dx=0.05 ox=0.287 niter=10
     ''')
Plot('inv',
     '''
     grey title="Hyperbolic Radon Transform" 
     label2=Slowness unit2=s/km
     ''')

Flow('cmp2',['inv',hradon],
     './${SOURCES[1]} adj=n nx=60 dx=0.05 ox=0.287')
Plot('cmp2',
     'grey title="Inverse Hyperbolic Radon Transform" clip=8.66')

Result('inv','cmp inv cmp2','SideBySideAniso')

# Velocity scan

Flow('vscan','cmp',
     'vscan semblance=y half=n v0=1.2 nv=131 dv=0.02')
Plot('vscan',
     'grey color=j allpos=y title="Semblance Scan" unit2=km/s')

# Automatic pick

Flow('vpick','vscan',
     '''
     mutter inner=y x0=1.4 half=n v0=0.45 t0=0.5 | 
     pick rect1=50 vel0=1.5
     ''')
Plot('vpick',
     '''
     graph yreverse=y transp=y plotcol=7 plotfat=7 
     pad=n min2=1.2 max2=3.8 wantaxis=n wanttitle=n
     ''')

Plot('vscan2','vscan vpick','Overlay')

# NMO

Flow('nmo','cmp vpick','nmo half=n velocity=${SOURCES[1]}')
Plot('nmo','grey title="NMO with Primary Velocity" clip=9.83')

Result('vscan','cmp vscan2 nmo','SideBySideAniso')

Flow('nmorad0',['cmp',hradon],
     './${SOURCES[1]} adj=y np=161 dp=0.005 op=0')
Flow('nmorad',['nmo',hradon,'nmorad0'],
     '''
     conjgrad ./${SOURCES[1]} mod=${SOURCES[2]} 
     np=161 dp=0.005 op=0 nx=60 dx=0.05 ox=0.287 niter=10
     ''')
Plot('nmorad',
     '''
     grey title="Hyperbolic Radon Transform" 
     label2=Slowness unit2=s/km
     ''')

Flow('nmo2',['nmorad',hradon],
     './${SOURCES[1]} adj=n nx=60 dx=0.05 ox=0.287')
Plot('nmo2',
     'grey title="Inverse Hyperbolic Radon Transform" clip=9.83')

Result('nmorad','nmo nmorad nmo2','SideBySideAniso')

Flow('cut','nmorad','cut min2=0.2')
Plot('cut',
     '''
     grey title="Hyperbolic Radon Transform" 
     label2=Slowness unit2=s/km
     ''')

Flow('signal',['cut',hradon],
     './${SOURCES[1]} adj=n nx=60 dx=0.05 ox=0.287')
Plot('signal',
     'grey title="Inverse Hyperbolic Radon Transform" clip=9.83')

Result('nmocut','nmo cut signal','SideBySideAniso')

# Inverse NMO

Flow('inmo','signal vpick',
     'inmo half=n velocity=${SOURCES[1]} | mutter half=n v0=1.2')
Plot('inmo','grey title=Signal clip=8.66')

Flow('pvscan','inmo',
     'vscan semblance=y half=n v0=1.2 nv=131 dv=0.02')
Plot('pvscan',
     'grey color=j allpos=y title="Primary Semblance Scan" ')

Flow('mult','cmp inmo','add scale=1,-1 ${SOURCES[1]}')
Plot('mult','grey title=Noise clip=8.66')

Flow('mvscan','mult',
     'vscan semblance=y half=n v0=1.2 nv=131 dv=0.02')
Plot('mvscan',
     'grey color=j allpos=y title="Multiples Semblance Scan" ')

Result('inmo','cmp inmo mult','SideBySideAniso')
Result('pvscan','vscan pvscan mvscan','SideBySideAniso')

End()

sfdd
sfgrey
sfconjgrad
sfvscan
sfmutter
sfpick
sfgraph
sfnmo
sfcut
sfinmo
sfadd

data/viking/cmp.HH