$#define DEBUG
#include <SEP.defs>

#ifdef IScray
#define PEMDIR /scr/martin
#define BIDIR /disks/lhdsy2/geophys/martin/bin/MTYPE
#define SCRATCH /scr/martin
#define MYLIBS -lsci
#else
#define PEMDIR ../../Data/Pem50
#define BIDIR ../../Bin/MTYPE
#define SCRATCH /scr/martin
#define MYLIBS -lblas
#endif
#define DATA 
#define TAPLOT Taplot pclip=90.
#define MOVIE Animator


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" 

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"
	
	
	

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