up [pdf]
from rsf.proj import *

private = {'login':os.environ.get('BEG_LOGIN'),
           'password':os.environ.get('BEG_PASSWORD'),
           'server':os.environ.get('BEG_SERVER')}


Fetch('elf0.H','elf',private)

# edit trace? 
Flow('elf','elf0.H',
     'dd form=native | cut n3=1 n2=1 n1=300 f3=663 f2=67')

Plot('near','elf',
     'window n2=1 f2=0   | grey pclip=99.5 title="Near offset" ')
Plot('far','elf',
     'window n2=1 f2=100 | grey pclip=99.5 title="Far offset" ')

Result('elf','near far','SideBySideAniso')

v0=1400
nv=120
dv=25

Flow('elf-scn','elf',
     'mutter v0=%g | vscan semblance=y v0=%g nv=%d dv=%g' % (v0,v0,nv,dv))

Flow('elf-vel','elf-scn','pick rect1=35 rect2=35 | window')

Result('elf-vel',
       '''
       grey title="NMO Velocity" 
       label1="Time (s)" label2="Lateral (m)"
       color=j scalebar=y bias=%g barlabel="Velocity (m/s)"
       barreverse=y
       ''' % (v0+0.5*nv*dv))

Flow('elf-nmo','elf elf-vel','mutter v0=%g | nmo velocity=${SOURCES[1]}' % v0)

Flow('shot','elf-nmo','cmp2shot')
Flow('shot3','shot','window n3=3 f3=800')

for shot in range(3):
    eshot = 'shot%d' % (shot+1)
    Plot(eshot,'shot3',
         '''
         window n3=1 f3=%d |
         grey label2=offset crowd1=0.85 title="Shot %d"
         ''' % (shot,shot+1))

Result('elfshot3','shot1 shot3','SideBySideIso')

Flow('fill','shot3',
     '''
     window f1=20 j3=2 | logstretch nout=2048 |
     fft1 | transp | transp plane=23 |
     infill eps=0.05
     ''')
Flow('shin','fill',
     '''
     window f2=1 n2=1 |
     transp | fft1 inv=y |
     logstretch inv=y |
     pad beg1=20
     ''')

Flow('bench','shot3','window n3=1 f3=1')
Flow('diff','shin bench','add scale=1,-1 ${SOURCES[1]}')

Flow('simp','shot3','window j3=2 | stack axis=3 norm=n | scale dscale=0.5')
Flow('diff0','simp bench','add scale=1,-1 ${SOURCES[1]}')

title = {
    'diff':'error',
    'shin':'interpolated shot',
    'simp': '(shot1+shot3)/2',
    'diff0': 'error: (shot1+shot3)/2 - shot2'}

for file in title.keys():
    Plot(file,
         '''
         grey clip=11033 label1=time label2=offset crowd1=0.85
         title="%s"
         ''' % title[file])

Result('elfshotin','shin diff simp diff0','TwoRows')

End()

sfdd
sfcut
sfwindow
sfgrey
sfmutter
sfvscan
sfpick
sfnmo
sfcmp2shot
sflogstretch
sffft1
sftransp
sfinfill
sfpad
sfadd
sfstack
sfscale