up [pdf]
from rsf.proj import *

par = dict(
    ns=2801,
    dt=0.0005,

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

        ireconstruct=0,
    xrec1=0.0,
    zrec1=0.0,
    xrec2=0.0,
    zrec2=0.0,
    )

import bptti2007

bptti2007.get_model('Vp Vs Epsilon Delta Theta')

# =============================================================
Flow('vp0','Vp',
     '''
     smooth rect1=3 rect2=3
     ''')
#     math output=input
Flow('vs0','Vs',
     '''
     math output=input
     ''')

Flow('epsi','Epsilon',
     '''
     math output=input
     ''')

Flow('del','Delta',
     '''
     math output=input
     ''')

Flow('the','Theta',
     '''
     smooth rect1=10 rect2=10
     ''')

name0='''
vp0 vs0
'''

name00='''
epsi del the
'''

for ff in Split(name0):
        Result(ff,
        '''
        grey color=j polarity=n scalebar=y screenratio=0.87 wanttitle=n pclip=100
        ''')

for gg in Split(name00):
        Result(gg,
        '''
        grey color=j polarity=n scalebar=y screenratio=0.87 wanttitle=n pclip=100
        ''')

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

Flow(['Elasticx',  'Elasticz',  'ElasticSepP', 'ElasticSepSV'],
         'vp0  vs0  epsi del the',
         '''
         tti2delrsep
         vp0=${SOURCES[0]}
         vs0=${SOURCES[1]}
         epsi=${SOURCES[2]} 
         del=${SOURCES[3]}
         the=${SOURCES[4]}
         Elasticz=${TARGETS[1]}
         ElasticSepP=${TARGETS[2]}
         ElasticSepSV=${TARGETS[3]}
         ns=%d 
         dt=%g
         eps=%g
         seed=%d
         npk=%d
         ''' % (par['ns'],par['dt'],par['eps'],par['seed'],par['npk'])
    )

for qq in Split(name1):
        Result(qq,
        '''
        grey polarity=n scalebar=n screenratio=1. wanttitle=n axisfat=5 axiscol=7 labelsz=10 pclip=99
        ''')

# =================================================================================
# Vector decomposition
# =================================================================================
name2='''
ElasticX ElasticZ ElasticPx ElasticPz ElasticSVx ElasticSVz
'''

Flow(['ElasticX',  'ElasticZ',  'ElasticPx', 'ElasticPz', 'ElasticSVx', 'ElasticSVz'],
      'vp0  vs0  epsi del the',
         '''
         tti2delrdecomp2p
         vp0=${SOURCES[0]}
         vs0=${SOURCES[1]}
         epsi=${SOURCES[2]} 
         del=${SOURCES[3]}
         the=${SOURCES[4]}
         ElasticZ=${TARGETS[1]}
         ElasticPx=${TARGETS[2]}
         ElasticPz=${TARGETS[3]}
         ElasticSVx=${TARGETS[4]}
         ElasticSVz=${TARGETS[5]}
         ns=%d 
         dt=%g
         eps=%g
         seed=%d
         npk=%d
                 ireconstruct=%d
         xrec1=%g
         zrec1=%g
         xrec2=%g
         zrec2=%g
         ''' % (par['ns'],par['dt'],par['eps'],par['seed'],par['npk'],par['ireconstruct'],par['xrec1'],par['zrec1'],par['xrec2'],par['zrec2'])
    )

for qq in Split(name2):
        Result(qq,
        '''
        grey polarity=n scalebar=n screenratio=1. wanttitle=n axisfat=5 axiscol=7 labelsz=10 pclip=99
        ''')
End()

sfsegyread
sfput
sfmath
sfgrey
sfwindow
sfsmooth
sftti2delrsep
sftti2delrdecomp2p
sfcp
sfadd