up [pdf]
from rsf.proj import *
from rsf.recipes.beg import server

sr=1.2
lsz=8
def plotimage():
        return'''
        grey title= screenratio=%g labelsz=%g labelfat=3
        ''' %(sr,lsz)

Fetch('sseis.HH','zhiguang',server)
Flow('lseis','sseis.HH','dd form=native')
Result('lseis',plotimage())

# synthetic model
Flow('trace','lseis','window n2=1 f2=100 |put o2=0')
Flow('top','trace','window n1=100 |pad2 right=600')
Flow('bot','trace','window f1=500 |pad2 right=600')
Flow('left','trace','window n1=400 f1=100 |pad2 right=500 |put o1=0 o2=0 |mutter half=n v0=1 |pad2 left=100 |put o1=100 o2=0')
Result('left',plotimage())

Flow('warp','trace','window n1=400 f1=100|put o1=0 |math output="sin(x1/200*2*3.1415926)*10+x1"')
Result('warp','math output="input-x1" |put o1=500 d1=-1 label2=Displacement |graph title= screenratio=1.5 transp=y barreverse=y wherexlabel=top min2=-20 max2=20')

Flow('trace2','trace warp','window n1=400 f1=100 |put o1=0 |iwarp warp=${SOURCES[1]} inv=n')
Flow('right2','trace2','pad2 right=500 |put o1=0 o2=0 |mutter half=n v0=1 |pad2 left=100 |put o1=100 o2=0')
Flow('right','trace2 right2','pad2 right=500 |put o1=0 o2=0 |pad2 left=100 |put o1=100 o2=0 |add scale=1,-1 ${SOURCES[1]}')
Result('right',plotimage())

Flow('syn','left right top bot','add ${SOURCES[1]} |cat axis=1 ${SOURCES[2]} ${SOURCES[3]} order=2,1,3')
Plot('syn',plotimage())

# left trace
x1=80
z1=100
x2=480
z2=500
Flow('line1.asc',None,'echo %s n1=4 data_format=ascii_float in=$TARGET'% ' '.join(map(str,(x1,z1, x2,z2))))
Plot('line1','line1.asc',
                '''
                dd type=complex form=native |
                graph min1=0 max1=600 min2=0 max2=600 pad=n plotfat=4 plotcol=0 dash=1
                wantaxis=n wanttitle=n yreverse=y scalebar=n screenratio=%g labelsz=%d
                ''' %(sr,lsz))
# right trace
x1=120
z1=100
x2=520
z2=500
Flow('line2.asc',None,'echo %s n1=4 data_format=ascii_float in=$TARGET'% ' '.join(map(str,(x1,z1, x2,z2))))
Plot('line2','line2.asc',
                '''
                dd type=complex form=native |
                graph min1=0 max1=600 min2=0 max2=600 pad=n plotfat=4 plotcol=0 dash=1
                wantaxis=n wanttitle=n yreverse=y scalebar=n screenratio=%g labelsz=%d
                ''' %(sr,lsz))
Result('syn','syn line1 line2','Overlay')

# local similarity
Flow('line1','trace','window n1=400 f1=100|put o1=0')
Flow('line2','trace2','cp')
Flow('scan','line1 line2','warpscan other=${SOURCES[1]} shift=y niter=50 ng=41 dg=1 g0=-20 rect1=5 rect2=1')
Plot('scan','pad end1=1 |grey title= allpos=y color=j label2=Shift screenratio=%g labelsz=%d labelfat=3 scalebar=y' %(sr,lsz))
Flow('pick','scan','pick vel0=0 smooth=n')
Plot('pick','pad end1=1 |graph transp=y min2=-20 max2=20 yreverse=y plotcol=7 plotfat=5 wantaxis=n title= pad=n screenratio=%g plotfat=%d scalebar=y' %(sr,lsz))
Result('pick','scan pick','Overlay')

Plot('scan2','scan','pad end1=1 |transp plane=12|put o2=100  |grey title= allpos=y color=j label1=Shift wherexlabel=top label2=Depth screenratio=%g labelsz=%d labelfat=3' %(0.2,11))
Plot('pick2','pick','pad end1=1 |graph transp=n min2=-20 max2=20 yreverse=y plotcol=7 plotfat=5 wantaxis=n title= pad=n screenratio=%g plotfat=%d' %(0.2,lsz))
Result('pick2','scan2 pick2','Overlay')
Result('lines','line1 line2','cat axis=2 ${SOURCES[1]} |put o1=100 d1=1 |graph screenratio=0.2 title= wherexlabel=top label2=Amplitude unit2= labelsz=11')

End()

sfdd
sfgrey
sfwindow
sfput
sfpad2
sfmutter
sfmath
sfgraph
sfiwarp
sfadd
sfcat
sfcp
sfwarpscan
sfpad
sfpick
sftransp