up [pdf]
from rsf.proj import *
import math
from rsf.gallery import sigsbee

cigpos=6.15

#
Plot ('vLine0',None,
      '''
          spike n1=4 nsp=4 k1=1,2,3,4 mag=2.0,%g,9,%g | dd type=complex |
          graph transp=y yreverse=y min2=4.0 max2=8.0 min1=2.0 max1=9 wanttitle=n wantaxis=n plotfat=6 pad=n dash=2 plotcol=7
          ''' % (cigpos,cigpos) )
Plot ('vLine',None,
      '''
          spike n1=4 nsp=4 k1=1,2,3,4 mag=2.0,%g,9,%g | dd type=complex |
          graph transp=y yreverse=y min2=4.0 max2=8.0 min1=2.0 max1=9 wanttitle=n wantaxis=n plotfat=2 pad=n dash=2 plotcol=0
          ''' % (cigpos,cigpos) )

# fetch data
sigsbee.getvel ('vel','migvel')
sigsbee.getshots ('shot')

# add crossline and offset axes
Flow ('sigs_data','shot',
          '''
          transp plane=23 | halfint inv=y adj=y |
          put n3=1 d3=100 o3=0 label3="Crossline" unit3="km"
          n4=348 o4=0 d4=0.02286 label4="Offset" unit4="km"
          ''')
Flow ('sigs_velModel','vel','smooth rect1=10 rect2=10 | put n3=1 d3=100 o3=0 label3="Crossline" unit3="km"')

# migration
Flow ('sigs-image sigs_dags sigs_cig', 'sigs_data sigs_velModel',
      '''
      dmigda vel=${SOURCES[1]} 
      dag=${TARGETS[1]} cig=${TARGETS[2]}
      izn=1601 izo=1500 izd=5
      ixn=921 ixo=3300 ixd=25
      iscato=0 iscatn=11 iscatd=10
      dipo=-160 dipn=321 dipd=1.0
      ''')

# figures
Result ('sigs-image',
        '''
        put o1=1.5 d1=0.005 unit1=km o2=3.3 d2=0.025 unit2=km |
        grey wanttitle=n
        ''')

Flow ('sigs_dag', 'sigs_dags', 'window min3=4000 max3=8000')

Plot ('sigs-image', 'sigs_dag',
          '''
      stack |
          put d1=0.005 o1=1.5 unit1=km d2=0.025 o2=4.0 label2=distance unit2=km |
          grey wanttitle=n labelsz=11. min1=2
          ''')
Plot ('image-input','sigs-image vLine','Overlay')
Plot ('dag-input', 'sigs_dag',
                '''
                put d1=0.005 o1=1.5 unit1=km d3=0.025 o3=4.0 unit3=km | 
                window min3=%g n3=1 min2=-60 max2=60 | grey wanttitle=n screenratio=1.5 labelsz=11. wantaxis1=n
            d1num=30 o1num=-60 n1tic=5 min1=2
                ''' % cigpos)
Result ('sigs-input','image-input dag-input','SideBySideAniso')

# apex protector

dz = 5.0
dx = 25.0

Flow ('dip','sigs-image-clean','dip2 rect1=21 rect2=21')
Flow ('dips','dip','math output="-180/%g*%g/%g*atan(input)"' % (math.pi, dz, dx))

Flow ('ap','sigs_dag dips','dagap dips=${SOURCES[1]} ddep=y greyarea=5 dz=10')
Flow ('dag-ap','sigs_dag ap','mul ${SOURCES[1]}')

Plot ('sigs-image-ap','dag-ap',
          '''
          put d1=0.005 o1=1.5 unit1=km d3=0.025 o3=4.0 unit3=km label3=distance | stack |
          grey wanttitle=n labelsz=11. min1=2
          ''')
Plot ('image-ap','sigs-image-ap vLine','Overlay')
Plot ('dag-ap',
          '''
          put d1=0.005 o1=1.5 unit1=km d3=0.025 o3=4.0 unit3=km | 
          window min3=%g n3=1 min2=-60 max2=60 |
          grey wanttitle=n screenratio=1.5 labelsz=11. wantaxis1=n
          d1num=30 o1num=-60 n1tic=5 min1=2
          ''' % cigpos)
