up [pdf]
from rsf.proj import *

############################
# Data fetching, SEG-Y -> RSF
#############################

rawsegy=['L23535','L23536','L23537']

for file in rawsegy  :
    Fetch(file+'.SGY',
          server='http://certmapper.cr.usgs.gov',
          top='nersl/NPRA/SEISMIC/1981/31_81',
          dir='DMUX')
    Flow([file, file+'.bin',  file+'.asc', 't'+file],
         file+'.SGY',
         '''
         segyread bfile=${TARGETS[1]} hfile=${TARGETS[2]} tfile=${TARGETS[3]}
         ''')

# concatinate the input files

Flow('line',rawsegy,'cat axis=2 ${SOURCES[1:3]}')
Flow('tline',map(lambda x: 't'+x,rawsegy),'cat axis=2 ${SOURCES[1:3]}')

# display the first 3000 traces

Plot('first','line',
     'window n2=3000 | grey pclip=90 title="First 3,000 Traces" ')

Result('zoomfirst','line',
       '''
       window min2=1000 max2=1250 min1=0 max1=3 |
       grey pclip=90 title=Zoom
       ''')

Result('firstrec24','line',
       '''
       window min2=2324 max2=2424 min1=0 max1=6 |
       grey pclip=90 title="First Record"
       ''')

# Window out misfire
Flow('shotmask','tline',
     '''
     window n1=1 f1=2 | mask min=157 max=157 |
     add add=-1 | add scale=-1
     ''')

# Convert to shots
Flow('shots','line shotmask',
     '''
     headerwindow mask=${SOURCES[1]} |
     put n2=101 n3=67 |
     window n2=96 f3=10 |
     put o3=100 d3=1
     ''')

Flow('tshots','tline shotmask',
     '''
     headerwindow mask=${SOURCES[1]} |
     put n2=101 n3=67 |
     window n2=96 f3=10 |
     put o3=100 d3=1
     ''')

#############################
# Elevation profile, datuming
#############################

Flow('spelev','../line31-81/spnElev.txt',
     '''
     echo in=$SOURCE data_format=ascii_float n1=2 n2=33 |
     dd form=native
     ''',stdin=0)
Plot('spelev',
     '''
     dd type=complex |
     window |
     graph wanttitle=n wantaxis=n symbol=o plotcol=5
     min2=75 max2=125 min1=85 max1=165
     ''')

Flow('coord','spelev','window n1=1')
Flow('elev','spelev coord',
     'window f1=1 | invbin1 eps=0 head=${SOURCES[1]} x0=85 dx=1 nx=81')
Plot('elev',
     '''
     graph title=Elevation label1=Shot 
     min2=75 max2=125 min1=85 max1=165 
     ''')
Result('elev','elev spelev','Overlay')

###########################
# Previous Stack
###########################
Fetch('31_81_PR.SGY',
      server='http://certmapper.cr.usgs.gov',
      top='nersl/NPRA/SEISMIC/1981/31_81',
      dir='PROCESSED')

file='checkstack'
Flow([file, file+'.bin',  file+'.asc', 't'+file],
     '31_81_PR.SGY',
     '''
     segyread bfile=${TARGETS[1]} hfile=${TARGETS[2]} tfile=${TARGETS[3]}
     ''')

Result('checkstack','grey title="Check Stack" pclip=90')
Result('zoomcheckstack','checkstack',
       '''
       window max1=3 |
       grey title="Zoom Check Stack" pclip=90
       ''')

# Local slope
Flow('dip','checkstack','dip rect1=50 rect2=10 order=2')
Result('dip','grey color=j scalebar=y title=Slope')

Flow('pwd','checkstack dip','pwd dip=${SOURCES[1]} order=2')
Result('pwd','grey title=PWD')
Result('zoompwd','pwd',
       '''
       window max1=3 |
       grey title="Zoom PWD" pclip=90
       ''')

End()

sfsegyread
sfcat
sfwindow
sfgrey

nersl/NPRA/SEISMIC/1981/31_81/DMUX/L23535.SGY
nersl/NPRA/SEISMIC/1981/31_81/DMUX/L23536.SGY
nersl/NPRA/SEISMIC/1981/31_81/DMUX/L23537.SGY