up [pdf]
from rsf.proj import *
import math

# Model
z0 = 2.7
x0 = 7.0

Flow('diff.asc', None, 'echo %g %g n1=2 data_format=ascii_float in=$TARGET' % (x0,z0))
Plot ('diff','diff.asc',
     '''
     dd format=native type=complex |
     graph symbol=* min2=1 max2=3 min1=4 max1=8
     yreverse=y plotfat=20 title=model pad=n
     label1=distance unit1=km label2=depth unit2=km 
     grid1=y g1num=0.5
     ''')

z = (1.5,0.6)
a = (0,15)
x = (4.0,4.5)
gamma = (0.9,1.0,1.1)
v=2.0

for ref in range(2):
    a0 = a[ref]*math.pi/180

    refl = 'refl%d' % ref
    Flow(refl, None,
         '''
         math n1=1001 d1=0.01 o1=0 output="%g+x1*%g"
         ''' % (z[ref],math.tan(a0)))
    Plot(refl,
         '''
         graph min2=1 max2=3 yreverse=y plotfat=5 min1=4 max1=8
         wanttitle=n wantaxis=n pad=n
         ''')

Result ('theo-model','diff refl0 refl1','Overlay')

Flow ('reflmodel', 'refl0 refl1', 'cat axis=2 ${SOURCES[1]}')
Flow ('diffmodel', None,'math n1=1 o1=%g d1=0.001 output=%g' % (x0, z0) )

Flow ('refldata', 'reflmodel', 'kirmod nt=1001 freq=30 ns=801 s0=2 ds=0.01 nh=1 h0=0.0 dh=0.01 twod=y type=c vel=2 verb=y cmp=n')
Flow ('diffdata', 'diffmodel', 'kirmod nt=1001 freq=30 ns=801 s0=2 ds=0.01 nh=1 h0=0.0 dh=0.01 twod=y type=c vel=2 verb=y cmp=n')

Flow ('data_init','refldata diffdata','add scale=1,500 ${SOURCES[1]} | put label3=source unit3=km label2=offset unit2=km init')
Flow ('data0','data_init','transp plane=23 | put n4=1 o4=0.0 d4=0.01 unit4=km label4=offset n3=1 label2=distance label1=time')
Result ('data0','grey wanttitle=n min2=4 max2=8 min1=1')

Flow ('data','data0','halfint inv=y adj=y')

Flow ('vel', None, 'math n1=1001 n2=1001 d1=0.004 d2=0.01 o1=0 o2=0 output="2" | put n3=1 o3=0 d3=0.025 unit1=s unit2=km unit3=km')

Flow ('dimage ddag dcig','data vel',
          '''
          dmigda vel=${SOURCES[1]}
          dag=${TARGETS[1]} cig=${TARGETS[2]}
          ixo=4000 ixn=161 ixd=25
          izo=1000 izn=401 izd=5
          dipn=481 dipo=-60 dipd=0.25
          iscatn=1 iscato=0 iscatd=1
          ''')

# lines
Plot ('vline', None,
      '''
          spike n1=4 nsp=4 k1=1,2,3,4 mag=0,7,3,7 | dd type=complex |
          graph transp=y yreverse=y wanttitle=n wantaxis=n plotfat=6 pad=n plotcol=0 min2=4 max2=8 min1=1 max1=3 dash=2
          ''')
Plot ('zo-image-init0','ddag',
                '''
                stack | 
                put o1=1 d1=0.005 unit1=km label2=distance unit2=km o2=4 d2=0.025 |     
                grey wanttitle=n min1=1
                ''')
Plot ('zo-image-init','zo-image-init0 vline','Overlay')

Plot ('zo-dag-init','ddag',
          '''
          put o1=1 d1=0.005 unit1=km unit3=km o3=4 d3=0.025 |
          window min3=7 n3=1 | grey wanttitle=n min1=1 screenratio=1.5
          d1num=30 o1num=-60 n1tic=5 pclip=100
          ''')