Result ('sigs-ap','image-ap dag-ap','SideBySideAniso')

# taper 
Flow ('sigs-pimages', 'sigs_dag', 'transp plane=23')
Flow ('dipstan', 'sigs-pimages','fdip rect1=5 rect2=5 n4=0 order=3 verb=y')
Flow ('pdips', 'dipstan', 'math output="%g*atan(-input*%g)"' % (180/math.pi,dz/dx))
Flow ('taper','pdips','diptaper')
Flow ('sigs-clean', 'sigs-pimages taper','mul ${SOURCES[1]}')
Flow ('sigs-dag-tprd','sigs-clean','transp plane=23')


# semb coher

xapp=9
Flow ('sigs_dag0', 'sigs_dag', 'put d1=0.005 o1=1.5 unit1=km d3=0.025 o3=4 unit3=km')
Flow ('sigs_dag-sq', 'sigs_dag0', 'math output=input*input')
Flow ('weight','sigs_dag0 sigs_dag-sq','crssemb dataSq=${SOURCES[1]} xapp=%d s1=0.2 s2=0.4 | smooth rect1=3 rect2=3' % xapp)
Flow ('sigs-dag-clean', 'sigs_dag weight','math x=${SOURCES[0]} y=${SOURCES[1]} output=x*y')

Plot ('dag-semb', 'sigs-dag-clean',
                '''
                put d1=0.005 o1=1.5 unit1=km d3=0.025 o3=4.0 unit3=km |                 
                window min3=%g n3=1 min2=-60 max2=60 |
                grey screenratio=1.5 wanttitle=n labelsz=11. d1num=30 o1num=-60 n1tic=5 wantaxis1=n min1=2 pclip=99.5
                ''' % cigpos)

Flow ('sigs-image-clean','sigs-dag-clean','stack')

Plot ('sigs-image-clean',
            '''
                put d1=0.005 o1=1.5 unit1=km d2=0.025 o2=4.0 unit2=km label2=distance |
                grey wanttitle=n labelsz=12. min1=2
                ''')
Plot ('image-semb','sigs-image-clean vLine0 vLine','Overlay')
Result ('sigs-semb','image-semb dag-semb','SideBySideAniso')

# partial images 15 deg

Flow ('sigs_pimages-input','sigs_dag','transp plane=23 | put d1=0.005 o1=1.5 unit1=km d2=0.025 o2=4.0 unit2=km label2=distance')
Flow ('sigs_pimages-semb','sigs-dag-clean','transp plane=23 | put d1=0.005 o1=1.5 unit1=km d2=0.025 o2=4.0 unit2=km label2=distance')

Flow ('pimage15-input','sigs_pimages-input','window min3=15 n3=1')
Plot ('pimage15-input','grey wanttitle=n clip=2e-7')
Result ('pimage15-input-l','pimage15-input vLine0 vLine','Overlay')

Flow ('pimage15-semb','sigs_pimages-semb','window min3=15 n3=1')
Plot ('pimage15-semb',
          '''
          grey wanttitle=n label2=distance clip=2e-7
          ''')
Result ('pimage15-semb-l','pimage15-semb vLine0 vLine','Overlay')

Flow ('pimage15-mask','weight','window min2=15 n2=1')
Result ('pimage15-mask',
                '''
                put o1=1.5 d1=0.005 unit1=km o2=4.0 d2=0.025 label2=distance unit2=km | 
            grey wanttitle=n color=e scalebar=y wherebarlabel=bottom bartype=h bias=0. maxval=1 minval=0
                ''')

End ()

sfsegyread
sfwindow
sfmask
sfdd
sfmath
sfcat
sftransp
sfspike
sfgraph
sfscale
sfput
sfintbin
sfmutter
sfhalfint
sfsmooth
sfdmigda
sfgrey
sfstack
sfdip2
sfdagap
sfmul
sffdip
sfdiptaper
sfcrssemb

data/sigsbee/sigsbee2a_nfs.sgy
data/sigsbee/sigexp.rsf
data/sigsbee/sigsbee2a_migvel.sgy