from rsf.proj import *
from rsf.recipes import fdmod
from math import *
par = {
'nt':5301, 'dt':0.001,'ot':0.0, 'lt':'t', 'ut':'s',
'nx':601, 'dx':10.0, 'ox':-3000, 'lx':'x', 'ux':'km',
'nz':433, 'dz':10.0, 'oz':-500, 'lz':'z', 'uz':'km',
'nb':150,
'jsnap':200,
'jdata':1
}
par['ompnth']=14
fdmod.param(par)
par['height']=8.0
par['ratio']=0.5
par['nshots'] = 501
par['x_left'] = -2500.0
Flow('rrs_',None,'math n1=%d d1=%g o1=%g output=0' % (par['nshots'],par['dx'],par['x_left']))
Flow('rrs_z','rrs_','math output="%g" ' % 0.0)
Flow('rrs_x','rrs_','math output="x1" ')
Flow('rrs',['rrs_x','rrs_z'],
'''
cat axis=2 space=n
${SOURCES[1]} | transp |
put label1="" unit1="" label2="" unit2=""
''')
Plot('rrs',fdmod.rrplot('',par))
par['tf']=0.3
par['kt']=par['tf']/par['dt']
par['nt2']=par['nt']-par['kt']
par['fc']=20.0
par['pi']=pi
fdmod.wavelet('wav1__',par['fc'],par)
Flow( 'wav1', 'wav1__','math output="input*1.0" | transp' % par)
Result('wav1','window |' + fdmod.waveplot('',par))
Flow( 'wav1fft', 'wav1','transp | fft1' % par)
Result('wav1fft',
'''
window max1=100 | math output="abs(input)" | real |
graph n1tic=50 grid1=y labelsz=5 title="Ricker wavlet"
''')
par['df']=0.01
par['fn']=1.0/(2.0*par['dt'])
par['nf']=int(par['fn']/par['df']+1)
par['f2'] = int(2*round(5/par['df']))
par['f3'] = int(2*round(10/par['df']))
par['f4'] = int(1*round(45/par['df']))
print par['f2']
print par['f3']
print par['f4']
par['fn'] = par['f2']/2
Flow('wl1',None,
'''
math n1=%(f2)d d1=1 o1=0 output="0.5*(1.0-cos(2.0*%(pi)g*(x1)/(%(f2)d-1)))" |
window n1=%(fn)d
''' % par);
par['fn'] = par['f3']/2
Flow('wr1',None,
'''
math n1=%(f3)d d1=1 o1=0 output="0.5*(1.0-cos(2.0*%(pi)g*(x1)/(%(f3)d-1)))" |
window f1=%(fn)d
''' % par);
Flow('wc1',None, 'math n1=%(f4)d d1=1 o1=0 output="1"' % par);
Flow('ww1',['wl1','wc1','wr1'],'cat axis=1 ${SOURCES[1:3]} | pad n1=%(nf)d | rtoc' % par)
Flow('wavfs1fft','ww1',
'''
math n1=%(nf)d d1=%(df)g o1=0.0 output="input*exp(I*2*%(pi)g*x1*(-%(tf)g*%(df)g))" |
put d1=%(df)g
''' % par)
Result('wavfs1fft',
'''
window max1=100 | math output="abs(input)" | real |
graph n1tic=50 grid1=y labelsz=5 title="Flat spectrum wavlet"
''')
Flow('wavfs1','wavfs1fft',
'''
fft1 inv=y opt=y sym=n |
put d1=%(dt)g o1=%(ot)g label1="t" unit1="s" |
scale axis=2 |
window n1=%(nt)d | transp
''' % par)
Result('wavfs1',
'''
transp | window n1=2000 |
graph n1tic=50 grid1=y labelsz=5 title="Flat spectrum wavlet"
''')
Flow('wav1fft_con','wav1','transp | fft1')
Flow('wavfs1fft_con','wavfs1','transp | fft1')
Flow('convwaves1',['wav1fft_con','wavfs1fft_con'],
'''
math y=${SOURCES[1]} type=complex output="input*y" | fft1 inv=y
''')
Result('convwaves1','window n1=500 f1=500 | graph')
Flow('max_conv','convwaves1','max axis=1 max=y')
Flow('scale','max_conv','math output="2.0*%(dx)g/input"' % par)
Flow('scalemat','scale','spray axis=1 n=%(nshots)d | spray axis=2 n=%(nt2)d | spray axis=3 n=%(nshots)d' % par)
par['nxvs'] = 3
par['dxvs'] = 50*par['dx']
par['oxvs'] = -500.0
par['nzvs'] = 2
par['dzvs'] = 10*par['dz']
par['ozvs'] = 1200.0
Flow('vs_x',None,'math n1=%d d1=%g o1=%g output="x1"' % (par['nxvs'],par['dxvs'],par['oxvs']))
for idepth in range(par['nzvs']):
par['zdepth'] = par['ozvs'] + idepth*par['dzvs']
tag = "_%04d" % par['zdepth']
Flow('vs'+tag,['vs_x'],
'''
math output="%(zdepth)g" |
cat axis=2 space=n ${SOURCES[0]} |
transp | rotate rot1=1 |
put label1="" unit1="" label2="" unit2="" o2="%(zdepth)g"
''' % par)
Plot('vs'+tag,fdmod.rrplot('plotcol=8',par))
limits = int(par['ozvs']), int(par['ozvs'] + par['nzvs']*par['dzvs']), int(par['dzvs'])
vs_all = map(lambda x: 'vs'+'_%04d' % x,range(*limits))
par['z1']=900
par['dip']=0.0
par['kd1']=int((par['z1']-par['oz']-par['dip']*par['ox'])/par['dx'])+1+5
par['ld1']=par['kd1']-1
par['z2']=1400
par['kd2']=int((par['z2']-par['oz']-par['dip']*par['ox'])/par['dx'])+1+5
par['ld2']=par['kd2']-1
par['z3']=2400
par['kd3']=int((par['z3']-par['oz']-par['dip']*par['ox'])/par['dx'])+1+5
par['ld3']=par['kd3']-1
Flow('vel_',None,
'''
spike mag=2000,2600,2200,2400 nsp=4
k1=1,%(kd1)d,%(kd2)d,%(kd3)d l1=%(ld1)d,%(ld2)d,%(ld3)d,4000
p2="-%(dip)g"
n1=4000 n2=%(nx)d
d1=%(dz)g d2=%(dx)g
o1=%(oz)g o2=%(ox)g
unit1="km" unit2="km"
label1="z" label2="x"
''' % par)
Flow('vel','vel_',
'''
window n1=%(nz)d f1=5 | put o1=%(oz)g
''' % par)
Plot('vel',fdmod.cgrey('allpos=y bias=2000 pclip=100 color=j wantscalebar=n',par))
Result('vel',['vel','rrs']+vs_all,'Overlay')
Flow('den_',None,
'''
spike mag=1200,3500,1400,1900 nsp=4
k1=1,%(kd1)d,%(kd2)d,%(kd3)d l1=%(ld1)d,%(ld2)d,%(ld3)d,4000
p2="-%(dip)g"
n1=4000 n2=%(nx)d
d1=%(dz)g d2=%(dx)g
o1=%(oz)g o2=%(ox)g
unit1="km" unit2="km"
label1="z" label2="x"
''' % par)
Flow('den','den_',
'''
window n1=%(nz)d f1=5 | put o1=%(oz)g
''' % par)
Plot('den',fdmod.cgrey('allpos=y bias=0.0 pclip=100 color=j wantscalebar=n',par))
Result('den',['den','rrs']+vs_all,'Overlay')
for ishot in range(par['nshots']):
par['xshot'] = par['x_left'] + ishot*par['dx']
par['zshot'] = 0.0
tag = "_%05d_%04d" % (par['xshot'],par['zshot'])
Flow('shot_location'+tag,None,'spike nsp=2 mag=%(xshot)g,%(zshot)g n1=2 k1=1,2' % par)
Flow(['shot'+tag],['wavfs1','vel','den','shot_location'+tag,'rrs'],
'''
awefd2d_fo
ompchunk=%(ompchunk)d ompnth=%(ompnth)d
verb=y free=n snap=n jsnap=%(jsnap)d jdata=%(jdata)d
dabc=y nb=%(nb)d expl=n srctype=2
vel=${SOURCES[1]}
den=${SOURCES[2]}
sou=${SOURCES[3]}
rec=${SOURCES[4]}
wfl=${TARGETS[1]} |
window min2=%(tf)g | put o2=0.0
''' % par)
Result('shot_00200_0000','transp | grey wantscalebar=n polarity=n pclip=98')
limits = int(par['x_left']), int(par['x_left'] + par['nshots']*par['dx']), int(par['dx'])
shot_all = map(lambda x: 'shot'+'_%05d_%04d' % (x,0.0),range(*limits))
Flow('shot_all',shot_all,'cat axis=3 ${SOURCES[1:%d]}' % par['nshots'])
par['nxdir'] = par['nx']*2 - 1
par['oxdir'] = par['ox']*2
Flow('velh',None,
'''
spike mag=2000 nsp=1
n1=%(nz)d n2=%(nxdir)d
d1=%(dz)g d2=%(dx)g
o1=%(oz)g o2=%(oxdir)g
unit1="km" unit2="km"
label1="z" label2="x"
''' % par)
Plot('velh',fdmod.cgrey('allpos=y bias=0.0 pclip=100 color=j wantscalebar=n',par))
Flow('denh',None,
'''
spike mag=1200 nsp=1
n1=%(nz)d n2=%(nxdir)d
d1=%(dz)g d2=%(dx)g
o1=%(oz)g o2=%(oxdir)g
unit1="km" unit2="km"
label1="z" label2="x"
''' % par)
Plot('denh',fdmod.cgrey('allpos=y bias=0.0 pclip=100 color=j wantscalebar=n',par))
par['nshots_direct'] = int((par['nshots']-1)*2+1)
Flow('rrs_direct_x',None,'math n1=%d d1=%g o1=%g output=x1' % (par['nshots_direct'],par['dx'],par['x_left']*2))
Flow('rrs_direct_z','rrs_direct_x','math output="%g" ' % 0.0)
Flow('rrs_direct',['rrs_direct_x','rrs_direct_z'],
'''
cat axis=2 space=n
${SOURCES[1]} | transp |
put label1="" unit1="" label2="" unit2=""
''')
Plot('rrs_direct',fdmod.rrplot('',par))
par['xshot'] = 0.0
par['zshot'] = 0.0
fdmod.point('shot_location',par['xshot'],par['zshot'],par)
Flow(['direct','wfl_direct'],['wavfs1','velh','denh','shot_location','rrs_direct'],
'''
awefd2d_fo
ompchunk=%(ompchunk)d ompnth=%(ompnth)d
verb=y free=n snap=y jsnap=%(jsnap)d jdata=%(jdata)d
dabc=y nb=%(nb)d expl=n srctype=2
vel=${SOURCES[1]}
den=${SOURCES[2]}
sou=${SOURCES[3]}
rec=${SOURCES[4]}
wfl=${TARGETS[1]} |
window min2=%(tf)g | put o2=0.0
''' % par)
Result('direct','transp | grey wantscalebar=n polarity=n pclip=98')
Flow('direct_all','direct','patch w=%(nshots)d,%(nt)d p=%(nshots)d,1 | reverse which=1' % par)
Flow('refl_all',['direct_all','shot_all','scalemat'],
'''
add scale=-1,1 ${SOURCES[1]} |
add ${SOURCES[2]} mode='p'
''')
Flow('refl_100','refl_all','window n3=1 f3=100 | transp')
Result('refl_100','grey wantscalebar=n polarity=n pclip=98')
Flow('refl_fft_all','refl_all','window j2=4 n2=1250 | put d2=0.004 | transp | fft1 --out=stdout')
Flow('vel_smooth','vel',
'''
math output="1/input" |
smooth rect1=50 rect2=50 repeat=3 | math output="1/input" | put o1=%(oz)g
''' % par)
Plot('vel_smooth',fdmod.cgrey('allpos=y bias=0.0 pclip=100 color=j wantscalebar=n',par))
Result('vel_smooth',['vel_smooth','rrs']+vs_all,'Overlay')
Flow('den_smooth','den',
'''
math output="1/input" |
smooth rect1=50 rect2=50 repeat=3 | math output="1/input" | put o1=%(oz)g
''' % par)
Plot('den_smooth',fdmod.cgrey('allpos=y bias=0.0 pclip=100 color=j wantscalebar=n',par))
Result('den_smooth',['den_smooth','rrs']+vs_all,'Overlay')
par['nshots_nxvs'] = par['nshots']*par['nxvs']
par['f1'] = - (par['ox'] - par['x_left'])/par['dx'] + 1
par['f2'] = - (par['oz'] - 0.0)/par['dz']
print par['f1']
print par['f2']
Flow('wav1fft_ext','wav1fft','spray axis=2 n=%(nshots_nxvs)d' % par)
Flow('eik_x',None,'math n1=%(nxvs)d d1=%(dxvs)g o1=%(oxvs)g output="0"' % par)
Flow('eik_y',None,'math n1=%(nxvs)d d1=%(dxvs)g o1=%(oxvs)g output="x1"' % par)
for idepth in range(par['nzvs']):
par['zdepth'] = par['ozvs'] + idepth*par['dzvs']
tag = "_%04d" % par['zdepth']
Flow('eik_z'+tag,None,'math n1=%(nxvs)d d1=%(dxvs)g o1=%(oxvs)g output="%(zdepth)g"' % par)
Flow('eik_shotfile'+tag,['eik_z'+tag,'eik_y','eik_x'],
'''
cat axis=2 space=n ${SOURCES[1:3]} |
transp |
put label1="" unit1="" label2="" unit2="" o2="%(zdepth)g"
''' % par)
Flow('p00plus_eik'+tag,['vel_smooth','wav1fft_ext','eik_shotfile'+tag],
'''
eikonal shotfile=${SOURCES[2]} |
transp plane=34 memsize=1024 |
window n1=1 f1=%(f1)d n2=%(nshots)d f2=%(f2)d j2=1 |
put n1=%(nshots_nxvs)d n2=1 |
rtoc |
spray axis=1 n=2701 |
put fft_n1=5301 d1=0.185185 o1=0.0 |
math n1=2701 o1=0.0 d1=0.185185 n2=%(nshots_nxvs)d wav1=${SOURCES[1]} output="wav1*exp(I*2*%(pi)g*x1*(-input)+I*%(pi)g/4)" |
fft1 inv=y opt=y sym=n |
window min1=%(tf)g d1=0.004 n1=1250 |
put o1=%(ot)g label1="t" unit1="s" d2=10 o2=%(x_left)g |
put n2=%(nshots)d n3=%(nxvs)d
''' % par)
Result('p00plus_eik'+tag,'grey wantscalebar=n polarity=n pclip=98 title="First arrival"')
par['scale2']=4.0
par['niter'] = 21
par['ntaper'] = 151
tag = "_%04d" % par['ozvs']
Flow('max_p00plus','p00plus_eik'+tag,'max max=y axis=0')
par['eps'] = 0.95 * 1e-2
par['shift'] = -5
for idepth in range(par['nzvs']):
par['zdepth'] = par['ozvs'] + idepth*par['dzvs']
tag = "_%04d" % par['zdepth']
Flow(['Gp'+tag,'Gm'+tag,'G'+tag,'wdwi'+tag],['p00plus_eik'+tag,'refl_fft_all'],
'''
marchenko refl=${SOURCES[1]}
conj=y twin=y pandq=n Gtot=y Htot=n ompnth=%d niter=%d ntaper=%d scale=%g eps=%g shift=%d verb=n
Gm=${TARGETS[1]} G=${TARGETS[2]} window=${TARGETS[3]}
''' % (par['ompnth'],par['niter'],par['ntaper'],par['scale2'],par['eps'],par['shift']))
Result('G'+tag, 'grey wantscalebar=n polarity=n pclip=98')
Result('Gp'+tag,'grey wantscalebar=n polarity=n pclip=98')
Result('Gm'+tag,'grey wantscalebar=n polarity=n pclip=98')
par['jsnap'] = 100
par['xvs'] = -500.0
par['zvs'] = 1300.0
par['xshot'] = par['xvs']
par['zshot'] = par['zvs']
tag = "_%05d_%04d" % (par['xshot'],par['zshot'])
Flow('shot_location'+tag,None,'spike nsp=2 mag=%(xshot)g,%(zshot)g n1=2 k1=1,2' % par)
Flow(['reference'+tag,'reference_wfl'+tag],['wav1','vel','den','shot_location'+tag,'rrs'],
'''
awefd2d_fo
ompchunk=%(ompchunk)d ompnth=%(ompnth)d
verb=y free=n snap=y jsnap=%(jsnap)d jdata=%(jdata)d
dabc=y nb=%(nb)d expl=n srctype=1
vel=${SOURCES[1]}
den=${SOURCES[2]}
sou=${SOURCES[3]}
rec=${SOURCES[4]}
wfl=${TARGETS[1]} |
window min2=0.3 | put o2=0.0 | window j2=4 n2=1250 | put d2=0.004
''' % par)
Result('reference'+tag, 'transp | grey wantscalebar=n polarity=n pclip=98')
Plot('reference_line'+tag,'reference'+tag,'window n1=1 min1=0 | graph plotcol=5')
tagG = "_%04d" % (par['zshot'])
Plot('G_line'+tagG,'G'+tagG,'window n2=1 min2=0 n3=1 f3=%d | graph' % (0))
Result('ref_G_eik_comp',['reference_line'+tag,'G_line'+tagG],'Overlay')
End() |