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,
        phi_1=0.0,
    vp0_2=3600,
    vs0_2=1800,
    eps_2=0.2,
    del_2=0.1,
    gam_2=0.05,
    the_2=30.0,
        phi_2=30.0,

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

        iflagvti=0,
    )

# =================================================================================
Flow(['vp0','vs0','epsi','del','gam','the','phi'], None,
     '''
         twolayer3dti
         vs0=${TARGETS[1]}
         epsi=${TARGETS[2]}
         del=${TARGETS[3]}
         gam=${TARGETS[4]}
         the=${TARGETS[5]}
         phi=${TARGETS[6]}
         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
         phi_1=%g
         vp0_2=%g
         vs0_2=%g
         eps_2=%g
         del_2=%g
         gam_2=%g
         the_2=%g
         phi_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['phi_1'],
                par['vp0_2'],par['vs0_2'],par['eps_2'],par['del_2'],par['gam_2'],par['the_2'],par['phi_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 the phi',
      '''
         tti3de
         vp0=${SOURCES[0]}
         vs0=${SOURCES[1]}
         epsi=${SOURCES[2]}
         del=${SOURCES[3]}
         gam=${SOURCES[4]}
         the=${SOURCES[5]}
         phi=${SOURCES[6]}
         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 the phi Elasticx Elasticy Elasticz',
      '''
         tti3delrsepP
         vp0=${SOURCES[0]}
         vs0=${SOURCES[1]}
         epsi=${SOURCES[2]}
         del=${SOURCES[3]}
         gam=${SOURCES[4]}
         the=${SOURCES[5]}
         phi=${SOURCES[6]}
         Elasticx=${SOURCES[7]}
         Elasticy=${SOURCES[8]}
         Elasticz=${SOURCES[9]}
         seed=%d
         eps=%g
         npk=%d
                 iflagvti=%d
     ''' % (par['seed'],par['eps'],par['npk'],par['iflagvti'])
)

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

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

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
sftti3de
sfmath
sfgraph3
sftti3delrsepP
sftti3delrsepSV
sftti3delrsepSH