up [pdf]
from rsf.proj import *

# SConscript('../fetch/SConstruct')

Flow('gathers','../fetch/npr3_gathers.rsf ../fetch/npr3_gathers_hdr.rsf',
     'intbin3 head=${SOURCES[1]} xkey=-1')

Flow('offset mask','../fetch/npr3_gathers_hdr.rsf',
     'window n1=1 f1=11 squeeze=n | intbin3 head=$SOURCE xkey=-1 mask=${TARGETS[1]} | dd type=float')

Flow('fold','mask','dd type=float | stack axis=1 norm=n')

Result('fold',
       '''
       grey transp=n yreverse=n title=Fold allpos=y color=j scalebar=y 
       label1=Inline unit1= label2=Crossline
       ''')

tnmo=(0.0,.617,.769,.913,1.027,1.196,1.767,3.0,10.00)
vnmo=(9132.86,10764.47,10941.73,11235.75,11902.71,12580.03,14513.85,16982.86)

Flow('vnmo.asc',None,
     '''
     echo %s n1=%d n2=2 data_format=ascii_float in=$TARGET
     ''' % (' '.join(map(str,tnmo)+map(str,vnmo)),len(tnmo)))
Flow('vnmo','vnmo.asc gathers',
     'dd form=native | linear pattern=${SOURCES[1]}') # rect=5 niter=100')

Result('vnmo','graph title="NMO Velocity" label1=Time unit1=s label2=Velocity unit2=ft/s')

Flow('vnmo3','vnmo','spray axis=1 n=1 | spray axis=3 n=188 | spray axis=4 n=345')
Flow('mask3','mask','spray axis=1 n=1')

Flow('nmo','gathers offset vnmo3 mask3',
     '''
     nmo offset=${SOURCES[1]} half=n velocity=${SOURCES[2]} mask=${SOURCES[3]}
     ''',split=[4,345])

Flow('stack','nmo','stack',split=[4,345],reduce='cat axis=3')

Result('stack',
       '''
       window n1=1000
       | byte gainpanel=all 
       | grey3 title=Stack frame1=500 frame2=120 frame3=140
        ''')
Result('stack141','stack',
       '''
       window n1=1000 n3=1 f3=141 | grey title='stack line 141'
       ''')
Result('stackx121','stack',
       '''
       window n1=1000 n2=1 f2=121 | grey title='stack xline 121'
       ''')


# Velocity analysis at one CMP
Flow('gather1','gathers','window n3=1 n4=1 f3=120 f4=140')
Flow('offset1','offset', 'window n3=1 n4=1 f3=120 f4=140')
Flow('mask1','mask3',    'window n3=1 n4=1 f3=120 f4=140')

Result('gather1','gather1 offset1',
       '''
       wiggle xpos=${SOURCES[1]} transp=y poly=y yreverse=y title="CMP Gather" 
       label2=Offset unit2=ft
       ''')

Flow('vscan1','gather1 offset1 mask1',
     'vscan offset=${SOURCES[1]} mask=${SOURCES[2]} v0=9000 nv=101 dv=100 semblance=y half=n nb=10')

Result('vscan1','grey color=j allpos=y title="Semblance Scan" unit2=ft/s')

# Try a supergather???

End()

sfintbin3
sfwindow
sfdd
sfstack
sfgrey
sflinear
sfgraph
sfspray
sfnmo
sfcat
sfbyte
sfgrey3
sfwiggle
sfvscan