up [pdf]
from rsf.proj import *

# CIG to tan
def hcig2ssk():
    return '''
    slant adj=y p0=-2 np=401 dp=0.01 |
    put label2=tan
    '''
# tan to angle
def hssk2ang():
    return '''
    tan2ang a0=-60 na=241 da=0.5 |
    put label2=ang
    '''

##### ################Get sigsbee local offset gathers  

Fetch('SRC0x.hh','sigsbee')

##### Transpose from axis x-z-h to axis z-h-x 

#Flow('SRC0x','SRC0x.hh','window | transp plane=14 | window')


#####################################

Flow('off','SRC0x.hh','window | transp plane=14| window | window min3=15000 max3=80000')

Result('off','SRC0x.hh',
       '''
       window | transp plane=12 | byte gainpanel=all pclip=99| grey3 labelrot=n title="ODCIGs" 
        pclip=99   label1="z" label2="x" label3="h" 
       frame1=500 frame2=250 frame3=20 point2=0.7 point1=0.7 point3=0.15 unit1=ft unit3=ft unit2=ft
       ''')

Result('imag-off','off','window n2=1 min2=0 | grey  title="Zero offset image" unit1=ft unit2=ft')

Flow('ssk','off', hcig2ssk())

Flow('sskt','ssk','transp plane=23 memsize=150')
Result('ssk','sskt',
       '''
       window j1=2 |
       byte gainpanel=all pclip=99| grey3 labelrot=n title="PhDCIGs" 
       pclip=99   label1="z" label2="x" label3="tan"
       frame1=250 frame2=250 frame3=200 point2=0.7 point1=0.7 point3=0.15 unit1=ft  unit2=ft
       ''')

Flow('ang','ssk',hssk2ang())

Flow('angt','ang','transp plane=23 memsize=150')
Result('angs','angt',
       '''
        byte gainpanel=all pclip=99| grey3 flat=n labelrot=n wanttitle=n 
        pclip=99   label1="z" label2="x" label3="\F10 q\F3" 
       frame1=500 frame2=250 frame3=120 point2=0.8 point1=0.8  unit1=ft unit3="\^o\_" unit2=ft
       ''')

Result('ang1','angt',
       '''
        window min3=0 n3=1 | grey labelrot=n wanttitle=n 
        pclip=99   label1="z" label2="x"  unit1=ft  unit2=ft
       ''')
Result('ang2','angt',
       '''
        window min3=20 n3=1 | grey labelrot=n wanttitle=n 
        pclip=99   label1="z" label2="x"  unit1=ft  unit2=ft
       ''')

Flow('stack','ang','stack')

Result('sigstack','stack',' grey pclip=97 label1=z label2=x unit1=ft unit2=ft wanttitle=n ')

Flow('stacks','stack','spray axis=2 n=241')

Flow('weights', 'ang stacks',
     '''similarity other=${SOURCES[1]} niter=30 rect1=50 rect2=3
     ''')

Flow('tweights','weights','threshold pclip=99.5')

Flow('similt','tweights','transp plane=23 memsize=150')

Result('simil1','similt',
       '''
        smooth rect1=10 rect2=5 rect3=5 | window min3=0 n3=1 |  grey labelrot=n wanttitle=n 
        pclip=99   label1="z" label2="x"  unit1=ft  unit2=ft color=j 
       ''')

Result('simil2','similt',
       '''
        smooth rect1=10 rect2=5 rect3=5| window min3=20 n3=1 |  grey labelrot=n wanttitle=n 
        pclip=99   label1="z" label2="x"  unit1=ft  unit2=ft color=j 
       ''')

Flow('scale','tweights','stack | spray axis=2 n=241')

Flow('simistack','tweights ang scale',
     '''
     sfmath y=${SOURCES[1]} z=${SOURCES[2]} output="input*y/(z+0.005)" | stack  
     ''')

Result('sigsimistack','simistack',' grey pclip=97 label1=z label2=x unit1=ft unit2=ft wanttitle=n ')



End()

sfwindow
sftransp
sfbyte
sfgrey3
sfgrey
sfslant
sfput
sftan2ang
sfstack
sfspray
sfsimilarity
sfthreshold
sfsmooth
sfmath

data/sigsbee/SRC0x.hh