$#define DEBUG
#include <SEP.defs>

#define PEMDIR /scr6/martin/Pem
#define BINDIR /geophys/martin/bin/MTYPE
#define SCRATCH /scr/martin
#define MYLIBS -lblas

#define TAPLOT Taplot pclip=90.
#define MOVIE Animator

figures&: filterscan filtersingle filter40 slicexx1.ps slicexx2.ps symslicexx.ps devslicexx.ps slicexx1eq.ps compxx.ps
/*
	cp slice\*.v ../../Fig
	cp slice\*.ps ../../Fig
*/

filterscan&:
	Thplot alpha=30 <filter0.h out=fil0.v head=/dev/null title="0-1sec"
	Thplot alpha=30 <filter250.h out=fil1-2.v head=/dev/null title="1-2sec" 
	Thplot alpha=30 <filter500.h out=fil2-3.v head=/dev/null title="2-3sec"
	Thplot alpha=30 <filter750.h out=fil3-4.v head=/dev/null title="3-4sec"
	Thplot alpha=30 <filter1000.h out=fil4-5.v head=/dev/null title="4-5sec"
	Thplot alpha=30 <filter1250.h out=fil6-7.v head=/dev/null title="6-7sec" 

filtersingle&:
	Thplot alpha=30 <filterl1xx.h out=fil1xx.v head=/dev/null title="Xx filter"
	Thplot alpha=30 <filterl1yy.h out=fil1yy.v head=/dev/null title="Yy filter" 
	Thplot alpha=30 <filterl1zz.h out=fil1zz.v head=/dev/null title="Zz filter"
	Thplot alpha=30 <filterl1xy.h out=fil1xy.v head=/dev/null title="Xy filter"
	Thplot alpha=30 <filterl1xz.h out=fil1xz.v head=/dev/null title="Xz filter"
	Thplot alpha=30 <filterl1yz.h out=fil1yz.v head=/dev/null title="Yz filter" 


filter40&: 
	Window <filterl19.40.h f1=0 n1=41 |Thplot alpha=0 out=filxx.40.v  head=/dev/null title="xx filter"
	Window <filterl19.40.h f1=41 n1=41 |Thplot alpha=0 out=filxy.40.v  head=/dev/null title="xy filter"
	Window <filterl19.40.h f1=82 n1=41 |Thplot alpha=0 out=filxz.40.v  head=/dev/null title="xz filter"
	Window <filterl19.40.h f1=123 n1=41 |Thplot alpha=0 out=filyx.40.v  head=/dev/null title="yx filter"
	Window <filterl19.40.h f1=164 n1=41 |Thplot alpha=0 out=filyy.40.v  head=/dev/null title="yy filter"
	Window <filterl19.40.h f1=205 n1=41 |Thplot alpha=0 out=filyz.40.v  head=/dev/null title="yz filter"
	Window <filterl19.40.h f1=246 n1=41 |Thplot alpha=0 out=filzx.40.v  head=/dev/null title="zx filter"
	Window <filterl19.40.h f1=287 n1=41 |Thplot alpha=0 out=filzy.40.v  head=/dev/null title="zy filter"
	Window <filterl19.40.h f1=328 n1=41 |Thplot alpha=0 out=filzz.40.v  head=/dev/null title="zz filter"
	
	
	


/*
all.A&: slicexx1.A slicexx1eq.A slicexx2.A symslicexx.A  compxx.A


slicexx1.A:
	Window f2=40 n2=120 n3=50 f3=120 <norminxx.h.TS >junk
        echo "o2=-60" >>junk
        Taplot <junk pclip=95 >slicexx1.A out=./_slicexx1.A@

slicexx1eq.A:
	Window f2=40 n2=120 n3=50 f3=140 <norminxx.eq.TS >junk
        echo "o2=-60" >>junk
        Taplot <junk pclip=95  >slicexx1eq.A  out=./_slicexx1eq.A@

slicexx2.A:
	Window f2=40 n2=120 n3=50 f3=120 <reciinxx.h.TS >junk
        echo "o2=-60" >>junk
        Taplot <junk pclip=95 >slicexx2.A  out=./_slicexx2.A@

symslicexx.A devslicexx.A:
	Window f2=40 n2=120 n3=50 f3=120 <norminxx.h.TS >junk
	Window f2=40 n2=120 n3=50 f3=120 <reciinxx.h.TS >junk2
	echo "o2=-60" >>junk
	echo "o2=-60" >>junk2
        Add junk junk2 >junk3 mode=sum scale=0.5,0.5
	Taplot <junk3 pclip=95 >symslicexx.A  out=./_symslicexx.A@
        Add junk junk2 >junk3 mode=sum scale=0.5,-0.5
	Taplot <junk3 pclip=95 >devslicexx.A  out=./_devslicexx.A@

compxx.A: slicexx1.A slicexx1eq.A
	Merge axis=1 space=n slicexx1.A slicexx1eq.A >compxx.A out=./_compxx.A

*/

