#correct velocity:
#/net/koko/tang/Research/wemva.trpl/tripl.vmod.coarse.H

#wrong velocity
tripl.vwrg.H:
	< /net/koko/tang/Research/wemva.trpl/tripl.vwrg.H Window3d | Transp | Pad extend=1 beg2=500 end2=500 end1=300 > $@

tripl.vwrg.lloyd.H:
	Transp plane=12 reshape=1,3 < tripl.vwrg.H | Lloyd_vel nref=1 min_region_pct=2 niter_lloyd=120 min_slow_dev=.01 > $@

tripl.shtprof.H:
	< /net/koko/tang/Research/wemva.trpl/tripl.crec.coarse.H Window3d n4=1 f4=200 squeeze=n > x.H \
	< x.H ~claudio/research.ln/Prst_ExpRefl/ShtPSPI/bin/OWmig2d_par.x \
	sou=/net/koko/tang/Research/wemva.trpl/tripl.csou.H vel=tripl.vwrg.H image=tripl.vwrg.image.H \
	vref=tripl.vwrg.lloyd.H xmin=-3750 xmax=3750 noencode=0  node=16 zmin=0 zmax=3000 \
	nh=1 oh=0 dh=10 wbott=0 > /dev/null

tripl.csou.H:
	Window3d < /net/koko/tang/Research/wemva.trpl/tripl.csou.H squeeze=n > $@
	echo o3=9.663283 d3=0.33321 >> $@

#source function
#/net/koko/tang/Research/wemva.trpl/tripl.csou.H

#original data
#/net/koko/tang/Research/wemva.trpl/tripl.crec.coarse.H

#image with correct velocity
#/net/koko/tang/Research/wemva.trpl/tripl.imag.H

#image with wrong velocity
#/net/koko/tang/Research/wemva.trpl/tripl.imag.vwrg.H
0000tripl_rot: 
	< /net/koko/tang/Research/wemva.trpl/tripl.imag.vwrg.H Window3d|Transp plane=12|Transp plane=12 reshape=2,3 > junk.H
	~claudio/research.ln/Others/Biondo/rotation/v3/RotCig_v3.x Cig_hx=junk.H Cig_tilt=0001tripl_rot_sou.H \
	par=Cig-rot.P positive_rot=0
	~claudio/research.ln/Others/Biondo/rotation/v3/RotCig_v3.x Cig_hx=junk.H Cig_tilt=0001tripl_rot_rec.H \
	par=Cig-rot.P positive_rot=1

0001tripl: # correct velocity areal shot random encode in w
#	< 0001tripl_rot_rec.H Window3d | Transp plane=23 | Window3d squeeze=n min3=-1500 max3=0 > junk_rec.H
#	< 0001tripl_rot_sou.H Window3d | Transp plane=23 | Window3d squeeze=n min3=-1500 max3=0 > junk_sou.H
	< 0001tripl_rot_rec.H Window3d | Transp plane=23 > junk_rec.H
	< 0001tripl_rot_sou.H Window3d | Transp plane=23 > junk_sou.H
	~claudio/research.ln/Prst_ExpRefl/Tese/bin/OW_arealsht.x rec_cig=junk_rec.H sou_cig=junk_sou.H sou=tripl.csou.H \
	vel=tripl.vwrg.H vref=tripl.vwrg.lloyd.H rec_out=0001tripl_rec_gencw_vwrg.H sou_out=0001tripl_sou_gencw_vwrg.H \
	ngap=20 padtraces=41 zmax= 3000 encode=1 random=1 encz=1 eps=1 injection=1 nreal=2 node=16 12 jshift=1 \
	> /dev/null 


twin.imag.bvel.H:
	< /net/koko/tang/Report/SEP136/yaxun1/twin.imag.bvel.H Window3d | Transp plane=12 reshape=2,3 > $@

twin.bvel.H:
	< /net/koko/tang/Report/SEP136/yaxun1/twin.bvel.H Window3d | Transp | Pad extend=1 beg2=1000 end2=1000 end1=500 > $@

