/*
n1=1500
d1=0.004 d2=1 d3=1
o1=0 o2=0     o3=0
esize=4
data_format="xdr_float"
$PEMFULL=/SDA/martin/PemFull


in=$PEMFULL/Line1x/x/_xx1.data.h@   n2=10000 n3=1
in=$PEMFULL/Line1x/x/_xx2.data.h@   n2=9751 n3=1
in=$PEMFULL/Line1x/x/_xx3.data.h@   n2=9701 n3=1
in=$PEMFULL/Line1x/x/_xx4.data.h@   n2=9651 n3=1
in=$PEMFULL/Line1x/x/_xx5.data.h@   n2=9600 n3=1

#concatenate all

in=$PEMFULL/Line1x/x/_xx1.data.h@;$PEMFULL/Line1x/x/_xx2.data.h@;$PEMFULL/Line1x
/x/_xx3.data.h@;$PEMFULL/Line1x/x/_xx4.data.h@;$PEMFULL/Line1x/x/_xx5.data.h@
n1=1500 n2=48703 n3=1

attrfile=$PEMFULL/All/xxall.hdr.H
attrfile=/SDA/martin/PemFull/All/xxall.hdr.H

*/

#define PEMFULL /SDA/martin/PemFull

default&:


makeHeaderReadable&:
	( cd .. ; All/Replace.csh )

doesNOTwork&:
	Cat n1=-1 ../Line1x/x/xx1.data.h.H ../Line1x/x/xx2.data.h.H >cat.H
	Cat n1=-1 ../Line1x/x/xx2.hdr.h.H ../Line1x/x/xx2.hdr.h.H >cathdr.H

%cube&:
	time Cubify axis2=OFFSET axis3=CDP-X <%.H attrfile=h%.H attrout=h%cube.H >%cube.H



cat&:
	Merge axis=2 space=n   n1.H  n2.H   n3.H n4.H  n5.H  >cat.H
	Merge axis=2 space=n   hn1.H hn2.H hn3.H hn4.H hn5.H >cathdr.H
	time Cubify axis2=OFFSET axis3=CDP-X <cat.H attrfile=cathdr.H attrout=hcatcube.H >catcube.H o3=5637.5 d3=110. n3=200

head-%1.%2&:
        Window <../Line1%1/%2/%1%21.hdr.h.H n2=9000 >hn1.H
        Window <../Line1%1/%2/%1%22.hdr.h.H n2=9000 >hn2.H
        Window <../Line1%1/%2/%1%23.hdr.h.H n2=9000 >hn3.H
        Window <../Line1%1/%2/%1%24.hdr.h.H n2=9000 >hn4.H
        Window <../Line1%1/%2/%1%25.hdr.h.H n2=9000 >hn5.H
        Merge axis=2 space=n  hn1.H hn2.H hn3.H hn4.H hn5.H > %1%2.hdr.H
        Rm hn1.H hn2.H hn3.H hn4.H hn5.H

cubit-%1.%2&:
        Window <../Line1%1/%2/%1%21.data.h.H n2=9000 >n1.H
        Window <../Line1%1/%2/%1%22.data.h.H n2=9000 >n2.H
        Window <../Line1%1/%2/%1%23.data.h.H n2=9000 >n3.H
        Window <../Line1%1/%2/%1%24.data.h.H n2=9000 >n4.H
        Window <../Line1%1/%2/%1%25.data.h.H n2=9000 >n5.H
        Merge axis=2 space=n  n1.H n2.H n3.H n4.H n5.H > %1%2.data.H
        Rm n1.H n2.H n3.H n4.H n5.H

/* do the whole stuff */
cube-%1.%2&: cubit-%1.%2 head-%1.%2
        time Cubify axis2=OFFSET axis3=CDP-X <%1%2.data.H attrfile=%1%2.hdr.H attrout=h%1%2cube.H >%1%2cube.H o3=5637.5 d3=110. n3=200
	/*  cake copy-%1.%2 */