Result ('zo-res-init','zo-image-init zo-dag-init','SideBySideAniso')

Plot ('line00f',None,
      '''
          spike n1=4 nsp=4 k1=1,2,3,4 mag=1.5,4,1.5,8 | dd type=complex |
          graph transp=y yreverse=y wanttitle=n wantaxis=n plotfat=8 pad=n plotcol=0 min2=4 max2=8 min1=1 max1=3 dash=3
          ''')

Plot ('line01f',None,
      '''
          spike n1=4 nsp=4 k1=1,2,3,4 mag=2.7,6.75,2.7,7.25 | dd type=complex |
          graph transp=y yreverse=y wanttitle=n wantaxis=n plotfat=8 pad=n plotcol=0 min2=4 max2=8 min1=1 max1=3 dash=3
          ''')

Plot ('line00n',None,
      '''
          spike n1=4 nsp=4 k1=1,2,3,4 mag=1.5,4,1.5,8 | dd type=complex |
          graph transp=y yreverse=y wanttitle=n wantaxis=n plotfat=4 pad=n plotcol=7 min2=4 max2=8 min1=1 max1=3 dash=3
          ''')

Plot ('line01n',None,
      '''
          spike n1=4 nsp=4 k1=1,2,3,4 mag=2.7,6.75,2.7,7.25 | dd type=complex |
          graph transp=y yreverse=y wanttitle=n wantaxis=n plotfat=4 pad=n plotcol=7 min2=4 max2=8 min1=1 max1=3 dash=3
          ''')

Plot ('_dpis0','ddag',
                '''
            put o1=1 d1=0.005 unit1=km label3=distance unit3=km o3=4 d3=0.025 |
                window min2=0 n2=1 | grey wanttitle=n min1=1
                ''')

Result ('zodpis0','_dpis0 line00f line01f line00n line01n','Overlay')

Plot ('line10f',None,
      '''
          spike n1=4 nsp=4 k1=1,2,3,4 mag=1.6716,4,2.7432,8 | dd type=complex |
          graph transp=y yreverse=y wanttitle=n wantaxis=n plotfat=8 pad=n plotcol=0 min2=4 max2=8 min1=1 max1=3 dash=3
          ''')

Plot ('line11f',None,
      '''
          spike n1=4 nsp=4 k1=1,2,3,4 mag=2.633,6.75,2.767,7.25 | dd type=complex |
          graph transp=y yreverse=y wanttitle=n wantaxis=n plotfat=8 pad=n plotcol=0 min2=4 max2=8 min1=1 max1=3 dash=3
          ''')

Plot ('line10n',None,
      '''
          spike n1=4 nsp=4 k1=1,2,3,4 mag=1.6716,4,2.7432,8 | dd type=complex |
          graph transp=y yreverse=y wanttitle=n wantaxis=n plotfat=4 pad=n plotcol=7 min2=4 max2=8 min1=1 max1=3 dash=3
          ''')

Plot ('line11n',None,
      '''
          spike n1=4 nsp=4 k1=1,2,3,4 mag=2.633,6.75,2.767,7.25 | dd type=complex |
          graph transp=y yreverse=y wanttitle=n wantaxis=n plotfat=4 pad=n plotcol=7 min2=4 max2=8 min1=1 max1=3 dash=3
          ''')

Plot ('_dpis15','ddag',
                '''
            put o1=1 d1=0.005 unit1=km label3=distance unit3=km o3=4 d3=0.025 |
                window min2=-15 n2=1 | grey wanttitle=n min1=1
                ''')

Result ('zodpis15','_dpis15 line10f line11f line10n line11n','Overlay')

End()

sfdd
sfgraph
sfmath
sfcat
sfkirmod
sfadd
sfput
sftransp
sfgrey
sfhalfint
sfdmigda
sfspike
sfstack
sfwindow