compxx.v: slicexx1.v slicexx1eq.v
	vp_OverUnderIso slicexx1.v slicexx1eq.v >compxx.v

slicexx1eq.v:
	Window n3=1 <slicexx1eq.A >junk
	Ta2vplot <junk title="Equalized Xx Prestack Time Slice" label1="source axis" label2="offset" >/dev/null out=slicexx1eq.v 

slicexx1.v:
	Window n3=1 <slicexx1.A >junk
	 <junk Ta2vplot title="Xx Prestack Time Slice" label1="source axis" label2="offset" >/dev/null out=slicexx1.v 

slicexx2.v:
	Window n3=1 <slicexx2.A >junk
	<junk Ta2vplot title="Xx Reciprocal Prestack Time Slice" label1="reciprocal source axis" label2="reciprocal offset">/dev/null out=slicexx2.v 


symslicexx.v devslicexx.v:
	Window  n3=1 <symslicexx.A >junk
	Window  n3=1 <devslicexx.A >junk2
	<junk Ta2vplot title="Xx Symmetric Part" label1="source axis" label2="offset" >/dev/null out=symslicexx.v 
	<junk2 Ta2vplot title="Xx Deviatoric Part" label1="source axis" label2="offset">/dev/null out=devslicexx.v 




in%.h:
	Window f1=500 n1=500 <PEMDIR/l1%.data.h |SCALE >DATA/in%.h

norm%.h scd%: in%.h
	time Count sxbias=55. scdfile=csd% recifile=reci%.h <in%.h  >norm%.h

eqline%&: norm%.h
	time EqualizePre5 <norm%.h recifile=reci%.h  >norm%.eq filter1=filterl1%.h  par=parfile.l1




filter%&:  /*  eqline%  */
	Efilter  filter1=filterl1%.h error1=err1l1%.h error2=err2l1%.h <l1%.data.s >l1%.data.eq

equalonly%&: DATA/norm%.h
	Scale dscale=1.e-7 <DATA/norm%.h >DATA/norm%.s 
	EqualizePre <DATA/norm%.s par=parfile.% >DATA/norm%.equal.s


diff%.h: DATA/norm%.h DATA/reci%.h
	Add mode=sum scale=1.,-1. DATA/norm%.h DATA/reci%.h >diff%.h


%.s: %.h
	Window f3=0 n3=10  <%.h |Scale  dscale=1.e-14 >%.s

sgplot%: sgplot%.V
	Xtpen <sgplot%.V


sgplot%.V: PEMDIR/l1%.hdr.h
	Window <PEMDIR/l1%.hdr.h >junk f1=6 n1=1
	Window <PEMDIR/l1%.hdr.h >junk2 f1=8 n1=1
	Merge axis=3 space=n junk junk2 >junk3
	Transp plane=13 <junk3 |Reedfloat >junk4
	echo "esize=8 n1=1" >>junk4
	Window n1=1 <junk4 | Graph  max2=33000 min2=4000 max1=22000 min1=16000 symbol="*" >sgplotxx.V title='S-G-Plot L1 %  Pembrook' label1="shot inline" label2="geophone inline"



jcomp%: DATA/norm%.h DATA/reci%.h diff%.h
	Window j1=4 j3=10 <DATA/norm%.h |Scale dscale=1.e-7  >j1
 	Window j1=4 j3=10 <DATA/reci%.h |Scale dscale=1.e-7 >j2
 	Window j1=4 j3=10 <diff%.h |Scale dscale=1.e-7  >j3
	Merge axis=1 space=y j1 j2 j3 >jcomp% datapath=DECSCRATCH/


show%&: jcomp%
	Reedfloat <jcomp% >jj
	TAPLOT  <jj >j4.m
	MOVIE <j4.m




plot-filter%.V:
	Thplot alpha=0 <filterl1%.h title="% Eq-filter" >plot-filter%.V

plot2-filter%.V:
	Thplot alpha=30 <filterl1%.h title="% Eq-filter" >plot2-filter%.V