copy-%1.%2:
	mv /SDA/martin/PemFull/All/%1%2cube.H /SDA/martin/PemFull/CDP/%1%2cube.H
	echo "in=/SDA/martin/PemFull/CDP/_%1%2cube.H@" >> /SDA/martin/PemFull/CDP/%1%2cube.H
	mv /SDA/martin/%1%2cube.H@ /SDA/martin/PemFull/CDP/_%1%2cube.H@
	mv /SDA/martin/PemFull/All/h%1%2cube.H /SDA/martin/PemFull/CDP/h%1%2cube.H
	echo "in=/SDA/martin/PemFull/CDP/_h%1%2cube.H@" >> /SDA/martin/PemFull/CDP/h%1%2cube.H
	mv /SDA/martin/h%1%2cube.H@ /SDA/martin/PemFull/CDP/_h%1%2cube.H@

/*
	Cp </SDA/martin/PemFull/All/%1%2cube.H >/SDA/martin/PemFull/CDP/%1%2cube.H out=/SDA/martin/PemFull/CDP/_%1%2cube.H@
	Cp </SDA/martin/PemFull/All/h%1%2cube.H >/SDA/martin/PemFull/CDP/h%1%2cube.H out=/SDA/martin/PemFull/CDP/_h%1%2cube.H@
*/
/*
	rsh pele "( /usr/local/seplibV2/bin/Cp </SDA/martin/PemFull/All/%1%2cube.H >/SDA/martin/PemFull/CDP/%1%2cube.H out=/SDA/martin/PemFull/CDP/_%1%2cube.H@ ) "
	rsh pele "( /usr/local/seplibV2/bin/Cp </SDA/martin/PemFull/All/h%1%2cube.H >/SDA/martin/PemFull/CDP/h%1%2cube.H out=/SDA/martin/PemFull/CDP/_h%1%2cube.H@ ) "
	Rm %1%2.data.H %1%2.hdr.H
*/


#define CONCAT(WHERE,A,B) Merge axis=2 space=n PEMFULL/WHERE/A/**/1./**/B/**/.h.H PEMFULL/WHERE/A/**/2./**/B/**/.h.H PEMFULL/WHERE/A/**/3./**/B/**/.h.H PEMFULL/WHERE/A/**/4./**/B/**/.h.H PEMFULL/WHERE/A/**/5./**/B/**/.h.H > A/**/all./**/B/**/.H datapath=PEMFULL/Concat/
#define FIXTRACES(A,B)  echo n2=48703 n3=1 >> A/**/all./**/B/**/.H

#define WHERE Line1x/x
xxcube.H:
	time CONCAT(WHERE,xx,data)
	FIXTRACES(WHERE,xx,data)
	time CONCAT(WHERE,xx,hdr)
	FIXTRACES(WHERE,xx,hdr)

window&:
	Window <../Line1x/x/xx1.data.h.H n2=9000 >n1.H
	Window <../Line1x/x/xx2.data.h.H n2=9000 >n2.H
	Window <../Line1x/x/xx3.data.h.H n2=9000 >n3.H
	Window <../Line1x/x/xx4.data.h.H n2=9000 >n4.H
	Window <../Line1x/x/xx5.data.h.H n2=9000 >n5.H
	Merge axis=2 space=n  n1.H n2.H n3.H n4.H n5.H > xx.data.H
	Window <../Line1x/x/xx1.hdr.h.H n2=9000 >hn1.H
	Window <../Line1x/x/xx2.hdr.h.H n2=9000 >hn2.H
	Window <../Line1x/x/xx3.hdr.h.H n2=9000 >hn3.H
	Window <../Line1x/x/xx4.hdr.h.H n2=9000 >hn4.H
	Window <../Line1x/x/xx5.hdr.h.H n2=9000 >hn5.H
	Merge axis=2 space=n  hn1.H hn2.H hn3.H hn4.H hn5.H > xx.hdr.H

cube&: /* window */
	time Cubify axis2=OFFSET axis3=CDP-X <xx.data.H attrfile=xx.hdr.H attrout=hxxsmallcdp.H >xxsmallcdp.H n3=306


all&: small big

small&:
	time Cp <xxall.data.H >junkall.H
	time Cubify axis2=OFFSET axis3=CDP-X <junkall.H attrfile=xxall.hdr.H attrout=hxxsmallcdp.H >xxsmallcdp.H n3=306

big&:
	time Cubify axis2=OFFSET axis3=CDP-X <xxall.data.H attrfile=xxall.hdr.H attrout=hxxallcdp.H >xxallcdp.H

