up [pdf]
from rsf.proj import *

Flow('vrms',None,
     'math d1=0.004 n1=1001 o1=0 output="x1*125+2000+50*sin(9*x1)" ')

Flow('synt',None,
     '''
     spike d1=0.004 n1=1001 |
     noise rep=y seed=2006 |
     cut n1=100 | 
     bandpass flo=4 fhi=20 |
     spray axis=2 n=256 d=25 o=-3200 label=Offset unit=m 
     ''')

Flow('cmpa','synt vrms',
     'inmo velocity=${SOURCES[1]} half=y | noise seed=2007 var=1e-10')


############################################################
####### Blend 
############################################################
## Apply dithering
Flow('dither','cmpa',
     '''
     window n1=1 |
     noise rep=y seed=122011 var=10 | math output="1000*input"
     ''')

Flow('shottime1','cmpa','window n1=1 | math output=3*1000*x1')
Flow('shottime2','shottime1 dither','add scale=1,1 ${SOURCES[1]}')


## Blend 
Flow('cmp','cmpa cmpa shottime1 shottime2','blend shot_time_in=${SOURCES[3]} shot_time_out=${SOURCES[2]} |add scale=1,1 ${SOURCES[1]}' )

for case in ('a',''):
        dat='cmp'+case
        Result(dat,'grey wanttitle=n clip=0.74 ' )

dat='cmp'
typ='semblance'
scn=typ+'scn'
Flow(scn,'cmp','vscan half=y v0=2000 dv=10 nv=101 type=%s | clip2 lower=0' %typ)
Plot(scn+'0',scn,
                '''
                grey color=j allpos=y wanttitle=n pclip=100
                ''')
pik=typ+'pik'
Flow(pik,scn,'scale axis=2 | pick rect1=50')
Plot(pik,
             '''
             graph yreverse=y transp=y min2=2000 max2=3000 pad=n
             Resultcol=7 Resultfat=7 wanttitle=n wantaxis=n
             ''')
Result(scn,[scn+'0',pik],'Overlay')
nmo = typ + 'nmo'
Flow(nmo,[dat,pik],'nmo half=y velocity=${SOURCES[1]} str=0.1 ')
Result(nmo,
                        '''
                        grey wanttitle=n
                        grid2=y gridcol=6 gridfat=7 g2num=0.5 clip=0.74
                        ''' )

nmomf = typ + 'nmomf'
Flow(nmomf,nmo,'transp | mf nfw=9 | transp')
Result(nmomf,
                        '''
                        grey wanttitle=n 
                        grid2=y gridcol=6 gridfat=7 g2num=0.5 clip=0.74
                        ''' )
inmo = typ + 'inmo'
Flow(inmo,[nmomf,pik],'inmo half=y velocity=${SOURCES[1]} str=0.4')
Result(inmo,
                        '''
                        grey wanttitle=n clip=0.74
                        ''' )
diffmf=typ+'diffmf'
Flow(diffmf,['cmp',inmo],'add scale=1,-1 ${SOURCES[1]}')
Result(diffmf,
                        '''
                        grey wanttitle=n clip=0.74
                        ''' )
errormf=typ+'errormf'
Flow(errormf,['cmpa',inmo],'add scale=1,-1 ${SOURCES[1]}')
Result(errormf,
                        '''
                        grey wanttitle=n clip=0.74
                        ''' )


Result('comp1','./Fig/cmpa.vpl ./Fig/cmp.vpl ./Fig/semblancescn.vpl','SideBySideAniso')
Result('comp2','./Fig/semblancenmo.vpl ./Fig/semblancenmomf.vpl' ,'SideBySideAniso')
Result('comp3','./Fig/semblanceinmo.vpl ./Fig/semblancediffmf.vpl ./Fig/semblanceerrormf.vpl' ,'SideBySideAniso')




End()

sfmath
sfspike
sfnoise
sfcut
sfbandpass
sfspray
sfinmo
sfwindow
sfadd
sfblend
sfgrey
sfvscan
sfclip2
sfscale
sfpick
sfgraph
sfnmo
sftransp
sfmf