up [pdf]
from rsf.proj import *

sys.path.append('..')
import sigsbee

sigsbee.getvel('vel','migvel')
Result('vel','grey color=j allpos=y bias=1.5 scalebar=y barreverse=y wanttitle=n')

sigsbee.getzo('zodata')
Result('zodata','grey title="Zero Offset" ')


# Interpolate velocity to a coarser grid

Flow('xpat','zodata','window n1=1')
Flow('vel2','vel xpat',
     '''
     transp | math output=1/input |
     remap1 pattern=${SOURCES[1]} | 
     math output=1/input 
     ''')
Result('vel2','grey color=j allpos=y bias=1.5 scalebar=y barreverse=y title="Migration Velocity" transp=n')

# Lowrank decomposition
Flow('fft','vel2','fft1 | fft3 axis=2 pad=1')
Flow('right left','vel2 fft',
     'scale dscale=0.5 | isolr2 seed=2012 dt=0.004 fft=${SOURCES[1]} left=${TARGETS[1]}')

# Zero-offset migration
Flow('zomig','zodata left right',
     '''
     spline n1=3000 o1=0 d1=0.004 |
     reverse which=1 |
     transp |
     fftexp0 mig=y
     left=${SOURCES[1]} right=${SOURCES[2]}
     nz=1201 dz=0.00762
     ''')

Result('zomig','grey title="Zero-Offset Migration" unit2=km')

# High-resolution exploding-reflector sigsbee
Fetch('sigexp.rsf','sigsbee')

Flow('exp','sigexp.rsf','dd form=native')

sigsbee.getvel('vels','strvel')

Flow('ffts','vels','transp | fft1 | fft3 axis=2 pad=1')

Flow('rights lefts','vels ffts',
     '''
     transp | scale dscale=0.5 |
     isolr2 seed=2012 dt=0.001 fft=${SOURCES[1]} left=${TARGETS[1]} 
     ''')

# High-resolution zero-offset migration
Flow('zomigs','exp lefts rights',
     '''
     reverse which=1 |
     transp |
     fftexp0 mig=y
     left=${SOURCES[1]} right=${SOURCES[2]}
     nz=1201 dz=0.00762
     ''')

Result('zomigs','grey title="Zero-Offset Migration" unit2=km')

Flow('dip','exp','dip rect1=400 rect2=100 order=5')

Result('dip','grey color=j scalebar=y title=Slope')

Flow('pwd','exp dip','pwd dip=${SOURCES[1]} order=5')

Result('exp','grey title="Zero-Offset Data" ')
Result('pwd','grey title="Separated Diffractions" ')

# High-resolution diffraction imaging
Flow('zodif','pwd lefts rights',
     '''
     reverse which=1 |
     transp |
     fftexp0 mig=y
     left=${SOURCES[1]} right=${SOURCES[2]}
     nz=1201 dz=0.00762
     ''')

Result('zodif','grey title="Zero-Offset Migration (Diffractions)" unit2=km')


End()

sfsegyread
sfwindow
sfmask
sfdd
sfmath
sfcat
sftransp
sfscale
sfput
sfgrey
sfheaderwindow
sfcut
sfreverse
sfcostaper
sfremap1
sffft1
sffft3
sfisolr2
sfspline
sffftexp0

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