include ${SEPINC}/SEP.top
include ../../Src/thesis.include
include ../../Src/synth.top.inc
include ../../Src/mig.include
RESULTSCR=res.vel1 res.velb
RESULTSCR=res.vel1.steerz res.vel1.lapz all.res.vel1.tau res.vel1.steer \
          res.vel3.steer all.res.vel3.tau res.vel2.lapz res.vel3.steerz \
          vel1 velb
RESULTSER=bad


UPSTEXFLAGS=invras=y
RMV=${BINDIR}/Tomo_2d.x



UF90INCLUDES= -I/net/kana/biondo/include/gendown3d_v9/${MTYPE} -I/net/kana/biondo/include/timers_v1/${MTYPE} -I//net/kana/biondo/include/gendown3d_v9/${MTYPE} -I/net/kana/biondo/include/gendownkern3d_v2/${MTYPE} ${BOBINCS} ${BIONDOINC}
UF90FLAGS=-mp
UF90LIBS=-L/net/kana/biondo/lib/gendown3d_v9/${MTYPE} -L/net/kana/biondo/lib/timers_v1/${MTYPE}   -lgendown3d  -lSEPtimers -L/net/kana/biondo/lib/gendownkern3d_v2/${MTYPE} -lgendownkern3d ${BOBLIBS} -mp ${BIONDOLIBS} ${FFT}
UCLIBS=-lsuperset -lsep3d -lsep




vel_cor.mig.H:	vel_cor.view.H
	Window < vel_cor.view.H j1=2 |Transp plane=12 |Transp plane=23 >vel_cor.mig.H


GREY_VEL=Grey >/dev/null min1=0 max1=5 min2=2 max2=18  title=" " \
 wantscalebar=y color=v label1="Depth(km)" label2="X Position(km)"  color=j


#MIG=../Bin/Pre2D_salt_ssf.x

test:	${BINDIR}/Pre2D_salt_ssf.x

#################################
#####  PLOTTING         #########
#################################

PANELS=7 7.25 7.5 7.75 8 8.25 8.50 8.75 9 9.25 9.5 9.75 10 10.25 10.5 10.75 11 11.25 

${RESDIR}/rays.v:	px.vel_cor.H px.vel0.H reflectors.z.vel_cor.H reflectors.vel0.H
	Window3d < px.vel_cor.H f4=5 f3=8 j2=6 >a.H synch=1 n3=1 min2=6 max2=14
	Window3d < px.vel0.H f4=5 f3=8 j2=6 >b.H synch=1 n3=1 j1=4 min2=6 max2=14
	Graph < a.H  >cor.V yreverse=y min1=2 max1=18 min2=0 max2=5 title=" " wantaxis=n  plotcol=3 plotfat=3
	Graph < b.H  >zero.V yreverse=y min1=2 max1=18 min2=0 max2=5 title=" " wantaxis=n dash=2 plotcol=1 plotfat=3 symbol="*" symbolsz=2
	Graph < reflectors.vel_cor.H  >ref_cor.V yreverse=y min1=2 max1=18 min2=0 max2=5 title=" " wantaxis=n dash=0 plotcol=1 plotfat=3
	Window j1=4 < reflectors.vel0.H |Graph  >ref_zero.V yreverse=y min1=2 max1=18 min2=0 max2=5 title=" " wantaxis=n dash=2 plotcol=1 plotfat=3 symbol="*" symbolsz=2
	${GREY} < vel_cor.z.HH >vel.V wantscalebar=n bias=2.
	Vppen vpstyle=n erase=o <vel.V zero.V cor.V ref_zero.V ref_cor.V >rays.V out=$@

${RESDIR}/synth-model.v: zero-synth.v vel_cor.v
	vp_SideBySideIso vel_cor.v zero-synth.v  >$@

${RESDIR}/semb-mig0.v:	overlay.vel0.8.v
	cp  overlay.vel0.8.v $@

${RESDIR}/iter3-comp-vel.v: vel3.tau.H vel3.z.H
	${GREY} < vel3.tau.H >a.V bias=2 allpos=y barlabel="Velocity(km/s)"
	${GREY} < vel3.z.H >b.V bias=2 allpos=y barlabel="Velocity(km/s)"
	Vppen gridnum=2,1 < b.V a.V >comp-vel.V out=$@ 

${RESDIR}/iter1-comp.v:	 vel1.z.delta.V vel1.tau.delta.V
	Vppen gridnum=1,2 vpstyle=n <vel1.z.delta.V vel1.tau.delta.V >iter1-comp.V out=$@ xscale=2