twin.csou.H:
	Cp /net/koko/tang/Report/SEP136/yaxun1/twin.csou.H $@; echo d3=0.3333 o3=4.6666 >> $@

0001twin: # correct velocity areal shot random encode in w
	~claudio/research.ln/Prst_ExpRefl/Tese/bin/OW_arealsht.x rec_cig=twin.imag.bvel.H sou_cig=twin.imag.bvel.H sou=twin.csou.H \
	vel=twin.bvel.H rec_out=0001twin_rec_encw_bvel.H sou_out=0001twin_sou_encw_bvel.H \
	nrefvel=1 vsal=3000 ngap=10 padtraces=41 zmax=2000 encode=1 random=1 encw=1 eps=1 injection=1 nreal=2 node= 8 \
	> /dev/null 

00011twin: # correct velocity areal shot random encode in w
	~claudio/research.ln/Prst_ExpRefl/Tese/bin/OW_arealsht.x rec_cig=twin.imag.bvel.H sou_cig=twin.imag.bvel.H sou=twin.csou.H \
	vel=twin.bvel.H rec_out=00011twin_rec_encw_bvel.H sou_out=00011twin_sou_encw_bvel.H \
	nrefvel=1 vsal=3000 ngap=10 padtraces=41 zmax=2000 encode=1 random=1 encw=1 eps=1 injection=1 nreal=2 node= 8 \
	> /dev/null 

0111twin:
	Cat 0001twin_rec_encw_bvel.H 00011twin_rec_encw_bvel.H axis=4> 0111twin_rec_encw_bvel.H
	Cat 0001twin_sou_encw_bvel.H 00011twin_sou_encw_bvel.H axis=4> 0111twin_sou_encw_bvel.H

0002twin_encw_bvel.H: # correct velocity areal shot random encode in w
	< 0001twin_rec_encw_bvel.H Transp plane=13 > 0001twin_rec_encw_bvel_tr.H
	< 0001twin_sou_encw_bvel.H Transp plane=13 > 0001twin_sou_encw_bvel_tr.H
	< 0001twin_rec_encw_bvel_tr.H ~claudio/research.ln/Prst_ExpRefl/Tese/InvVel/bin/OWmig2d_areal.x \
	sou=0001twin_sou_encw_bvel_tr.H vel=twin.bvel.H vsal=3000 nrefvel=1 \
	xmin=-5000 xmax=5000 zmin=0 zmax=2000 nh=33 oh=-160 dh=10 \
	traces_in_taper=0 every=0 encode=1 migration=1 node= 8 16 > $@ 
	Rm 0001tripl*_tr.H
	
###########
#
# Model space encoding
1111twin: # correct velocity areal shot random encode in w
	~claudio/research.ln/Prst_ExpRefl/Tese/bin/OW_arealsht.x rec_cig=twin.imag.bvel.H sou_cig=twin.imag.bvel.H sou=twin.csou.H \
	vel=twin.bvel.H rec_out=1111twin_rec_encw_bvel.H sou_out=1111twin_sou_encw_bvel.H \
	nrefvel=1 vsal=3000 ngap=10 padtraces=41 zmax=2000 encode=1 random=1 encw=1 eps=1 injection=1 nreal=40 node=12 8 \
	> /dev/null 

1112twin_encw_bvel.H: # correct velocity areal shot random encode in w
	< 1111twin_rec_encw_bvel.H Transp plane=13 | Window3d squeeze=n n4=20 > 1111twin_rec_encw_bvel_tr.H
	< 1111twin_sou_encw_bvel.H Transp plane=13 | Window3d squeeze=n n4=20 > 1111twin_sou_encw_bvel_tr.H
	< 1111twin_rec_encw_bvel_tr.H ~claudio/research.ln/Prst_ExpRefl/Tese/InvVel/bin/OWmig2d_areal.x \
	sou=1111twin_sou_encw_bvel_tr.H vel=twin.bvel.H vsal=3000 nrefvel=1 \
	xmin=-5000 xmax=5000 zmin=0 zmax=2000 nh=1 33 oh=0 -160 dh=10 \
	traces_in_taper=0 every=0 encode=1 migration=1 node= 8 16 > $@ 

