up [pdf]
from rsf.proj import *

box = '''
      box x0=%g y0=%g label="%s" xt=%g yt=%g lab_fat=3
      '''
#Get data
Fetch('dragon.HH','dragon')

Flow('dragon1','dragon.HH','dd form=native')
Plot('dragon1',
     '''
     window min1=4. |
     wiggle transp=y yreverse=y color=n wanttitle=n 
     wherexlabel=top poly=y parallel2=n n2tic=20 labelfat=3 gridfat=3
     label1=Time label2=Distance unit1=s unit2=km
     ''')

x = 200
y = 245
w = 2
w1= 6

Flow('frame.asc',None,
     'echo %s n1=10 data_format=ascii_int in=$TARGET' % \
     string.join(map(str,(x,y,x+w,y,x+w,y+w1,x,y+w1,x,y))))
Plot('frame','frame.asc',
     '''
     dd type=complex form=native |
     graph min1=198 max1=212 min2=233 max2=257 pad=n plotfat=10 plotcol=3
     wantaxis=n wanttitle=n
     ''')
Plot('label0',None,box % (5.3,7.1,"D",0.,0.))
Plot('label01',None,box % (4.5,8.0,"A",0.5,0.5))
Plot('label02',None,box % (7.0,3.7,"B",-0.5,0.5))
Plot('label03',None,box % (12.0,6.0,"C",-0.5,0.5))

Result('dragon1','dragon1 frame label0 label01 label02 label03','Overlay')

Flow('dspec','dragon1','window n2=1 f2=20 | spectra ')
Result('dspec',
       '''
       graph wanttitle=n max2=6 parallel2=n n2tic=20 labelfat=3
       gridfat=3 label2=Amplitude label1=Frequency unit2= unit1=Hz
       ''')

# Filters
transf = {'11mf':'mf nfw=11 |bandpass flo=5 fhi=70 ' ,
          '11tvmf':'tvmf nfw=7 |bandpass flo=5 fhi=70'}

# Apply Filters to white noise
for tt in range(2):
    t = transf.keys()[tt]

    # Apply filter
    Flow(t,'dragon1',transf[t])
    Result(t,
           '''
           window min1=4. |
           wiggle transp=y yreverse=y color=n wanttitle=n 
           wherexlabel=top poly=y parallel2=n n2tic=20 labelfat=3 gridfat=3
           label1=Time label2=Distance unit1=s unit2=km
           ''' )

Flow('fspec','11tvmf','window n2=1 f2=20 | spectra ')
Result('fspec',
       '''
       graph wanttitle=n max2=6 parallel2=n n2tic=20 labelfat=3 
       gridfat=3 label2=Amplitude label1=Frequency unit2= unit1=Hz
       ''')

Flow('mfspec','11mf','window n2=1 f2=20 | spectra ')
Result('mfspec',
       '''
       graph wanttitle=n max2=6 parallel2=n n2tic=20 labelfat=3 gridfat=3 
       label2=Amplitude label1=Frequency unit2= unit1=Hz
       ''')

Flow('band','dragon1','bandpass flo=5 fhi=60 ')
Result('band',
       '''
       window min1=4. |
       wiggle transp=y yreverse=y color=n wanttitle=n
       wherexlabel=top poly=y parallel2=n n2tic=20 labelfat=3 gridfat=3
       label1=Time label2=Distance unit1=s unit2=km
       ''')
Flow('bspec','band','window n2=1 f2=20 | spectra ')
Result('bspec',
       '''
       graph wanttitle=n max2=6 parallel2=n n2tic=20 labelfat=3 gridfat=3 
       label2=Amplitude label1=Frequency unit2= unit1=Hz
       ''')

Flow('diff','dragon1 11tvmf','add scale=1,-1 ${SOURCES[1]}')
Result('diff',
       '''
       window min1=4. |
       put d2=0.04238 |
       wiggle transp=y yreverse=y color=n wanttitle=n
       wherexlabel=top poly=y parallel2=n n2tic=20 labelfat=3 gridfat=3
       label1=Time label2=Distance unit1=s unit2=km
       ''')

#Get NMO+stack+AGC data and TVMF+NMO+stack+AGC data
oldsgy = 'nmo_stack_agc.sgy'
newsgy = 'tvmf_agc.sgy'

Fetch([oldsgy,newsgy],'dragon')

Flow('oldstack toldstack oldstack.asc oldstack.bin',oldsgy,
     '''
    segyread tfile=${TARGETS[1]} hfile=${TARGETS[2]} bfile=${TARGETS[3]} 
     ''')


Flow('newstack tnewstack newstack.asc newstack.bin',newsgy,
     '''
    segyread tfile=${TARGETS[1]} hfile=${TARGETS[2]} bfile=${TARGETS[3]} 
     ''')

Plot('stack1','oldstack',
     '''
     window n2=100 min1=2 max1=4 | 
     put d2=0.04238 |
     wiggle transp=y yreverse=y color=n wanttitle=n 
     wherexlabel=top poly=y parallel2=n n2tic=20 labelfat=3 gridfat=3
     label1=Time label2=Distance unit1=s unit2=km
     ''')

x1 = 198
y1 = 251
w0 = 4
w01= 6

Flow('frame1.asc',None,
     'echo %s n1=10 data_format=ascii_int in=$TARGET' % \
     string.join(map(str,(x1,y1,x1+w0,y1,x1+w0,y1+w01,x1,y1+w01,x1,y1))))
Plot('frame1','frame1.asc',
     '''
     dd type=complex form=native |
     graph min1=198 max1=212 min2=233 max2=257 pad=n plotfat=10 plotcol=3
     wantaxis=n wanttitle=n
     ''')
Plot('label00',None,box % (5.2,7.1,"H",0.,0.))
Plot('label1',None,box % (7,7.3,"E",-0.5,0.5))
Plot('label2',None,box % (4.8,5.8,"F",-0.5,-0.5))
Plot('label3',None,box % (10.8,7.7,"G",0.5,-0.5))
Result('stack1','stack1 frame1 label00 label1 label2 label3','Overlay')

Plot('stack2','newstack',
     '''
     window n2=100 min1=2 max1=4 |
     put d2=0.04238 |
     wiggle transp=y yreverse=y color=n wanttitle=n 
     wherexlabel=top poly=y parallel2=n n2tic=20 labelfat=3 gridfat=3
     label1=Time label2=Distance unit1=s unit2=km
     ''')

Result('stack2','stack2 label1 label2 label3','Overlay')

End()

sfdd
sfwindow
sfwiggle
sfgraph
sfbox
sfspectra
sfmf
sfbandpass
sftvmf
sfadd
sfput
sfsegyread

data/dragon/dragon.HH
data/dragon/nmo_stack_agc.sgy
data/dragon/tvmf_agc.sgy