from rsf.proj import *
import math
from rsf.recipes.tpx import FPX
def section(title,label1='Time',unit1='s',min1=5.8,max1=8.0,extra=" "):
return '''
window min1=%g max1=%g |
grey title="%s"
label1="%s" unit1="%s" label2=Distance unit2=m %s
''' % (min1,max1,title,label1,unit1,extra)
def sectionw(title,label1='Time',unit1='s',min1=5.5,max1=7.0):
return '''
window min1=%g max1=%g max2=5500 |
grey title="%s"
label1="%s" unit1="%s" label2=Distance unit2=m
''' % (min1,max1,title,label1,unit1)
def plotvel(title,min1=5.5,max1=8.0):
return '''
grey min1=%g max1=%g minval=1480 maxval=2000 bias=1700
clip=200 allpos=n color=j scalebar=y barreverse=y barunit=m/s barlabel="Velocity"
title="%s" label2="Distance" unit2=m
''' %(min1,max1,title)
def plotdip(title,min1=5.5,max1=8.0):
return '''
grey min1=%g max1=%g color=j scalebar=y barlabel="Dip"
title="%s" label2="Distance" unit2=m
''' %(min1,max1,title)
def plotdipw(title,label1='Time',unit1='s',min1=5.5,max1=7.0):
return '''
window min1=%g max1=%g max2=5500 |
grey title="%s" color=j scalebar=y barlabel="Dip"
label1="%s" unit1="%s" label2=Distance unit2=m
''' % (min1,max1,title,label1,unit1)
frame1=(int)( (7.0-5.5)/0.002 )
frame2=(int)( (2000)/16.667 )
frame3=(int)( (1500-1400)/20 )
print frame1
print frame2
print frame3
def plotdip3d(title,min1=5.5,max1=8.0,fr1=frame1,fr2=frame2,fr3=frame3):
return '''
window min1=%g max1=%g max2=5500 | byte | grey3 flat=n color=j scalebar=n barlabel="Dip"
title="%s" label2="Distance" label3="Velocity" unit3="m/s" unit2=m frame1=%d frame2=%d frame3=%d
point1=.6 point2=.7
''' %(min1,max1,title,fr1,fr2,fr3)
def plotpick(min2=1400,max2=2600):
return '''
graph yreverse=y transp=y plotcol=7 plotfat=7
pad=n min2=%g max2=%g wantaxis=n wanttitle=n
'''%(min2,max2)
def plot3d(title,min1=5.5,max1=8.0,fr1=frame1,fr2=frame2,fr3=frame3):
return '''
window min1=%g max1=%g max2=5500 | byte | grey3 flat=n scalebar=n barlabel="Dip"
title="%s" label2="Distance" label3="Velocity" unit3="m/s" unit2=m frame1=%d frame2=%d frame3=%d
point1=.6 point2=.7
''' %(min1,max1,title,fr1,fr2,fr3)
Fetch('Nshots.su','nankai')
Flow('shots tshots','Nshots.su',
'suread suxdr=y tfile=${TARGETS[1]}')
Flow('mean','shots','stack axis=1 | spray axis=1 n=5500 o=0.0 d1=0.002')
Flow('shotsdc','shots mean','add scale=1,-1 ${SOURCES[1]}')
Flow('shotsf','shotsdc','bandpass flo=10')
Flow('shotsw','shotsf','window min1=5.5')
Flow('mask0','shotsw','mul $SOURCE | stack axis=1 | mask min=1e-20')
Flow('shots0','shotsw mask0','headerwindow mask=${SOURCES[1]}')
Flow('tshots0','tshots mask0','headerwindow mask=${SOURCES[1]}')
Flow('arms','shots0',
'mul $SOURCE | stack axis=1 | math output="log(input)"')
Flow('indexshot','tshots0','window n1=1 f1=2')
Flow('offsets4index','tshots0',' headermath output=offset | dd type=float | window')
Flow('offsetindex','offsets4index','math output="abs(input) - 170" | dd type=int')
Flow('midpoint','tshots0','window n1=1 f1=5')
Flow('cmps4index','tshots0',' headermath output=cdp | dd type=float | math output="input*16.667" | window')
Flow('recv','cmps4index offsets4index','add scale=1,0.5 ${SOURCES[1]} | math output="input - 13799" | dd type=int')
Flow('index','indexshot offsetindex',
'''
cat axis=2 ${SOURCES[1]}
''')
Flow('extindex','index midpoint',
'''
cat axis=2 ${SOURCES[1]}
''')
Flow('extindrecv','extindex recv',
'''
cat axis=2 ${SOURCES[1]}
''')
def plot(title):
return '''
spray axis=1 n=1 |
intbin head=${SOURCES[1]} yk=fldr xk=tracf | window |
grey title="%s" label2="Shot Number" unit2=
label1="Offset Number" unit1= scalebar=y
''' % (title)
def plotb(title,bias=-5):
return '''
spray axis=1 n=1 |
intbin head=${SOURCES[1]} yk=fldr xk=tracf | window |
grey title="%s" label2="Shot Number" unit2=
label1="Offset Number" unit1= scalebar=y clip=3 bias=%g
''' % (title,bias)
Flow('varms','arms tshots0','spray axis=1 n=1 | intbin head=${SOURCES[1]} yk=fldr xk=tracf | window')
Plot('varms','arms tshots0',plotb('Log-Amplitude'))
prog = Program('surface-consistent.c')
sc = str(prog[0])
Flow('recvmodel',['arms','extindrecv',sc],
'./${SOURCES[2]} index=${SOURCES[1]} verb=y')
Flow('recvsc',['arms','extindrecv',sc,'recvmodel'],
'''
conjgrad ./${SOURCES[2]} index=${SOURCES[1]}
mod=${SOURCES[3]} niter=150
''')
Flow('recvscarms',['recvsc','extindrecv',sc],
'./${SOURCES[2]} index=${SOURCES[1]} adj=n')
Plot('recvvscarms','recvscarms tshots0',
plotb('Source, Offset, CDP, Recv S-C Log(A)'))
Flow('recvadiff','arms recvscarms','add scale=1,-1 ${SOURCES[1]}')
Plot('recvadiff','recvadiff tshots0',plot('s,h,cdp,r difference'))
Flow('ampl','recvscarms',
'math output="exp(-input/2)" | spray axis=1 n=5500 d=0.002 o=0')
Flow('shotsf0','shotsf mask0','headerwindow mask=${SOURCES[1]}')
Flow('shots-preproc','shotsf0 ampl','mul ${SOURCES[1]}')
Plot('shots-preproc','shots-preproc','window n2=100 | grey min1=6.0 max1=8.0 title="Shots Preproc"')
Plot('shots-raw','shots0','window n2=100 | grey min1=6.0 max1=8.0 title="Shots Raw"')
Flow('subsampled','shots-preproc',
'''
bandpass fhi=125 | window j1=2
''')
Flow('cmps mask','subsampled tshots0',
'''
intbin xk=tracf yk=cdp head=${SOURCES[1]} mask=${TARGETS[1]} |
put o3=900 d3=16.667 label3=Distance unit3=m |
pow pow1=2
''')
Flow('cmps-raw mask-raw','shots0 tshots0',
'''
intbin xk=tracf yk=cdp head=${SOURCES[1]} mask=${TARGETS[1]} |
put o3=900 d3=16.667 label3=Distance unit3=m
''')
Flow('offset-file','tshots0',
'''
sfheadermath output=offset | dd type=float |
intbin xk=tracf yk=cdp head=$SOURCE
''')
Flow('watervel','cmps','window n2=1 | math output="1500"')
Flow('nmo-wat-vel-preproc','cmps offset-file mask watervel',
'''
nmo half=n offset=${SOURCES[1]} mask=${SOURCES[2]}
velocity=${SOURCES[3]}
''')
Flow('nmo-wat-vel-raw','cmps-raw offset-file mask watervel',
'''
nmo half=n offset=${SOURCES[1]} mask=${SOURCES[2]}
velocity=${SOURCES[3]}
''')
Flow('stack-wat-vel-preproc','nmo-wat-vel-preproc','stack')
Flow('stack-wat-vel-raw','nmo-wat-vel-raw','stack')
nv=60
Flow('stacks','cmps offset-file mask',
'''
window min1=4 |
stacks half=n v0=1400 nv=%g dv=20
offset=${SOURCES[1]} mask=${SOURCES[2]}
'''%nv,split=[3,'omp'])
p = 100
min1=5.5
max1=8.0
mute = '''
mutter v0=130 x0=1300 t0=4.0 half=n inner=n |
mutter x0=1400 v0=20 t0=5.0 half=n inner=y |
mutter v0=2500 x0=1400 t0=5.8 half=n inner=n |
mutter v0=500 x0=1400 t0=7.0 half=n inner=y
'''
pick = '''
pick rect1=50 rect2=20 vel0=1480
'''
mutec = '''
mutter v0=130 x0=1300 t0=4.0 half=n inner=n |
mutter x0=1400 v0=20 t0=5.0 half=n inner=y |
mutter v0=2500 x0=1400 t0=5.8 half=n inner=n |
mutter v0=500 x0=1400 t0=7.0 half=n inner=y
'''
pickc = '''
pick rect1=80 rect2=20 vel0=1400
'''
Flow('envelope-stacks','stacks','envelope | scale axis=2',split=[3,'omp'])
Flow('vpick-stacks','envelope-stacks',mutec + ' | ' + pickc)
Flow('slice-stacks','stacks vpick-stacks','slice pick=${SOURCES[1]}')
Flow('stackst','stacks','costaper nw3=20')
Flow('cosft','stackst','cosft sign1=1 sign3=1')
Flow('transp','cosft','transp',split=[3,'omp'])
Flow('map','transp',
'''
math output="x1/sqrt(1+0.25*x3*x3*x1*x1/(x2*x2))" |
cut n2=1
''')
Flow('fowler','transp map','iwarp warp=${SOURCES[1]} | transp',
split=[3,'omp'])
Flow('dmo','fowler','cosft sign1=-1 sign3=-1')
Flow('envelope','dmo','envelope | scale axis=2',split=[3,'omp'])
Flow('vpick','envelope',mutec + ' | ' + pickc)
Flow('slice','dmo vpick','slice pick=${SOURCES[1]}')
Result('slice',section('DMO stack'))
Flow('vc15','slice',
'''
cosft sign2=1 |
vczo v0=0.0 nv=1 dv=1500 |
window |
cosft sign2=-1
''')
rect1=30
rect2=20
rect3=30
Flow('dip-vc','vc15','dip rect1=%d rect2=%d' % (rect1, rect2))
Flow('pwd-vc','vc15 dip-vc','pwd dip=${SOURCES[1]}')
Flow('dif','pwd-vc',
'''
cosft sign2=1 |
vczo v0=1500.0 nv=1 dv=-1500 |
window |
cosft sign2=-1
''')
Result('dif',section('Separated Diffractions'))
pad=1800
Flow('warp','dif','t2warp pad=%i'%(pad))
Plot('dif-spectrum','dif','sffft1 | sfmath output="abs(input)" | sfreal | stack | sfgraph title="Spectrum before warping"')
Plot('spectrum','warp','sffft1 | sfmath output="abs(input)" | sfreal | stack | sfgraph title="Spectrum after warping"')
np=151
p0=-0.014
nw=901
FPX('fpx','warp',np=np,p0=p0,nw=nw,v0=0.0)
Flow('txp','fpx','fft1 inv=y | t2warp inv=y | transp plane=23 memsize=1000')
Flow('fkp','fpx','transp plane=23 memsize=1000 | fft3 axis=2')
Flow('ovc-fkp-15','fkp','ovczo nv=%d dv=%g v0=%g' % (1,1500,0.0))
Flow('ovc-15','ovc-fkp-15','window | fft3 axis=2 inv=y | fft1 inv=y | t2warp inv=y | transp plane=23 memsize=5000')
Flow('ovc-15-image','ovc-15','stack')
nv = 60
dv = 20
v0 = 1400
Flow('ovc-1st-step','fkp','ovczo nv=%d dv=%g v0=%g | window' % (1,v0,0.0))
Flow('ovc-fkp','ovc-1st-step','ovczo nv=%d dv=%g v0=%g' % (nv,dv,v0),split=[3,np],reduce='cat axis=4')
Flow('txvp','ovc-fkp',
'''
transp plane=23 memsize=1000 |
fft3 axis=2 inv=y |
fft1 memsize=100 inv=y |
t2warp inv=y
''',split=[4,np])
Flow('ovc','txvp','stack axis=4')
Flow('txv1','txvp','stack norm=n axis=4')
Flow('txv2','txvp','mul $SOURCE | stack norm=n axis=4')
Flow('sem','txv1 txv2',
'''
mul ${SOURCES[0]} | divn den=${SOURCES[1]} rect1=5 rect2=5 niter=25 |
clip2 lower=0
''')
Flow('semb','sem','transp plane=23 | math output="input/36.4387"')
mutesemb = '''
mutter v0=130 x0=1300 t0=4.0 half=n inner=n |
mutter x0=1400 v0=20 t0=5.0 half=n inner=y |
mutter v0=2500 x0=1400 t0=5.8 half=n inner=n |
mutter v0=500 x0=1400 t0=7.0 half=n inner=y
'''
picksemb = '''
pick rect1=50 rect2=20 vel0=1480
'''
Flow('semb-mute','semb',mutesemb)
Flow('vpick-semb','semb-mute',picksemb)
Result('vpick-semb',plotvel('OVC Picked Velocity'))
picking = []
pickingm = []
picking1 = []
picking1m = []
for loc in (1200, 2700, 3000, 5000, 6500):
Flow('semb-%g'%loc,'semb','window n3=1 min3=%g min1=%g max1=%g' % (loc,min1,max1))
Flow('semb-m-%g'%loc,'semb-mute','window n3=1 min3=%g min1=%g max1=%g' % (loc,min1,max1))
Plot('semb-%g'%loc,
'''
grey color=j allpos=y title="CMP %g m"
label2=Velocity unit2=m/s labelsz=12. titlesz=12.
d1num=250 n1tic=5 o1num=1450 d2num=0.5 n2tic=6 o2num=5.5
'''%loc)
Plot('semb-m-%g'%loc,
'''
grey color=j allpos=y title="CMP %g m"
label2=Velocity unit2=m/s labelsz=12. titlesz=12. d2num=0.25 n2tic=4 o2num=5.5
'''%loc)
Flow('vpick-semb-%g'%loc,'vpick-semb','window n2=1 min2=%g min1=%g max1=%g' % (loc,min1,max1))
Plot('vpick-semb-%g'%loc,plotpick())
Plot('vpick-semb-plot-%g'%loc,'semb-%g vpick-semb-%g'%(loc,loc),'Overlay')
picking.append('vpick-semb-plot-%g'%loc)
Plot('vpick-semb-plot-m-%g'%loc,'semb-m-%g vpick-semb-%g'%(loc,loc),'Overlay')
pickingm.append('vpick-semb-plot-m-%g'%loc)
Flow('vpick-semb-1-%g'%loc,'semb-mute','window n3=1 min3=%g | '%loc + picksemb + '| window min1=%g max1=%g'% (min1,max1))
Plot('vpick-semb-1-%g'%loc,plotpick())
Plot('vpick-semb-plot-1-%g'%loc,'semb-%g vpick-semb-1-%g'%(loc,loc),'Overlay')
picking1.append('vpick-semb-plot-1-%g'%loc)
Plot('vpick-semb-plot-m-1-%g'%loc,'semb-m-%g vpick-semb-1-%g'%(loc,loc),'Overlay')
picking1m.append('vpick-semb-plot-m-1-%g'%loc)
Result('g-picking','vpick-semb-plot-1-2700 vpick-semb-plot-1-5000 vpick-semb-plot-1-6500','SideBySideAniso')
Flow('vc-slice-semb','ovc vpick-semb','transp plane=23 memsize=1000 | slice pick=${SOURCES[1]}')
Result('vc-slice-semb',section('Diffraction Image'))
Flow('vc-fw','slice',
'''
cosft sign2=1 |
vczo nv=1 dv=%g v0=0.0 | window |
vczo nv=%d dv=%g v0=%g |
transp plane=23 memsize=1000 |
cosft sign2=-1
'''%(v0,nv,dv,v0))
Flow('vc-fw-slice-semb','vc-fw vpick-semb','transp plane=23 memsize=1000 | slice pick=${SOURCES[1]}')
Result('vc-fw-slice-semb',section('Conventional Image'))
ovcmin1=6.0
ovcmax1=7.0
ovcmin2=3000
ovcmax2=5000
pmin=-0.004
pmax=0.004
dp = 0.000186667
frameovc1 = (int)((6.5 - ovcmin1)/0.004)
frameovc2 = (int)((pmax)/(dp))
frameovc3 = (int)((4100.06 - ovcmin2)/16.667)
x1 = 2666.70
x2 = 4100.06
x3 = 4216.73
dx=200
for case in (1,2,3):
if case == 1:
name = 'left'
x = x1
if case == 2:
name = 'center-s'
x = x2
if case == 3:
name = 'center-w'
x = x3
locxmin = x-dx
locxmax = x+dx
Flow('vpick-semb-slice','vpick-semb','window n2=1 min2=%g | spray axis=2 n=%d d=0.000186667 o=%g'%(x,np,p0))
Flow('txp-slice-'+name,'txvp vpick-semb-slice',
'''
window n2=1 min2=%g |
slice pick=${SOURCES[1]}
'''%x)
Result('txp14-slice-'+name,'txvp',
'''
window n2=1 min2=%g n3=1 min3=1400 |
grey min1=%g max1=%g min2=%g max2=%g unit2="s\^2\_/m" title="Slope Gather for v = 1.4 km/s"
'''%(x,ovcmin1,ovcmax1,pmin,pmax))
Result('txp25-slice-'+name,'txvp',
'''
window n2=1 min2=%g n3=1 min3=2500 |
grey min1=%g max1=%g min2=%g max2=%g unit2="s\^2\_/m" title="Slope Gather for v = 2.5 km/s"
'''%(x,ovcmin1,ovcmax1,pmin,pmax))
Result('txp-slice-'+name,
'''
grey min1=%g max1=%g min2=%g max2=%g unit2="s\^2\_/m" title="Slope Gather for Migration Velocity"
'''%(ovcmin1,ovcmax1,pmin,pmax))
Result('image-'+name,'vc-slice-semb',section('Diffraction Image','Time','s',6.0,7.0,'min2=%g max2=%g'%(locxmin,locxmax)))
Plot('txp14-slice','txvp','window n2=1 min2=2700 n3=1 min3=1400 | grey min1=%g max1=%g min2=%g max2=%g wanttitle=n'%(ovcmin1,ovcmax1,pmin,pmax))
Plot('txp25-slice','txvp','window n2=1 min2=2700 n3=1 min3=2500 | grey min1=%g max1=%g min2=%g max2=%g wanttitle=n'%(ovcmin1,ovcmax1,pmin,pmax))
for cignum in (2700, 4500, 6500):
plotillum14 = 'window n2=1 min2=%g n3=1 min3=%g | grey min1=%g max1=%g wanttitle=n'%(cignum,1400,ovcmin1,ovcmax1)
plotillum25 = 'window n2=1 min2=%g n3=1 min3=%g | grey min1=%g max1=%g wanttitle=n'%(cignum,2500,ovcmin1,ovcmax1)
plotillum2 = 'grey min1=%g max1=%g wanttitle=n'%(ovcmin1,ovcmax1)
Plot('txp14-slice-%g'%cignum,'txvp',plotillum14)
Plot('txp25-slice-%g'%cignum,'txvp',plotillum25)
Flow('txp-slice-%g'%cignum,'txvp vpick-semb-slice',
'''
window n2=1 min2=%g |
slice pick=${SOURCES[1]}
'''%cignum)
Plot('txp-slice-%g'%cignum,plotillum2)
Result('tpx','fpx',
'''
fft1 inv=y | t2warp inv=y |
window min1=%g max1=%g min2=%g max2=%g min3=%g max3=%g |
byte |
grey3 frame1=%d frame2=%d frame3=%d label1=Time flat=n unit2="s\^2\_/m"
title="Slope Decomposed Diffraction Data" d1num=0.004 n1tic=3 o1num=-0.004 o3num=%g n3tic=4 d3num=500
'''%(ovcmin1,ovcmax1,pmin,pmax,ovcmin2,ovcmax2,frameovc1,frameovc2,frameovc3,ovcmin2+500))
Flow('vpick-semb-slice-mig','vpick-semb','window min2=%g max2=%g | spray axis=3 n=%d d=0.000186667 o=%g'%(ovcmin2,ovcmax2,np,p0))
Flow('tvxp','txvp','transp plane=23 memsize=5000')
Flow('txp-migrated','tvxp vpick-semb-slice-mig','window min3=%g max3=%g | slice pick=${SOURCES[1]}'%(ovcmin2,ovcmax2))
Result('txp-migrated',
'''
transp plane=23 |
window min1=%g max1=%g min2=%g max2=%g min3=%g max3=%g |
byte |
grey3 frame1=%d frame2=%d frame3=%d label1=Time flat=n unit2="s\^2\_/m"
title="Slope Decomposed Diffraction Image" d1num=0.004 n1tic=3 o1num=-0.004 o3num=%g n3tic=4 d3num=500
'''%(ovcmin1,ovcmax1,pmin,pmax,ovcmin2,ovcmax2,frameovc1,frameovc2,frameovc3,ovcmin2+500))
End() |