$#define DEBUG
#include <SEP.defs>

#define PEMDIR /scr5/martin/Pem
#define DATA .
#define SCALE Scale dscale=1.e-14 
#define BINDIR /geophys/martin/bin/MTYPE
#define SCRATCH /scr/martin
#define MYLIBS -lblas

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

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

/*
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 




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%&: in%.h
$	Count <in%.h sxbias=55. >normin%.h recifile=reciin%.h scdfile=inscd%.h
$	echo 'data_format="xdr_float"' >>norminxx.h
$	echo 'data_format="xdr_float"' >>reciinxx.h
$	echo 'data_format="xdr_float"' >>inscdxx.h
	EqualizePre5 <normin%.h damp=0.01 par=parfile.% recifile=reciin%.h scdfile=inscd%.h  >in%.equal.h



inxy.h:
	Window f1=500 n1=500 <PEMDIR/l1xy.data.h |SCALE  >j1
	Window f1=500 n1=500 <PEMDIR/l1yx.data.h |SCALE  >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 <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>