twin.slow.H:
	Window3d < /net/koko/tang/Report/SEP136/yaxun1/twin.slow.H | Transp | Pad extend=1 beg2=1000 end2=1000 end1=500 > $@

0003Dimg_twin.H: # computing the perturbed image (forward modeling)
	< 0001twin_rec_encw_bvel.H Transp plane=13 > 0001twin_rec_encw_bvel_tr.H
	< 0001twin_sou_encw_bvel.H Transp plane=13 > 0001twin_sou_encw_bvel_tr.H
	Math file1=twin.slow.H file2=twin.bvel.H exp="file1-1/file2" > twin.deltaS.H
	< 0001twin_rec_encw_bvel_tr.H /net/koko/claudio/Research/Prst_ExpRefl/Tese/InvVel/bin/OWwemva_opers.x \
	sou=0001twin_sou_encw_bvel_tr.H vel=twin.bvel.H deltaS=twin.deltaS.H \
	nrefvel=1 xmin=-5570 xmax=5570 zmin=0 zmax=2000 nh=33 oh=-160 dh=10 wbott=0 adj=0 vsal=3000 node=16 \
	traces_in_taper=25 > $@ 

0003Dslow_twin.H: # computing the slowness perturbation (adjoint)
	< 0001twin_rec_encw_bvel_tr.H /net/koko/claudio/Research/Prst_ExpRefl/Tese/InvVel/bin/OWwemva_opers.x \
	sou=0001twin_sou_encw_bvel_tr.H vel=twin.bvel.H deltaI=0003Dimg_twin.H \
	nrefvel=1 xmin=-5570 xmax=5570 zmin=0 zmax=2000 nh=33 oh=-160 dh=10 wbott=0 adj=1 vsal=3000 node=16 \
	traces_in_taper=25 > $@ 

0033Dimg_twin.H: # computing the perturbed image (forward modeling)
	< 0111twin_rec_encw_bvel.H Transp plane=13 > 0111twin_rec_encw_bvel_tr.H
	< 0111twin_sou_encw_bvel.H Transp plane=13 > 0111twin_sou_encw_bvel_tr.H
	< 0111twin_rec_encw_bvel_tr.H /net/koko/claudio/Research/Prst_ExpRefl/Tese/InvVel/bin/OWwemva_opers.x \
	sou=0111twin_sou_encw_bvel_tr.H vel=twin.bvel.H deltaS=twin.deltaS.H \
	nrefvel=1 xmin=-5570 xmax=5570 zmin=0 zmax=2000 nh=33 oh=-160 dh=10 wbott=0 adj=0 vsal=3000 node=16 \
	traces_in_taper=25 > $@ 

0033Dslow_twin.H: # computing the slowness perturbation (adjoint)
	< 0111twin_rec_encw_bvel_tr.H /net/koko/claudio/Research/Prst_ExpRefl/Tese/InvVel/bin/OWwemva_opers.x \
	sou=0111twin_sou_encw_bvel_tr.H vel=twin.bvel.H deltaI=0033Dimg_twin.H \
	nrefvel=1 xmin=-5570 xmax=5570 zmin=0 zmax=2000 nh=33 oh=-160 dh=10 wbott=0 adj=1 vsal=3000 node=16 \
	traces_in_taper=25 > $@ 

00011tripl: # correct velocity areal shot random encode in w
	< 0001tripl_rot_rec.H Window3d | Transp plane=23 | Window3d squeeze=n min3=-1500 max3=0 > junk_rec.H
	< 0001tripl_rot_sou.H Window3d | Transp plane=23 | Window3d squeeze=n min3=-1500 max3=0 > junk_sou.H