${RESDIR}/mig0.v:	mig.vel0.H vel0.H reflectors.z.vel_cor.H
	${GREY} < vel0.H out=a.v bias=2 allpos=y >/dev/null \
   barlabel="Velocity(km/s)"
	Window < mig.vel0.H n2=1 |Grey out=b.v >/dev/null wantscalebar=n title=" " label1="Depth(km)" label2="X Position (km)"
	Window j1=16 < reflectors.z.vel_cor.H|Graph out=c.v min1=2 max1=18  min2=0 max2=5 yreverse=1 >/dev/null  symbolsz=16 plotcol=0 symbol="*" wantaxis=n title=" "
	Window j1=16 < reflectors.z.vel_cor.H |Graph out=d.v min1=2 max1=18  min2=0 max2=5 yreverse=1 >/dev/null  symbolsz=8 plotcol=7 symbol="*" wantaxis=n title=" "
	vp_Overlay b.v c.v d.v >e.v
	vp_SideBySideIso a.v e.v >$@


${RESDIR}/tau-initial.v:  tau-vel_cor.v tau-vel0.v
	vp_SideBySideIso tau-vel_cor.v tau-vel0.v >$@

${RESDIR}/res.vel3.z.v:	res.vel3.z.v
	cp res.vel3.z.v $@

${RESDIR}/res.vel3.tau.v:	res.vel3.tau.v
	cp res.vel3.tau.v $@

${RESDIR}/res.vel0.v:	res.vel0.v
	cp res.vel0.v $@


vel1.z.delta.V:	vel1.z.H
	Window < delta.vel0.z.H f3=1 |\
	${GREY}   >a.V  barlabel="Slowness (s/km)"  o2=-2.56 d2=.256 o1=-.64 d1=.064\
   labelsz=16 crowd2=.7
	${GREY} < vel1.z.H barlabel="Velocity(km/s)" >b.V allpos=y bias=2 clip=2 labelsz=16 crowd2=.7
	Vppen vpstyle=n gridnum=2,1 <a.V b.V >$@ yscale=2

vel1.tau.delta.V:	vel1.tau.H
	Window < delta.vel0.tau.H  f3=1|\
	${GREY}  >a.V  barlabel="Slowness (s/km)"  o2=-2.56 d2=.256 \
		o1=-.48 d1=.048 max1=4 label1="Tau(s)" labelsz=16 crowd2=.7
	${GREY} < vel1.tau.H barlabel="Velocity(km/s)" >b.V allpos=y bias=2 clip=2 labelsz=16 crowd2=.7
	Vppen vpstyle=n gridnum=2,1 <a.V b.V >$@ yscale=2


BAR=barlabel="Velocity(km/s)"
tau-%.v:	tau-%.H
	Real <  tau-$*.H | ${GREY}  out=tau_$*.v max1=3.5 clip=2. bias=2. allpos=y ${BAR}
	${GRAPH} < tau_reflectors.$*.H out=tau_reflectors.$*.v max2=3.5
	vp_Overlay tau_$*.v tau_reflectors.$*.v >$@

${RESDIR}/semb-mig0-ref.v:	${addprefix semb-ref.vel0.,${addsuffix .V,0 1 2 3 4 5}}
	Vppen <${addprefix semb-ref.vel0.,${addsuffix .V,0 1 2 3 4 5}} out=$@ vpstyle=n gridnum=1,6 >/dev/null xscale=6
	
vel_cor.v:	vel_cor.H reflectors.z.vel_cor.H
	${GREY} < vel_cor.H  out=a.v bias=2 allpos=y barlabel="Velocity(km/s)"
	${GRAPH} < reflectors.z.vel_cor.H out=b.v symbol="*" plotcol=7
	vp_Overlay a.v b.v >$@

cor.v:
	Grey < mig.vel_cor.H  eout=1| Transp plane=23 >tt.T
	Cubeplot < tt.T frame1=85  frame2=240 out=$@  frame3=1>/dev/null point1=.7 point2=.7 pint3=.3 label1="Depth(km)" title=" " flat=y label2="X_position (km)" label3="phx (s/km)"

zero-synth.v: ${DATA}
	Grey < ${DATA} eout=1 >tt.T
	Cubeplot < tt.T frame1=200  frame2=100 out=$@ >/dev/null point1=.7 point2=.7 pint3=.3 label1="Time(s)" title=" " flat=n

ov.movie.v:	${addprefix overlay.,${addsuffix .v,${PANELS}}}
	vp_Movie ${addprefix overlay.,${addsuffix .v,${PANELS}}} >$@


