up [pdf]
from rsf.proj import *

par = dict(
    ny=201,
    nx=201,
    nz=201,
    dy=0.005,
    dx=0.005,
    dz=0.005,
    y0=0.0,
    x0=0.0,
    z0=0.0,

    ns=341,
    dt=0.0005,

    vp0_1=2500,
    vs0_1=1200,
    eps_1=0.25,
    del_1=-0.25,
    gam_1=0.0,
    the_1=0.0,
    vp0_2=3600,
    vs0_2=1800,
    eps_2=0.2,
    del_2=0.1,
    gam_2=0.05,
    the_2=0.0,

    seed=2012,
    eps=1.e-6,
    npk=30,
    )

# =================================================================================
Flow(['vp0','vs0','epsi','del','the','gam'], None,
     '''
         twolayer3dti
         vs0=${TARGETS[1]}
         epsi=${TARGETS[2]}
         del=${TARGETS[3]}
         the=${TARGETS[4]}
         gam=${TARGETS[5]}
         ny=%d
         nx=%d
         nz=%d
         dy=%g
         dx=%g
         dz=%g
         vp0_1=%g
         vs0_1=%g
         eps_1=%g
         del_1=%g
         gam_1=%g
         the_1=%g
         vp0_2=%g
         vs0_2=%g
         eps_2=%g
         del_2=%g
         gam_2=%g
         the_2=%g
         ''' % (par['ny'],par['nx'],par['nz'],par['dy'],par['dx'],par['dz'],
                par['vp0_1'],par['vs0_1'],par['eps_1'],par['del_1'],par['gam_1'],par['the_1'],
                par['vp0_2'],par['vs0_2'],par['eps_2'],par['del_2'],par['gam_2'],par['the_2'])
    )

Result('vp0','vp0',
      '''
      byte |
          grey3 polarity=n scalebar=n frame1=101 frame2=101 frame3=101 wanttitle=n flat=y screenratio=1
      ''')

# =================================================================================
# calculate separated wave-mode:         yes
# =================================================================================
name1='''
Elasticx Elasticy Elasticz
'''

Flow(['Elasticx',  'Elasticy', 'Elasticz'],'vp0 vs0 epsi del gam',
      '''
         vti3de
         vp0=${SOURCES[0]}
         vs0=${SOURCES[1]}
         epsi=${SOURCES[2]}
         del=${SOURCES[3]}
         gam=${SOURCES[4]}
         Elasticy=${TARGETS[1]}
         Elasticz=${TARGETS[2]}
         ns=%d 
         ny=%d 
         nx=%d 
         nz=%d 
         dt=%g
         dy=%g
         dx=%g
         dz=%g
     ''' % (par['ns'],par['ny'],par['nx'],par['nz'],par['dt'],par['dy'],par['dx'],par['dz'])
)

Flow('interface','Elasticx',
     '''
     math output=.41666666666666666666
     '''
    )

Plot('interface',
     '''
     graph3 min=0 max=1 plotfat=1 dash=5 polarity=n scalebar=n wanttitle=n wantaxis=n flat=y screenratio=1.
     '''
     )

for qq in Split(name1):
        Plot(qq,
        '''
        byte gainpanel=all |
                grey3 color=j polarity=n scalebar=n frame1=101 frame2=101 frame3=101 wanttitle=n flat=y screenratio=1
        ''')

for qq in Split(name1):
    Result(qq+'Interf',[qq,'interface'],'Overlay')

# =================================================================================
# wave mode seapration using low-rank decomposition 
# =================================================================================
name2='''
ElasticP ElasticSV ElasticSH
'''

Flow('ElasticP','vp0 vs0 epsi del gam Elasticx Elasticy Elasticz',
      '''
         vti3delrsepP
         vp0=${SOURCES[0]}
         vs0=${SOURCES[1]}
         epsi=${SOURCES[2]}
         del=${SOURCES[3]}
         gam=${SOURCES[4]}
         Elasticx=${SOURCES[5]}
         Elasticy=${SOURCES[6]}
         Elasticz=${SOURCES[7]}
         seed=%d
         eps=%g
         npk=%d
     ''' % (par['seed'],par['eps'],par['npk'])
)

Flow('ElasticSV','vp0 vs0 epsi del gam Elasticx Elasticy Elasticz',
      '''
         vti3delrsepSV
         vp0=${SOURCES[0]}
         vs0=${SOURCES[1]}
         epsi=${SOURCES[2]}
         del=${SOURCES[3]}
         gam=${SOURCES[4]}
         Elasticx=${SOURCES[5]}
         Elasticy=${SOURCES[6]}
         Elasticz=${SOURCES[7]}
         seed=%d
         eps=%g
         npk=%d
     ''' % (par['seed'],par['eps'],par['npk'])
)

Flow('ElasticSH', 'vp0 vs0 epsi del gam Elasticx Elasticy Elasticz',
      '''
         vti3delrsepSH
         vp0=${SOURCES[0]}
         vs0=${SOURCES[1]}
         epsi=${SOURCES[2]}
         del=${SOURCES[3]}
         gam=${SOURCES[4]}
         Elasticx=${SOURCES[5]}
         Elasticy=${SOURCES[6]}
         Elasticz=${SOURCES[7]}
         seed=%d
         eps=%g
         npk=%d
     ''' % (par['seed'],par['eps'],par['npk'])
)

for qq in Split(name2):
        Plot(qq,
        '''
        byte gainpanel=all |
                grey3 color=j polarity=n scalebar=n frame1=101 frame2=101 frame3=101 wanttitle=n flat=y screenratio=1
        ''')

for qq in Split(name2):
    Result(qq+'Interf',[qq,'interface'],'Overlay')

End()

sftwolayer3dti
sfbyte
sfgrey3
sfvti3de
sfmath
sfgraph3
sfvti3delrsepP
sfvti3delrsepSV
sfvti3delrsepSH