#	< 0001tripl_rot_rec.H Window3d | Transp plane=23 > junk_rec.H
#	< 0001tripl_rot_sou.H Window3d | Transp plane=23 > junk_sou.H
	~claudio/research.ln/Prst_ExpRefl/Tese/bin/OW_arealsht.x rec_cig=junk_rec.H sou_cig=junk_sou.H sou=tripl.csou.H \
	vel=tripl.vwrg.H vref=tripl.vwrg.lloyd.H rec_out=00011tripl_rec_gencw_vwrg.H sou_out=00011tripl_sou_gencw_vwrg.H \
	ngap=20 padtraces=41 zmax=3000 encode=1 random=1 encz=1 eps=1 injection=1 nreal=1 node=10 12 jshift=1 \
	> /dev/null 

00021tripl_encz_vwrg.H: # correct velocity areal shot random encode in w
	< 00011tripl_rec_gencw_vwrg.H Transp plane=13 > 00011tripl_rec_gencw_vwrg_tr.H
	< 00011tripl_sou_gencw_vwrg.H Transp plane=13 > 00011tripl_sou_gencw_vwrg_tr.H
	< 00011tripl_rec_gencw_vwrg_tr.H ~claudio/research.ln/Prst_ExpRefl/Tese/InvVel/bin/OWmig2d_areal.x \
	sou=00011tripl_sou_gencw_vwrg_tr.H vel=tripl.vwrg.H vref=tripl.vwrg.lloyd.H \
	xmin=-4000 xmax=4000 zmin=0 zmax=3800 nh=1 1 65 oh=0 -50 -320 dh=10 \
	traces_in_taper=0 every=0 encode=1 migration=1 node=10 > $@ 
	Rm 00011tripl*_tr.H

0001lloyd.H:
	< ../../../Prst_ExpRefl/Tese/44413vlow1.9_transp.H Lloyd_vel nref=1 min_region_pct=2 niter_lloyd=120 min_slow_dev=.01 > $@

0003imp.H:
	Spike n1=501 d1=0.004 o1=0. n2=301 o2=-3 d2=0.02 d3=0.02 o3=0 nsp=1 k1=251 k2=151 mag=10 | Bandpass flo=6 fhi=30 | \
	/net/koko/bob/SEP_BOB/bin/Transf shotmig=y is2d=y wei=y f_min=2 f_min1=6 f_max1=32 f_max=40 maxsize=1000 > j2.H
	< j2.H Transp reshape=1,3,5 plane=23 | Pad beg1=200 end1=200 > $@

0004sou.H:
	Spike n1=501 d1=0.004 o1=0. n2=1 o2=-0 d2=0.02 n3=1 d3=0.02 o3=0 nsp=1 k1=251 k2=1 mag=10 | Bandpass flo=6 fhi=30 > x.H
	echo o1=-1 >> x.H
	< x.H /net/koko/bob/SEP_BOB/bin/Transf shotmig=y is2d=y wei=y f_min=2 f_min1=6 f_max1=24 f_max=30 maxsize=1000 > j2.H
	< j2.H Transp plane=35 > $@

0005mig.H:
	@date
	/net/koko/claudio/Research/Others/ShotMig/ShotMig \
	D=0003imp.H D_d=0004sou.H V=../../../Prst_ExpRefl/Tese/44413vlow1.9_transp.H R=$@ \
	pverb=2  nx_shots=1 ox_shots=0 \
	par=go_sis.P taper=y taper_pcent=2 marine=y minx=-7 maxx=7  #restart=y

00051mig.H:
	< 0003imp.H /net/koko/claudio/Research/Prst_ExpRefl/ShtPSPI/bin/OWmig2d_par.x sou=0004sou.H \
	vel=/net/koko/claudio/Research/Prst_ExpRefl/Tese/44413vlow1.9.H vref= 0001lloyd.H image=$@ vsal=3 nrefvel=1 \
	xmin=-7.4 xmax=7.4 zmin=0 zmax=1.25 nh=41 1 oh=-.4 dh=0.02 encode=0 node= 1 eps=1 > /dev/null

