📄 prog.tex
字号:
\noindent\doublebox{\parbox{\textwidth}{\input{sfcut}}}The \texttt{sfcut} command is related to \texttt{sfwindow} and has the sameset of arguments only instead of extracting the selected window, it fills itwith zeroes. The size of the input data is preserved. Examples:\begin{verbatim}bash$ sfspike n1=5 n2=5 > in.rsfbash$ < in.rsf sfdisfil 0: 1 1 1 1 1 5: 1 1 1 1 1 10: 1 1 1 1 1 15: 1 1 1 1 1 20: 1 1 1 1 1bash$ < in.rsf sfcut n1=2 f1=1 n2=3 f2=2 | sfdisfil 0: 1 1 1 1 1 5: 1 1 1 1 1 10: 1 0 0 1 1 15: 1 0 0 1 1 20: 1 0 0 1 1bash$ < in.rsf sfcut j1=2 | sfdisfil 0: 0 1 0 1 0 5: 0 1 0 1 0 10: 0 1 0 1 0 15: 0 1 0 1 0 20: 0 1 0 1 0\end{verbatim}\noindent\doublebox{\parbox{\textwidth}{\input{sfdd}}}The \texttt{sfdd} program is used to change either the form (\texttt{ascii},\texttt{xdr}, \texttt{native}) or the type (\texttt{complex}, \texttt{float},\texttt{int}, \texttt{char}) of the input dataset. In the example below, we create a plain text (ASCII) file with numbers andthen use \texttt{sfdd} to generate an RSF file in \texttt{xdr} form with\texttt{complex} numbers. \begin{verbatim}bash$ cat test.txt1 2 3 4 5 6bash$ echo n1=6 data_format=ascii_int in=test.txt > test.rsfbash$ sfin test.rsftest.rsf: in="test.txt" esize=0 type=int form=ascii n1=6 d1=? o1=? 6 elementsbash$ sfdd < test.rsf form=xdr type=complex > test2.rsfbash$ sfin test2.rsftest2.rsf: in="/tmp/test2.rsf@" esize=8 type=complex form=xdr n1=3 d1=? o1=? 3 elements 24 bytesbash$ sfdisfil < test2.rsf 0: 1, 2i 3, 4i 5, 6i\end{verbatim}To learn more about the data format in RSF, consult the\href{http://egl.beg.utexas.edu/RSF/book/rsf/rsf/format_html/}{guide to RSF format}.\noindent\doublebox{\parbox{\textwidth}{\input{sfdisfil}}}The \texttt{sfdisfil} program simply dumps the data contents to the standardoutput in a text form. It is used mostly for debugging purposes to quicklyexamine RSF files. Here is an example:\begin{verbatim}bash$ sfmath o1=0 d1=2 n1=12 output=x1 > test.rsfbash$ < test.rsf sfdisfil 0: 0 2 4 6 8 5: 10 12 14 16 18 10: 20 22\end{verbatim}The output format is easily configurable.\begin{verbatim}bash$ < test.rsf sfdisfil col=6 number=n format="%5.1f" 0.0 2.0 4.0 6.0 8.0 10.0 12.0 14.0 16.0 18.0 20.0 22.0\end{verbatim}Along with \texttt{sfdd}, \texttt{sfdisfil} provides a simple way to convertRSF data to an ASCII form.\noindent\doublebox{\parbox{\textwidth}{ \input{sfdottest}}}\texttt{sfdottest} is a generic dot-product test program for testinglinear operators. Suppose there is an executable program\texttt{<prog>} that takes an RSF file from the standard input andproduces an RSF file in the standard output. It may take any number ofadditional parameters but one of them must be \texttt{adj=} that setsthe forward (\texttt{adj=0}) or adjoint (\texttt{adj=1}) operations.The program \texttt{<prog>} is typically an RSF program but it couldbe anything (a script, a multiprocessor MPI program, etc.) as long asit implements a linear operator $\mathbf{L}$ and its adjoint$\mathbf{L}^T$. The \texttt{sfdottest} program is testing the equality\begin{equation}\label{eq:dptest}\mathbf{d}^T\,\mathbf{L}\,\mathbf{m} = \mathbf{m}^T\,\mathbf{L}^T\,\mathbf{d}\end{equation}by using random vectors $\mathbf{m}$ and $\mathbf{d}$. You can invoke it with\begin{verbatim}bash$ sfdottest <prog> [optional aruments] mod=mod.rsf dat=dat.rsf\end{verbatim}where \texttt{mod.rsf} and \texttt{dat.rsf} are RSF files thatrepresent vectors from the model and data spaces. \texttt{sfdottest}does not create any temporary files and does not have any restrictivelimitations on the size of the vectors.Here is an example. We first setup a vector with 100 elements using\texttt{sfspike} and then run \texttt{sfdottest} to test the\texttt{sfcausint} program. \texttt{sfcausint} implements a linearoperator of causal integration and its adjoint, the anti-causalintegration.\begin{verbatim}bash$ sfspike n1=100 > vec.rsfbash$ sfdottest sfcausint mod=vec.rsf dat=vec.rsfsfdottest: L[m]*d=1410.2sfdottest: L'[d]*m=1410.2bash$ sfdottest sfcausint mod=vec.rsf dat=vec.rsfsfdottest: L[m]*d=1165.87sfdottest: L'[d]*m=1165.87\end{verbatim}The numbers are different on subsequent runs because of changingseed in the random number generator.Here is a somewhat more complicated example. The \texttt{sfhelicon}program implements Claerbout's multidimensional helical filtering\cite[]{GEO63-05-15321541}. It requires a filter to be specified inaddition to the input and output vectors. We create a helical 2-D filter using the Unix \texttt{echo} command.\begin{verbatim}bash$ echo 1 19 20 n1=3 n=20,20 data_format=ascii_int in=lag.rsf > lag.rsfbash$ echo 1 1 1 a0=-3 n1=3 data_format=ascii_float in=flt.rsf > flt.rsf\end{verbatim}Next, we create an example 2-D model and data vector with \texttt{sfspike}.\begin{verbatim}bash$ sfspike n1=50 n2=50 > vec.rsf\end{verbatim}Now the \texttt{sfdottest} program can perform the dot product test.\begin{verbatim}bash$ sfdottest sfhelicon filt=flt.rsf lag=lag.rsf \> mod=vec.rsf dat=vec.rsfsfdottest: L[m]*d=8.97375sfdottest: L'[d]*m=8.97375\end{verbatim}Here is the same program tested in the inverse filtering mode:\begin{verbatim}bash$ sfdottest sfhelicon filt=flt.rsf lag=lag.rsf \> mod=vec.rsf dat=vec.rsf inv=ysfdottest: L[m]*d=15.0222sfdottest: L'[d]*m=15.0222\end{verbatim}\noindent\doublebox{\parbox{\textwidth}{\input{sfget}}}The \texttt{sfget} program extracts a parameter value from an RSF file. It isuseful mostly for scripting. Here is, for example, a quick calculation of themaximum value on the first axis in an RSF dataset (the output of\texttt{sfspike}) using the standard Unix \texttt{bc} calculator.\begin{verbatim}bash$ ( sfspike n1=100 | sfget n1 d1 o1; echo "o1+(n1-1)*d1" ) | bc.396\end{verbatim}See also \texttt{sfput}.\noindent\doublebox{\parbox{\textwidth}{\input{sfheaderattr}}}The \texttt{sfheaderattr} examines the contents of a trace header file,typically generated by \texttt{sfsegyread}. In the example below, we examinetrace headers in the output of \texttt{suplane}, a program from Seismic Unix.\begin{verbatim}bash$ suplane > plane.subash$ sfsegyread tape=plane.su su=y tfile=tfile.rsf > plane.rsfbash$ sfheaderattr < tfile.rsf*******************************************71 headers, 32 traceskey[0]="tracl" min[0]=1 max[31]=32 mean=16.5key[1]="tracr" min[0]=1 max[31]=32 mean=16.5key[11]="offset" min[0]=400 max[31]=400 mean=400key[38]="ns" min[0]=64 max[31]=64 mean=64key[39]="dt" min[0]=4000 max[31]=4000 mean=4000*******************************************\end{verbatim}For different standard keywords, a minimum, maximum, and mean valuesare reported unless they are identically zero. This quick inspectioncan help in identifying meaningful keywords set in the data. The inputdata type must be \texttt{int}.\noindent\doublebox{\parbox{\textwidth}{ \input{sfheadercut} }}\texttt{sfheadercut} is close to \texttt{sfheaderwindow} but insteadof windowing the dataset, it fills the traces specified by the headermask with zeroes. The size of the input data is preserved.Here is an example of using \texttt{sfheaderwindow} for zeroing every other trace in the input file. First, let us createan input file with ten traces:\begin{verbatim}bash$ sfmath n1=5 n2=10 output=x2+1 > input.rsfbash$ < input.rsf sfdisfil 0: 1 1 1 1 1 5: 2 2 2 2 2 10: 3 3 3 3 3 15: 4 4 4 4 4 20: 5 5 5 5 5 25: 6 6 6 6 6 30: 7 7 7 7 7 35: 8 8 8 8 8 40: 9 9 9 9 9 45: 10 10 10 10 10\end{verbatim}Next, we can create a mask with alternating ones and zeros using\texttt{sfinterleave}.\begin{verbatim}bash$ sfspike n1=5 mag=1 | sfdd type=int > ones.rsfbash$ sfspike n1=5 mag=0 | sfdd type=int > zeros.rsfbash$ sfinterleave axis=1 ones.rsf zeros.rsf > mask.rsfbash$ sfdisfil < mask.rsf 0: 1 0 1 0 1 0 1 0 1 0\end{verbatim}Finally, \texttt{sfheadercut} zeros the input traces.\begin{verbatim}bash$ sfheadercut < input.rsf mask=mask.rsf > output.rsfbash$ sfdisfil < output.rsf 0: 1 1 1 1 1 5: 0 0 0 0 0 10: 3 3 3 3 3 15: 0 0 0 0 0 20: 5 5 5 5 5 25: 0 0 0 0 0 30: 7 7 7 7 7 35: 0 0 0 0 0 40: 9 9 9 9 9 45: 0 0 0 0 0\end{verbatim}\noindent\doublebox{\parbox{\textwidth}{\input{sfheadermath}}}\texttt{sfheadermath} is a versatile program for mathematicaloperations on rows of the input file. If the input file is an\texttt{n1} by \texttt{n2} matrix, the output will be a \texttt{1} by\texttt{n2} matrix that contains one row made out of mathematicaloperations on the other rows. \texttt{sfheadermath} can identify a rowby number or by a standard SEGY keyword. The latter is useful forprocessing headers extracted from SEGY or SU files.Here is an example. First, we create an SU file with \texttt{suplane} and convert it to RSF using \texttt{sfsegyread}.\begin{verbatim}bash$ suplane > plane.subash$ sfsegyread tape=plane.su su=y tfile=tfile.rsf > plane.rsf\end{verbatim}The trace header information is saved in \texttt{tfile.rsf}. Itcontains 71 headers for 32 traces in integer format.\begin{verbatim}bash$ sfin tfile.rsftfile.rsf: in="/tmp/tfile.rsf@" esize=4 type=int form=native n1=71 d1=? o1=? n2=32 d2=? o2=? 2272 elements 9088 bytes\end{verbatim}Next, we will convert \texttt{tfile.rsf} to a floating-point formatand run \texttt{sfheadermath} to create a new header.\begin{verbatim}bash$ < tfile.rsf sfdd type=float | \sfheadermath myheader=1 output="sqrt(myheader+(2+10*offset^2))" > new.rsfbash$ sfin new.rsfnew.rsf: in="/tmp/new.rsf@" esize=4 type=float form=native n1=1 d1=? o1=? n2=32 d2=? o2=? 32 elements 128 bytes\end{verbatim}We defined ``myheader'' as being the row number 1 in the input (notethat numbering starts with 0) and combined it with ``offset'', which
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -