up [pdf]
from rsf.proj import *

from rsf.recipes.beg import server
# replace with your own data server

for case in ('a1','a2','b1'):
    segy = 'salt-%s.segy' % case
    Fetch(segy,'segsalt',server)

    Flow([case,'t'+case,case+'.asc',case+'.bin'],segy,
         '''
         segyread tfile=${TARGETS[1]} hfile=${TARGETS[2]} bfile=${TARGETS[3]}
         ''')

Flow('a1s','ta1',
     '''
     window n1=1 f1=22 n2=49116 | dd type=float | math output="(input-1020)/80"
     ''')
Flow('a1x','ta1',
     '''
     window n1=1 f1=23 n2=49116 | dd type=float |
     math output="(input-7500)/80"
     ''')
Flow('a1y','ta1 a1s',
     '''
     window n1=1 f1=24 n2=49116 | dd type=float |
     math s=${SOURCES[1]} output="(input-(1020+s*80))/40" 
     ''')
Flow('a1head','a1s a1y a1x',
     'cat axis=2 ${SOURCES[1:3]} | transp | dd type=int')

Flow('a1data','a1 a1head',
     '''
     window n2=49116 |
     intbin3 head=${SOURCES[1]} xkey=0 ykey=1 zkey=2 |
     put
     o2=1020  d2=80 label2=sy
     o3=-2720 d3=40 label3=hy
     o4=-200  d4=80 label4=hx     
     ''')

Result('a1near','a1data',
       '''
       window n3=1 f3=-1 n4=1 f4=3 |
       tpow tpow=1 |
       grey title="A1 Near Offset"
       ''')

Flow('a2s','ta2',
     '''
     window n1=1 f1=21 n2=50916 | dd type=float | math output="(input-1520)/80"
     ''')
Flow('a2x','ta2 a2s',
     '''
     window n1=1 f1=23 n2=50916 | dd type=float |
     math s=${SOURCES[1]} output="(input-(1520+s*80))/40"
     ''')
Flow('a2y','ta2',
     '''
     window n1=1 f1=24 n2=50916 | dd type=float |
     math output="(input-5060)/40"
     ''')
Flow('a2head','a2s a2x a2y',
     'cat axis=2 ${SOURCES[1:3]} | transp | dd type=int')

Flow('a2data','a2 a2head',
     '''
     window n2=50916 | 
     intbin3 head=${SOURCES[1]} xkey=0 ykey=1 zkey=2 |
     put
     o2=1520  d2=80 label2=sx
     o3=-2760 d3=40 label3=hx
     o4=-200  d4=40 label4=hy     
     ''')

Result('a2near','a2data',
       '''
       window n3=1 f3=65 n4=1 f4=8 |
       tpow tpow=1 |
       grey title="A2 Near Offset"
       ''')

End()

sfsegyread
sfwindow
sfdd
sfmath
sfcat
sftransp
sfintbin3
sfput
sftpow
sfgrey