0006areal: # correct velocity areal shot random encode in w
	< 0005mig.H Window3d min1=-2 max1=2.02 | Transp plane=13 > junk.H
	~claudio/research.ln/Prst_ExpRefl/Tese/bin/OW_arealsht.x rec_cig=junk.H sou_cig=junk.H sou=0004sou.H \
	vel=../../../Prst_ExpRefl/Tese/44413vlow1.9.H rec_out=0006rec_encw.H sou_out=0006sou_encw.H \
	ngap=20 padtraces=41 zmax=1.25 encode=1 random=1 encw=1 eps=1 injection=1 nreal=1 node= 10 6 12 nrefvel=1 vsal=3 \
	> /dev/null 

0007mig.H: # correct velocity areal shot random encode in w
	< 0006rec_encw.H Transp plane=13 > 0006rec_encw_tr.H
	< 0006sou_encw.H Transp plane=13 > 0006sou_encw_tr.H
	< 0006rec_encw_tr.H ~claudio/research.ln/Prst_ExpRefl/Tese/InvVel/bin/OWmig2d_areal.x \
	sou=0006sou_encw_tr.H vel=../../../Prst_ExpRefl/Tese/44413vlow1.9.H vref= tripl.vwrg.lloyd.H nrefvel=1 vsal=3 \
	xmin=-2 xmax=2 zmin=0 zmax=1.25 nh=41 1 oh=-.4 dh=0.02 \
	traces_in_taper=0 every=0 encode=1 migration=1 node= 10 > $@ 
	Rm 0006*encw_tr.H

0055imp_rot: 
	< 00051mig.H Transp plane=13|Transp plane=32 > junk.H
	~claudio/research.ln/Others/Biondo/rotation/v3/RotCig_v3.x Cig_hx=junk.H Cig_tilt=0055imp_rot_sou.H \
	par=Cig-rot.P positive_rot=0
	~claudio/research.ln/Others/Biondo/rotation/v3/RotCig_v3.x Cig_hx=junk.H Cig_tilt=0055imp_rot_rec.H \
	par=Cig-rot.P positive_rot=1

0066areal: # correct velocity areal shot random encode in w
	< 0055imp_rot_rec.H Transp plane=23 | Window3d min3=-2 max3=2.02 > junk_rec.H
	< 0055imp_rot_sou.H Transp plane=23 | Window3d min3=-2 max3=2.02 > junk_sou.H
	~claudio/research.ln/Prst_ExpRefl/Tese/bin/OW_arealsht.x rec_cig=junk_rec.H sou_cig=junk_sou.H sou=0004sou.H \
	vel=../../../Prst_ExpRefl/Tese/44413vlow1.9.H rec_out=0066rec_encw.H sou_out=0066sou_encw.H \
	ngap=20 padtraces= 41 zmax=1.25 encode=1 random=1 encw=1 eps=1 injection=1 nreal=1 node= 10 6 12 nrefvel=1 vsal=3 \
	> /dev/null 

0077mig.H: # correct velocity areal shot random encode in w
	< 0066rec_encw.H Transp plane=13 > 0006rec_encw_tr.H
	< 0066sou_encw.H Transp plane=13 > 0006sou_encw_tr.H
	< 0006rec_encw_tr.H ~claudio/research.ln/Prst_ExpRefl/Tese/InvVel/bin/OWmig2d_areal.x \
	sou=0006sou_encw_tr.H vel=../../../Prst_ExpRefl/Tese/44413vlow1.9.H vref= tripl.vwrg.lloyd.H nrefvel=1 vsal=3 \
	xmin=-2 xmax=2 zmin=0 zmax=1.25 nh=41 1 oh=-.4 dh=0.02 \
	traces_in_taper=0 every=0 encode=1 migration=1 node= 10 > $@ 
	Rm 0006*encw_tr.H