%.TS: 
	Transp plane=12 <% | Transp plane=13 >%.TS

%.ps: %.v if cando %.v
	pstexpen %.v %.ps

%.ps: %.V if cando %.V
	Pspen <%.V out=%.ps head=/dev/null

clean&:
	-RM_CMD *.x *.o  a.out core

#include <SEP.obj.rules>
#include <SEP.prog.rules>
















/*  testing the new stuff   */
in9.h:
	Window f1=500 n1=500 <PEMDIR/l1xx.data.h >jj1
	Scale <jj1 dscale=1.e-14 >j1
	Window f1=500 n1=500 <PEMDIR/l1yy.data.h >jj1
	Scale <jj1 dscale=1.e-14  >j2
	Window f1=500 n1=500 <PEMDIR/l1zz.data.h >jj1
	Scale <jj1 dscale=1.e-14 >j3
	Window f1=500 n1=500 <PEMDIR/l1xy.data.h >jj1
	Scale <jj1 dscale=1.e-14  >j4
	Window f1=500 n1=500 <PEMDIR/l1yx.data.h >jj1 
	Scale <jj1 dscale=1.e-14 >j5
	Window f1=500 n1=500 <PEMDIR/l1xz.data.h >jj1
	Scale <jj1 dscale=1.e-14  >j6
	Window f1=500 n1=500 <PEMDIR/l1zx.data.h >jj1
	Scale <jj1 dscale=1.e-14 >j7
	Window f1=500 n1=500 <PEMDIR/l1yz.data.h >jj1
	Scale <jj1 dscale=1.e-14  >j8
	Window f1=500 n1=500 <PEMDIR/l1zy.data.h >jj1 
	Scale <jj1 dscale=1.e-14 >j9
	Cat j1 j2 j3 j4 j5 j6 j7 j8 j9 >in9.h 
	Cat PEMDIR/l1xx.hdr.h PEMDIR/l1yy.hdr.h PEMDIR/l1zz.hdr.h PEMDIR/l1xy.hdr.h PEMDIR/l1yx.hdr.h PEMDIR/l1xz.hdr.h PEMDIR/l1zx.hdr.h PEMDIR/l1yz.hdr.h PEMDIR/l1zy.hdr.h >hdr9.h
	echo "attrfile=./hdr9.h" >>in9.h

norm9.h scd9: in9.h
	time Count6 sxbias=55. scdfile=csd9 recifile=reci9.h <in9.h  >norm9.h

eqline9&: norm9.h
	time EqualizePre6 scdfile=csd9 <norm9.h recifile=reci9.h  >norm9.eq filter1=filterl19.h  par=parfile.l1

restart9&:
	time EqualizePre6 restart=y scdfile=csd9 <norm9.h recifile=reci9.h  >norm9.eq.restart filter1=filterl19.h  par=parfile.l1

/*    end of testing  */







diagnose%&:
	Count <PEMDIR/l1%.data.h sxbias=55. >/dev/null 

inspect&:
	Count <PEMDIR/l1%.data.h sxbias=55. >DATA/norm%.h recifile=DATA/reci%.h scdfile=DATA/scd%.h

equal%&: SCRATCH/l1%.data.s
	Window f1=250 n1=750 <SCRATCH/l1%.data.s >inxx.h
	EqualizePre4 <inxx.h damp=0.01 par=parfile.% >DATA/l1%.equal.h



inxy.h:
	Window f1=500 n1=500 <PEMDIR/l1xy.data.h |Scale dscale=1.e-14  >j1
	Window f1=500 n1=500 <PEMDIR/l1yx.data.h |Scale dscale=1.e-14 >j2
	Cat j1 j2 >inxy.h 
	Cat PEMDIR/l1xy.hdr.h PEMDIR/l1yx.hdr.h >hdrxy.h
	echo "attrfile=./hdrxy.h" >>inxy.h

normxy.h scdxy: inxy.h
	time Count6 sxbias=55. scdfile=csdxy recifile=recixy.h <inxy.h  >normxy.h

eqlinexy&: /*normxy.h*/
	time EqualizePre6 scdfile=csdxy <normxy.h recifile=recixy.h  >normxy.eq filter1=filterl1xy.h  par=parfile.l1


