#!/bin/sh # /******************* self documentation **********************/ DOC () { echo ' SEP2SU - transform sep-data to SU-data sep2su "in.sep" [optional parameters] | .... Optional Parameters: [in[file]=]"in.sep" the input sep file verbose=0 =1, for diagnostic print on stdout ftn=0 =1, data written unformatted from Fortran other options that you forgot to put in "in.sep" Here "in.sep" is a SEP header file. This utility assumes that the binary file pointed to by the "in=" keyword contains seismic data. In particular the first axis is treated as a time axis. The data dimension of the file may be at most three, as the SEGY and SU formats require. The keyword bintype determines the meanings of the second and the third axes in the "in.sep" file: bintype="csg": axis2=offset axis3=shot bintype="cog": axis2=shot axis3=offset bintype="cmp": axis2=offset axis3=cmp bintype="cdp": axis2=offset axis3=cmp If not set in the "in.sep" file, bintype defaults to "csg". Half-offset instead of offset is signified by halfoffset=1; the halfoffset keyword defaults to 0. Note that in agreement with SU practice the header cdp denotes the CMP location in the same coordinates as source and receiver locations (sx and gx), NOT the cdp number as is conventional in SEGY usage. Default input units are ms and m. If the data is given in other units, namely s or km, the units are converted provided that the aXIs units, n=1, 2, 3, keyword is set in the "in.sep" file. The f1,d1,f2,d2 optional SU headers are defined and dimnesioned in s and km respectively for plotting purposes. The possible parameters in the "in.sep" file are: n1, n2, n3, o1, o2, o3, d1, d2, d3, esize, in, bintype, halfoffset, dim, rd, zsrc, zrec, aXIs1 unit, aXIs2 unit, aXIs3 unit, zsrc unit, zrec unit. The June.97 version adapts (ignores) spaces put around "=" for arguments: in command line input and in the "in.sep" file.' } # /**************** end self doc ********************************/ # Author: Seongjai Kim October-8-1996 # modified WWS 30.10.96 # rev SKIM, June-11-1997 PATH=:/bin:/usr/bin:/usr/ucb:$CWPROOT/bin_${OSTYPE} infile= verbose=0 ftn=0 OPT= #------------------------------------------- #--- read optional parameters -------------- #------------------------------------------- case $# in 0) DOC | more -20 1>&2; exit 1 ;; *) ARGS="`echo $* | sed -e 's/\ =/=/g' -e 's/=\ /=/g' -e 's/\"//g'`" for i in $ARGS do case $i in verb*=*) verbose=`echo $i | sed 's/verb.*=//'` ;; in*=*) infile=`echo $i | sed 's/in.*=//'` ;; ftn=*) ftn=`echo $i | sed 's/ftn=//'` ;; a*s1) OPT="$OPT $i" ;; a*s2) OPT="$OPT $i" ;; a*s3) OPT="$OPT $i" ;; zsrc) OPT="$OPT $i" ;; zrec) OPT="$OPT $i" ;; *=*) OPT="$OPT $i" ;; *) infile=$i ;; esac done ;; esac if test "$infile" = "" ; then infile=$stdin elif test ! -f "$infile" ; then echo 1>&2 ; echo " There is no file named \"$infile\"" 1>&2 echo 1>&2 ; echo " To stop the program, press ^C " 1>&2 sleep 604800 ; exit 1 fi #------------------------------------------- #--- get information from your "*.sep" ----- #------------------------------------------- unit1=ms ; unit2=m ; unit3=m unitdata=; unitzsrc=m ; unitzrec=m n1=101; o1=0 ; d1=4 n2=1 ; o2=0 ; d2=0 n3=1 ; o3=0 ; d3=0 bintype=csg; halfoffset=0 zsrc=0 ; zrec=0 TERMS="`cat $infile` $OPT" TERMS="`echo $TERMS | sed -e 's/\ =/=/g' -e 's/=\ /=/g' -e 's/\"//g'`" for term in $TERMS ; do case $term in n1=*) n1=`echo $term | sed 's/n1=//'` ;; n2=*) n2=`echo $term | sed 's/n2=//'` ;; n3=*) n3=`echo $term | sed 's/n3=//'` ;; o1=*) o1=`echo $term | sed 's/o1=//'` ;; o2=*) o2=`echo $term | sed 's/o2=//'` ;; o3=*) o3=`echo $term | sed 's/o3=//'` ;; d1=*) d1=`echo $term | sed 's/d1=//'` ;; d2=*) d2=`echo $term | sed 's/d2=//'` ;; d3=*) d3=`echo $term | sed 's/d3=//'` ;; esize=*) esize=`echo $term | sed 's/esize=//'` ;; in=*) in=`echo $term | sed -e 's/in=//'` ;; bintype=*) bintype=`echo $term | sed -e 's/bintype=//'` ;; halfoffset=*) halfoffset=`echo $term | sed 's/halfoffset=//'` ;; dim=*) dim=`echo $term | sed 's/dim=//'` ;; rd=*) rd=`echo $term | sed 's/rd=//'` ;; zsrc=*) zsrc=`echo $term | sed 's/zsrc=//'` ;; zrec=*) zrec=`echo $term | sed 's/zrec=//'` ;; ftn=*) ftn=`echo $term | sed 's/ftn=//'` ;; a*s1) axis=1 ;; a*s2) axis=2 ;; a*s3) axis=3 ;; data) axis=data ;; zsrc) axis=zsrc ;; zrec) axis=zrec ;; unit=*) case $axis in 1) unit1=`echo $term | sed -e 's/unit=//'` ;; 2) unit2=`echo $term | sed -e 's/unit=//'` ;; 3) unit3=`echo $term | sed -e 's/unit=//'` ;; data) unitdata=`echo $term | sed -e 's/unit=//'` ;; zsrc) unitzsrc=`echo $term | sed -e 's/unit=//'` ;; zrec) unitzrec=`echo $term | sed -e 's/unit=//'` ;; esac ;; esac done #--------------------------------------------------- # ------- adjust the parameters -------------------- #--------------------------------------------------- unit1=`echo $unit1 | tr "[A-Z]" "[a-z]"` unit2=`echo $unit2 | tr "[A-Z]" "[a-z]"` unit3=`echo $unit3 | tr "[A-Z]" "[a-z]"` unitdata=`echo $unitdata | tr "[A-Z]" "[a-z]"` unitzsrc=`echo $unitzsrc | tr "[A-Z]" "[a-z]"` unitzrec=`echo $unitzrec | tr "[A-Z]" "[a-z]"` bintype=`echo $bintype | tr "[A-Z]" "[a-z]"` #----- set half offset adjustment -------- if test $halfoffset -eq 1 ; then d2=`bc -l <&2 if test $ftn -eq 1; then echo " that was written unformatted from Fortran" 1>&2 fi fi if test $bintype = "cmp" ; then bintype=cdp fi if test "$bintype" = "csg" ; then kw2=offset; kw3=sx ; gcd=1 ck1=cdp ; ck2=sx c2b=1 ; c2d=2 elif test "$bintype" = "cog" ; then kw2=sx ; kw3=offset; gcd=1 ck1=cdp ; ck2=sx c2b=1 ; c2d=2 elif test "$bintype" = "cdp" ; then kw2=offset; kw3=cdp ; gcd=2 ck1=sx ; ck2=offset c2b=-1 ; c2d=1 else echo "unknown gather type: bintype=$bintype" 1>&2; exit 1 fi if test $verbose -eq 1 ; then echo " SEP to SU conversion of `echo $bintype | tr '[a-z]' '[A-Z]'` DATA suaddhead ns=$n1 ftn=$ftn < $in | sushw key=dt,f1,d1,f2,d2 a=$dt,$o1s,$d1s,$o2km,$d2km | [ sushw key=dt a=$dt | ] sushw key=sdepth,gelev a=$zsrc,$zrec | sushw key=$kw2 a=$o2 b=$d2 c=0 j=$n2 | sushw key=$kw3 a=$o3 b=0 c=$d3 j=$n2 | suchw key1=gx key2=$kw2 key3=$kw3 a=0 b=1 c=$gcd d=$gcd | suchw key1=$ck1 key2=$ck2 key3=gx a=0 b=$c2b c=1 d=$c2d " 1>&2 fi #sushw key=dt a=$dt | #sushw key=dt,f1,d1,f2,d2 a=$dt,$o1s,$d1s,$o2km,$d2km | suaddhead ns=$n1 ftn=$ftn < $in | sushw key=dt,f1,d1,f2,d2 a=$dt,$o1s,$d1s,$o2km,$d2km | sushw key=sdepth,gelev a=$zsrc,$zrec | sushw key=$kw2 a=$o2 b=$d2 c=0 j=$n2 | sushw key=$kw3 a=$o3 b=0 c=$d3 j=$n2 | suchw key1=gx key2=$kw2 key3=$kw3 a=0 b=1 c=$gcd d=$gcd | suchw key1=$ck1 key2=$ck2 key3=gx a=0 b=$c2b c=1 d=$c2d