overlay.vel0.%.v:	${BINDIR}/plot_it.x smooth_sem.vel0.H mig.vel0.H reflectors.vel0.H
	Window < mig.vel0.H min3=$* n3=1  >pn.H
	<pn.H Grey out=a.v >/dev/null min1=0 max1=4.5 min2=0 max2=.62 title="$*"
	Window <  smooth_sem.vel0.H min1=$* n1=1  >de.H
	${BINDIR}/plot_it.x  pan=pn.H reflectors=reflectors.vel0.H < de.H >cur.H par=coher.P
	< cur.H Graph out=b.v >/dev/null yreverse=y min2=0 max2=4.5 min1=0 max1=.62\
   wantaxis=n  title=" " symbol="*" symbolsz=16 plotcol=0 
	< cur.H Graph out=c.v >/dev/null yreverse=y min2=0 max2=4.5 min1=0 max1=.62\
   wantaxis=n symbolsz=8 plotcol=7 title=" "
	vp_Overlay a.v b.v  c.v >$@


semb-ref.vel1.z.%.V:	smooth_sem.vel1.z.H sem_ref.vel1.z.H
	Window < sem_ref.vel1.z.H f3=$* n3=1 |Grey out=a.v  min1=-4 max1=4 min2=2 max2=18 allpos=y >a.V title=" " crowd=1 axis=n
	Window <smooth_sem.vel1.z.H f2=$* n2=1 |Graph symbolsz=20 min1=2 max1=18 min2=-4 max2=4 out=b.v >b.V yreverse=y title=" " crowd=1. crowd=1 axis=n plotfat=13 symbol="*"
	Vppen<  a.V b.V  vpstyle=n erase=n >$@ 

semb-ref.vel1.tau.%.V:	smooth_sem.vel1.tau.H sem_ref.vel1.tau.H
	Window < sem_ref.vel1.tau.H f3=$* n3=1 |Grey out=a.v  min1=-4 max1=4 min2=2 max2=18 allpos=y >a.V title=" " crowd=1 axis=n
	Window <smooth_sem.vel1.tau.H f2=$* n2=1 |Graph symbolsz=20 min1=2 max1=18 min2=-4 max2=4 out=b.v >b.V yreverse=y title=" " crowd=1. crowd=1 axis=n plotfat=13 symbol="*"
	Vppen<  a.V b.V >$@ vpstyle=n erase=n  

semb-ref.vel3.z.%.V:	smooth_sem.vel3.z.H sem_ref.vel3.z.H
	Window < sem_ref.vel3.z.H f3=$* n3=1 |Grey out=a.v  min1=-4 max1=4 min2=2 max2=18 allpos=y >a.V title=" " crowd=1 axis=n
	Window <smooth_sem.vel3.z.H f2=$* n2=1 |Graph symbolsz=20 min1=2 max1=18 min2=-4 max2=4 out=b.v >b.V yreverse=y title=" " crowd=1. crowd=1 axis=n plotfat=13 symbol="*"
	Vppen<  a.V b.V >$@ vpstyle=n erase=n  

semb-ref.vel3.tau.%.V:	smooth_sem.vel3.tau.H sem_ref.vel3.tau.H
	Window < sem_ref.vel3.tau.H f3=$* n3=1 |Grey out=a.v  min1=-4 max1=4 min2=2 max2=18 allpos=y >a.V title=" " crowd=1 axis=n
	Window <smooth_sem.vel3.tau.H f2=$* n2=1 |Graph symbolsz=20 min1=2 max1=18 min2=-4 max2=4 out=b.v >b.V yreverse=y title=" " crowd=1. crowd=1 axis=n plotfat=13 symbol="*"
	Vppen<  a.V b.V >$@ vpstyle=n erase=n 

semb-ref.vel0.%.V:	smooth_sem.vel0.H sem_ref.vel0.H
	Window < sem_ref.vel0.H f3=$* n3=1 |Grey out=a.v  min1=-4 max1=4 min2=2 max2=18 allpos=y >a.V title=" " crowd=1 axis=n
	Window <smooth_sem.vel0.H f2=$* n2=1 |Graph symbolsz=16 min1=2 max1=18 min2=-4 max2=4 out=b.v >b.V yreverse=y title=" " crowd=1. crowd=1 axis=n plotfat=13 symbol="*"
	Window <smooth_sem.vel0.H f2=$* n2=1 |Graph symbolsz=8 plotcol=7 min1=2 max1=18 min2=-4 max2=4 out=b.v >c.V yreverse=y title=" " crowd=1. crowd=1 axis=n plotfat=13 symbol="*"
	Vppen<  a.V b.V c.V >$@ vpstyle=n erase=o 

${RESDIR}/sigma.v: tau-vel_cor.H
	Imag <  tau-vel_cor.H | ${GREY}  out=$@ max1=3.5  color=I barlabel="Amplitude"


include ../../Src/synth.bot.inc
include ${SEPINC}/SEP.bottom