inxz.h:
	Window  f1=500 n1=500 <PEMDIR/l1xz.data.h |Scale dscale=1.e-14  >j1
	Window  f1=500 n1=500 <PEMDIR/l1zx.data.h |Scale dscale=1.e-14 >j2
	Cat j1 j2 >inxz.h 
	Window  <PEMDIR/l1xz.hdr.h >j1
	Window  <PEMDIR/l1zx.hdr.h >j2
	Cat j1 j2 >hdrxz.h
	echo "attrfile=./hdrxz.h" >>inxz.h
	/*Cat PEMDIR/l1xz.hdr.h PEMDIR/l1zx.hdr.h >hdrxz.h */

normxz.h scdxz: /*inxz.h*/
	time Count6 sxbias=55. scdfile=csdxz recifile=recixz.h <inxz.h  >normxz.h

eqlinexz&: normxz.h
	time EqualizePre6 scdfile=csdxz  <normxz.h recifile=recixz.h  >normxz.eq filter1=filterl1xz.h  par=parfile.l1


inyz.h:
	Window f1=500 n1=500 <PEMDIR/l1yz.data.h |Scale dscale=1.e-14  >j1
	Window f1=500 n1=500 <PEMDIR/l1zy.data.h |Scale dscale=1.e-14 >j2
	Cat j1 j2 >inyz.h 
	Cat PEMDIR/l1yz.hdr.h PEMDIR/l1zy.hdr.h >hdryz.h
	echo "attrfile=./hdryz.h" >>inyz.h

normyz.h scdyz: inyz.h
	time Count6 sxbias=55. scdfile=csdyz recifile=reciyz.h <inyz.h  >normyz.h

eqlineyz&: normyz.h
	time EqualizePre6 scdfile=csdyz  <normyz.h recifile=reciyz.h  >normyz.eq filter1=filterl1yz.h  par=parfile.l1




in%.h:
	Window f1=500 n1=500 <SCRATCH/l1%.data.h |Scale dscale=1.e-14 >in%.h

norm%.h scd%: in%.h
	time Count sxbias=55. scdfile=csd% recifile=reci%.h <in%.h  >norm%.h

eqline%&: norm%.h
	time EqualizePre5 <norm%.h recifile=reci%.h  >norm%.eq filter1=filterl1%.h  par=parfile.l1




filter%&:  /*  eqline%  */
	Efilter  filter1=filterl1%.h error1=err1l1%.h error2=err2l1%.h <l1%.data.s >l1%.data.eq

equalonly%&: DATA/norm%.h
	Scale dscale=1.e-7 <DATA/norm%.h >DATA/norm%.s 
	EqualizePre <DATA/norm%.s par=parfile.% >DATA/norm%.equal.s


diff%.h: DATA/norm%.h DATA/reci%.h
	Add mode=sum scale=1.,-1. DATA/norm%.h DATA/reci%.h >diff%.h


%.s: %.h
	Window f3=0 n3=10  <%.h |Scale  dscale=1.e-14 >%.s

sgplot%: sgplot%.V
	Xtpen <sgplot%.V


sgplot%.V: PEMDIR/l1%.hdr.h
	Window <PEMDIR/l1%.hdr.h >junk f1=6 n1=1
	Window <PEMDIR/l1%.hdr.h >junk2 f1=8 n1=1
	Merge axis=3 space=n junk junk2 >junk3
	Transp plane=13 <junk3 |Reedfloat >junk4
	echo "esize=8 n1=1" >>junk4
	Window n1=1 <junk4 | Graph  max2=33000 min2=4000 max1=22000 min1=16000 symbol="*" >sgplotxx.V title='S-G-Plot L1 %  Pembrook' label1="shot inline" label2="geophone inline"



jcomp%: DATA/norm%.h DATA/reci%.h diff%.h
	Window j1=4 j3=10 <DATA/norm%.h |Scale dscale=1.e-7  >j1
 	Window j1=4 j3=10 <DATA/reci%.h |Scale dscale=1.e-7 >j2
 	Window j1=4 j3=10 <diff%.h |Scale dscale=1.e-7  >j3
	Merge axis=1 space=y j1 j2 j3 >jcomp% datapath=DECSCRATCH/


show%&: jcomp%
	Reedfloat <jcomp% >jj
	TAPLOT  <jj >j4.m
	MOVIE <j4.m




plot-filter%.V:
	Thplot alpha=0 <filterl1%.h title="% Eq-filter" >plot-filter%.V

plot2-filter%.V:
	Thplot alpha=30 <filterl1%.h title="% Eq-filter" >plot2-filter%.V


%.ps: %.V
	Pspen <%.V out=%.ps head=/dev/null

clean&:
	-RM_CMD *.x *.o  a.out core

#include <SEP.obj.rules>
#include <SEP.prog.rules>
