from rsf.proj import *
from rsf.recipes.beg import server
from rsf.recipes.tpx import FPX
import math
import tail_el
import velcon2d
Flow('surf',None,'spike n1=1001 d1=0.001 k1=500 mag=0.375')
Flow('refl',None,'spike n1=1001 d1=0.001 k1=500 mag=0.7')
Flow('diffr_data','surf refl',
'''
kirmod nt=250 dt=0.004 freq=20
nh=1 dh=0.5 h0=0.
ns=1001 ds=0.001 s0=0.
cmp=y refl=${SOURCES[1]}
vel=1.5 type=c |
put label2=Offset unit2=km label3=Midpoint unit3=km |
window |
costaper nw1=100 nw2=100
''',split=[1,1001],reduce='add')
nv_vc=100
dv_vc=.01
v0_vc=1.0
pad_time=200
pad_af1=1000
pad_af2=1000
taper = '''
costaper nw1=50 nw2=50
'''
pad = '''
pad end1=%d beg2=%d end2=%d
''' % (pad_time,pad_af1,pad_af2)
wind = '''
window n1=%d n3=%d f3=%d | put o3=%g
''' %(250,1001,pad_af1,0)
Flow('vczo_input','diffr_data',taper + ' | ' + pad + ' | cosft sign2=1')
Flow('vczo_1st_step','vczo_input','vczo nv=%g dv=%g v0=%g | window' %(1,v0_vc,0.0))
Flow('vczo_confft','vczo_1st_step',
'''
vczo nv=%g dv=%g v0=%g
'''% (nv_vc,dv_vc,v0_vc),split=[2,'omp'],reduce='cat axis=3' )
Flow('vczo_con','vczo_confft','cosft sign3=-1 | ' + wind + ' | transp plane=23')
Flow('vczo_125','vczo_con','window n3=1 min3=1.25')
Flow('vczo_15','vczo_con','window n3=1 min3=1.5')
Flow('vczo_175','vczo_con','window n3=1 min3=1.75')
Flow('vczo_con_nw','vczo_confft','cosft sign3=-1 | transp plane=23')
Flow('path_integral','vczo_con','stack axis=3')
Flow('path1','vczo_con','window n3=1')
Flow('path2','vczo_con','window n3=1 f3=-1')
shift_num=3
tail_el.tail_el('path_integral','path2','path1',
nt = 250,
nsh=shift_num,
lrect1=20,
lrect2=30,
lniter=400)
sym='y'
invft = '''
fft3 axis=2 inv=y |
fft1 inv=y |
t2warp inv=y
'''
fwdft = '''
t2warp pad=1000 |
fft1 |
fft3 axis=2
'''
opt='n'
invftexp = '''
fft3 axis=2 inv=y sym=%s opt=%s |
transp |
fft3 axis=2 inv=y sym=%s opt=%s |
transp |
real |
t2warp inv=y
'''%(sym,opt,sym,opt)
fwdftexp = '''
t2warp pad=1000 |
transp plane=12 | rtoc |
fft3 axis=2 sym=%s opt=%s |
transp plane=12 |
fft3 axis=2 sym=%s opt=%s
'''%(sym,opt,sym,opt)
Flow('fft','diffr_data','costaper nw1=10 nw2=100 | ' + fwdft)
Flow('fft-exp','diffr_data','costaper nw1=10 nw2=100 | ' + fwdftexp)
Flow('erfi_input','fft','math output="1.0 + I*0.0"')
Flow('erfi_input-exp','fft-exp','math output="1.0 + I*0.0"')
Flow('pi_gaussian_erfi','erfi_input','gpi3dzo v_0=1.5 v_a=1.0 v_b=2.0 beta=10')
Flow('pi_gaussian_fft','fft','gpi3dzo v_0=1.5 v_a=1.0 v_b=2.0 beta=10')
Flow('pi_gaussian','pi_gaussian_fft',
'''
fft3 axis=2 inv=y |
fft1 inv=y |
t2warp inv=y
''')
Flow('left_taper_fft','fft','gpi3dzo v_0=1.0 v_a=0.5 v_b=1.0 beta=10')
Flow('right_taper_fft','fft','gpi3dzo v_0=2.0 v_a=2.0 v_b=2.5 beta=10')
Flow('flat_fft','fft','gpi3dzo v_0=1.5 v_a=1.0 v_b=2.0 beta=0.0')
Flow('left','left_taper_fft',
'''
fft3 axis=2 inv=y |
fft1 inv=y |
t2warp inv=y
''')
Flow('right','right_taper_fft',
'''
fft3 axis=2 inv=y |
fft1 inv=y |
t2warp inv=y
''')
Flow('flat','flat_fft',
'''
fft3 axis=2 inv=y |
fft1 inv=y |
t2warp inv=y
''')
Flow('gpi_taper','left flat right','add scale=1,1 ${SOURCES[1]} | add scale=1,1 ${SOURCES[2]}')
eps=0.0001
v_a=1.0
v_b=2.0
exp0=0
exp1=1
velcon2d.pi2d(eps,'erfi_input','fft','path-sum',v_a,v_b,exp0,opt,sym)
velcon2d.pi2d(eps,'erfi_input-exp','fft-exp','path-sum-exp',v_a,v_b,exp1,opt,sym)
cube2append = []
cube2appendfft = []
velcon2d.vc2d('fft','all','vc-2d-fft','vc-2d',cube2append,cube2appendfft,
v0_vc,
nv_vc,
dv_vc,
eps)
def grey(title):
return '''
grey title="%s" gainpanel=each pclip=100
label1=Time unit1="s" label2=Distance unit2="km"
titlefat=3 labelfat=3 font=2
''' % (title)
def grey_ng(title):
return '''
math output="(input)" |
grey title="%s" clip=2.0e-04 screenratio=1
label1=Time unit1="s" label2=Distance unit2="km"
titlefat=3 labelfat=3 font=2
''' % (title)
Result('a-data','diffr_data',grey_ng(''' Diffraction '''))
Result('a-path-integral','pi_4_path-sum',grey_ng(''' Path-Summation Image '''))
Result('a-pi-gaussian','pi_gaussian',
'''
math output="(input)" |
grey title="%s" clip=2.0e-04 screenratio=1
label1=Time unit1="s" label2=Distance unit2="km"
titlefat=3 labelfat=3 font=2
'''%('PS Image: Gaussian Weighting'))
def fftgrey(title,extra=''):
return '''
math output="abs(input)" | real | scale axis=2 |
grey title="%s" min2=-100 max2=100 max1=80
label1=Frequency unit1="Hz" label2=Wavenumber unit2="1/km" color=i bias=0.2 clip=0.3
titlefat=3 labelfat=3 font=2 scalebar=y allpos=n minval=0.0 maxval=1.0 barlabel="magnitude" %s
''' % (title,extra)
def fftgreyph(title,extra=''):
return '''
math output="arg(input)" | real |
grey title="%s" min2=-100 max2=100 max1=80
label1=Frequency unit1="Hz" label2=Wavenumber unit2="1/km" color=x
titlefat=3 labelfat=3 font=2 scalebar=y allpos=n bias=0.0 barlabel="phase" barunit="radians" %s
''' % (title,extra)
def fftgraph(title,freq=20,extra=''):
return '''
window n1=1 min1=%g min2=-50 max2=50 | math output="abs(input)" | real |
graph title="%s" %s
''' % (freq,title,extra)
def fftgraphm(title,extra=''):
return '''
window n1=1 min1=30 min2=-50 max2=50 squeeze=y | math output="arg(input)" | real |
graph3 title="%s" %s frame2=45 frame3=9 movie=2
''' % (title,extra)
def fftgraphmabs(title,extra=''):
return '''
window n1=1 min1=20 min2=-50 max2=50 squeeze=y | math output="abs(input)" | real |
graph3 title="%s" %s frame2=45 frame3=9 movie=3
''' % (title,extra)
Result('a-erfi-fft-mag','erfi_ba_4_path-sum',fftgrey('PS Magnitude'))
Result('a-erfi-fft-phase','erfi_ba_4_path-sum',fftgreyph('PS Phase'))
Result('a-gaussian-erfi-mag','pi_gaussian_erfi',fftgrey('GPS Magnitude'))
Result('a-gaussian-erfi-phase','pi_gaussian_erfi',fftgreyph('GPS Phase'))
Result('a-fft-mag','fft',fftgrey('Data FFT Magnitude','screenratio=1'))
Result('a-pi-fft-mag','pi_erfi_fft_4_path-sum',fftgrey('PS Magnitude'))
Result('a-gpi-fft-mag','pi_gaussian_fft',fftgrey('GPS Magnitude'))
prog = Program('filter.c')
v1=2.0
v2=2.5
Flow('pi_erfi_fft-cut','pi_erfi_fft_4_path-sum %s' % prog[0],'./${SOURCES[1]} logis=30 v1=%g v2=%g'% (v1,v2))
Flow('pi-cut','pi_erfi_fft-cut',invft)
sm2 = 5
rep = 10
Flow('re-erfi-ps-sm','erfi_ba_4_path-sum','real | smooth rect2=%g repeat=%d | rtoc'%(sm2,rep))
Flow('erfi-ps-sm','erfi_ba_4_path-sum re-erfi-ps-sm',
'''
imag |
smooth rect2=%g repeat=%d |
rtoc | math output="I*real(input)" |
add scale=1,1 ${SOURCES[1]}
'''%(sm2,rep))
Flow('pi-erfi-smooth','fft erfi-ps-sm',
'''
math K=${SOURCES[1]} output="input*K" |
''' + invft)
Plot('graph-erfi-fft-mag','erfi_ba_4_path-sum',fftgraph('PI erfi graph',20))
Plot('graph-g-erfi-fft-mag','pi_gaussian_erfi',fftgraph('GPI erfi graph',20))
Plot('graph-pi-fft-mag','pi_erfi_fft_4_path-sum',fftgraph('PI graph',20))
Plot('graph-gpi-fft-mag','pi_gaussian_fft',fftgraph('GPI graph',20))
Plot('graph-picut-fft-mag','pi_erfi_fft-cut',fftgraph('PI cut graph',20))
Flow('filter-time','erfi_ba_4_path-sum',invft)
Flow('filter-time-exp','erfi_ba_4_path-sum-exp',invftexp)
Flow('filter-fft','filter-time',fwdft)
Flow('filter-fft-exp','filter-time-exp',fwdftexp)
End() |