<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://ahay.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Vnikitin</id>
	<title>Madagascar - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://ahay.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Vnikitin"/>
	<link rel="alternate" type="text/html" href="https://ahay.org/wiki/Special:Contributions/Vnikitin"/>
	<updated>2026-04-19T19:49:11Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.42.7</generator>
	<entry>
		<id>https://ahay.org/index.php?title=Guide_to_madagascar_programs&amp;diff=1964</id>
		<title>Guide to madagascar programs</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Guide_to_madagascar_programs&amp;diff=1964"/>
		<updated>2011-08-02T05:56:45Z</updated>

		<summary type="html">&lt;p&gt;Vnikitin: /* sfdisfil */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;center&amp;gt;&amp;lt;font size=&amp;quot;-1&amp;quot;&amp;gt;&#039;&#039;This page was created from the LaTeX source in [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/book/rsf/rsf/prog.tex?view=markup book/rsf/rsf/prog.tex] using [[latex2wiki]]&#039;&#039;&amp;lt;/font&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This guide introduces some of the most used &amp;lt;tt&amp;gt;madagascar&amp;lt;/tt&amp;gt; programs and illustrates their usage with examples.&lt;br /&gt;
=Main programs=&lt;br /&gt;
The source files for these programs can be found under [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/ system/main] in the Madagascar distribution. The &amp;quot;main&amp;quot; programs perform general-purpose operations on RSF hypercubes regardless of the data dimensionality or physical dimensions.&lt;br /&gt;
&lt;br /&gt;
==sfadd==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Add, multiply, or divide  RSF datasets.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfadd &amp;gt; out.rsf scale= add= sqrt= abs= log= exp= mode= [&amp;lt; file0.rsf] file1.rsf file2.rsf ...&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | The various operations, if selected, occur in the following order:&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;(1) Take absolute value, abs=&amp;lt;br&amp;gt;(2) Add a scalar, add=&amp;lt;br&amp;gt;(3) Take the natural logarithm, log=&amp;lt;br&amp;gt;(4) Take the square root, sqrt=&amp;lt;br&amp;gt;(5) Multiply by a scalar, scale=&amp;lt;br&amp;gt;(6) Compute the base-e exponential, exp=&amp;lt;br&amp;gt;(7) Add, multiply, or divide the data sets, mode=&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sfadd operates on integer, float, or complex data, but all the input&amp;lt;br&amp;gt;and output files must be of the same data type.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;An alternative to sfadd is sfmath, which is more versatile, but may be&amp;lt;br&amp;gt;less efficient.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bools  &#039;&#039; || &#039;&#039;&#039;abs=&#039;&#039;&#039; ||   || 	If true take absolute value  [nin]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;floats &#039;&#039; || &#039;&#039;&#039;add=&#039;&#039;&#039; ||   || 	Scalar values to add to each dataset  [nin]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bools  &#039;&#039; || &#039;&#039;&#039;exp=&#039;&#039;&#039; ||   || 	If true compute exponential  [nin]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bools  &#039;&#039; || &#039;&#039;&#039;log=&#039;&#039;&#039; ||   || 	If true take logarithm  [nin]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;mode=&#039;&#039;&#039; ||   || 	&#039;a&#039; means add (default), &amp;lt;br&amp;gt;       &#039;p&#039; or &#039;m&#039; means multiply, &amp;lt;br&amp;gt;       &#039;d&#039; means divide&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;floats &#039;&#039; || &#039;&#039;&#039;scale=&#039;&#039;&#039; ||   || 	Scalar values to multiply each dataset with  [nin]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bools  &#039;&#039; || &#039;&#039;&#039;sqrt=&#039;&#039;&#039; ||   || 	If true take square root  [nin]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfadd&amp;lt;/tt&amp;gt; is useful for combining (adding, dividing, or&lt;br /&gt;
multiplying) several datasets. What if you want to subtract two&lt;br /&gt;
datasets? Easy. Use the &amp;lt;tt&amp;gt;scale&amp;lt;/tt&amp;gt; parameter as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfadd data1.rsf data2.rsf scale=1,-1 &amp;gt; diff.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfadd &amp;lt; data1.rsf data2.rsf scale=1,-1 &amp;gt; diff.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The same task can be accomplished with the more general &amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt; program:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath one=data1.rsf two=data2.rsf output=&#039;one-two&#039; &amp;gt; diff.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath &amp;lt; data1.rsf two=data2.rsf output=&#039;input-two&#039; &amp;gt; diff.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In both cases, the size and shape of &amp;lt;tt&amp;gt;data1.rsf&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;data2.rsf&amp;lt;/tt&amp;gt; hypercubes should be the same, and a warning&lt;br /&gt;
message is printed out if the the axis sampling parameters (such as&lt;br /&gt;
&amp;lt;tt&amp;gt;o1&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;d1&amp;lt;/tt&amp;gt;) in these files are different.&lt;br /&gt;
====Implementation: [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/add.c?view=markup system/main/add.c]====&lt;br /&gt;
The first input file is either in the list or in the standard input.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* find number of input files */&lt;br /&gt;
    if (isatty(fileno(stdin))) { &lt;br /&gt;
        /* no input file in stdin */&lt;br /&gt;
	nin=0;&lt;br /&gt;
    } else {&lt;br /&gt;
	in[0] = sf_input(&amp;quot;in&amp;quot;);&lt;br /&gt;
	nin=1;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Collect input files in the &amp;lt;tt&amp;gt;in&amp;lt;/tt&amp;gt; array from all command-line&lt;br /&gt;
parameters that don&#039;t contain an &amp;quot;&amp;lt;tt&amp;gt;=&amp;lt;/tt&amp;gt;&amp;quot; sign. The total number&lt;br /&gt;
of input files in &amp;lt;tt&amp;gt;nin&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (i=1; i&amp;lt; argc; i++) { /* collect inputs */&lt;br /&gt;
	if (NULL != strchr(argv[i],&#039;=&#039;)) continue; &lt;br /&gt;
	in[nin] = sf_input(argv[i]);&lt;br /&gt;
	nin++;&lt;br /&gt;
    }&lt;br /&gt;
    if (0==nin) sf_error (&amp;quot;no input&amp;quot;);&lt;br /&gt;
    /* nin = no of input files*/&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A helper function &amp;lt;tt&amp;gt;check_compat&amp;lt;/tt&amp;gt; checks the compatibility of&lt;br /&gt;
input files.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
static void &lt;br /&gt;
check_compat (sf_datatype type /* data type */, &lt;br /&gt;
	      size_t      nin  /* number of files */, &lt;br /&gt;
	      sf_file*    in   /* input files [nin] */, &lt;br /&gt;
	      int         dim  /* file dimensionality */, &lt;br /&gt;
	      const int*  n    /* dimensions [dim] */)&lt;br /&gt;
/* Check that the input files are compatible. &lt;br /&gt;
   Issue error for type mismatch or size mismatch.&lt;br /&gt;
   Issue warning for grid parameters mismatch. */&lt;br /&gt;
{&lt;br /&gt;
    int ni, id;&lt;br /&gt;
    size_t i;&lt;br /&gt;
    float d, di, o, oi;&lt;br /&gt;
    char key[3];&lt;br /&gt;
    const float tol=1.e-5; /* tolerance for comparison */&lt;br /&gt;
    &lt;br /&gt;
    for (i=1; i &amp;lt; nin; i++) {&lt;br /&gt;
	if (sf_gettype(in[i]) != type) &lt;br /&gt;
	    sf_error (&amp;quot;type mismatch: need %d&amp;quot;,type);&lt;br /&gt;
	for (id=1; id &amp;lt;= dim; id++) {&lt;br /&gt;
	    (void) snprintf(key,3,&amp;quot;n%d&amp;quot;,id);&lt;br /&gt;
	    if (!sf_histint(in[i],key,&amp;amp;ni) || ni != n[id-1])&lt;br /&gt;
		sf_error(&amp;quot;%s mismatch: need %d&amp;quot;,key,n[id-1]);&lt;br /&gt;
	    (void) snprintf(key,3,&amp;quot;d%d&amp;quot;,id);&lt;br /&gt;
	    if (sf_histfloat(in[0],key,&amp;amp;d)) {&lt;br /&gt;
		if (!sf_histfloat(in[i],key,&amp;amp;di) || &lt;br /&gt;
		    (fabsf(di-d) &amp;gt; tol*fabsf(d)))&lt;br /&gt;
		    sf_warning(&amp;quot;%s mismatch: need %g&amp;quot;,key,d);&lt;br /&gt;
	    } else {&lt;br /&gt;
		d = 1.;&lt;br /&gt;
	    }&lt;br /&gt;
	    (void) snprintf(key,3,&amp;quot;o%d&amp;quot;,id);&lt;br /&gt;
	    if (sf_histfloat(in[0],key,&amp;amp;o) &amp;amp;&amp;amp; &lt;br /&gt;
		(!sf_histfloat(in[i],key,&amp;amp;oi) || &lt;br /&gt;
		 (fabsf(oi-o) &amp;gt; tol*fabsf(d))))&lt;br /&gt;
		sf_warning(&amp;quot;%s mismatch: need %g&amp;quot;,key,o);&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we enter the main loop, where input data are getting read&lt;br /&gt;
buffer by buffer and combined in the total product depending on the&lt;br /&gt;
data type.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (nbuf /= sf_esize(in[0]); nsiz &amp;gt; 0; nsiz -= nbuf) {&lt;br /&gt;
	if (nbuf &amp;gt; nsiz) nbuf=nsiz;&lt;br /&gt;
&lt;br /&gt;
	for (j=0; j &amp;lt; nin; j++) {&lt;br /&gt;
	    collect = (bool) (j != 0);&lt;br /&gt;
	    switch(type) {&lt;br /&gt;
		case SF_FLOAT:&lt;br /&gt;
		    sf_floatread((float*) bufi,&lt;br /&gt;
				 nbuf,&lt;br /&gt;
				 in[j]);	    &lt;br /&gt;
		    add_float(collect, &lt;br /&gt;
			      nbuf,&lt;br /&gt;
			      (float*) buf,&lt;br /&gt;
			      (const float*) bufi, &lt;br /&gt;
			      cmode, &lt;br /&gt;
			      scale[j], &lt;br /&gt;
			      add[j], &lt;br /&gt;
			      abs_flag[j], &lt;br /&gt;
			      log_flag[j], &lt;br /&gt;
			      sqrt_flag[j], &lt;br /&gt;
			      exp_flag[j]);&lt;br /&gt;
		    break;&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The data combination program for floating point numbers is&lt;br /&gt;
&amp;lt;tt&amp;gt;add_float&amp;lt;/tt&amp;gt;.  &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
static void add_float (bool   collect,    /* if collect */&lt;br /&gt;
		       size_t nbuf,       /* buffer size */&lt;br /&gt;
		       float* buf,        /* output [nbuf] */&lt;br /&gt;
		       const float* bufi, /* input  [nbuf] */  &lt;br /&gt;
		       char   cmode,      /* operation */&lt;br /&gt;
		       float  scale,      /* scale factor */&lt;br /&gt;
		       float  add,        /* add factor */&lt;br /&gt;
		       bool   abs_flag,   /* if abs */&lt;br /&gt;
		       bool   log_flag,   /* if log */&lt;br /&gt;
		       bool   sqrt_flag,  /* if sqrt */&lt;br /&gt;
		       bool   exp_flag    /* if exp */)&lt;br /&gt;
/* Add floating point numbers */&lt;br /&gt;
{&lt;br /&gt;
    size_t j;&lt;br /&gt;
    float f;&lt;br /&gt;
&lt;br /&gt;
    for (j=0; j &amp;lt; nbuf; j++) {&lt;br /&gt;
	f = bufi[j];&lt;br /&gt;
	if (abs_flag)    f = fabsf(f);&lt;br /&gt;
	f += add;&lt;br /&gt;
	if (log_flag)    f = logf(f);&lt;br /&gt;
	if (sqrt_flag)   f = sqrtf(f);&lt;br /&gt;
	if (1. != scale) f *= scale;&lt;br /&gt;
	if (exp_flag)    f = expf(f);&lt;br /&gt;
	if (collect) {&lt;br /&gt;
	    switch (cmode) {&lt;br /&gt;
		case &#039;p&#039;: /* product */&lt;br /&gt;
		case &#039;m&#039;: /* multiply */&lt;br /&gt;
		    buf[j] *= f;&lt;br /&gt;
		    break;&lt;br /&gt;
		case &#039;d&#039;: /* delete */&lt;br /&gt;
		    if (f != 0.) buf[j] /= f;&lt;br /&gt;
		    break;&lt;br /&gt;
		default:  /* add */&lt;br /&gt;
		    buf[j] += f;&lt;br /&gt;
		    break;&lt;br /&gt;
	    }&lt;br /&gt;
	} else {&lt;br /&gt;
	    buf[j] = f;&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfattr==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Display dataset attributes.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfattr &amp;lt; in.rsf want=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; |    &amp;lt;br&amp;gt;Sample output from &amp;quot;sfspike n1=100 | sfbandpass fhi=60 | sfattr&amp;quot;&amp;lt;br&amp;gt;******************************************* &amp;lt;br&amp;gt;rms = 0.992354 &amp;lt;br&amp;gt;mean value = 0.987576 &amp;lt;br&amp;gt;2-norm value = 9.92354 &amp;lt;br&amp;gt;variance = 0.00955481 &amp;lt;br&amp;gt;standard deviation = 0.0977487 &amp;lt;br&amp;gt;maximum value = 1.12735 at 97 &amp;lt;br&amp;gt;minimum value = 0.151392 at 100 &amp;lt;br&amp;gt;number of nonzero samples = 100 &amp;lt;br&amp;gt;total number of samples = 100 &amp;lt;br&amp;gt;******************************************* &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;rms                = sqrt[ sum(data^2) / n ]&amp;lt;br&amp;gt;mean               = sum(data) / n&amp;lt;br&amp;gt;norm               = sum(abs(data)^lval)^(1/lval)&amp;lt;br&amp;gt;variance           = [ sum(data^2) - n*mean^2 ] / [ n-1 ]&amp;lt;br&amp;gt;standard deviation = sqrt [ variance ]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int &#039;&#039; || &#039;&#039;&#039;lval=2&#039;&#039;&#039; ||   || 	norm option, lval is a non-negative integer, computes the vector lval-norm&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;want=&#039;&#039;&#039; ||   || 	&#039;all&#039;(default),&#039;rms&#039;,&#039;mean&#039;,&#039;norm&#039;,&#039;var&#039;,&#039;std&#039;,&#039;max&#039;,&#039;min&#039;,&#039;nonzero&#039;,&#039;samples&#039;,&#039;short&#039; &lt;br /&gt;
:want=   &#039;rms&#039; displays the root mean square&lt;br /&gt;
:want=   &#039;norm&#039; displays the square norm, otherwise specified by lval.&lt;br /&gt;
:want=   &#039;var&#039; displays the variance&lt;br /&gt;
:want=   &#039;std&#039; displays the standard deviation&lt;br /&gt;
:want=   &#039;nonzero&#039; displays number of nonzero samples&lt;br /&gt;
:want=   &#039;samples&#039; displays total number of samples&lt;br /&gt;
:want=   &#039;short&#039; displays a short one-line version&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfattr&amp;lt;/tt&amp;gt; is a useful diagnostic program. It reports certain&lt;br /&gt;
statistical values for an RSF dataset: RMS (root-mean-square)&lt;br /&gt;
amplitude, mean value, vector norm value, variance, standard deviation,&lt;br /&gt;
maximum and minimum values, number of nonzero samples, and the total&lt;br /&gt;
number of samples.&lt;br /&gt;
If we denote data values as &amp;lt;math&amp;gt;d_i&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt;i=0,1,2,\ldots,n&amp;lt;/math&amp;gt;, then the RMS&lt;br /&gt;
value is &amp;lt;math&amp;gt;\sqrt{\frac{1}{n}\,\sum\limits_{i=0}^n d_i^2}&amp;lt;/math&amp;gt;, the mean&lt;br /&gt;
value is &amp;lt;math&amp;gt;\frac{1}{n}\,\sum\limits_{i=0}^n d_i&amp;lt;/math&amp;gt;, the &amp;lt;math&amp;gt;L_2&amp;lt;/math&amp;gt;-norm value&lt;br /&gt;
is &amp;lt;math&amp;gt;\sqrt{\sum\limits_{i=0}^n d_i^2}&amp;lt;/math&amp;gt;, the variance is&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{n-1}\,\left[\sum\limits_{i=0}^n d_i^2 - \frac{1}{n}\left(\sum\limits_{i=0}^n d_i\right)^2\right]&amp;lt;/math&amp;gt;, and the standard&lt;br /&gt;
deviation is the square root of the variance. Using &amp;lt;tt&amp;gt;sfattr&amp;lt;/tt&amp;gt;&lt;br /&gt;
is a quick way to see the distribution of data values and check it for anomalies.&lt;br /&gt;
&lt;br /&gt;
The output can be parsed using utilities such as &amp;lt;tt&amp;gt;awk&amp;lt;/tt&amp;gt;, to extract only a numeric value for feeding it as a parameter value into a command line interface. Notice the backticks in the example below:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfgrey &amp;lt;vel.rsf allpos=y bias=`sfattr &amp;lt;vel.rsf want=min | awk &#039;{print $4}&#039;` | sfpen&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Implementation: [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/attr.c?view=markup system/main/attr.c]====&lt;br /&gt;
&lt;br /&gt;
Computations start by finding the input data (&amp;lt;tt&amp;gt;in&amp;lt;/tt&amp;gt;) size&lt;br /&gt;
(&amp;lt;tt&amp;gt;nsiz&amp;lt;/tt&amp;gt;) and dimensions (&amp;lt;tt&amp;gt;dim&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    dim = (size_t) sf_filedims (in,n);&lt;br /&gt;
    for (nsiz=1, i=0; i &amp;lt; dim; i++) {&lt;br /&gt;
	nsiz *= n[i];&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the main loop, we read the input data buffer by buffer.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (nleft=nsiz; nleft &amp;gt; 0; nleft -= nbuf) {&lt;br /&gt;
	nbuf = (bufsiz &amp;lt; nleft)? bufsiz: nleft;&lt;br /&gt;
	switch (type) {&lt;br /&gt;
	    case SF_FLOAT: &lt;br /&gt;
		sf_floatread((float*) buf,nbuf,in);&lt;br /&gt;
		break;&lt;br /&gt;
	    case SF_INT:&lt;br /&gt;
		sf_intread((int*) buf,nbuf,in);&lt;br /&gt;
		break;&lt;br /&gt;
	    case SF_COMPLEX:&lt;br /&gt;
		sf_complexread((sf_complex*) buf,nbuf,in);&lt;br /&gt;
		break;&lt;br /&gt;
	    case SF_UCHAR:&lt;br /&gt;
		sf_ucharread((unsigned char*) buf,nbuf,in);&lt;br /&gt;
		break;&lt;br /&gt;
	    case SF_CHAR:&lt;br /&gt;
	    default:&lt;br /&gt;
		sf_charread(buf,nbuf,in);&lt;br /&gt;
		break;&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The data attributes are accumulated in corresponding double-precision&lt;br /&gt;
variables. &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
	    fsum += f;&lt;br /&gt;
	    fsqr += f*f;&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, the attributes are reduced and printed out.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    fmean = fsum/nsiz;&lt;br /&gt;
    if (lval==2)      fnorm = sqrt(fsqr);&lt;br /&gt;
    else if (lval==0) fnorm = nsiz-nzero;&lt;br /&gt;
    else              fnorm = pow(flval,1./lval);&lt;br /&gt;
    frms = sqrt(fsqr/nsiz);&lt;br /&gt;
    if (nsiz &amp;gt; 1) fvar = (fsqr-nsiz*fmean*fmean)/(nsiz-1);&lt;br /&gt;
    else          fvar = 0.0;&lt;br /&gt;
    fstd = sqrt(fvar);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    if(NULL==want || 0==strcmp(want,&amp;quot;rms&amp;quot;))&lt;br /&gt;
	printf(&amp;quot;rms = %g \n&amp;quot;,(float) frms);&lt;br /&gt;
    if(NULL==want || 0==strcmp(want,&amp;quot;mean&amp;quot;))&lt;br /&gt;
	printf(&amp;quot;mean value = %g \n&amp;quot;,(float) fmean);&lt;br /&gt;
    if(NULL==want || 0==strcmp(want,&amp;quot;norm&amp;quot;))&lt;br /&gt;
	printf(&amp;quot;%d-norm value = %g \n&amp;quot;,lval,(float) fnorm);&lt;br /&gt;
    if(NULL==want || 0==strcmp(want,&amp;quot;var&amp;quot;))&lt;br /&gt;
	printf(&amp;quot;variance = %g \n&amp;quot;,(float) fvar);&lt;br /&gt;
    if(NULL==want || 0==strcmp(want,&amp;quot;std&amp;quot;))&lt;br /&gt;
	printf(&amp;quot;standard deviation = %g \n&amp;quot;,(float) fstd);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfcat==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Concatenate datasets. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcat &amp;gt; out.rsf space= axis=3 nspace=(int) (ni/(20*nin) + 1) [&amp;lt;file0.rsf] file1.rsf file2.rsf ... &lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | sfmerge inserts additional space between merged data.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axis=3&#039;&#039;&#039; ||   || 	Axis being merged&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nspace=(int) (ni/(20*nin) + 1)&#039;&#039;&#039; ||   || 	if space=y, number of traces to insert&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;space=&#039;&#039;&#039; ||  [y/n] || 	Insert additional space.&lt;br /&gt;
:y is default for sfmerge, n is default for sfcat&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfcat&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sfmerge&amp;lt;/tt&amp;gt; concatenate two or more files&lt;br /&gt;
together along a particular axis. It is the same program, only&lt;br /&gt;
&amp;lt;tt&amp;gt;sfcat&amp;lt;/tt&amp;gt; has the default &amp;lt;tt&amp;gt;space=n&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sfmerge&amp;lt;/tt&amp;gt;&lt;br /&gt;
has the default &amp;lt;tt&amp;gt;space=y&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Example of &amp;lt;tt&amp;gt;sfcat&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=2 n2=3 &amp;gt; one.rsf&lt;br /&gt;
bash$ sfin one.rsf&lt;br /&gt;
one.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/one.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=2           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        6 elements 24 bytes&lt;br /&gt;
bash$ sfcat one.rsf one.rsf axis=1 &amp;gt; two.rsf&lt;br /&gt;
bash$ sfin two.rsf&lt;br /&gt;
two.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/two.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=4           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        12 elements 48 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Example of &amp;lt;tt&amp;gt;sfmerge&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmerge one.rsf one.rsf axis=2 &amp;gt; two.rsf&lt;br /&gt;
bash$ sfin two.rsf&lt;br /&gt;
two.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/two.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=2           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=7           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        14 elements 56 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this case, an extra empty trace is inserted between the two merged files.&lt;br /&gt;
The axes that are not being merged are checked for consistency:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfcat one.rsf two.rsf &amp;gt; three.rsf&lt;br /&gt;
sfcat: n2 mismatch: need 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Implementation: [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/cat.c?view=markup system/main/cat.c]====&lt;br /&gt;
The first input file is either in the list or in the standard input.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    in = (sf_file*) sf_alloc ((size_t) argc,sizeof(sf_file));&lt;br /&gt;
&lt;br /&gt;
    if (!sf_stdin()) { /* no input file in stdin */&lt;br /&gt;
	nin=0;&lt;br /&gt;
    } else {&lt;br /&gt;
	in[0] = sf_input(&amp;quot;in&amp;quot;);&lt;br /&gt;
	nin=1;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Everything on the command line that does not contain a &amp;quot;=&amp;quot; sign is&lt;br /&gt;
treated as a file name, and the corresponding file object is added to the list.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (i=1; i&amp;lt; argc; i++) { /* collect inputs */&lt;br /&gt;
	if (NULL != strchr(argv[i],&#039;=&#039;)) &lt;br /&gt;
	    continue; /* not a file */&lt;br /&gt;
	in[nin] = sf_input(argv[i]);&lt;br /&gt;
	nin++;&lt;br /&gt;
    }&lt;br /&gt;
    if (0==nin) sf_error (&amp;quot;no input&amp;quot;);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As explained above, if the &amp;lt;tt&amp;gt;space=&amp;lt;/tt&amp;gt; parameter is not set, it is&lt;br /&gt;
inferred from the program name: &amp;lt;tt&amp;gt;sfmerge&amp;lt;/tt&amp;gt; corresponds to&lt;br /&gt;
&amp;lt;tt&amp;gt;space=y&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sfcat&amp;lt;/tt&amp;gt; corresponds to &amp;lt;tt&amp;gt;space=n&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    if (!sf_getbool(&amp;quot;space&amp;quot;,&amp;amp;space)) {&lt;br /&gt;
	/* Insert additional space.&lt;br /&gt;
	   y is default for sfmerge, n is default for sfcat */&lt;br /&gt;
	prog = sf_getprog();&lt;br /&gt;
	if (NULL != strstr (prog, &amp;quot;merge&amp;quot;)) {&lt;br /&gt;
	    space = true;&lt;br /&gt;
	} else if (NULL != strstr (prog, &amp;quot;cat&amp;quot;)) {&lt;br /&gt;
	    space = false;&lt;br /&gt;
	} else {&lt;br /&gt;
	    sf_warning(&amp;quot;%s is neither merge nor cat,&amp;quot;&lt;br /&gt;
		       &amp;quot; assume merge&amp;quot;,prog);&lt;br /&gt;
	    space = true;&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the axis for the merging (from the command line &amp;lt;tt&amp;gt;axis=&amp;lt;/tt&amp;gt;&lt;br /&gt;
argument) and figure out two sizes: &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; for everything after&lt;br /&gt;
the axis and &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt; for everything before the axis.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    n1=1;&lt;br /&gt;
    n2=1;&lt;br /&gt;
    for (i=1; i &amp;lt;= dim; i++) {&lt;br /&gt;
	if      (i &amp;lt; axis) n1 *= n[i-1];&lt;br /&gt;
	else if (i &amp;gt; axis) n2 *= n[i-1];&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the output, the selected axis will get extended.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* figure out the length of extended axis */&lt;br /&gt;
    ni = 0;&lt;br /&gt;
    for (j=0; j &amp;lt; nin; j++) {&lt;br /&gt;
	ni += naxis[j];&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    if (space) {&lt;br /&gt;
	if (!sf_getint(&amp;quot;nspace&amp;quot;,&amp;amp;nspace)) &lt;br /&gt;
	    nspace = (int) (ni/(20*nin) + 1);&lt;br /&gt;
	/* if space=y, number of traces to insert */ &lt;br /&gt;
	ni += nspace*(nin-1);&lt;br /&gt;
    } &lt;br /&gt;
&lt;br /&gt;
    (void) snprintf(key,3,&amp;quot;n%d&amp;quot;,axis);&lt;br /&gt;
    sf_putint(out,key,(int) ni);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The rest is simple: loop through the datasets reading and writing the&lt;br /&gt;
data in buffer-size chunks and adding extra empty chunks if&lt;br /&gt;
&amp;lt;tt&amp;gt;space=y&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (i2=0; i2 &amp;lt; n2; i2++) {&lt;br /&gt;
	for (j=0; j &amp;lt; nin; j++) {&lt;br /&gt;
	    for (ni = n1*naxis[j]*esize; ni &amp;gt; 0; ni -= nbuf) {&lt;br /&gt;
		nbuf = (BUFSIZ &amp;lt; ni)? BUFSIZ: ni;&lt;br /&gt;
		sf_charread (buf,nbuf,in[j]);&lt;br /&gt;
		sf_charwrite (buf,nbuf,out);&lt;br /&gt;
	    }&lt;br /&gt;
	    if (!space || j == nin-1) continue;&lt;br /&gt;
	    /* Add spaces */&lt;br /&gt;
	    memset(buf,0,BUFSIZ);&lt;br /&gt;
	    for (ni = n1*nspace*esize; ni &amp;gt; 0; ni -= nbuf) {&lt;br /&gt;
		nbuf = (BUFSIZ &amp;lt; ni)? BUFSIZ: ni;&lt;br /&gt;
		sf_charwrite (buf,nbuf,out);&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfcdottest==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generic dot-product test for complex linear operators with adjoints &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcdottest mod=mod.rsf dat=dat.rsf &amp;gt; pip.rsf&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;dat=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;mod=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
A simple demonstration of the program can be made taking advantage that the complex-to-complex FFT is a linear operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfspike n1=100 | sfrtoc &amp;gt; spike.rsf&lt;br /&gt;
&amp;lt; spike.rsf sffft axis=1 pad=1 &amp;gt; spike2.rsf&lt;br /&gt;
sfcdottest sffft mod=spike.rsf dat=spike2.rsf axis=1 pad=1&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should show values identical down to the last decimal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfcdottest:  L[m]*d=(3.73955,-1.86955)&lt;br /&gt;
sfcdottest: L&#039;[d]*m=(3.73955,-1.86955)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfcmplx==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Create a complex dataset from its real and imaginary parts.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcmplx &amp;gt; cmplx.rsf real.rsf imag.rsf&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | There has to be only two input files specified and no additional parameters.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfcmplx&amp;lt;/tt&amp;gt; simply creates a complex dataset from its real and&lt;br /&gt;
imaginary parts. The reverse operation can be accomplished with&lt;br /&gt;
&amp;lt;tt&amp;gt;sfreal&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sfimag&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Example of &amp;lt;tt&amp;gt;sfcmplx&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=2 n2=3 &amp;gt; one.rsf&lt;br /&gt;
bash$ sfin one.rsf&lt;br /&gt;
one.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/one.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=2           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        6 elements 24 bytes&lt;br /&gt;
bash$ sfcmplx one.rsf one.rsf &amp;gt; cmplx.rsf&lt;br /&gt;
bash$ sfin cmplx.rsf&lt;br /&gt;
cmplx.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/cmplx.rsf@&amp;quot;&lt;br /&gt;
    esize=8 type=complex form=native&lt;br /&gt;
    n1=2           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        6 elements 48 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Implementation: [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/cmplx.c?view=markup system/main/cmplx.c]====&lt;br /&gt;
The program flow is simple. First, get the names of the input files.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* the first two non-parameters are real and imaginary files */&lt;br /&gt;
    for (i=1; i&amp;lt; argc; i++) { &lt;br /&gt;
	if (NULL == strchr(argv[i],&#039;=&#039;)) {&lt;br /&gt;
	    if (NULL == real) {&lt;br /&gt;
		real = sf_input (argv[i]);&lt;br /&gt;
	    } else {&lt;br /&gt;
		imag = sf_input (argv[i]);&lt;br /&gt;
		break;&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    if (NULL == imag) {&lt;br /&gt;
	if (NULL == real) sf_error (&amp;quot;not enough input&amp;quot;);&lt;br /&gt;
	/* if only one input, real is in stdin */&lt;br /&gt;
	imag = real;&lt;br /&gt;
	real = sf_input(&amp;quot;in&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The main part of the program reads the real and imaginary parts buffer by buffer and assembles and writes out the complex input. &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (nleft= (size_t) (rsize*resize); nleft &amp;gt; 0; nleft -= nbuf) {&lt;br /&gt;
	nbuf = (BUFSIZ &amp;lt; nleft)? BUFSIZ: nleft;&lt;br /&gt;
	sf_charread(rbuf,nbuf,real);&lt;br /&gt;
	sf_charread(ibuf,nbuf,imag);&lt;br /&gt;
	for (i=0; i &amp;lt; nbuf; i += resize) {&lt;br /&gt;
	    memcpy(cbuf+2*i,       rbuf+i,(size_t) resize);&lt;br /&gt;
	    memcpy(cbuf+2*i+resize,ibuf+i,(size_t) resize);&lt;br /&gt;
	}&lt;br /&gt;
	sf_charwrite(cbuf,2*nbuf,cmplx);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
==sfconjgrad==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generic conjugate-gradient solver for linear inversion &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfconjgrad &amp;lt; dat.rsf mod=mod.rsf &amp;gt; to.rsf &amp;lt; from.rsf &amp;gt; out.rsf niter=1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;niter=1&#039;&#039;&#039; ||   || 	number of iterations&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfconjgrad&amp;lt;/tt&amp;gt; is a generic program for least-squares linear&lt;br /&gt;
inversion with the [http://en.wikipedia.org/wiki/Conjugate_gradient_method conjugate-gradient method]. Suppose you have an&lt;br /&gt;
executable program &amp;lt;tt&amp;gt;&amp;lt;prog&amp;gt;&amp;lt;/tt&amp;gt; that takes an RSF file from the&lt;br /&gt;
standard input and produces an RSF file in the standard output. It may&lt;br /&gt;
take any number of additional parameters but one of them must be&lt;br /&gt;
&amp;lt;tt&amp;gt;adj=&amp;lt;/tt&amp;gt; that sets the forward (&amp;lt;tt&amp;gt;adj=0&amp;lt;/tt&amp;gt;) or adjoint&lt;br /&gt;
(&amp;lt;tt&amp;gt;adj=1&amp;lt;/tt&amp;gt;) operations.  The program &amp;lt;tt&amp;gt;&amp;lt;prog&amp;gt;&amp;lt;/tt&amp;gt; is typically&lt;br /&gt;
an RSF program but it could be anything (a script, a multiprocessor&lt;br /&gt;
MPI program, etc.) as long as it implements a linear operator&lt;br /&gt;
&amp;lt;math&amp;gt;\mathbf{L}&amp;lt;/math&amp;gt; and its adjoint. There are no restrictions on the data&lt;br /&gt;
size or shape. You can easily test the adjointness with&lt;br /&gt;
&amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt;. The &amp;lt;tt&amp;gt;sfconjgrad&amp;lt;/tt&amp;gt; program searches for a&lt;br /&gt;
vector &amp;lt;math&amp;gt;\mathbf{m}&amp;lt;/math&amp;gt; that minimizes the least-square misfit &lt;br /&gt;
&amp;lt;math&amp;gt;\|\mathbf{d - L\,m}\|^2&amp;lt;/math&amp;gt; for the given input data vector &amp;lt;math&amp;gt;\mathbf{d}&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
The pseudocode for &amp;lt;tt&amp;gt;sfconjgrad&amp;lt;/tt&amp;gt; is given at the end of the [http://www.reproducibility.org/RSF/book/gee/lsq/paper.pdf &amp;quot;Model fitting with least squares&amp;quot; chapter] of &#039;&#039;Imaging Estimation by Example&#039;&#039; by Jon Claerbout, with the earliest form published in [http://sepwww.stanford.edu/data/media/public/oldreports/sep48/48_25.pdf &amp;quot;Conjugate Gradient Tutorial&amp;quot;] (SEP-48, 1986, same author). A simple toy implementation with a small matrix shows that this is algorithm produces the same steps as the algorithm described in equations 45-49 of [http://www.cs.cmu.edu/~quake-papers/painless-conjugate-gradient.pdf &amp;quot;An introduction to the Conjugate Gradient Method Without the Agonizing Pain&amp;quot;] by J.R. Shewchuk, 1994, when the equation &amp;lt;math&amp;gt;A^T A x = A^T b&amp;lt;/math&amp;gt; (in Shewchuk&#039;s notation) is solved. Multiplying with the transpose ensures a correct solution even when matrix A is square but not symmetric, or not square at all. The program [http://www.reproducibility.org/RSF/sfcconjgrad.html sfcconjgrad] implements this algorithm for the case when inputs are complex.&lt;br /&gt;
&lt;br /&gt;
Here is an example. The &amp;lt;tt&amp;gt;sfhelicon&amp;lt;/tt&amp;gt;&lt;br /&gt;
program implements Claerbout&#039;s multidimensional helical filtering&lt;br /&gt;
(Claerbout, 1998&amp;lt;ref&amp;gt;Claerbout, J.,  1998, Multidimensional recursive filters via a helix:  Geophysics, &#039;&#039;&#039;63&#039;&#039;&#039;, 1532--1541.&amp;lt;/ref&amp;gt;). It requires a filter to be specified in&lt;br /&gt;
addition to the input and output vectors. We create a helical &lt;br /&gt;
2-D filter using the Unix &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ echo 1 19 20 n1=3 n=20,20 data_format=ascii_int in=lag.rsf &amp;gt; lag.rsf&lt;br /&gt;
bash$ echo 1 1 1 a0=-3 n1=3 data_format=ascii_float in=flt.rsf &amp;gt; flt.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Next, we create an example 2-D model and data vector with &amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=50 n2=50 &amp;gt; vec.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt; program can perform the dot product test to&lt;br /&gt;
check that the adjoint mode works correctly.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfdottest sfhelicon filt=flt.rsf lag=lag.rsf \&lt;br /&gt;
&amp;gt; mod=vec.rsf dat=vec.rsf&lt;br /&gt;
sfdottest:  L[m]*d=5.28394&lt;br /&gt;
sfdottest: L&#039;[d]*m=5.28394&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Your numbers may be different because &amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt; generates new&lt;br /&gt;
random input on each run.&lt;br /&gt;
Next, let us make some random data with &amp;lt;tt&amp;gt;sfnoise&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfnoise seed=2005 rep=y &amp;lt; vec.rsf &amp;gt; dat.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and try to invert the filtering operation using &amp;lt;tt&amp;gt;sfconjgrad&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfconjgrad sfhelicon filt=flt.rsf lag=lag.rsf \&lt;br /&gt;
mod=vec.rsf &amp;lt; dat.rsf &amp;gt; mod.rsf niter=10&lt;br /&gt;
sfconjgrad: iter 1 of 10&lt;br /&gt;
sfconjgrad: grad=3253.65&lt;br /&gt;
sfconjgrad: iter 2 of 10&lt;br /&gt;
sfconjgrad: grad=289.421&lt;br /&gt;
sfconjgrad: iter 3 of 10&lt;br /&gt;
sfconjgrad: grad=92.3481&lt;br /&gt;
sfconjgrad: iter 4 of 10&lt;br /&gt;
sfconjgrad: grad=36.9417&lt;br /&gt;
sfconjgrad: iter 5 of 10&lt;br /&gt;
sfconjgrad: grad=18.7228&lt;br /&gt;
sfconjgrad: iter 6 of 10&lt;br /&gt;
sfconjgrad: grad=11.1794&lt;br /&gt;
sfconjgrad: iter 7 of 10&lt;br /&gt;
sfconjgrad: grad=7.26941&lt;br /&gt;
sfconjgrad: iter 8 of 10&lt;br /&gt;
sfconjgrad: grad=5.15945&lt;br /&gt;
sfconjgrad: iter 9 of 10&lt;br /&gt;
sfconjgrad: grad=4.23055&lt;br /&gt;
sfconjgrad: iter 10 of 10&lt;br /&gt;
sfconjgrad: grad=3.57495&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The output shows that, in 10 iterations, the norm of the gradient vector decreases by almost 1000. &lt;br /&gt;
We can check the residual misfit before&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; dat.rsf sfattr want=norm&lt;br /&gt;
norm value = 49.7801&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and after&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfhelicon filt=flt.rsf lag=lag.rsf &amp;lt; mod.rsf | \&lt;br /&gt;
sfadd scale=1,-1 dat.rsf | sfattr want=norm&lt;br /&gt;
norm value = 5.73563&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In 10 iterations, the misfit decreased by an order of magnitude. The&lt;br /&gt;
result can be improved by running the program for more iterations.&lt;br /&gt;
&lt;br /&gt;
An equivalent implementation for complex-valued inputs is [http://www.reproducibility.org/RSF/sfcconjgrad.html sfcconjgrad]. A simple, lightweight Python implementation can be found in [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/user/fomels/conjgrad.py?view=markup $RSFROOT/lib/conjgrad.py].&lt;br /&gt;
&lt;br /&gt;
==sfcp==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Copy or move a dataset.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcp in.rsf out.rsf&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | sfcp - copy, sfmv - move.&amp;lt;br&amp;gt;Mimics standard Unix commands.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfcp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sfmv&amp;lt;/tt&amp;gt; command imitate the Unix&lt;br /&gt;
&amp;lt;tt&amp;gt;cp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;mv&amp;lt;/tt&amp;gt; commands and serve for copying and moving&lt;br /&gt;
RSF files. Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=2 n2=3 &amp;gt; one.rsf&lt;br /&gt;
bash$ sfin one.rsf&lt;br /&gt;
one.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/one.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=2           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        6 elements 24 bytes&lt;br /&gt;
bash$ sfcp one.rsf two.rsf&lt;br /&gt;
bash$ sfin two.rsf&lt;br /&gt;
two.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/two.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=2           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        6 elements 24 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Implementation: [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/cp.c?view=markup system/main/cp.c]====&lt;br /&gt;
First, we look for the two first command-line arguments that don&#039;t&lt;br /&gt;
have the &amp;quot;=&amp;quot; character in them and consider them as the names of the&lt;br /&gt;
input and the output files.  &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* the first two non-parameters are in and out files */&lt;br /&gt;
    for (i=1; i&amp;lt; argc; i++) { &lt;br /&gt;
	if (NULL == strchr(argv[i],&#039;=&#039;)) {&lt;br /&gt;
	    if (NULL == in) {&lt;br /&gt;
		infile = argv[i];&lt;br /&gt;
		in = sf_input (infile);&lt;br /&gt;
	    } else {&lt;br /&gt;
		out = sf_output (argv[i]);&lt;br /&gt;
		break;&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    if (NULL == in || NULL == out)&lt;br /&gt;
	sf_error (&amp;quot;not enough input&amp;quot;);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we use library functions &amp;lt;font color=&amp;quot;#cd4b19&amp;quot;&amp;gt;sf_cp&amp;lt;/font&amp;gt; and &amp;lt;font color=&amp;quot;#cd4b19&amp;quot;&amp;gt;sf_rm&amp;lt;/font&amp;gt; to do the actual work.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    sf_cp(in,out);&lt;br /&gt;
    if (NULL != strstr (sf_getprog(),&amp;quot;mv&amp;quot;)) &lt;br /&gt;
	sf_rm(infile,false,false,false);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfcut==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Zero a portion of the dataset. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcut &amp;lt; in.rsf &amp;gt; out.rsf verb=n [j1=1 j2=1 ... f1=0 f2=0 ... n1=n1 n2=n2 ... max1= max2= ... min1= min2= ...]&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | jN defines the jump in N-th dimension&amp;lt;br&amp;gt;fN is the window start&amp;lt;br&amp;gt;nN is the window size&amp;lt;br&amp;gt;minN and maxN is the maximum and minimum in N-th dimension&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Reverse of window. &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	Verbosity flag&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfcut&amp;lt;/tt&amp;gt; command is related to &amp;lt;tt&amp;gt;sfwindow&amp;lt;/tt&amp;gt; and has the same&lt;br /&gt;
set of arguments only instead of extracting the selected window, it fills it&lt;br /&gt;
with zeroes. The size of the input data is preserved. &lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=5 n2=5 &amp;gt; in.rsf&lt;br /&gt;
bash$ &amp;lt; in.rsf sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
  15:             1            1            1            1            1&lt;br /&gt;
  20:             1            1            1            1            1&lt;br /&gt;
bash$ &amp;lt; in.rsf sfcut n1=2 f1=1 n2=3 f2=2 | sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            0            0            1            1&lt;br /&gt;
  15:             1            0            0            1            1&lt;br /&gt;
  20:             1            0            0            1            1&lt;br /&gt;
bash$ &amp;lt; in.rsf sfcut j1=2 | sfdisfil&lt;br /&gt;
   0:             0            1            0            1            0&lt;br /&gt;
   5:             0            1            0            1            0&lt;br /&gt;
  10:             0            1            0            1            0&lt;br /&gt;
  15:             0            1            0            1            0&lt;br /&gt;
  20:             0            1            0            1            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfdd==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Convert between different formats. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfdd &amp;lt; in.rsf &amp;gt; out.rsf line=8 form= type= format=&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;form=&#039;&#039;&#039; ||   || 	ascii, native, xdr&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;format=&#039;&#039;&#039; ||   || 	Element format (for conversion to ASCII)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;line=8&#039;&#039;&#039; ||   || 	Number of numbers per line (for conversion to ASCII)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;type=&#039;&#039;&#039; ||   || 	int, float, complex&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfdd&amp;lt;/tt&amp;gt; program is used to change either the form (&amp;lt;tt&amp;gt;ascii&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;xdr&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;native&amp;lt;/tt&amp;gt;) or the type (&amp;lt;tt&amp;gt;complex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;float&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;int&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;char&amp;lt;/tt&amp;gt;) of the input dataset. &lt;br /&gt;
In the example below, we create a plain text (ASCII) file with numbers and&lt;br /&gt;
then use &amp;lt;tt&amp;gt;sfdd&amp;lt;/tt&amp;gt; to generate an RSF file in &amp;lt;tt&amp;gt;xdr&amp;lt;/tt&amp;gt; form with&lt;br /&gt;
&amp;lt;tt&amp;gt;complex&amp;lt;/tt&amp;gt; numbers. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ cat test.txt&lt;br /&gt;
1 2 3 4 5 6&lt;br /&gt;
bash$ echo n1=6 data_format=ascii_int in=test.txt &amp;gt; test.rsf&lt;br /&gt;
bash$ sfin test.rsf&lt;br /&gt;
test.rsf:&lt;br /&gt;
    in=&amp;quot;test.txt&amp;quot;&lt;br /&gt;
    esize=0 type=int form=ascii&lt;br /&gt;
    n1=6           d1=?           o1=?&lt;br /&gt;
        6 elements&lt;br /&gt;
bash$ sfdd &amp;lt; test.rsf form=xdr type=complex &amp;gt; test2.rsf&lt;br /&gt;
bash$ sfin test2.rsf&lt;br /&gt;
test2.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/test2.rsf@&amp;quot;&lt;br /&gt;
    esize=8 type=complex form=xdr&lt;br /&gt;
    n1=3           d1=?           o1=?&lt;br /&gt;
        3 elements 24 bytes&lt;br /&gt;
bash$ sfdisfil &amp;lt; test2.rsf&lt;br /&gt;
   0:          1,         2i         3,         4i         5,         6i&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To learn more about the RSF data format, consult the [[Guide to RSF file format| guide to RSF format]].&lt;br /&gt;
&lt;br /&gt;
==sfdisfil==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Print out data values.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfdisfil &amp;lt; in.rsf number=y col=0 format= header= trailer=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Alternatively, use sfdd and convert to ASCII form.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;col=0&#039;&#039;&#039; ||   || 	Number of columns.&lt;br /&gt;
:The default depends on the data type:&lt;br /&gt;
:10 for int and char,&lt;br /&gt;
:5 for float,&lt;br /&gt;
:3 for complex&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;format=&#039;&#039;&#039; ||   || 	Format for numbers (printf-style).&lt;br /&gt;
:The default depends on the data type:&amp;lt;br&amp;gt;       &amp;quot;%4d &amp;quot; for int and char,&amp;lt;br&amp;gt;       &amp;quot;%13.4g&amp;quot; for float,&amp;lt;br&amp;gt;       &amp;quot;%10.4g,%10.4gi&amp;quot; for complex&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;header=&#039;&#039;&#039; ||   || 	Optional header string to output before data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;number=y&#039;&#039;&#039; ||  [y/n] || 	If number the elements&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;trailer=&#039;&#039;&#039; ||   || 	Optional trailer string to output after data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfdisfil&amp;lt;/tt&amp;gt; program simply dumps the data contents to the standard&lt;br /&gt;
output in a text form. It is used mostly for debugging purposes to quickly&lt;br /&gt;
examine RSF files. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath o1=0 d1=2 n1=12 output=x1 &amp;gt; test.rsf&lt;br /&gt;
bash$ &amp;lt; test.rsf sfdisfil&lt;br /&gt;
   0:             0            2            4            6            8&lt;br /&gt;
   5:            10           12           14           16           18&lt;br /&gt;
  10:            20           22&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The output format is easily configurable.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfdisfil col=6 number=n format=&amp;quot;%5.1f&amp;quot;&lt;br /&gt;
  0.0  2.0  4.0  6.0  8.0 10.0&lt;br /&gt;
 12.0 14.0 16.0 18.0 20.0 22.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Along with &amp;lt;tt&amp;gt;sfdd&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sfdisfil&amp;lt;/tt&amp;gt; provides a simple way to convert&lt;br /&gt;
RSF data to an ASCII form.&lt;br /&gt;
&lt;br /&gt;
==sfdottest==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generic dot-product test for linear operators with adjoints &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfdottest mod=mod.rsf dat=dat.rsf &amp;gt; pip.rsf&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt; is a generic dot-product test program for testing&lt;br /&gt;
linear operators. Suppose there is an executable program&lt;br /&gt;
&amp;lt;tt&amp;gt;&amp;lt;prog&amp;gt;&amp;lt;/tt&amp;gt; that takes an RSF file from the standard input and&lt;br /&gt;
produces an RSF file in the standard output. It may take any number of&lt;br /&gt;
additional parameters but one of them must be &amp;lt;tt&amp;gt;adj=&amp;lt;/tt&amp;gt; that sets&lt;br /&gt;
the forward (&amp;lt;tt&amp;gt;adj=0&amp;lt;/tt&amp;gt;) or adjoint (&amp;lt;tt&amp;gt;adj=1&amp;lt;/tt&amp;gt;) operations.&lt;br /&gt;
The program &amp;lt;tt&amp;gt;&amp;lt;prog&amp;gt;&amp;lt;/tt&amp;gt; is typically an RSF program but it could&lt;br /&gt;
be anything (a script, a multiprocessor MPI program, etc.) as long as&lt;br /&gt;
it implements a linear operator &amp;lt;math&amp;gt;\mathbf{L}&amp;lt;/math&amp;gt; and its adjoint&lt;br /&gt;
&amp;lt;math&amp;gt;\mathbf{L}^T&amp;lt;/math&amp;gt;. The &amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt; program is testing the equality&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
d^T\,L\,m = m^T\,L^T\,d&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
by using random vectors &amp;lt;math&amp;gt;\mathbf{m}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{d}&amp;lt;/math&amp;gt;. You can invoke it with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfdottest &amp;lt;prog&amp;gt; [optional aruments] mod=mod.rsf dat=dat.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
where &amp;lt;tt&amp;gt;mod.rsf&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;dat.rsf&amp;lt;/tt&amp;gt; are RSF files that&lt;br /&gt;
represent vectors from the model and data spaces. Pay attention to the &lt;br /&gt;
dimension and size of these vectors! If the program does not respond&lt;br /&gt;
for a very long time, it is quite possible that the dimension and size&lt;br /&gt;
of the vectors are inconsistent with the requirement of the program to be&lt;br /&gt;
tested. &amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt;&lt;br /&gt;
does not create any temporary files and does not have any restrictive&lt;br /&gt;
limitations on the size of the vectors.&lt;br /&gt;
Here is an example. We first setup a vector with 100 elements using&lt;br /&gt;
&amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt; and then run &amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt; to test the&lt;br /&gt;
&amp;lt;tt&amp;gt;sfcausint&amp;lt;/tt&amp;gt; program. &amp;lt;tt&amp;gt;sfcausint&amp;lt;/tt&amp;gt; implements a linear&lt;br /&gt;
operator of causal integration and its adjoint, the anti-causal&lt;br /&gt;
integration.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=100 &amp;gt; vec.rsf&lt;br /&gt;
bash$ sfdottest sfcausint mod=vec.rsf dat=vec.rsf&lt;br /&gt;
sfdottest:  L[m]*d=1410.2&lt;br /&gt;
sfdottest: L&#039;[d]*m=1410.2&lt;br /&gt;
bash$ sfdottest sfcausint mod=vec.rsf dat=vec.rsf&lt;br /&gt;
sfdottest:  L[m]*d=1165.87&lt;br /&gt;
sfdottest: L&#039;[d]*m=1165.87&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The numbers are different on subsequent runs because of changing&lt;br /&gt;
seed in the random number generator.&lt;br /&gt;
Here is a somewhat more complicated example. The &amp;lt;tt&amp;gt;sfhelicon&amp;lt;/tt&amp;gt;&lt;br /&gt;
program implements Claerbout&#039;s multidimensional helical filtering&lt;br /&gt;
(Claerbout, 1998&amp;lt;ref&amp;gt;Claerbout, J.,  1998, Multidimensional recursive filters via a helix:  Geophysics, &#039;&#039;&#039;63&#039;&#039;&#039;, 1532--1541.&amp;lt;/ref&amp;gt;). It requires a filter to be specified in&lt;br /&gt;
addition to the input and output vectors. We create a helical &lt;br /&gt;
2-D filter using the Unix &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ echo 1 19 20 n1=3 n=20,20 data_format=ascii_int in=lag.rsf &amp;gt; lag.rsf&lt;br /&gt;
bash$ echo 1 1 1 a0=-3 n1=3 data_format=ascii_float in=flt.rsf &amp;gt; flt.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Next, we create an example 2-D model and data vector with &amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=50 n2=50 &amp;gt; vec.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now the &amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt; program can perform the dot product test.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfdottest sfhelicon filt=flt.rsf lag=lag.rsf \&lt;br /&gt;
&amp;gt; mod=vec.rsf dat=vec.rsf&lt;br /&gt;
sfdottest:  L[m]*d=8.97375&lt;br /&gt;
sfdottest: L&#039;[d]*m=8.97375&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here is the same program tested in the inverse filtering mode:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfdottest sfhelicon filt=flt.rsf lag=lag.rsf \&lt;br /&gt;
&amp;gt; mod=vec.rsf dat=vec.rsf div=y&lt;br /&gt;
sfdottest:  L[m]*d=15.0222&lt;br /&gt;
sfdottest: L&#039;[d]*m=15.0222&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfget==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Output parameters from the header.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfget &amp;lt; in.rsf parform=y par1 par2 ...&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;parform=y&#039;&#039;&#039; ||  [y/n] || 	If y, print out parameter=value. If n, print out value.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfget&amp;lt;/tt&amp;gt; program extracts a parameter value from an RSF file. It is&lt;br /&gt;
useful mostly for scripting. Here is, for example, a quick calculation of the&lt;br /&gt;
maximum value on the first axis in an RSF dataset (the output of&lt;br /&gt;
&amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt;) using the standard Unix &amp;lt;tt&amp;gt;bc&amp;lt;/tt&amp;gt; calculator.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ ( sfspike n1=100 | sfget n1 d1 o1; echo &amp;quot;o1+(n1-1)*d1&amp;quot; ) | bc&lt;br /&gt;
.396&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
See also &amp;lt;tt&amp;gt;sfput&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
====Implementation: [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/get.c?view=markup system/main/get.c]====&lt;br /&gt;
The implementation is trivial. Loop through all command-line parameters that contain &lt;br /&gt;
the &amp;quot;=&amp;quot; character.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (i = 1; i &amp;lt; argc; i++) {&lt;br /&gt;
	key = argv[i];&lt;br /&gt;
	if (NULL != strchr(key,&#039;=&#039;)) continue;&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the parameter value (as string) and output it as either&lt;br /&gt;
&amp;lt;tt&amp;gt;key=value&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt;, depending on the&lt;br /&gt;
&amp;lt;tt&amp;gt;parform&amp;lt;/tt&amp;gt; parameter.  &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
	string = sf_histstring(in,key);&lt;br /&gt;
	if (NULL == string) {&lt;br /&gt;
	    sf_warning(&amp;quot;No key %s&amp;quot;,key);&lt;br /&gt;
	} else {&lt;br /&gt;
	    if (parform) printf (&amp;quot;%s=&amp;quot;,key);&lt;br /&gt;
	    printf(&amp;quot;%s\n&amp;quot;,string);&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfheadercut==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Zero a portion of a dataset based on a header mask.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfheadercut mask=head.rsf &amp;lt; in.rsf &amp;gt; out.rsf&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;The input data is a collection of traces n1xn2,&amp;lt;br&amp;gt;mask is an integer array of size n2.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfheadercut&amp;lt;/tt&amp;gt; is close to &amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; but instead&lt;br /&gt;
of windowing the dataset, it fills the traces specified by the header&lt;br /&gt;
mask with zeroes. The size of the input data is preserved.&lt;br /&gt;
Here is an example of using &amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; for &lt;br /&gt;
zeroing every other trace in the input file. First, let us create&lt;br /&gt;
an input file with ten traces:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=5 n2=10 output=x2+1 &amp;gt; input.rsf&lt;br /&gt;
bash$ &amp;lt; input.rsf sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             2            2            2            2            2&lt;br /&gt;
  10:             3            3            3            3            3&lt;br /&gt;
  15:             4            4            4            4            4&lt;br /&gt;
  20:             5            5            5            5            5&lt;br /&gt;
  25:             6            6            6            6            6&lt;br /&gt;
  30:             7            7            7            7            7&lt;br /&gt;
  35:             8            8            8            8            8&lt;br /&gt;
  40:             9            9            9            9            9&lt;br /&gt;
  45:            10           10           10           10           10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Next, we can create a mask with alternating ones and zeros using&lt;br /&gt;
&amp;lt;tt&amp;gt;sfinterleave&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=5 mag=1 | sfdd type=int &amp;gt; ones.rsf&lt;br /&gt;
bash$ sfspike n1=5 mag=0 | sfdd type=int &amp;gt; zeros.rsf&lt;br /&gt;
bash$ sfinterleave axis=1 ones.rsf zeros.rsf &amp;gt; mask.rsf&lt;br /&gt;
bash$ sfdisfil &amp;lt; mask.rsf&lt;br /&gt;
   0:    1    0    1    0    1    0    1    0    1    0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finally, &amp;lt;tt&amp;gt;sfheadercut&amp;lt;/tt&amp;gt; zeros the input traces.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfheadercut &amp;lt; input.rsf mask=mask.rsf &amp;gt; output.rsf&lt;br /&gt;
bash$ sfdisfil &amp;lt; output.rsf &lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             0            0            0            0            0&lt;br /&gt;
  10:             3            3            3            3            3&lt;br /&gt;
  15:             0            0            0            0            0&lt;br /&gt;
  20:             5            5            5            5            5&lt;br /&gt;
  25:             0            0            0            0            0&lt;br /&gt;
  30:             7            7            7            7            7&lt;br /&gt;
  35:             0            0            0            0            0&lt;br /&gt;
  40:             9            9            9            9            9&lt;br /&gt;
  45:             0            0            0            0            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==sfheadersort==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Sort a dataset according to a header key. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfheadersort &amp;lt; in.rsf &amp;gt; out.rsf head=&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;head=&#039;&#039;&#039; ||   || 	header file&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfheadersort&amp;lt;/tt&amp;gt; is used to sort traces in the input file&lt;br /&gt;
according to trace header information. &lt;br /&gt;
Here is an example of using&lt;br /&gt;
&amp;lt;tt&amp;gt;sfheadersort&amp;lt;/tt&amp;gt; for randomly shuffling traces in the input&lt;br /&gt;
file. First, let us create an input file with seven traces:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=5 n2=7 output=x2+1 &amp;gt; input.rsf&lt;br /&gt;
bash$ &amp;lt; input.rsf sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             2            2            2            2            2&lt;br /&gt;
  10:             3            3            3            3            3&lt;br /&gt;
  15:             4            4            4            4            4&lt;br /&gt;
  20:             5            5            5            5            5&lt;br /&gt;
  25:             6            6            6            6            6&lt;br /&gt;
  30:             7            7            7            7            7 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Next, we can create a random file with seven header values using&lt;br /&gt;
&amp;lt;tt&amp;gt;sfnoise&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=7 | sfnoise rep=y type=n &amp;gt; random.rsf&lt;br /&gt;
bash$ &amp;lt; random.rsf sfdisfil&lt;br /&gt;
   0:       0.05256      -0.2879       0.1487       0.4097       0.1548&lt;br /&gt;
   5:        0.4501       0.2836&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you reproduce this example, your numbers will most likely be different,&lt;br /&gt;
because, in the absence of &amp;lt;tt&amp;gt;seed=&amp;lt;/tt&amp;gt; parameter, &amp;lt;tt&amp;gt;sfnoise&amp;lt;/tt&amp;gt;&lt;br /&gt;
uses a random seed value to generate pseudo-random numbers. Finally, we&lt;br /&gt;
apply &amp;lt;tt&amp;gt;sfheadersort&amp;lt;/tt&amp;gt; to shuffle the input traces.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; input.rsf sfheadersort head=random.rsf &amp;gt; output.rsf&lt;br /&gt;
bash$ &amp;lt; output.rsf sfdisfil&lt;br /&gt;
   0:             2            2            2            2            2&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             3            3            3            3            3&lt;br /&gt;
  15:             5            5            5            5            5&lt;br /&gt;
  20:             7            7            7            7            7&lt;br /&gt;
  25:             4            4            4            4            4&lt;br /&gt;
  30:             6            6            6            6            6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As expected, the order of traces in the output file corresponds to the&lt;br /&gt;
order of values in the header. Thanks to the separation between&lt;br /&gt;
headers and data, the operation of &amp;lt;tt&amp;gt;sfheadersort&amp;lt;/tt&amp;gt; is optimally&lt;br /&gt;
efficient. It first sorts the headers and only then accesses the data,&lt;br /&gt;
reading each data trace only once.&lt;br /&gt;
&lt;br /&gt;
==sfheaderwindow==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Window a dataset based on a header mask.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfheaderwindow mask=head.rsf &amp;lt; in.rsf &amp;gt; out.rsf&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;The input data is a collection of traces n1xn2,&amp;lt;br&amp;gt;mask is an integer array os size n2, windowed is n1xm2,&amp;lt;br&amp;gt;where m2 is the number of nonzero elements in mask.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; is used to window traces in the input file&lt;br /&gt;
according to trace header information. &lt;br /&gt;
Here is an example of using &amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; for randomly&lt;br /&gt;
selecting part of the traces in the input file. First, let us create&lt;br /&gt;
an input file with ten traces:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=5 n2=10 output=x2+1 &amp;gt; input.rsf&lt;br /&gt;
bash$ &amp;lt; input.rsf sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             2            2            2            2            2&lt;br /&gt;
  10:             3            3            3            3            3&lt;br /&gt;
  15:             4            4            4            4            4&lt;br /&gt;
  20:             5            5            5            5            5&lt;br /&gt;
  25:             6            6            6            6            6&lt;br /&gt;
  30:             7            7            7            7            7&lt;br /&gt;
  35:             8            8            8            8            8&lt;br /&gt;
  40:             9            9            9            9            9&lt;br /&gt;
  45:            10           10           10           10           10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Next, we can create a random file with ten header values using&lt;br /&gt;
&amp;lt;tt&amp;gt;sfnoise&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=10 | sfnoise rep=y type=n &amp;gt; random.rsf&lt;br /&gt;
bash$ &amp;lt; random.rsf sfdisfil&lt;br /&gt;
   0:     -0.005768      0.02258     -0.04331      -0.4129      -0.3909&lt;br /&gt;
   5:      -0.03582       0.4595      -0.3326        0.498      -0.3517&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you reproduce this example, your numbers will most likely be different,&lt;br /&gt;
because, in the absence of &amp;lt;tt&amp;gt;seed=&amp;lt;/tt&amp;gt; parameter, &amp;lt;tt&amp;gt;sfnoise&amp;lt;/tt&amp;gt;&lt;br /&gt;
uses a random seed value to generate pseudo-random numbers. Finally,&lt;br /&gt;
we apply &amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; to window the input traces selecting&lt;br /&gt;
only those for which the header is greater than zero.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; random.rsf sfmask min=0 &amp;gt; mask.rsf&lt;br /&gt;
bash$ &amp;lt; mask.rsf sfdisfil&lt;br /&gt;
   0:    0    1    0    0    0    0    1    0    1    0&lt;br /&gt;
bash$ &amp;lt; input.rsf sfheaderwindow mask=mask.rsf &amp;gt; output.rsf&lt;br /&gt;
bash$ &amp;lt; output.rsf sfdisfil&lt;br /&gt;
   0:             2            2            2            2            2&lt;br /&gt;
   5:             7            7            7            7            7&lt;br /&gt;
  10:             9            9            9            9            9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this case, only three traces are selected for the output. Thanks to&lt;br /&gt;
the separation between headers and data, the operation of&lt;br /&gt;
&amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; is optimally efficient. &lt;br /&gt;
&lt;br /&gt;
==sfin==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Display basic information about RSF files.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfin info=y check=2. trail=y file1.rsf file2.rsf ...&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | n1,n2,... are data dimensions&amp;lt;br&amp;gt;o1,o2,... are axis origins&amp;lt;br&amp;gt;d1,d2,... are axis sampling intervals&amp;lt;br&amp;gt;label1,label2,... are axis labels&amp;lt;br&amp;gt;unit1,unit2,... are axis units&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;check=2.&#039;&#039;&#039; ||   || 	Portion of the data (in Mb) to check for zero values.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;info=y&#039;&#039;&#039; ||  [y/n] || 	If n, only display the name of the data file.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;trail=y&#039;&#039;&#039; ||  [y/n] || 	If n, skip trailing dimensions of  one&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfin&amp;lt;/tt&amp;gt; is one of the most useful programs for operating with&lt;br /&gt;
RSF files. It produces quick information on the file hypercube&lt;br /&gt;
dimensions and checks the consistency of the associated data file.&lt;br /&gt;
Here is an example. Let us create an RSF file and examine it with &amp;lt;tt&amp;gt;sfin&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=100 n2=20 &amp;gt; spike.rsf&lt;br /&gt;
bash$ sfin spike.rsf&lt;br /&gt;
spike.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/spike.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=100         d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=20          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        2000 elements 8000 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfin&amp;lt;/tt&amp;gt; reports the following information:&lt;br /&gt;
  &lt;br /&gt;
*location of the data file (&amp;lt;tt&amp;gt;/tmp/spike.rsf\@&amp;lt;/tt&amp;gt;) &lt;br /&gt;
*element size (4 bytes) &lt;br /&gt;
*element type (floating point) &lt;br /&gt;
*element form (native) &lt;br /&gt;
*hypercube dimensions (100 by 20) &lt;br /&gt;
*axes scale (0.004 and 0.1) &lt;br /&gt;
*axes origin (0 and 0) &lt;br /&gt;
*axes labels &lt;br /&gt;
*axes units &lt;br /&gt;
*total number of elements &lt;br /&gt;
*total number of bytes in the data file &lt;br /&gt;
Suppose that the file got corrupted by a buggy program and reports&lt;br /&gt;
incorrect dimensions. The &amp;lt;tt&amp;gt;sfin&amp;lt;/tt&amp;gt; program should be able to&lt;br /&gt;
catch the discrepancy.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ echo n2=100 &amp;gt;&amp;gt; spike.rsf&lt;br /&gt;
bash$ sfin spike.rsf &amp;gt; /dev/null&lt;br /&gt;
sfin:           Actually 8000 bytes, 20% of expected.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfin&amp;lt;/tt&amp;gt; also checks the first records in the file for zeros. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=100 n2=100 k2=99 &amp;gt; spike2.rsf&lt;br /&gt;
bash$ sfin spike2.rsf &amp;gt;/dev/null&lt;br /&gt;
sfin: The first 32768 bytes are all zeros&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The number of bytes to check is adjustable&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfin spike2.rsf check=0.01 &amp;gt;/dev/null&lt;br /&gt;
sfin: The first 16384 bytes are all zeros&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can also output only the location of the data file. This is&lt;br /&gt;
sometimes handy in scripts.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfin spike.rsf spike2.rsf info=n&lt;br /&gt;
/tmp/spike.rsf@ /tmp/spike2.rsf@&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An alternative is to use &amp;lt;tt&amp;gt;sfget&amp;lt;/tt&amp;gt;, as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfget parform=n in &amp;lt; spike.rsf&lt;br /&gt;
/tmp/spike.rsf@&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To actually eliminate annoying trailing dimensions of length one (not just stop displaying them with &amp;lt;tt&amp;gt;trail=n&amp;lt;/tt&amp;gt;), you may use &amp;lt;tt&amp;gt;sed&amp;lt;/tt&amp;gt;. Example for eliminating axis 6:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sed -i &#039;s/n6=1//g&#039; file.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfinterleave==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Combine several datasets by interleaving.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfinterleave &amp;gt; out.rsf axis=3 [&amp;lt; file0.rsf] file1.rsf file2.rsf ...&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axis=3&#039;&#039;&#039; ||   || 	Axis for interleaving&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfinterleave&amp;lt;/tt&amp;gt; combines two or more datasets by interleaving them on one&lt;br /&gt;
of the axes. Here is a quick example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=5 n2=5 &amp;gt; one.rsf&lt;br /&gt;
bash$ sfdisfil &amp;lt; one.rsf&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
  15:             1            1            1            1            1&lt;br /&gt;
  20:             1            1            1            1            1&lt;br /&gt;
bash$ sfscale &amp;lt; one.rsf dscale=2 &amp;gt; two.rsf&lt;br /&gt;
bash$ sfdisfil &amp;lt; two.rsf&lt;br /&gt;
   0:             2            2            2            2            2&lt;br /&gt;
   5:             2            2            2            2            2&lt;br /&gt;
  10:             2            2            2            2            2&lt;br /&gt;
  15:             2            2            2            2            2&lt;br /&gt;
  20:             2            2            2            2            2&lt;br /&gt;
bash$ sfinterleave one.rsf two.rsf axis=1 | sfdisfil&lt;br /&gt;
   0:             1            2            1            2            1&lt;br /&gt;
   5:             2            1            2            1            2&lt;br /&gt;
  10:             1            2            1            2            1&lt;br /&gt;
  15:             2            1            2            1            2&lt;br /&gt;
  20:             1            2            1            2            1&lt;br /&gt;
  25:             2            1            2            1            2&lt;br /&gt;
  30:             1            2            1            2            1&lt;br /&gt;
  35:             2            1            2            1            2&lt;br /&gt;
  40:             1            2            1            2            1&lt;br /&gt;
  45:             2            1            2            1            2&lt;br /&gt;
bash$ sfinterleave &amp;lt; one.rsf two.rsf axis=2 | sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             2            2            2            2            2&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
  15:             2            2            2            2            2&lt;br /&gt;
  20:             1            1            1            1            1&lt;br /&gt;
  25:             2            2            2            2            2&lt;br /&gt;
  30:             1            1            1            1            1&lt;br /&gt;
  35:             2            2            2            2            2&lt;br /&gt;
  40:             1            1            1            1            1&lt;br /&gt;
  45:             2            2            2            2            2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfmask==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Create a mask.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfmask &amp;lt; in.rsf &amp;gt; out.rsf min=-FLT_MAX max=+FLT_MAX&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Mask is an integer data with ones and zeros. &amp;lt;br&amp;gt;Ones correspond to input values between min and max.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;The output can be used with sfheaderwindow.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;max=+FLT_MAX&#039;&#039;&#039; ||   || 	maximum header value&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;min=-FLT_MAX&#039;&#039;&#039; ||   || 	minimum header value&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfmask&amp;lt;/tt&amp;gt; creates an integer output of ones and zeros comparing&lt;br /&gt;
the values of the input data to specified &amp;lt;tt&amp;gt;min=&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;max=&amp;lt;/tt&amp;gt; parameters. It is useful for &amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; and&lt;br /&gt;
in many other applications. Here is a quick example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=10 output=&amp;quot;sin(x1)&amp;quot; &amp;gt; sin.rsf&lt;br /&gt;
bash$ &amp;lt; sin.rsf sfdisfil&lt;br /&gt;
   0:             0       0.8415       0.9093       0.1411      -0.7568&lt;br /&gt;
   5:       -0.9589      -0.2794        0.657       0.9894       0.4121&lt;br /&gt;
bash$ &amp;lt; sin.rsf sfmask min=-0.5 max=0.5 | sfdisfil&lt;br /&gt;
   0:    1    0    0    1    0    0    1    0    0    1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfmath==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Mathematical operations on data files.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfmath &amp;gt; out.rsf type= unit= output=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Known functions: cos,  sin,  tan,  acos,  asin,  atan, &amp;lt;br&amp;gt;                 cosh, sinh, tanh, acosh, asinh, atanh,&amp;lt;br&amp;gt;                 exp,  log,  sqrt, abs, conj (for complex data).&amp;lt;br&amp;gt;                 &amp;lt;br&amp;gt;sfmath will work on float or complex data, but all the input and output&amp;lt;br&amp;gt;files must be of the same data type.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;An alternative to sfmath is sfadd, which may be more efficient, but is&amp;lt;br&amp;gt;less versatile.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Examples:&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sfmath x=file1.rsf y=file2.rsf power=file3.rsf output=&#039;sin((x+2*y)^power)&#039; &amp;gt; out.rsf&amp;lt;br&amp;gt;sfmath &amp;lt; file1.rsf tau=file2.rsf output=&#039;exp(tau*input)&#039; &amp;gt; out.rsf&amp;lt;br&amp;gt;sfmath n1=100 type=complex output=&amp;quot;exp(I*x1)&amp;quot; &amp;gt; out.rsf&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;See also: sfheadermath.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;output=&#039;&#039;&#039; ||   || 	Mathematical description of the output&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;type=&#039;&#039;&#039; ||   || 	output data type [float,complex]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit=&#039;&#039;&#039; ||   || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt; is a versatile program for mathematical operations&lt;br /&gt;
with RSF files. It can operate with several input file, all of the&lt;br /&gt;
same dimensions and data type. The data type can be real (floating&lt;br /&gt;
point) or complex. Here is an example that demonstrates several&lt;br /&gt;
features of &amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=629 d1=0.01 o1=0 n2=40 d2=1 o2=5 \&lt;br /&gt;
output=&amp;quot;x2*(8+sin(6*x1+x2/10))&amp;quot; &amp;gt; rad.rsf&lt;br /&gt;
bash$ &amp;lt; rad.rsf sfrtoc | sfmath output=&amp;quot;input*exp(I*x1)&amp;quot; &amp;gt; rose.rsf&lt;br /&gt;
bash$ &amp;lt; rose.rsf sfgraph title=Rose screenratio=1 wantaxis=n | sfpen&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The first line creates a 2-D dataset that consists of 40 traces 629&lt;br /&gt;
samples each. The values of the data are computed with the formula&lt;br /&gt;
&amp;lt;font color=&amp;quot;#cd4b19&amp;quot;&amp;gt;&amp;quot;x2*(8+sin(6*x1+x2/10))&amp;quot;&amp;lt;/font&amp;gt;, where &amp;lt;tt&amp;gt;x1&amp;lt;/tt&amp;gt; refers to the&lt;br /&gt;
coordinate on the first axis, and &amp;lt;tt&amp;gt;x2&amp;lt;/tt&amp;gt; is the coordinate of the&lt;br /&gt;
second axis. In the second line, we convert the data from real to&lt;br /&gt;
complex using &amp;lt;tt&amp;gt;sfrtoc&amp;lt;/tt&amp;gt; and produce a complex dataset using&lt;br /&gt;
formula &amp;lt;font color=&amp;quot;#cd4b19&amp;quot;&amp;gt;&amp;quot;input*exp(I*x1)&amp;quot;&amp;lt;/font&amp;gt;, where &amp;lt;tt&amp;gt;input&amp;lt;/tt&amp;gt; refers to the&lt;br /&gt;
input file. Finally, we plot the complex data as a collection of&lt;br /&gt;
parametric curves using &amp;lt;tt&amp;gt;sfgraph&amp;lt;/tt&amp;gt; and display the result using&lt;br /&gt;
&amp;lt;tt&amp;gt;sfpen&amp;lt;/tt&amp;gt;.  The plot appearing on your screen should look similar&lt;br /&gt;
to the figure.&lt;br /&gt;
[[Image:rose.png|frame|center|This figure was created with &amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt;.]]&lt;br /&gt;
One possible alternative to the second line above is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; rad.rsf sfmath output=x1 &amp;gt; ang.rsf&lt;br /&gt;
bash$ sfmath r=rad.rsf a=ang.rsf output=&amp;quot;r*cos(a)&amp;quot; &amp;gt; cos.rsf&lt;br /&gt;
bash$ sfmath r=rad.rsf a=ang.rsf output=&amp;quot;r*sin(a)&amp;quot; &amp;gt; sin.rsf&lt;br /&gt;
bash$ sfcmplx cos.rsf sin.rsf &amp;gt; rose.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here we refer to input files by names (&amp;lt;tt&amp;gt;r&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;a&amp;lt;/tt&amp;gt;) and combine the names in a formula.&lt;br /&gt;
&lt;br /&gt;
==sfpad==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Pad a dataset with zeros.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfpad &amp;lt; in.rsf &amp;gt; out.rsf [beg1= beg2= ... end1= end2=... | n1=  n2 = ... | n1out= n2out= ...]&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | begN specifies the number of zeros to add before the beginning of axis N.&amp;lt;br&amp;gt;endN specifies the number of zeros to add after the end of axis N.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Alternatively:&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;nN or nNout specify the output length of axis N, padding occurs at the end.&amp;lt;br&amp;gt;nN and nNout are equivalent.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;pad&amp;lt;/tt&amp;gt; increases the dimensions of the input dataset by padding&lt;br /&gt;
the data with zeroes. Here are some simple examples.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=5 n2=3 &amp;gt; one.rsf&lt;br /&gt;
bash$ sfdisfil &amp;lt; one.rsf&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
bash$ &amp;lt; one.rsf sfpad n2=5 | sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
  15:             0            0            0            0            0&lt;br /&gt;
  20:             0            0            0            0            0&lt;br /&gt;
bash$ &amp;lt; one.rsf sfpad beg2=2 | sfdisfil&lt;br /&gt;
   0:             0            0            0            0            0&lt;br /&gt;
   5:             0            0            0            0            0&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
  15:             1            1            1            1            1&lt;br /&gt;
  20:             1            1            1            1            1&lt;br /&gt;
bash$ &amp;lt; one.rsf sfpad beg2=1 end2=1 | sfdisfil&lt;br /&gt;
   0:             0            0            0            0            0&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
  15:             1            1            1            1            1&lt;br /&gt;
  20:             0            0            0            0            0&lt;br /&gt;
bash$ &amp;lt; one.rsf sfwindow n1=3 | sfpad n1=5 n2=5 beg1=1 beg2=1 | sfdisfil&lt;br /&gt;
   0:             0            0            0            0            0&lt;br /&gt;
   5:             0            1            1            1            0&lt;br /&gt;
  10:             0            1            1            1            0&lt;br /&gt;
  15:             0            1            1            1            0&lt;br /&gt;
  20:             0            0            0            0            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can use &amp;lt;tt&amp;gt;sfcat&amp;lt;/tt&amp;gt; to pad data with values other than zeroes.&lt;br /&gt;
&lt;br /&gt;
==sfput==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Input parameters into a header. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfput &amp;lt; in.rsf &amp;gt; out.rsf&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfput&amp;lt;/tt&amp;gt; is a very simple program. It simply appends parameters&lt;br /&gt;
from the command line to the output RSF file. One can achieve similar&lt;br /&gt;
results with editing by hand or with standard Unix utilities like&lt;br /&gt;
&amp;lt;tt&amp;gt;sed&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt;. &amp;lt;tt&amp;gt;sfput&amp;lt;/tt&amp;gt; is sometimes more&lt;br /&gt;
convenient because it handles input/output operations similarly to&lt;br /&gt;
other regular RSF programs.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=10 &amp;gt; spike.rsf&lt;br /&gt;
bash$ sfin spike.rsf&lt;br /&gt;
spike.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/spike.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=10          d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
        10 elements 40 bytes&lt;br /&gt;
bash$ sfput &amp;lt; spike.rsf d1=25 label1=Depth unit1=m &amp;gt; spike2.rsf&lt;br /&gt;
bash$ sfin spike2.rsf&lt;br /&gt;
spike2.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/spike2.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=10          d1=25          o1=0          label1=&amp;quot;Depth&amp;quot; unit1=&amp;quot;m&amp;quot;&lt;br /&gt;
        10 elements 40 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfreal==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Extract real (sfreal) or imaginary (sfimag) part of a complex dataset. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfreal &amp;lt; cmplx.rsf &amp;gt; real.rsf&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfreal&amp;lt;/tt&amp;gt; extracts the real part of a complex type dataset. The&lt;br /&gt;
imaginary part can be extracted with &amp;lt;tt&amp;gt;sfimag&amp;lt;/tt&amp;gt;, an the real&lt;br /&gt;
and imaginary part can be combined together with &amp;lt;tt&amp;gt;sfcmplx&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Here is a simple example. Let us first create a complex dataset &lt;br /&gt;
with &amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=10 type=complex output=&amp;quot;(2+I)*x1&amp;quot; &amp;gt; cmplx.rsf&lt;br /&gt;
bash$ fdisfil &amp;lt; cmplx.rsf&lt;br /&gt;
   0:          0,         0i         2,         1i         4,         2i&lt;br /&gt;
   3:          6,         3i         8,         4i        10,         5i&lt;br /&gt;
   6:         12,         6i        14,         7i        16,         8i&lt;br /&gt;
   9:         18,         9i&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Extracting the real part with &amp;lt;tt&amp;gt;sfreal&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfreal &amp;lt; cmplx.rsf | sfdisfil&lt;br /&gt;
   0:             0            2            4            6            8&lt;br /&gt;
   5:            10           12           14           16           18&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Extracting the imaginary part with &amp;lt;tt&amp;gt;sfimag&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfimag &amp;lt; cmplx.rsf | sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             5            6            7            8            9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfreverse==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Reverse one or more axes in the data hypercube. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfreverse &amp;lt; in.rsf &amp;gt; out.rsf which=-1 verb=false memsize=sf_memsize() opt=&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;memsize=sf_memsize()&#039;&#039;&#039; ||   || 	Max amount of RAM (in Mb) to be used&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;opt=&#039;&#039;&#039; ||   || 	If y, change o and d parameters on the reversed axis;&lt;br /&gt;
:if i, don&#039;t change o and d&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	Verbosity flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;which=-1&#039;&#039;&#039; ||   || 	Which axis to reverse.&lt;br /&gt;
:To reverse a given axis, start with 0,&lt;br /&gt;
:add 1 to number to reverse n1 dimension,&lt;br /&gt;
:add 2 to number to reverse n2 dimension,&lt;br /&gt;
:add 4 to number to reverse n3 dimension, etc.&lt;br /&gt;
:Thus, which=7 would reverse the first three dimensions,&lt;br /&gt;
:which=5 just n1 and n3, etc.&lt;br /&gt;
:which=0 will just pass the input on through unchanged.&lt;br /&gt;
|}&lt;br /&gt;
Here is an example of using &amp;lt;tt&amp;gt;sfreverse&amp;lt;/tt&amp;gt;. First, let us create a&lt;br /&gt;
2-D dataset.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=5 d1=1 n2=3 d2=1 output=x1+x2 &amp;gt; test.rsf&lt;br /&gt;
bash$ &amp;lt; test.rsf sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
  10:             2            3            4            5            6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Reversing the first axis:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfreverse which=1 | sfdisfil&lt;br /&gt;
   0:             4            3            2            1            0&lt;br /&gt;
   5:             5            4            3            2            1&lt;br /&gt;
  10:             6            5            4            3            2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Reversing the second axis:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfreverse which=2 | sfdisfil&lt;br /&gt;
   0:             2            3            4            5            6&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
  10:             0            1            2            3            4&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Reversing both the first and the second axis:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfreverse which=3 | sfdisfil&lt;br /&gt;
   0:             2            3            4            5            6&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
  10:             0            1            2            3            4&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you can see, the &amp;lt;tt&amp;gt;which=&amp;lt;/tt&amp;gt; parameter controls the axes that are&lt;br /&gt;
being reversed by encoding them into one number.&lt;br /&gt;
When an axis is reversed, what happens with its axis origin and&lt;br /&gt;
sampling parameters? This behavior is controlled by &amp;lt;tt&amp;gt;opt=&amp;lt;/tt&amp;gt;. In&lt;br /&gt;
our example,&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfget n1 o1 d1&lt;br /&gt;
n1=5&lt;br /&gt;
o1=0&lt;br /&gt;
d1=1&lt;br /&gt;
bash$ &amp;lt; test.rsf sfreverse which=1 | sfget o1 d1&lt;br /&gt;
o1=4&lt;br /&gt;
d1=-1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The default behavior (equivalent to &amp;lt;tt&amp;gt;opt=y&amp;lt;/tt&amp;gt;) puts the origin&lt;br /&gt;
&amp;lt;tt&amp;gt;o1&amp;lt;/tt&amp;gt; at the end of the axis and reverses the sampling parameter&lt;br /&gt;
&amp;lt;tt&amp;gt;d1&amp;lt;/tt&amp;gt;.  Using &amp;lt;tt&amp;gt;opt=n&amp;lt;/tt&amp;gt; preserves the sampling but reverses&lt;br /&gt;
the origin.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfreverse which=1 opt=n | sfget o1 d1&lt;br /&gt;
o1=-4&lt;br /&gt;
d1=1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Using &amp;lt;tt&amp;gt;opt=i&amp;lt;/tt&amp;gt; preserves both the sampling and the origin while&lt;br /&gt;
reversing the axis.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfreverse which=1 opt=i | sfget o1 d1&lt;br /&gt;
o1=0&lt;br /&gt;
d1=1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
One of the three possible behaviors may be desirable depending on the&lt;br /&gt;
application.&lt;br /&gt;
&lt;br /&gt;
==sfrm==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Remove RSF files together with their data.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfrm file1.rsf [file2.rsf ...] [-i] [-v] [-f] &lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Mimics the standard Unix rm command.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;See also: sfmv, sfcp.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfrm&amp;lt;/tt&amp;gt; is a program for removing RSF files. Its arguments mimic&lt;br /&gt;
the arguments of the standard Unix &amp;lt;tt&amp;gt;rm&amp;lt;/tt&amp;gt; utility: &amp;lt;tt&amp;gt;-v&amp;lt;/tt&amp;gt;&lt;br /&gt;
for verbosity, &amp;lt;tt&amp;gt;-i&amp;lt;/tt&amp;gt; for interactive inquiry, &amp;lt;tt&amp;gt;-f&amp;lt;/tt&amp;gt; for&lt;br /&gt;
force removal of suspicious files. Unlike the Unix &amp;lt;tt&amp;gt;rm&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;sfrm&amp;lt;/tt&amp;gt; removes both the RSF header files and the binary files&lt;br /&gt;
that the headers point to. &lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=10 &amp;gt; spike.rsf datapath=./&lt;br /&gt;
bash&amp;amp;#36; sfget in &amp;lt; spike.rsf&lt;br /&gt;
in=./spike.rsf@&lt;br /&gt;
bash&amp;amp;#36; ls spike*&lt;br /&gt;
spike.rsf  spike.rsf@&lt;br /&gt;
bash&amp;amp;#36; sfrm -v spike.rsf&lt;br /&gt;
sfrm: sf_rm: Removing header spike.rsf&lt;br /&gt;
sfrm: sf_rm: Removing data ./spike.rsf@&lt;br /&gt;
bash&amp;amp;#36; ls spike*&lt;br /&gt;
ls: No match.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==sfrotate==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Rotate a portion of one or more axes in the data hypercube. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfrotate &amp;lt; in.rsf &amp;gt; out.rsf verb=n memsize=sf_memsize() rot#=(0,0,...)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;memsize=sf_memsize()&#039;&#039;&#039; ||   || 	Max amount of RAM (in Mb) to be used&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;rot#=(0,0,...)&#039;&#039;&#039; ||   || 	length of #-th axis that is moved to the end&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	Verbosity flag&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfrotate&amp;lt;/tt&amp;gt; modifies the input dataset by splitting it into&lt;br /&gt;
parts and putting the parts back in a different order. Here is a quick example.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath n1=5 d1=1 n2=3 d2=1 output=x1+x2 &amp;gt; test.rsf&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
  10:             2            3            4            5            6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Rotating the first axis by putting the last two columns in front:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfrotate rot1=2 | sfdisfil&lt;br /&gt;
   0:             3            4            0            1            2&lt;br /&gt;
   5:             4            5            1            2            3&lt;br /&gt;
  10:             5            6            2            3            4&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Rotating the second axis by putting the last row in front:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfrotate rot2=1 | sfdisfil&lt;br /&gt;
   0:             2            3            4            5            6&lt;br /&gt;
   5:             0            1            2            3            4&lt;br /&gt;
  10:             1            2            3            4            5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Rotating both the first and the second axis:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfrotate rot1=3 rot2=1 | sfdisfil&lt;br /&gt;
   0:             4            5            6            2            3&lt;br /&gt;
   5:             2            3            4            0            1&lt;br /&gt;
  10:             3            4            5            1            2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The transformation is shown schematically in Figure~(fig:rotate).&lt;br /&gt;
[[Image:rotate.png|frame|center|Schematic transformation of data with &amp;lt;tt&amp;gt;sfrotate&amp;lt;/tt&amp;gt;.]]&lt;br /&gt;
&lt;br /&gt;
==sfrtoc==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Convert real data to complex (by adding zero imaginary part).&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfrtoc &amp;lt; real.rsf &amp;gt; cmplx.rsf&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;See also: sfcmplx&lt;br /&gt;
|}&lt;br /&gt;
The input to &amp;lt;tt&amp;gt;sfrtoc&amp;lt;/tt&amp;gt; can be any &amp;lt;tt&amp;gt;type=float&amp;lt;/tt&amp;gt; dataset:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=10 n2=20 n3=30 &amp;gt;real.rsf&lt;br /&gt;
bash$ sfin real.rsf&lt;br /&gt;
real.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/real.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=10          d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=20          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=30          d3=0.1         o3=0          label3=&amp;quot;Distance&amp;quot; unit3=&amp;quot;km&amp;quot; &lt;br /&gt;
        6000 elements 24000 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The output dataset will have &amp;lt;tt&amp;gt;type=complex&amp;lt;/tt&amp;gt;, and its binary will be twice the size of the input:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt;real.rsf sfrtoc &amp;gt;complex.rsf&lt;br /&gt;
bash$ sfin complex.rsf &lt;br /&gt;
complex.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/complex.rsf@&amp;quot;&lt;br /&gt;
    esize=8 type=complex form=native &lt;br /&gt;
    n1=10          d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=20          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=30          d3=0.1         o3=0          label3=&amp;quot;Distance&amp;quot; unit3=&amp;quot;km&amp;quot; &lt;br /&gt;
        6000 elements 48000 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfscale==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Scale data.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfscale &amp;lt; in.rsf &amp;gt; out.rsf axis=0 rscale=0. dscale=1.&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;To scale by a constant factor, you can also use sfmath or sfheadermath.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axis=0&#039;&#039;&#039; ||   || 	Scale by maximum in the dimensions up to this axis.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dscale=1.&#039;&#039;&#039; ||   || 	Scale by this factor (works if rscale=0)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;rscale=0.&#039;&#039;&#039; ||   || 	Scale by this factor.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;tt&amp;gt;sfscale&amp;lt;/tt&amp;gt; scales the input dataset by a factor. Here&lt;br /&gt;
are some simple examples. First, let us create a test dataset.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath n1=5 n2=3 o1=1 o2=1 output=&amp;quot;x1*x2&amp;quot; &amp;gt; test.rsf&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfdisfil   &lt;br /&gt;
   0:             1            2            3            4            5&lt;br /&gt;
   5:             2            4            6            8           10&lt;br /&gt;
  10:             3            6            9           12           15&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Scale every data point by 2:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfscale dscale=2 | sfdisfil&lt;br /&gt;
   0:             2            4            6            8           10&lt;br /&gt;
   5:             4            8           12           16           20&lt;br /&gt;
  10:             6           12           18           24           30&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Divide every trace by its maximum value:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfscale axis=1 | sfdisfil&lt;br /&gt;
   0:           0.2          0.4          0.6          0.8            1&lt;br /&gt;
   5:           0.2          0.4          0.6          0.8            1&lt;br /&gt;
  10:           0.2          0.4          0.6          0.8            1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Divide by the maximum value in the whole 2-D dataset:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfscale axis=2 | sfdisfil&lt;br /&gt;
   0:       0.06667       0.1333          0.2       0.2667       0.3333&lt;br /&gt;
   5:        0.1333       0.2667          0.4       0.5333       0.6667&lt;br /&gt;
  10:           0.2          0.4          0.6          0.8            1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The &amp;lt;tt&amp;gt;rscale=&amp;lt;/tt&amp;gt; parameter is synonymous to &amp;lt;tt&amp;gt;dscale=&amp;lt;/tt&amp;gt; except&lt;br /&gt;
when it is equal to zero. With &amp;lt;tt&amp;gt;sfscale dscale=0&amp;lt;/tt&amp;gt;, the dataset gets&lt;br /&gt;
multiplied by zero. If using &amp;lt;tt&amp;gt;rscale=0&amp;lt;/tt&amp;gt;, the other parameters are&lt;br /&gt;
used to define scaling.  Thus, &amp;lt;tt&amp;gt;sfscale rscale=0 axis=1&amp;lt;/tt&amp;gt; is&lt;br /&gt;
equivalent to &amp;lt;tt&amp;gt;sfscale axis=1&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;sfscale rscale=0&amp;lt;/tt&amp;gt;&lt;br /&gt;
is equivalent to &amp;lt;tt&amp;gt;sfscale dscale=1&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==sfspike==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generate simple data: spikes, boxes, planes, constants. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfspike &amp;gt; spike.rsf mag= nsp=1 k#=[0,...] l#=[k1,k2,...] p#=[0,...] n#= o#=[0,0,...] d#=[0.004,0.1,0.1,...] label#=[Time,Distance,Distance,...] unit#=[s,km,km,...] title=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Spike positioning is given in samples and starts with 1.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d#=[0.004,0.1,0.1,...]&#039;&#039;&#039; ||   || 	sampling on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;ints   &#039;&#039; || &#039;&#039;&#039;k#=[0,...]&#039;&#039;&#039; ||   || 	spike starting position  [nsp]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;ints   &#039;&#039; || &#039;&#039;&#039;l#=[k1,k2,...]&#039;&#039;&#039; ||   || 	spike ending position  [nsp]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label#=[Time,Distance,Distance,...]&#039;&#039;&#039; ||   || 	label on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;floats &#039;&#039; || &#039;&#039;&#039;mag=&#039;&#039;&#039; ||   || 	spike magnitudes  [nsp]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n#=&#039;&#039;&#039; ||   || 	size of #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nsp=1&#039;&#039;&#039; ||   || 	Number of spikes&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;o#=[0,0,...]&#039;&#039;&#039; ||   || 	origin on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;floats &#039;&#039; || &#039;&#039;&#039;p#=[0,...]&#039;&#039;&#039; ||   || 	spike inclination (in samples)  [nsp]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;title=&#039;&#039;&#039; ||   || 	title for plots&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit#=[s,km,km,...]&#039;&#039;&#039; ||   || 	unit on #-th axis&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt; takes no input and generates an output with&lt;br /&gt;
&amp;quot;spikes&amp;quot;. It is an easy way to create data. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 k1=4 k2=1 | sfdisfil&lt;br /&gt;
   0:             0            0            0            1            0&lt;br /&gt;
   5:             0            0            0            0            0&lt;br /&gt;
  10:             0            0            0            0            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The spike location is specified by parameters &amp;lt;tt&amp;gt;k1=4&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;k2=1&amp;lt;/tt&amp;gt;. Note that the locations are numbered starting from 1. &lt;br /&gt;
If one of the parameters is omitted or given the value of zero, the &lt;br /&gt;
spike in the corresponding direction becomes a plane:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 k1=4 | sfdisfil   &lt;br /&gt;
   0:             0            0            0            1            0&lt;br /&gt;
   5:             0            0            0            1            0&lt;br /&gt;
  10:             0            0            0            1            0&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If no spike parameters are given, the whole dataset is filled with ones:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 | sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To create several spikes, use the &amp;lt;tt&amp;gt;nsp=&amp;lt;/tt&amp;gt; parameter and give a comma-separated list of values to &amp;lt;tt&amp;gt;k#=&amp;lt;/tt&amp;gt; arguments:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 nsp=3 k1=1,3,4 k2=1,2,3 | sfdisfil&lt;br /&gt;
   0:             1            0            0            0            0&lt;br /&gt;
   5:             0            0            1            0            0&lt;br /&gt;
  10:             0            0            0            1            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the number of values in the list is smaller than &amp;lt;tt&amp;gt;nsp&amp;lt;/tt&amp;gt;, the&lt;br /&gt;
last value gets repeated, and the spikes add on top of each other,&lt;br /&gt;
creating larger amplitudes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 nsp=3 k1=1,3 k2=1,2 | sfdisfil&lt;br /&gt;
   0:             1            0            0            0            0&lt;br /&gt;
   5:             0            0            2            0            0&lt;br /&gt;
  10:             0            0            0            0            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The magnitude of the spikes can be controlled explicitly with the&lt;br /&gt;
&amp;lt;tt&amp;gt;mag=&amp;lt;/tt&amp;gt; parameter:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 nsp=3 k1=1,3,4 k2=1,2,3 mag=1,4,2 | sfdisfil&lt;br /&gt;
   0:             1            0            0            0            0&lt;br /&gt;
   5:             0            0            4            0            0&lt;br /&gt;
  10:             0            0            0            2            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can create boxes instead of spikes by using &amp;lt;tt&amp;gt;l#=&amp;lt;/tt&amp;gt;&lt;br /&gt;
parameters:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 k1=2 l1=4 k2=2 mag=8 | sfdisfil&lt;br /&gt;
   0:             0            0            0            0            0&lt;br /&gt;
   5:             0            8            8            8            0&lt;br /&gt;
  10:             0            0            0            0            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this case, &amp;lt;tt&amp;gt;k1=2&amp;lt;/tt&amp;gt; specifies the box start, and &amp;lt;tt&amp;gt;l1=4&amp;lt;/tt&amp;gt;&lt;br /&gt;
specifies the box end.&lt;br /&gt;
Finally, multi-dimensional planes can be given an inclination by using &amp;lt;tt&amp;gt;p#=&amp;lt;/tt&amp;gt; parameters:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 k1=2 p2=1 | sfdisfil&lt;br /&gt;
   0:             0            1            0            0            0&lt;br /&gt;
   5:             0            0            1            0            0&lt;br /&gt;
  10:             0            0            0            1            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Note that &amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt; interprets the &amp;lt;tt&amp;gt;p#=&amp;lt;/tt&amp;gt; parameters in stepout from sample to sample, not in terms of axes units (i.e. s/m). &lt;br /&gt;
&lt;br /&gt;
More than one p parameter can be specified. In this case, a (hyper) plane will be created.&lt;br /&gt;
&lt;br /&gt;
When the inclination value is not integer, simple linear interpolation is used:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 k1=2 p2=0.7 | sfdisfil&lt;br /&gt;
   0:             0            1            0            0            0&lt;br /&gt;
   5:             0          0.3          0.7            0            0&lt;br /&gt;
  10:             0            0          0.6          0.4            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt; supplies default dimensions and labels to all axis:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 n3=4 &amp;gt; spike.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin spike.rsf&lt;br /&gt;
spike.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/spike.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=5           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=4           d3=0.1         o3=0          label3=&amp;quot;Distance&amp;quot; unit3=&amp;quot;km&amp;quot; &lt;br /&gt;
	60 elements 240 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you can see, the first axis is assumed to be time, with sampling of&lt;br /&gt;
&amp;lt;math&amp;gt;0.004&amp;lt;/math&amp;gt; seconds. All other axes are assumed to be distance, with&lt;br /&gt;
sampling of &amp;lt;math&amp;gt;0.1&amp;lt;/math&amp;gt; kilometers. All these parameters can be changed on&lt;br /&gt;
the command line.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 n3=4 label3=Offset unit3=ft d3=20 &amp;gt; spike.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin spike.rsf&lt;br /&gt;
spike.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/spike.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=5           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=4           d3=20          o3=0          label3=&amp;quot;Offset&amp;quot; unit3=&amp;quot;ft&amp;quot; &lt;br /&gt;
	60 elements 240 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfspray==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Extend a dataset by duplicating in the specified axis dimension.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfspray &amp;lt; in.rsf &amp;gt; out.rsf axis=2 n= d= o= label= unit=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; |    This operation is adjoint to sfstack.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axis=2&#039;&#039;&#039; ||   || 	which axis to spray&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d=&#039;&#039;&#039; ||   || 	Sampling of the newly created dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label=&#039;&#039;&#039; ||   || 	Label of the newly created dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n=&#039;&#039;&#039; ||   || 	Size of the newly created dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;o=&#039;&#039;&#039; ||   || 	Origin of the newly created dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit=&#039;&#039;&#039; ||   || 	Units of the newly created dimension&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfspray&amp;lt;/tt&amp;gt; extends the input hypercube by replicating the data&lt;br /&gt;
in one of the dimensions. The output dataset acquires one additional&lt;br /&gt;
dimension. Here is an example:&lt;br /&gt;
Start with a 2-D dataset&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath n1=5 n2=2 output=x1+x2 &amp;gt; test.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin test.rsf&lt;br /&gt;
test.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/test.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=5           d1=1           o1=0          &lt;br /&gt;
    n2=2           d2=1           o2=0          &lt;br /&gt;
        10 elements 40 bytes&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Extend the data in the second dimension&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfspray axis=2 n=3 &amp;gt; test2.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin test2.rsf&lt;br /&gt;
test2.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/test2.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=5           d1=1           o1=0          &lt;br /&gt;
    n2=3           d2=1           o2=0          &lt;br /&gt;
    n3=2           d3=1           o3=0          &lt;br /&gt;
        30 elements 120 bytes&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test2.rsf sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             0            1            2            3            4&lt;br /&gt;
  10:             0            1            2            3            4&lt;br /&gt;
  15:             1            2            3            4            5&lt;br /&gt;
  20:             1            2            3            4            5&lt;br /&gt;
  25:             1            2            3            4            5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The output is three-dimensional, with traces from the original&lt;br /&gt;
data duplicated along the second axis.&lt;br /&gt;
Extend the data in the third dimension&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfspray axis=3 n=2 &amp;gt; test3.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin test3.rsf&lt;br /&gt;
test3.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/test3.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=5           d1=1           o1=0          &lt;br /&gt;
    n2=2           d2=1           o2=0          &lt;br /&gt;
    n3=2           d3=?           o3=?          &lt;br /&gt;
        20 elements 80 bytes&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test3.rsf sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
  10:             0            1            2            3            4&lt;br /&gt;
  15:             1            2            3            4            5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The output is also three-dimensional, with the original data replicated&lt;br /&gt;
along the third axis.&lt;br /&gt;
&lt;br /&gt;
==sfstack==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Stack a dataset over one of the dimensions.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfstack &amp;lt; in.rsf &amp;gt; out.rsf axis=2 rms=n norm=y min=n max=n&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;This operation is adjoint to sfspray.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axis=2&#039;&#039;&#039; ||   || 	which axis to stack&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;max=n&#039;&#039;&#039; ||  [y/n] || 	If y, find maximum instead of stack.  Ignores rms and norm.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;min=n&#039;&#039;&#039; ||  [y/n] || 	If y, find minimum instead of stack.  Ignores rms and norm.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;norm=y&#039;&#039;&#039; ||  [y/n] || 	If y, normalize by fold.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;rms=n&#039;&#039;&#039; ||  [y/n] || 	If y, compute the root-mean-square instead of stack.&lt;br /&gt;
|}&lt;br /&gt;
While &amp;lt;tt&amp;gt;sfspray&amp;lt;/tt&amp;gt; adds a dimension to a hypercube,&lt;br /&gt;
&amp;lt;tt&amp;gt;sfstack&amp;lt;/tt&amp;gt; effectively removes one of the dimensions by stacking&lt;br /&gt;
over it. Here are some examples:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath n1=5 n2=3 output=x1+x2 &amp;gt; test.rsf&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
  10:             2            3            4            5            6&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfstack axis=2 | sfdisfil&lt;br /&gt;
   0:           1.5            2            3            4            5&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfstack axis=1 | sfdisfil&lt;br /&gt;
   0:           2.5            3            4&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Why is the first value not 1 (in the first case) or 2 (in the second&lt;br /&gt;
case)? By default, &amp;lt;tt&amp;gt;sfstack&amp;lt;/tt&amp;gt; normalizes the stack by the fold&lt;br /&gt;
(the number of non-zero entries). To avoid normalization, use&lt;br /&gt;
&amp;lt;tt&amp;gt;norm=n&amp;lt;/tt&amp;gt;, as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfstack norm=n | sfdisfil &lt;br /&gt;
   0:             3            6            9           12           15&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfstack&amp;lt;/tt&amp;gt; can also compute root-mean-square values as &lt;br /&gt;
well as minimum and maximum values.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfstack rms=y | sfdisfil&lt;br /&gt;
   0:         1.581         2.16        3.109        4.082        5.066&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfstack min=y | sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfstack axis=1 max=y | sfdisfil &lt;br /&gt;
   0:             4            5            6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sftransp==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Transpose two axes in a dataset. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sftransp &amp;lt; in.rsf &amp;gt; out.rsf memsize=sf_memsize() plane=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;If you get a &amp;quot;Cannot allocate memory&amp;quot; error, give the program a&amp;lt;br&amp;gt;memsize=1 command-line parameter to force out-of-core operation.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;memsize=sf_memsize()&#039;&#039;&#039; ||   || 	Max amount of RAM (in Mb) to be used&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;plane=&#039;&#039;&#039; ||   || 	Two-digit number with axes to transpose. The default is 12&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sftransp&amp;lt;/tt&amp;gt; program transposes the input hypercube&lt;br /&gt;
exchanging the two axes specified by the &amp;lt;b&amp;gt;plane=&amp;lt;/b&amp;gt; parameter. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=10 n2=20 n3=30 &amp;gt; orig123.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin orig123.rsf &lt;br /&gt;
orig123.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/orig123.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=10          d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=20          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=30          d3=0.1         o3=0          label3=&amp;quot;Distance&amp;quot; unit3=&amp;quot;km&amp;quot; &lt;br /&gt;
        6000 elements 24000 bytes&lt;br /&gt;
bash&amp;amp;#36; &amp;lt;orig123.rsf sftransp plane=23 &amp;gt;out132.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin out132.rsf &lt;br /&gt;
out132.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/out132.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=10          d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=30          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=20          d3=0.1         o3=0          label3=&amp;quot;Distance&amp;quot; unit3=&amp;quot;km&amp;quot; &lt;br /&gt;
        6000 elements 24000 bytes&lt;br /&gt;
bash&amp;amp;#36; &amp;lt;orig123.rsf sftransp plane=13 &amp;gt;out321.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin out321.rsf &lt;br /&gt;
out321.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/out132.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=30          d1=0.1         o1=0          label1=&amp;quot;Distance&amp;quot; unit1=&amp;quot;km&amp;quot; &lt;br /&gt;
    n2=20          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=10          d3=0.004       o3=0          label3=&amp;quot;Time&amp;quot; unit3=&amp;quot;s&amp;quot; &lt;br /&gt;
        6000 elements 24000 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sftransp&amp;lt;/tt&amp;gt; tries to fit the dataset in memory to transpose it&lt;br /&gt;
there but, if not enough memory is available, it performs a slower&lt;br /&gt;
transpose out of core using disk operations. You can control the&lt;br /&gt;
amount of available memory using the &amp;lt;b&amp;gt;memsize=&amp;lt;/b&amp;gt; parameter or&lt;br /&gt;
the &amp;lt;b&amp;gt;RSFMEMSIZE&amp;lt;/b&amp;gt; environmental variable.&lt;br /&gt;
&lt;br /&gt;
==sfwindow==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Window a portion of the dataset. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfwindow &amp;lt; in.rsf &amp;gt; out.rsf verb=n squeeze=y j#=(1,...) d#=(d1,d2,...) f#=(0,...) min#=(o1,o2,,...) n#=(0,...) max#=(o1+(n1-1)*d1,o2+(n1-1)*d2,,...)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d#=(d1,d2,...)&#039;&#039;&#039; ||   || 	sampling in #-th dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;f#=(0,...)&#039;&#039;&#039; ||   || 	window start in #-th dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;j#=(1,...)&#039;&#039;&#039; ||   || 	jump in #-th dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;max#=(o1+(n1-1)*d1,o2+(n1-1)*d2,,...)&#039;&#039;&#039; ||   || 	maximum in #-th dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;min#=(o1,o2,,...)&#039;&#039;&#039; ||   || 	minimum in #-th dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n#=(0,...)&#039;&#039;&#039; ||   || 	window size in #-th dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;squeeze=y&#039;&#039;&#039; ||  [y/n] || 	if y, squeeze dimensions equal to 1 to the end&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	Verbosity flag&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;sfwindow&amp;lt;/b&amp;gt; is used to window a portion of the dataset. Here is&lt;br /&gt;
a quick example: Start by creating some data.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath n1=5 n2=3 o1=1 o2=1 output=&amp;quot;x1*x2&amp;quot; &amp;gt; test.rsf&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfdisfil&lt;br /&gt;
   0:             1            2            3            4            5&lt;br /&gt;
   5:             2            4            6            8           10&lt;br /&gt;
  10:             3            6            9           12           15&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now window the first two rows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfwindow n2=2 | sfdisfil&lt;br /&gt;
   0:             1            2            3            4            5&lt;br /&gt;
   5:             2            4            6            8           10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Window the first three columns:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfwindow n1=3 | sfdisfil&lt;br /&gt;
   0:             1            2            3            2            4&lt;br /&gt;
   5:             6            3            6            9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Window the middle row:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfwindow f2=1 n2=1 | sfdisfil&lt;br /&gt;
   0:             2            4            6            8           10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can interpret the &amp;lt;b&amp;gt;f#&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;n#&amp;lt;/b&amp;gt; parameters as&lt;br /&gt;
meaning &amp;quot;skip that many rows/columns&amp;quot; and &amp;quot;select that many&lt;br /&gt;
rows/columns&amp;quot; correspondingly. Window the middle point in the dataset:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfwindow f1=2 n1=1 f2=1 n2=1 | sfdisfil&lt;br /&gt;
   0:             6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Window every other column:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfwindow j1=2 | sfdisfil&lt;br /&gt;
   0:             1            3            5            2            6&lt;br /&gt;
   5:            10            3            9           15&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Window every third column:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfwindow j1=3 | sfdisfil&lt;br /&gt;
   0:             1            4            2            8            3&lt;br /&gt;
   5:            12&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Alternatively, &amp;lt;b&amp;gt;sfwindow&amp;lt;/b&amp;gt; can use the minimum and maximum&lt;br /&gt;
parameters to select a window. In the following example, we are&lt;br /&gt;
creating a dataset with &amp;lt;b&amp;gt;sfspike&amp;lt;/b&amp;gt; and then windowing a portion of it&lt;br /&gt;
between 1 and 2 seconds in time and sampled at 8 miliseconds.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=1000 n2=10 &amp;gt; spike.rsf         &lt;br /&gt;
bash&amp;amp;#36; sfin spike.rsf&lt;br /&gt;
spike.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/spike.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=1000        d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=10          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
        10000 elements 40000 bytes&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; spike.rsf sfwindow min1=1 max1=2 d1=0.008 &amp;gt; window.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin window.rsf&lt;br /&gt;
window.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/window.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=126         d1=0.008       o1=1          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=10          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
        1260 elements 5040 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
By default, &amp;lt;b&amp;gt;sfwindow&amp;lt;/b&amp;gt; &amp;quot;squeezes&amp;quot; the hypercube dimensions&lt;br /&gt;
that are equal to one toward the end of the dataset. Here is an&lt;br /&gt;
example of taking a time slice:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; spike.rsf sfwindow n1=1 min1=1 &amp;gt; slice.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin slice.rsf &lt;br /&gt;
slice.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/slice.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=10          d1=0.1         o1=0          label1=&amp;quot;Distance&amp;quot; unit1=&amp;quot;km&amp;quot; &lt;br /&gt;
    n2=1           d2=0.004       o2=1          label2=&amp;quot;Time&amp;quot; unit2=&amp;quot;s&amp;quot; &lt;br /&gt;
        10 elements 40 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can change this behavior by specifying &amp;lt;b&amp;gt;squeeze=n&amp;lt;/b&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; spike.rsf sfwindow n1=1 min1=1 squeeze=n &amp;gt; slice.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin slice.rsf &lt;br /&gt;
slice.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/slice.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=1           d1=0.004       o1=1          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=10          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
        10 elements 40 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Seismic programs=&lt;br /&gt;
Programs in this category are specific for operations on seismic data. The source files for these programs can be found under [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/seismic/ system/seismic] in the Madagascar distribution.&lt;br /&gt;
&lt;br /&gt;
==sffkamo==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Computes Azimuth Move-Out (AMO) operator in the f-k log-stretch domain &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sffkamo &amp;lt; in.rsf &amp;gt; out.rsf h1= h2= f1= f2= maxe=10.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;f1=&#039;&#039;&#039; ||   || 	input azimuth in degrees&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;f2=&#039;&#039;&#039; ||   || 	output azimuth in degrees&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;h1=&#039;&#039;&#039; ||   || 	input offset&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;h2=&#039;&#039;&#039; ||   || 	output offset&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;maxe=10.&#039;&#039;&#039; ||   || 	stability constraint&lt;br /&gt;
|}&lt;br /&gt;
Sample workflow from [http://m8r.info/RSF/book/sep/fkamo/paper_html/ SEP-110, 63-70 (2001)], with the addition of a bandpass for the input:&lt;br /&gt;
&lt;br /&gt;
Create input -- a (t,x,y) common-offset cube:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfspike \&lt;br /&gt;
n1=128 o1=0.4 d1=0.0032 k1=65 label1=t \&lt;br /&gt;
n2=256 o2=-1.536 d2=0.012 k2=129 label2=x \&lt;br /&gt;
n3=128 o3=-1.024 d3=0.016 k3=65 label3=y | \&lt;br /&gt;
sfbandpass flo=5 fhi=60 &amp;gt; spikebps.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apply log-stretch FFT:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt;spikebps.rsf sfstretch rule=L dens=4 |\&lt;br /&gt;
sffft1 |\&lt;br /&gt;
sffft3 axis=2 |\&lt;br /&gt;
sffft3 axis=3 &amp;gt; spikefft3.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Compute AMO operator for a file of the dimensions of &amp;lt;tt&amp;gt;spikefft3.rsf&amp;lt;/tt&amp;gt;. The only information taken from stdin are the n, o, d parameters:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt;spikefft3.rsf sffkamo h2=2 f2=10 h1=1.8 f1=30 &amp;gt;oper.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apply the operator by multiplication and fft back to (t, mx, my):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; spikefft3.rsf sfadd mode=prod oper.rsf |\&lt;br /&gt;
sffft3 axis=3 inv=y |\&lt;br /&gt;
sffft3 axis=2 inv=y |\&lt;br /&gt;
sffft1 inv=y |\&lt;br /&gt;
sfstretch rule=L dens=4 inv=y &amp;gt; spikeamo.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Prepare for 8-bit greyscale visualization:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; spikeamo.rsf sfbyte pclip=100 gainpanel=a &amp;gt; spikebyte.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Picture from the middle of the impulse response:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt;spikebyte.rsf sfgrey3 frame1=65 frame2=129 frame3=65 \&lt;br /&gt;
point1=0.333 title=&#039;AMO saddle, no f-k filter&#039; | sfpen &amp;amp;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Picture illustrating the artifacts (i.e. need for f-k filter):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; spikebyte.rsf sfgrey3 frame1=65 frame2=97 frame3=97 \&lt;br /&gt;
point1=0.333 title=&#039;No f-k filter&#039; | sfpen &amp;amp;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apply the f-k filter and (in this case) visualize:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; spikeamo.rsf sffft1 |\&lt;br /&gt;
sffft3 axis=2 |\&lt;br /&gt;
sffft3 axis=3 |\&lt;br /&gt;
sfdipfilter v1=-2.5 v2=-1.5 v3=1.5 v4=2.5 taper=2 pass=0 dim=3 |\&lt;br /&gt;
sffft3 axis=3 inv=y |\&lt;br /&gt;
sffft3 axis=2 inv=y |\&lt;br /&gt;
sffft1 inv=y |\&lt;br /&gt;
sfbyte pclip=100 gainpanel=a |\&lt;br /&gt;
sfgrey3 frame1=65 frame2=97 frame3=97 point1=0.333 title=&#039;With f-k filter&#039; |\&lt;br /&gt;
sfpen &amp;amp;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfheaderattr==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Integer header attributes. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfheaderattr &amp;lt; head.rsf&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Only nonzero values are reported.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfheaderattr&amp;lt;/tt&amp;gt; examines the contents of a trace header file,&lt;br /&gt;
typically generated by &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt;. In the example below, we examine&lt;br /&gt;
trace headers in the output of &amp;lt;tt&amp;gt;suplane&amp;lt;/tt&amp;gt;, a program from Seismic Unix.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ suplane &amp;gt; plane.su&lt;br /&gt;
bash$ sfsegyread tape=plane.su su=y tfile=tfile.rsf &amp;gt; plane.rsf&lt;br /&gt;
bash$ sfheaderattr &amp;lt; tfile.rsf&lt;br /&gt;
*******************************************&lt;br /&gt;
71 headers, 32 traces&lt;br /&gt;
key[0]=&amp;quot;tracl&amp;quot;      min[0]=1            max[31]=32          mean=16.5&lt;br /&gt;
key[1]=&amp;quot;tracr&amp;quot;      min[0]=1            max[31]=32          mean=16.5&lt;br /&gt;
key[11]=&amp;quot;offset&amp;quot;    min[0]=400          max[31]=400         mean=400&lt;br /&gt;
key[38]=&amp;quot;ns&amp;quot;        min[0]=64           max[31]=64          mean=64&lt;br /&gt;
key[39]=&amp;quot;dt&amp;quot;        min[0]=4000         max[31]=4000        mean=4000&lt;br /&gt;
*******************************************&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
For different standard keywords, a minimum, maximum, and mean values&lt;br /&gt;
are reported unless they are identically zero.  This quick inspection&lt;br /&gt;
can help in identifying meaningful keywords set in the data. The input&lt;br /&gt;
data type must be &amp;lt;tt&amp;gt;int&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==sfheadermath==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Mathematical operations, possibly on header keys. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfheadermath &amp;lt; in.rsf &amp;gt; out.rsf memsize=sf_memsize() output=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Known functions: cos,  sin,  tan,  acos,  asin,  atan, &amp;lt;br&amp;gt;                 cosh, sinh, tanh, acosh, asinh, atanh,&amp;lt;br&amp;gt;                 exp,  log,  sqrt, abs&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;See also sfmath. &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;An addition operation can be performed by sfstack.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;memsize=sf_memsize()&#039;&#039;&#039; ||   || 	Max amount of RAM (in Mb) to be used&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;output=&#039;&#039;&#039; ||   || 	Describes the output in a mathematical notation.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;tt&amp;gt;sfheadermath&amp;lt;/tt&amp;gt; is a versatile program for mathematical&lt;br /&gt;
operations on rows of the input file. If the input file is an&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; by &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt; matrix, the output will be a &amp;lt;tt&amp;gt;1&amp;lt;/tt&amp;gt; by&lt;br /&gt;
&amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt; matrix that contains one row made out of mathematical&lt;br /&gt;
operations on the other rows. &amp;lt;tt&amp;gt;sfheadermath&amp;lt;/tt&amp;gt; can identify a row&lt;br /&gt;
by number or by a standard SEGY keyword. The latter is useful for&lt;br /&gt;
processing headers extracted from SEGY or SU files.&lt;br /&gt;
Here is an example. First, we create an SU file with &amp;lt;tt&amp;gt;suplane&amp;lt;/tt&amp;gt; and convert it to RSF using &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ suplane &amp;gt; plane.su&lt;br /&gt;
bash$ sfsegyread tape=plane.su su=y tfile=tfile.rsf &amp;gt; plane.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The trace header information is saved in &amp;lt;tt&amp;gt;tfile.rsf&amp;lt;/tt&amp;gt;. It&lt;br /&gt;
contains 71 headers for 32 traces in integer format.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfin tfile.rsf&lt;br /&gt;
tfile.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/tfile.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=int form=native&lt;br /&gt;
    n1=71          d1=?           o1=?&lt;br /&gt;
    n2=32          d2=?           o2=?&lt;br /&gt;
        2272 elements 9088 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Next, we will convert &amp;lt;tt&amp;gt;tfile.rsf&amp;lt;/tt&amp;gt; to a floating-point format&lt;br /&gt;
and run &amp;lt;tt&amp;gt;sfheadermath&amp;lt;/tt&amp;gt; to create a new header.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; tfile.rsf sfdd type=float | \&lt;br /&gt;
sfheadermath myheader=1 output=&amp;quot;sqrt(myheader+(2+10*offset^2))&amp;quot; &amp;gt; new.rsf&lt;br /&gt;
bash$ sfin new.rsf&lt;br /&gt;
new.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/new.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=1           d1=?           o1=?&lt;br /&gt;
    n2=32          d2=?           o2=?&lt;br /&gt;
        32 elements 128 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We defined &amp;quot;myheader&amp;quot; as being the row number 1 in the input (note&lt;br /&gt;
that numbering starts with 0) and combined it with &amp;quot;offset&amp;quot;, which&lt;br /&gt;
is a standard SEGY keyword that denotes row number 11 (see the output&lt;br /&gt;
of &amp;lt;tt&amp;gt;sfheaderattr&amp;lt;/tt&amp;gt; above.) A variety of mathematical expressions&lt;br /&gt;
can be defined in the &amp;lt;tt&amp;gt;output=&amp;lt;/tt&amp;gt; string. The expression&lt;br /&gt;
processing engine is shared with &amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==sfsegyheader==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Make a trace header file for segywrite.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfsegyheader &amp;lt; in.rsf &amp;gt; out.rsf n1= d1=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;   Use the output for tfile= argument in segywrite.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d1=&#039;&#039;&#039; ||   ||      trace sampling&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n1=&#039;&#039;&#039; ||   ||      number of samples in a trace&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==sfsegyread==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Convert a SEG-Y or SU dataset to RSF.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfsegyread mask=msk.rsf &amp;gt; out.rsf tfile=hdr.rsf verb=n su= suxdr=n endian=y format=segyformat (bhead) ns=segyns (bhead) tape= read= hfile= bfile=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Data headers and trace headers are separated from the data.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;quot;suread&amp;quot; is equivalent to &amp;quot;segyread su=y&amp;quot;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;SEGY key names:&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tracl: trace sequence number within line 0&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tracr: trace sequence number within reel 4&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;fldr:     field record number 8 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tracf:    trace number within field record 12 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;ep:       energy source point number 16 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;cdp:      CDP ensemble number 20 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;cdpt:     trace number within CDP ensemble 24 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;trid:     trace identification code:&amp;lt;br&amp;gt;1 = seismic data&amp;lt;br&amp;gt;2 = dead&amp;lt;br&amp;gt;3 = dummy&amp;lt;br&amp;gt;4 = time break&amp;lt;br&amp;gt;5 = uphole&amp;lt;br&amp;gt;6 = sweep&amp;lt;br&amp;gt;7 = timing&amp;lt;br&amp;gt;8 = water break&amp;lt;br&amp;gt;9---, N = optional use (N = 32,767) 28 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;nvs:      number of vertically summed traces 30 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;nhs:      number of horizontally summed traces 32 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;duse:     data use:&amp;lt;br&amp;gt;1 = production&amp;lt;br&amp;gt;2 = test 34&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;offset:   distance from source point to receiver&amp;lt;br&amp;gt;group (negative if opposite to direction&amp;lt;br&amp;gt;in which the line was shot) 36 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gelev:    receiver group elevation from sea level&amp;lt;br&amp;gt;(above sea level is positive) 40 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;selev:    source elevation from sea level&amp;lt;br&amp;gt;(above sea level is positive) 44 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sdepth:   source depth (positive) 48 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gdel:     datum elevation at receiver group 52 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sdel:     datum elevation at source 56 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;swdep:    water depth at source 60 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gwdep:    water depth at receiver group 64 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;scalel:   scale factor for previous 7 entries&amp;lt;br&amp;gt;with value plus or minus 10 to the&amp;lt;br&amp;gt;power 0, 1, 2, 3, or 4 (if positive,&amp;lt;br&amp;gt;multiply, if negative divide) 68 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;scalco:   scale factor for next 4 entries&amp;lt;br&amp;gt;with value plus or minus 10 to the&amp;lt;br&amp;gt;power 0, 1, 2, 3, or 4 (if positive,&amp;lt;br&amp;gt;multiply, if negative divide) 70 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sx:       X source coordinate 72 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sy:       Y source coordinate 76 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gx:       X group coordinate 80 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gy:       Y group coordinate 84 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;counit:   coordinate units code:&amp;lt;br&amp;gt;for previous four entries&amp;lt;br&amp;gt;1 = length (meters or feet)&amp;lt;br&amp;gt;2 = seconds of arc (in this case, the&amp;lt;br&amp;gt;X values are unsigned longitude and the Y values&amp;lt;br&amp;gt;are latitude, a positive value designates&amp;lt;br&amp;gt;the number of seconds east of Greenwich&amp;lt;br&amp;gt;or north of the equator 88 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;wevel:     weathering velocity 90 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;swevel:    subweathering velocity 92 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sut:       uphole time at source 94 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gut:       uphole time at receiver group 96 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sstat:     source static correction 98 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gstat:     group static correction 100 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tstat:     total static applied 102 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;laga:      lag time A, time in ms between end of 240-&amp;lt;br&amp;gt;byte trace identification header and time&amp;lt;br&amp;gt;break, positive if time break occurs after&amp;lt;br&amp;gt;end of header, time break is defined as&amp;lt;br&amp;gt;the initiation pulse which maybe recorded&amp;lt;br&amp;gt;on an auxiliary trace or as otherwise&amp;lt;br&amp;gt;specified by the recording system 104 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;lagb:      lag time B, time in ms between the time&amp;lt;br&amp;gt;break and the initiation time of the energy source,&amp;lt;br&amp;gt;may be positive or negative 106 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;delrt:     delay recording time, time in ms between&amp;lt;br&amp;gt;initiation time of energy source and time&amp;lt;br&amp;gt;when recording of data samples begins&amp;lt;br&amp;gt;(for deep water work if recording does not&amp;lt;br&amp;gt;start at zero time) 108 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;muts:      mute time--start 110 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;mute:      mute time--end 112 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;ns:        number of samples in this trace 114 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;dt:        sample interval, in micro-seconds 116 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gain:      gain type of field instruments code:&amp;lt;br&amp;gt;1 = fixed&amp;lt;br&amp;gt;2 = binary&amp;lt;br&amp;gt;3 = floating point&amp;lt;br&amp;gt;4 ---- N = optional use 118 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;igc:       instrument gain constant 120 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;igi:       instrument early or initial gain 122 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;corr:      correlated:&amp;lt;br&amp;gt;1 = no&amp;lt;br&amp;gt;2 = yes 124&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sfs:       sweep frequency at start 126 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sfe:       sweep frequency at end 128 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;slen:      sweep length in ms 130 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;styp:      sweep type code:&amp;lt;br&amp;gt;1 = linear&amp;lt;br&amp;gt;2 = cos-squared&amp;lt;br&amp;gt;3 = other 132&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;stas:      sweep trace length at start in ms 134 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;stae:      sweep trace length at end in ms 136 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tatyp:     taper type: 1=linear, 2=cos^2, 3=other 138 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;afilf:     alias filter frequency if used 140 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;afils:     alias filter slope 142 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;nofilf:    notch filter frequency if used 144 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;nofils:    notch filter slope 146 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;lcf:       low cut frequency if used 148 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;hcf:       high cut frequncy if used 150 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;lcs:       low cut slope 152 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;hcs:       high cut slope 154 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;year:      year data recorded 156 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;day:       day of year 158 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;hour:      hour of day (24 hour clock) 160 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;minute:    minute of hour 162 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sec:       second of minute 164 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;timbas:    time basis code:&amp;lt;br&amp;gt;1 = local&amp;lt;br&amp;gt;2 = GMT&amp;lt;br&amp;gt;3 = other 166&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;trwf:      trace weighting factor, defined as 1/2^N&amp;lt;br&amp;gt;volts for the least sigificant bit 168 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;grnors:    geophone group number of roll switch&amp;lt;br&amp;gt;position one 170&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;grnofr:    geophone group number of trace one within&amp;lt;br&amp;gt;original field record 172&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;grnlof:    geophone group number of last trace within&amp;lt;br&amp;gt;original field record 174&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gaps:      gap size (total number of groups dropped) 176 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;otrav:     overtravel taper code: &amp;lt;br&amp;gt;1 = down (or behind)&amp;lt;br&amp;gt;2 = up (or ahead) 178&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;cdpx:   X coordinate of CDP 180&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;cdpy:   Y coordinate of CDP 184&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;iline:  in-line number 188 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;xline:  cross-line number 192&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;shnum:  shotpoint number 196&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;shsca:  shotpoint scalar 200&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tval:   trace value meas. 202&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tconst4: transduction const 204&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tconst2: transduction const 208&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tunits:  transduction units 210&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;device:  device identifier 212&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tscalar: time scalar 214&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;stype:   source type 216&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sendir:  source energy dir. 218&amp;lt;br&amp;gt; &amp;lt;br&amp;gt;unknown: unknown 222&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;smeas4:  source measurement 224&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;smeas2:  source measurement 228&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;smeasu:  source measurement unit 230 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;unass1:  unassigned 232&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;unass2:  unassigned 236&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;bfile=&#039;&#039;&#039; ||   || 	output binary data header file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;endian=y&#039;&#039;&#039; ||  [y/n] || 	Whether to automatically estimate endianness or not&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;format=segyformat (bhead)&#039;&#039;&#039; ||  [1,2,3,5] || 	Data format. The default is taken from binary header.&lt;br /&gt;
:1 is IBM floating point&lt;br /&gt;
:2 is 4-byte integer&lt;br /&gt;
:3 is 2-byte integer&lt;br /&gt;
:5 is IEEE floating point&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;hfile=&#039;&#039;&#039; ||   || 	output text data header file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;mask=&#039;&#039;&#039; ||   || 	optional header mask for reading only selected traces (auxiliary input file name)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ns=segyns (bhead)&#039;&#039;&#039; ||   || 	Number of samples. The default is taken from binary header&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;read=&#039;&#039;&#039; ||   || 	what to read: h - header, d - data, b - both (default)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;su=&#039;&#039;&#039; ||  [y/n] || 	y if input is SU, n if input is SEGY&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;suxdr=n&#039;&#039;&#039; ||  [y/n] || 	y, SU has XDR support&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;tape=&#039;&#039;&#039; ||   || 	input data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;tfile=&#039;&#039;&#039; ||   || 	output trace header file (auxiliary output file name)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	Verbosity flag&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The SEG Y format is an [http://en.wikipedia.org/wiki/Open_standard open standard] for the exchange of geophysical data. It is controlled by the non-profit [http://www.seg.org/SEGportalWEBproject/portals/SEG_Online.portal?_nfpb=true&amp;amp;_pageLabel=pg_gen_content&amp;amp;Doc_Url=prod/SEG-Publications/Pub-Yearbook/committees.htm SEG Technical Standards Committee]. There are two versions of this standard: [http://www.seg.org/SEGportalWEBproject/prod/SEG-Publications/Pub-Technical-Standards/Documents/seg_y_rev0.pdf rev0] (1975)&amp;lt;ref&amp;gt;Barry, K.M., Cavers, D.A., and Kneale, C.W. 1975. Recommended standards for digital tape formats. &#039;&#039;Geophysics&#039;&#039;, &#039;&#039;&#039;40&#039;&#039;&#039;, no. 02, 344–352.&amp;lt;/ref&amp;gt; and [http://www.seg.org/SEGportalWEBproject/prod/SEG-Publications/Pub-Technical-Standards/Documents/seg_y_rev1.pdf rev1] (2002)&amp;lt;ref&amp;gt;Norris, M.W., Faichney, A.K., &#039;&#039;Eds&#039;&#039;. 2001. SEG Y rev1 Data Exchange format. Society of Exploration Geophysicists, Tulsa, OK, 45 pp.&amp;lt;/ref&amp;gt;. The implementation in &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt; is a mixture of rev0 (i.e. no checks for Extended Textual Headers) and rev1 ([http://en.wikipedia.org/wiki/IEEE_floating-point_standard IEEE floating point format] allowed for trace data samples).&lt;br /&gt;
&lt;br /&gt;
A SEG-Y file as understood by &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt; contains a &amp;quot;Reel Identification Header&amp;quot; (3200 bytes in EBCDIC followed by 400 bytes in a binary encoding), followed by a number of &amp;quot;Trace Blocks&amp;quot;. Each &amp;quot;Trace Block&amp;quot; contains a 240-byte &amp;quot;Trace Header&amp;quot; (binary) followed by &amp;quot;Trace Data&amp;quot; -- a sequence of &amp;lt;tt&amp;gt;ns&amp;lt;/tt&amp;gt; samples. Binary values in both reel headers and trace headers are two&#039;s complement integers, either two bytes or four bytes long. There are no floating-point values defined in the headers. Trace Data samples can have various encodings, either floating point or integer, described further down, but they are all big-endian. To convert from SEG-Y to RSF, &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt; will strip the tape reel EBCDIC header and convert it to ASCII, will extract the reel binary header without changing it, and will put the trace headers into one RSF file, and the traces themselves on another.&lt;br /&gt;
&lt;br /&gt;
===SEG-Y Trace Headers===&lt;br /&gt;
In the SEG-Y standard, only the first 180 bytes of the 240-byte trace header are defined; bytes 181-240 are reserved for non-standard header information, and these locations are increasingly used in modern SEG-Y files and its variants. The standard provides for a total of 71 4-byte and 2-byte predefined header words. These 71 standard words have defined lengths and byte offsets, and only these words and byte locations are read using &amp;lt;tt&amp;gt;segyread&amp;lt;/tt&amp;gt; and output to the RSF header file with the &amp;lt;tt&amp;gt;hfile=&amp;lt;/tt&amp;gt; option. The user may remap these predefined keywords to a different byte offsets.&lt;br /&gt;
&lt;br /&gt;
===SU File Format===&lt;br /&gt;
An [http://www.cwp.mines.edu/sututor/node22.html SU file] is nothing more than a SEG-Y file without the reel headers, and with the Trace Data samples in the native encoding of the CPU the file was created on (Attention -- limited portability!). So, to convert from SU to RSF, &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt; will just separate headers and traces into two RSF files. &lt;br /&gt;
&lt;br /&gt;
===SEG-Y specific parameters===&lt;br /&gt;
*&amp;lt;tt&amp;gt;hfile=&amp;lt;/tt&amp;gt; specifies the name of the file in which the EBCDIC reel header will be put after conversion to ASCII. If you are certain there is no useful information in it, &amp;lt;tt&amp;gt;hfile=/dev/null&amp;lt;/tt&amp;gt; works just fine. If you do not specify anything for this parameter you will get an ASCII file named &amp;lt;tt&amp;gt;header&amp;lt;/tt&amp;gt; in the current directory. If you want to quickly preview this header before running &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt;, use&amp;lt;pre&amp;gt;dd if=input.segy count=40 bs=80 cbs=80 conv=unblock,ascii&amp;lt;/pre&amp;gt;&lt;br /&gt;
*&amp;lt;tt&amp;gt;bfile=&amp;lt;/tt&amp;gt; specifies name of the file in which the binary reel header (the 400-bytes thing following the 3600-bytes EBCDIC) will be put without any conversion. The default name is &amp;quot;binary&amp;quot;. Unless you have software that knows how to read exactly this special type of file, it will be completely useless, so do &amp;lt;tt&amp;gt;bfile=/dev/null&amp;lt;/tt&amp;gt;&lt;br /&gt;
*&amp;lt;tt&amp;gt;format=&amp;lt;/tt&amp;gt; specifies the format in which the trace data samples are in the SEG-Y input file. This is read from the binary reel header of the SEG-Y file. Valid values are 1(IBM floating point), 2 (4-byte integer), 3 (2-byte integer) and 5 (IEEE floating point). If the input file is SU, the format will be assumed to be the native &amp;lt;tt&amp;gt;float&amp;lt;/tt&amp;gt; format.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;tt&amp;gt;keyname=&amp;lt;/tt&amp;gt; specifies the byte offset to remap a header using the trace header key names shown above. For example, if the CDP locations have been placed in bytes 181-184 instead of the standard 21-24, &amp;lt;tt&amp;gt;cdp=180&amp;lt;/tt&amp;gt; will remap the trace header to that location. &lt;br /&gt;
&lt;br /&gt;
===SU-specific parameters===&lt;br /&gt;
*&amp;lt;tt&amp;gt;suxdr=&amp;lt;/tt&amp;gt; specifies whether the input file was created with a SU package with XDR support enabled. If you have access to the source code of your SU install (try &amp;lt;tt&amp;gt;$CWPROOT/src&amp;lt;/tt&amp;gt;), type: &amp;lt;tt&amp;gt;grep &#039;XDRFLAG =&#039; $CWPROOT/src/Makefile.config&amp;lt;/tt&amp;gt; and look at the last uncommented entry. If no value is given for &amp;lt;tt&amp;gt;XDRFLAG&amp;lt;/tt&amp;gt;, the package was not compiled with XDR support.&lt;br /&gt;
===Common parameters===&lt;br /&gt;
*&amp;lt;tt&amp;gt;su=&amp;lt;/tt&amp;gt; specifies if the input file is SU or SEG-Y. Default is &amp;lt;tt&amp;gt;su=n&amp;lt;/tt&amp;gt; (SEG-Y file).&lt;br /&gt;
*&amp;lt;tt&amp;gt;tape=&amp;lt;/tt&amp;gt; specifies the input data. Stdin could not be used because &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt; has to work with tapes, and needs to fseek back and forth through the input file. Thankfully, output is on stdout.&lt;br /&gt;
*&amp;lt;tt&amp;gt;read=&amp;lt;/tt&amp;gt; specifies what parts of the &amp;quot;Trace Blocks&amp;quot; will be read. It can be &amp;lt;tt&amp;gt;read=t&amp;lt;/tt&amp;gt; (only trace data is read), &amp;lt;tt&amp;gt;read=h&amp;lt;/tt&amp;gt; (only trace headers are read) or &amp;lt;tt&amp;gt;read=b&amp;lt;/tt&amp;gt; (both are read).&lt;br /&gt;
*&amp;lt;tt&amp;gt;tfile=&amp;lt;/tt&amp;gt; gives the name of the RSF file to which trace headers are written. Obviously, it should be only specified with &amp;lt;tt&amp;gt;read=h&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;read=b&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*&amp;lt;tt&amp;gt;mask=&amp;lt;/tt&amp;gt; is an optional parameter specifying the name of a mask that says which traces will be read. The mask is a 1-D RSF file with integers. The number of samples in the mask is the same as the number of traces in the unmasked SEG-Y. In places corresponding to unwanted traces there should be zeros in the mask.&lt;br /&gt;
*&amp;lt;tt&amp;gt;ns=&amp;lt;/tt&amp;gt; specifies the number of samples in a trace. For SEG-Y files, the default is taken from the binary reel header, and for SU files, from the header of the first trace. This parameter is however critical enough that a command line override was given for it.&lt;br /&gt;
*&amp;lt;tt&amp;gt;verbose=&amp;lt;/tt&amp;gt; is the verbosity flag. Can be &amp;lt;tt&amp;gt;y&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*&amp;lt;tt&amp;gt;endian=&amp;lt;/tt&amp;gt; is a y/n flag (default y), specifying whether to automatically estimate or not if samples in the Trace Data blocks are big-endian or little-endian. Try it if you are in trouble and do not know what else to do, otherwise let the automatic estimation do its job.&lt;br /&gt;
&lt;br /&gt;
==sfsegywrite==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Convert an RSF dataset to SEGY or SU.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfsegywrite &amp;lt; in.rsf tfile=hdr.rsf verb=false su=false endian=sf_endian() tape= hfile= bfile=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Merges trace headers with data.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;bfile=&#039;&#039;&#039; ||   ||   input binary data header file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;endian=sf_endian()&#039;&#039;&#039; ||  [y/n] ||  big/little endian flag. The default is estimated automatically&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;hfile=&#039;&#039;&#039; ||   ||   input text data header file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;su=n&#039;&#039;&#039; ||  [y/n] ||        y if output is SU, n if output is SEGY&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;tape=&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] ||   Verbosity flag&lt;br /&gt;
|}&lt;br /&gt;
Please see &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt; for a complete description of parameter meanings and background issues. Parameters &amp;lt;tt&amp;gt;bfile&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;hfile&amp;lt;/tt&amp;gt; should only be given values when the desired file is SEG-Y (default). The output file is specified by the &amp;lt;tt&amp;gt;tape=&amp;lt;/tt&amp;gt; tag.&lt;br /&gt;
&lt;br /&gt;
=Plotting programs (stable)=&lt;br /&gt;
The source files for these programs can be found under&lt;br /&gt;
[http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/plot/main/ plot/main]&lt;br /&gt;
in the Madagascar distribution.&lt;br /&gt;
&lt;br /&gt;
==sfbox==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Draw a balloon-style label.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfbox lab_color=VP_WHITE lab_fat=0 pscale=1. pointer=y reverse=n lat=0. long=90. angle=0. x0=0. y0=0. scale0=1. xt=2. yt=0. x_oval=0. y_oval=0. boxit=y length= scalet= size=.25 label= &amp;gt; out.vpl&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;angle=0.&#039;&#039;&#039; ||   || 	longitude of floating label in 3-D&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;boxit=y&#039;&#039;&#039; ||  [y/n] || 	if y, create a box around text&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;lab_color=VP_WHITE&#039;&#039;&#039; ||   || 	label color&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;lab_fat=0&#039;&#039;&#039; ||   || 	label fatness&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label=&#039;&#039;&#039; ||   || 	text for label&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;lat=0.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;length=&#039;&#039;&#039; ||   || 	normalization for xt and yt&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;long=90.&#039;&#039;&#039; ||   || 	latitude and longitude of viewpoint in 3-D&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;pointer=y&#039;&#039;&#039; ||  [y/n] || 	if y, create arrow pointer&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;pscale=1.&#039;&#039;&#039; ||   || 	scale factor for width of pointer&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;reverse=n&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;scale0=1.&#039;&#039;&#039; ||   || 	scale factor for x0 and y0&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;scalet=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;size=.25&#039;&#039;&#039; ||   || 	text height in inches&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;x0=0.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;x_oval=0.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;xt=2.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;y0=0.&#039;&#039;&#039; ||   || 	position of the pointer tip&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;y_oval=0.&#039;&#039;&#039; ||   || 	size of the oval around pointer&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;yt=0.&#039;&#039;&#039; ||   || 	relative position of text&lt;br /&gt;
|}&lt;br /&gt;
==sfcontour==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Contour plot.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcontour &amp;lt; in.rsf c= min1=o1 min2=o2 max1=o1+(n1-1)*d1 max2=o2+(n2-1)*d2 nc=50 dc= c0= transp=y minval= maxval= allpos=y barlabel= &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Run &amp;quot;sfdoc stdplot&amp;quot; for more parameters.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;allpos=y&#039;&#039;&#039; ||  [y/n] || 	contour positive values only&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;barlabel=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;floats &#039;&#039; || &#039;&#039;&#039;c=&#039;&#039;&#039; ||   || 	 [nc]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;c0=&#039;&#039;&#039; ||   || 	first contour&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dc=&#039;&#039;&#039; ||   || 	contour increment&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;max1=o1+(n1-1)*d1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;max2=o2+(n2-1)*d2&#039;&#039;&#039; ||   || 	data window to plot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;maxval=&#039;&#039;&#039; ||   || 	maximum value for scalebar (default is the data maximum)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;min1=o1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;min2=o2&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;minval=&#039;&#039;&#039; ||   || 	minimum value for scalebar (default is the data minimum)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nc=50&#039;&#039;&#039; ||   || 	number of contours&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;transp=y&#039;&#039;&#039; ||  [y/n] || 	if y, transpose the axes&lt;br /&gt;
|}&lt;br /&gt;
==sfdots==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Plot signal with lollipops.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfdots &amp;lt; in.rsf labels= dots=(n1 &amp;lt;= 130)? 1: 0 seemean=(bool) (n2 &amp;lt;= 30) strings=(bool) (n1 &amp;lt;= 400) connect=1 corners= silk=n gaineach=y labelsz=8 yreverse=n constsep=n seedead=n transp=n xxscale=1. yyscale=1. clip=-1. overlap=0.9 screenratio=VP_SCREEN_RATIO screenht=VP_STANDARD_HEIGHT screenwd=screenhigh / screenratio radius=dd1/3 label1= unit1= title= &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;clip=-1.&#039;&#039;&#039; ||   || 	data clip&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;connect=1&#039;&#039;&#039; ||   || 	connection type: 1 - diagonal, 2 - bar, 4 - only for non-zero data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;constsep=n&#039;&#039;&#039; ||  [y/n] || 	if y, use constant trace separation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;corners=&#039;&#039;&#039; ||   || 	number of polygon corners (default is 6)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;dots=(n1 &amp;lt;= 130)? 1: 0&#039;&#039;&#039; ||   || 	type of dots: 1 - baloon, 0 - no dots, 2 - only for non-zero data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;gaineach=y&#039;&#039;&#039; ||  [y/n] || 	if y, gain each trace independently&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label1=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;strings&#039;&#039; || &#039;&#039;&#039;labels=&#039;&#039;&#039; ||   || 	trace labels  [n2]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;labelsz=8&#039;&#039;&#039; ||   || 	label size&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;overlap=0.9&#039;&#039;&#039; ||   || 	trace overlap&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;radius=dd1/3&#039;&#039;&#039; ||   || 	dot radius&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;screenht=VP_STANDARD_HEIGHT&#039;&#039;&#039; ||   || 	screen height&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;screenratio=VP_SCREEN_RATIO&#039;&#039;&#039; ||   || 	screen aspect ratio&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;screenwd=screenhigh / screenratio&#039;&#039;&#039; ||   || 	screen width&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;seedead=n&#039;&#039;&#039; ||  [y/n] || 	if y, show zero traces&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;seemean=(bool) (n2 &amp;lt;= 30)&#039;&#039;&#039; ||  [y/n] || 	if y, draw axis lines&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;silk=n&#039;&#039;&#039; ||  [y/n] || 	if y, silky plot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;strings=(bool) (n1 &amp;lt;= 400)&#039;&#039;&#039; ||  [y/n] || 	if y, draw strings&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;title=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;transp=n&#039;&#039;&#039; ||  [y/n] || 	if y, transpose the axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit1=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;xxscale=1.&#039;&#039;&#039; ||   || 	x scaling&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;yreverse=n&#039;&#039;&#039; ||  [y/n] || 	if y, reverse y axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;yyscale=1.&#039;&#039;&#039; ||   || 	y scaling&lt;br /&gt;
|}&lt;br /&gt;
==sfgraph3==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generate 3-D cube plot for surfaces.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfgraph3 &amp;lt; in.rsf orient=1 min= max= point1=0.5 point2=0.5 frame1=0.5*(min+max) frame2=n1-1 frame3=0 movie=0 dframe=1 n1pix=n1/point1+n3/(1.-point1) n2pix=n2/point2+n3/(1.-point2) flat=y &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dframe=1&#039;&#039;&#039; ||   || 	frame increment in a movie&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;flat=y&#039;&#039;&#039; ||  [y/n] || 	if n, display perspective view&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;frame1=0.5*(min+max)&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;frame2=n1-1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;frame3=0&#039;&#039;&#039; ||   || 	frame numbers for cube faces&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;max=&#039;&#039;&#039; ||   || 	maximum function value&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;min=&#039;&#039;&#039; ||   || 	minimum function value&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;movie=0&#039;&#039;&#039; ||   || 	0: no movie, 1: movie over axis 1, 2: axis 2, 3: axis 3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n1pix=n1/point1+n3/(1.-point1)&#039;&#039;&#039; ||   || 	number of vertical pixels&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n2pix=n2/point2+n3/(1.-point2)&#039;&#039;&#039; ||   || 	number of horizontal pixels&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;orient=1&#039;&#039;&#039; ||   || 	function orientation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;point1=0.5&#039;&#039;&#039; ||   || 	fraction of the vertical axis for front face&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;point2=0.5&#039;&#039;&#039; ||   || 	fraction of the horizontal axis for front face&lt;br /&gt;
|}&lt;br /&gt;
==sfgraph==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Graph plot.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfgraph &amp;lt; in.rsf symbolsz= pclip=100. transp=n symbol= &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Run &amp;quot;sfdoc stdplot&amp;quot; for more parameters.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;pclip=100.&#039;&#039;&#039; ||   || 	clip percentile&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;symbol=&#039;&#039;&#039; ||   || 	if set, plot with symbols instead of lines&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;floats &#039;&#039; || &#039;&#039;&#039;symbolsz=&#039;&#039;&#039; ||   || 	symbol size (default is 2)  [n2]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;transp=n&#039;&#039;&#039; ||  [y/n] || 	if y, transpose the axes&lt;br /&gt;
|}&lt;br /&gt;
==sfgrey3==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generate 3-D cube plot.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfgrey3 &amp;lt; in.rsf point1=0.5 point2=0.5 frame1=0 frame2=n2-1 frame3=0 movie=0 dframe=1 n1pix=n1/point1+n3/(1.-point1) n2pix=n2/point2+n3/(1.-point2) flat=y scalebar=n minval= maxval= barreverse=n nreserve=8 bar= color= &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Requires an &amp;quot;unsigned char&amp;quot; input (the output of sfbyte).&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;bar=&#039;&#039;&#039; ||   || 	file for scalebar data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;barreverse=n&#039;&#039;&#039; ||  [y/n] || 	if y, go from small to large on the bar scale&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;color=&#039;&#039;&#039; ||   || 	color scheme (default is i)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;dframe=1&#039;&#039;&#039; ||   || 	frame increment in a movie&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;flat=y&#039;&#039;&#039; ||  [y/n] || 	if n, display perspective view&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;frame1=0&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;frame2=n2-1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;frame3=0&#039;&#039;&#039; ||   || 	frame numbers for cube faces&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;maxval=&#039;&#039;&#039; ||   || 	maximum value for scalebar (default is the data maximum)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;minval=&#039;&#039;&#039; ||   || 	minimum value for scalebar (default is the data minimum)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;movie=0&#039;&#039;&#039; ||   || 	0: no movie, 1: movie over axis 1, 2: axis 2, 3: axis 3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n1pix=n1/point1+n3/(1.-point1)&#039;&#039;&#039; ||   || 	number of vertical pixels&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n2pix=n2/point2+n3/(1.-point2)&#039;&#039;&#039; ||   || 	number of horizontal pixels&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nreserve=8&#039;&#039;&#039; ||   || 	reserved colors&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;point1=0.5&#039;&#039;&#039; ||   || 	fraction of the vertical axis for front face&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;point2=0.5&#039;&#039;&#039; ||   || 	fraction of the horizontal axis for front face&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;scalebar=n&#039;&#039;&#039; ||  [y/n] || 	if y, draw scalebar&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Different [http://reproducibility.org/rsflog/index.php?/archives/14-Color-schemes.html color schemes] are available&lt;br /&gt;
for sfgrey and sfgrey3. Examples are in the book at [http://reproducibility.org/RSF/book/rsf/rsf/sfgrey.html rsf/rsf/sfgrey].&lt;br /&gt;
&lt;br /&gt;
==sfgrey==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generate raster plot.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfgrey &amp;lt; in.rsf &amp;gt; out.rsf bar=bar.rsf transp=y yreverse=y xreverse=n gpow= phalf= clip= pclip= gainstep=0.5+n1/256. allpos=n bias=0. polarity=n verb=n scalebar=n minval= maxval= barreverse=n wantframenum=(bool) (n3 &amp;gt; 1) nreserve=8 gainpanel= bar= color= &amp;gt; (plot.vpl | char.rsf)&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Can input char values.&amp;lt;br&amp;gt;If called &amp;quot;byte&amp;quot;, outputs char values.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Run &amp;quot;sfdoc stdplot&amp;quot; for more parameters.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;allpos=n&#039;&#039;&#039; ||  [y/n] || 	if y, assume positive data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;bar=&#039;&#039;&#039; ||   || 	file for scalebar data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;barreverse=n&#039;&#039;&#039; ||  [y/n] || 	if y, go from small to large on the bar scale&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;bias=0.&#039;&#039;&#039; ||   || 	subtract bias from data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;clip=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;color=&#039;&#039;&#039; ||   || 	color scheme (default is i)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;gainpanel=&#039;&#039;&#039; ||   || 	gain reference: &#039;a&#039; for all, &#039;e&#039; for each, or number&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;gainstep=0.5+n1/256.&#039;&#039;&#039; ||   || 	subsampling for gpow and clip estimation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;gpow=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;maxval=&#039;&#039;&#039; ||   || 	maximum value for scalebar (default is the data maximum)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;minval=&#039;&#039;&#039; ||   || 	minimum value for scalebar (default is the data minimum)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nreserve=8&#039;&#039;&#039; ||   || 	reserved colors&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;pclip=&#039;&#039;&#039; ||   || 	data clip percentile (default is 99)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;phalf=&#039;&#039;&#039; ||   || 	percentage for estimating gpow&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;polarity=n&#039;&#039;&#039; ||  [y/n] || 	if y, reverse polarity (white is high by default)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;scalebar=n&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;transp=y&#039;&#039;&#039; ||  [y/n] || 	if y, transpose the display axes&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	verbosity flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;wantframenum=(bool) (n3 &amp;gt; 1)&#039;&#039;&#039; ||  [y/n] || 	if y, display third axis position in the corner&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;xreverse=n&#039;&#039;&#039; ||  [y/n] || 	if y, reverse the horizontal axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;yreverse=y&#039;&#039;&#039; ||  [y/n] || 	if y, reverse the vertical axis&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Different [http://reproducibility.org/rsflog/index.php?/archives/14-Color-schemes.html color schemes] are available&lt;br /&gt;
and examples are in the book at [http://reproducibility.org/RSF/book/rsf/rsf/sfgrey.html rsf/rsf/sfgrey].&lt;br /&gt;
&lt;br /&gt;
==sfplas==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Plot Assembler - convert ascii to vplot. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfplas&lt;br /&gt;
|}&lt;br /&gt;
==sfpldb==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Plot Debugger - convert vplot to ascii. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfpldb&lt;br /&gt;
|}&lt;br /&gt;
==sfplotrays==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Plot rays.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfplotrays frame=frame.rsf nt=n1*n2 jr=1 frame= &amp;lt; rays.rsf &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Run &amp;quot;sfdoc stdplot&amp;quot; for more parameters.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;frame=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;jr=1&#039;&#039;&#039; ||   || 	skip rays&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nt=n1*n2&#039;&#039;&#039; ||   || 	maximum ray length&lt;br /&gt;
|}&lt;br /&gt;
==sfthplot==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Hidden-line surface plot.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfthplot &amp;lt; in.rsf uflag=y dflag=y alpha=45. titlsz=9 axissz=6 plotfat=0 titlefat=2 axisfat=2 plotcolup=VP_YELLOW plotcoldn=VP_RED axis=y axis1=y axis2=y axis3=y clip=0. pclip=100. gainstep=0.5+nx/256. bias=0. dclip=1. norm=y xc=1.5 zc=3 ratio=5. zmax= zmin= sz=6. label#= unit#= tpow=0 epow=0 gpow=1 title= &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;alpha=45.&#039;&#039;&#039; ||   || 	apparent angle in degrees, |alpha| &amp;lt; 89&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;axis=y&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;axis1=y&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;axis2=y&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;axis3=y&#039;&#039;&#039; ||  [y/n] || 	plot axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axisfat=2&#039;&#039;&#039; ||   || 	axes fatness&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axissz=6&#039;&#039;&#039; ||   || 	axes size&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;bias=0.&#039;&#039;&#039; ||   || 	subtract bias from data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;clip=0.&#039;&#039;&#039; ||   || 	data clip&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dclip=1.&#039;&#039;&#039; ||   || 	change the clip: clip *= dclip&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;dflag=y&#039;&#039;&#039; ||  [y/n] || 	if y, plot down side of the surface&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;epow=0&#039;&#039;&#039; ||   || 	exponential gain&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;gainstep=0.5+nx/256.&#039;&#039;&#039; ||   || 	subsampling for gpow and clip estimation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;gpow=1&#039;&#039;&#039; ||   || 	power gain&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label#=&#039;&#039;&#039; ||   || 	label on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;norm=y&#039;&#039;&#039; ||  [y/n] || 	normalize by the clip&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;pclip=100.&#039;&#039;&#039; ||   || 	data clip percentile&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;plotcoldn=VP_RED&#039;&#039;&#039; ||   || 	color of the lower side&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;plotcolup=VP_YELLOW&#039;&#039;&#039; ||   || 	color of the upper side&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;plotfat=0&#039;&#039;&#039; ||   || 	line fatness&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;ratio=5.&#039;&#039;&#039; ||   || 	plot adjustment&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;sz=6.&#039;&#039;&#039; ||   || 	vertical scale&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;title=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;titlefat=2&#039;&#039;&#039; ||   || 	title fatness&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;titlsz=9&#039;&#039;&#039; ||   || 	title size&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;tpow=0&#039;&#039;&#039; ||   || 	time power gain&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;uflag=y&#039;&#039;&#039; ||  [y/n] || 	if y, plot upper side of the surface&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit#=&#039;&#039;&#039; ||   || 	unit on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;xc=1.5&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;zc=3&#039;&#039;&#039; ||   || 	lower left corner of the plot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;zmax=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;zmin=&#039;&#039;&#039; ||   || &lt;br /&gt;
|}&lt;br /&gt;
==sfwiggle==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Plot data with wiggly traces. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfwiggle &amp;lt; in.rsf xpos=xpos.rsf xmax= xmin= poly=n fatp=1 xmask=1 ymask=1 pclip=98. zplot=0.75 clip=0. seemean=n verb=n transp=n yreverse=n xreverse=n xpos= &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Run &amp;quot;sfdoc stdplot&amp;quot; for more parameters.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;clip=0.&#039;&#039;&#039; ||   || 	data clip (estimated from pclip by default&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;fatp=1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;pclip=98.&#039;&#039;&#039; ||   || 	clip percentile&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;poly=n&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;seemean=n&#039;&#039;&#039; ||  [y/n] || 	if y, plot mean lines of traces&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;transp=n&#039;&#039;&#039; ||  [y/n] || 	if y, transpose the axes&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	verbosity flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;xmask=1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;xmax=&#039;&#039;&#039; ||   || 	maximum trace position (if using xpos)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;xmin=&#039;&#039;&#039; ||   || 	minimum trace position (if using xpos)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;xpos=&#039;&#039;&#039; ||   || 	optional header file with trace positions&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;xreverse=n&#039;&#039;&#039; ||  [y/n] || 	if y, reverse the horizontal axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ymask=1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;yreverse=n&#039;&#039;&#039; ||  [y/n] || 	if y, reverse the vertical axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;zplot=0.75&#039;&#039;&#039; ||   || &lt;br /&gt;
|}&lt;br /&gt;
=Plotting programs (development)=&lt;br /&gt;
==sfplsurf==&lt;br /&gt;
&amp;lt;tt&amp;gt;sfplsurf&amp;lt;/tt&amp;gt; utilizes PLplot&#039;s surface rendering capabilities. Output is dumped to stdout in VPLOT format, so it can easily be used in the same way as &amp;lt;tt&amp;gt;sfgrey&amp;lt;/tt&amp;gt; or other plotting programs. It also supports animation, if n3 &amp;gt; 1 in the input file. A SConstruct usage example can be found below. A [http://reproducibility.org/wikilocal/movies/sfplsurf_membrane.mpg movie of the output] is available as well.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&lt;br /&gt;
# x &amp;amp; y dimensions&lt;br /&gt;
o1=-2&lt;br /&gt;
o2=-2&lt;br /&gt;
n1=41&lt;br /&gt;
n2=41&lt;br /&gt;
d1=0.1&lt;br /&gt;
d2=0.1&lt;br /&gt;
# z dimension&lt;br /&gt;
o3=-1&lt;br /&gt;
n3=21&lt;br /&gt;
d3=0.1&lt;br /&gt;
&lt;br /&gt;
Flow(&#039;membrane&#039;,None,&lt;br /&gt;
    &#039;&#039;&#039;&lt;br /&gt;
    math o1=%g o2=%g n1=%d n2=%d d1=%g d2=%g&lt;br /&gt;
          o3=%g n3=%d d3=%g&lt;br /&gt;
          output=&amp;quot;x3*cos(x1*x1+x2*x2)*exp(-0.1*(x1*x1+x2*x2))&amp;quot;&lt;br /&gt;
    &#039;&#039;&#039; % (o1,o2,n1,n2,d1,d2,o3,n3,d3))&lt;br /&gt;
&lt;br /&gt;
Result(&#039;membrane&#039;,&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
      plsurf title=&amp;quot;Membrane&amp;quot; mesh=n color=j&lt;br /&gt;
              minval=%g maxval=%g&lt;br /&gt;
      &#039;&#039;&#039; % (o3,o3 + d3*(n3-1)))&lt;br /&gt;
&lt;br /&gt;
End()&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=system/generic programs=&lt;br /&gt;
==sfremap1==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | 1-D ENO interpolation. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfremap1 &amp;lt; in.rsf &amp;gt; out.rsf pattern=pattern.rsf n1=n1 d1=d1 o1=o1 order=3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d1=d1&#039;&#039;&#039; ||   || 	Output sampling&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n1=n1&#039;&#039;&#039; ||   || 	Number of output samples&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;o1=o1&#039;&#039;&#039; ||   || 	Output origin&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;order=3&#039;&#039;&#039; ||   || 	Interpolation order&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;pattern=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|}&lt;br /&gt;
To give an example of usage, we will create an input for &amp;lt;tt&amp;gt;sfremap1&amp;lt;/tt&amp;gt; with:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfmath n1=11 n2=11 d1=1 d2=1 o1=-5 o2=-5 output=&amp;quot;x1*x1+x2*x2&amp;quot; &amp;gt; inp2remap1.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Let us interpolate the data across both dimensions, then display it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt; inp2remap1.rsf sfremap1 n1=1001 d1=0.01 | sftransp | \&lt;br /&gt;
sfremap1 n1=1001 d1=0.01 | sftransp | sfgrey allpos=y | sfpen&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The comparison with the uninterpolated data ( &amp;lt;tt&amp;gt;&amp;amp;lt; inp2remap1.rsf sfgrey allpos=y | sfpen&amp;lt;/tt&amp;gt; ) is quite telling.&lt;br /&gt;
&lt;br /&gt;
=system/seismic programs=&lt;br /&gt;
==sfstretch==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Stretch of the time axis. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfstretch &amp;lt; in.rsf &amp;gt; out.rsf datum=dat.rsf inv=n dens=1 v0= half=y delay= tdelay= hdelay= nout=dens*n1 extend=4 mute=0 maxstr=0 rule=&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;datum=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;delay=&#039;&#039;&#039; ||   || 	time delay for rule=lmo&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;dens=1&#039;&#039;&#039; ||   || 	axis stretching factor&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;extend=4&#039;&#039;&#039; ||   || 	trace extension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;half=y&#039;&#039;&#039; ||  [y/n] || 	if y, the second axis is half-offset instead of full offset&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;hdelay=&#039;&#039;&#039; ||   || 	offset delay for rule=rad&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;inv=n&#039;&#039;&#039; ||  [y/n] || 	if y, do inverse stretching&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;maxstr=0&#039;&#039;&#039; ||   || 	maximum stretch&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;mute=0&#039;&#039;&#039; ||   || 	tapering size&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nout=dens*n1&#039;&#039;&#039; ||   || 	output axis length (if inv=n)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;rule=&#039;&#039;&#039; ||   || 	Stretch rule:&lt;br /&gt;
:n - normal moveout (nmostretch), default&lt;br /&gt;
:l - linear moveout (lmostretch)&lt;br /&gt;
:L - logarithmic stretch (logstretch)&lt;br /&gt;
:2 - t^2 stretch (t2stretch)&lt;br /&gt;
:c - t^2 chebyshev stretch (t2chebstretch)&lt;br /&gt;
:r - radial moveout (radstretch)&lt;br /&gt;
:d - datuming (datstretch)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;tdelay=&#039;&#039;&#039; ||   || 	time delay for rule=rad&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;v0=&#039;&#039;&#039; ||   || 	moveout velocity&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfstretch rule=d&amp;lt;/tt&amp;gt; (aka &amp;lt;tt&amp;gt;sfdatstretch&amp;lt;/tt&amp;gt;) can be used to apply statics. Here is a synthetic example, courtesy of Alessandro Frigeri:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# generate a dataset with &#039;flat&#039; signals&lt;br /&gt;
sfmath n1=200 n2=100 output=&amp;quot;sin(0.5*x1)&amp;quot; type=float &amp;gt; scan.rsf&lt;br /&gt;
&lt;br /&gt;
# generate a sinusoidal elevation correction&lt;br /&gt;
sfmath n1=100 output=&amp;quot;3*sin(x1)&amp;quot; type=float &amp;gt; statics.rsf&lt;br /&gt;
&lt;br /&gt;
# apply statics, producing a &#039;wavy&#039; output.&lt;br /&gt;
sfstretch &amp;lt; scan.rsf &amp;gt; out.rsf datum=statics.rsf rule=d&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=user/fomels programs=&lt;br /&gt;
==sfpick==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Automatic picking  from semblance-like panels. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfpick &amp;lt; scn.rsf &amp;gt; pik.rsf vel0=o2 niter=100 an=1. gate=3 smooth=y rect#=(1,1,...) rect1=1 rect2=1 ...&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | rectN defines the size of the smoothing stencil in N-th dimension.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Theory in Appendix B of:&amp;lt;br&amp;gt;S. Fomel, 2009, &amp;lt;br&amp;gt;Velocity analysis using AB semblance: Geophysical Prospecting, v. 57, 311-321.&amp;lt;br&amp;gt;Reproducible version in RSFSRC/book/jsg/avo &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;an=1.&#039;&#039;&#039; ||   || 	axes anisotropy&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;gate=3&#039;&#039;&#039; ||   || 	picking gate&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;niter=100&#039;&#039;&#039; ||   || 	number of iterations&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;rect#=(1,1,...)&#039;&#039;&#039; ||   || 	smoothing radius on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;smooth=y&#039;&#039;&#039; ||  [y/n] || 	if apply smoothing&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;vel0=o2&#039;&#039;&#039; ||   || 	surface velocity&lt;br /&gt;
|}&lt;br /&gt;
Short description of the algorithm:&lt;br /&gt;
# Start from the top (first time slice), pick an initial (source) point, evaluate all other points with the direct traveltime.&lt;br /&gt;
# At each grid point at the next level, find the traveltime to points at the previous level, add the traveltimes from the previous level, and select minimum. The search radius is limited by the aperture (gate= parameter in sfpick).&lt;br /&gt;
# Repeat step 2 until reaching the bottom.&lt;br /&gt;
# Pick the minimum traveltime at the bottom and track the ray back to the source by following the traveltime gradient direction.&lt;br /&gt;
# Postprocessing (smooth= parameter in sfpick): smooth the picked ray path using shaping regularization.&lt;br /&gt;
&lt;br /&gt;
The algorithm was discovered and rediscovered by many people. The best reference is probably &#039;&#039;V. Meshbey, E. Ragoza, D. Kosloff, U. Egozi, and D. Wexler, 2002, Three-dimensional Travel-time Calculation Based on Fermat&#039;s Principle: Pure and Applied Geophysics, v. 159, 1563-1582.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=user/ivlad programs=&lt;br /&gt;
==sfprep4plot==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Resamples a 2-D dataset to the desired picture resolution, with antialias&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfprep4plot inp= out= verb=n h=none w=none unit= ppi= prar=y&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Only one of the h and w parameters needs to be specified.&amp;lt;br&amp;gt;If prar=n, no action will be taken on axis for which h/w was not specified&amp;lt;br&amp;gt;If prar=y and only one par (h or w) is specified, the picture will scale&amp;lt;br&amp;gt;along both axes until it is of the specified dimension.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;h=none&#039;&#039;&#039; ||   || 	output height&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;inp=&#039;&#039;&#039; ||   || 	input file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;out=&#039;&#039;&#039; ||   || 	output file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ppi=&#039;&#039;&#039; ||   || 	output resolution (px/in). Necessary when unit!=px&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;prar=y&#039;&#039;&#039; ||  [y/n] || 	if y, PReserve Aspect Ratio of input&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit=&#039;&#039;&#039; ||   || 	unit of h and w. Can be: px(default), mm, cm, in&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	if y, print system commands, outputs&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;w=none&#039;&#039;&#039; ||   || 	output width&lt;br /&gt;
|}&lt;br /&gt;
For a figure that does not need the aspect ratio preserved,&lt;br /&gt;
and needs to fill a 1280x1024 projector display:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfprep4plot inp=file1.rsf out=file2.rsf w=1280 h=1024 prar=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
For a print figure that has to fit in a 6x8in box&lt;br /&gt;
at a resolution of 250 dpi, preserving the aspect ratio:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfprep4plot inp=file1.rsf out=file2.rsf w=6 h=8 unit=in ppi=250&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
A comparison of images before and after the application of &amp;lt;tt&amp;gt;sfprep4plot&amp;lt;/tt&amp;gt;, courtesy of Joachim Mispel, is shown below:&lt;br /&gt;
&lt;br /&gt;
[[Image:sf_prep4plot.jpg]]&lt;br /&gt;
&lt;br /&gt;
==sfcsv2rsf==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Convert a delimited-text ASCII file to RSF binary floating point or int.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcsv2rsf help=n delimiter=, dtype=float verb=n debug=n trunc=n o1=0. o2=0. d1=1. d2=1. unit1=unknown unit2=unknown label1=unknown label2=unknown&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Zeros will be added if number of elements is not the same in each row.&amp;lt;br&amp;gt;n1 and n2 are computed automatically. For consistency with sfdisfil and &amp;lt;br&amp;gt;sfmatmult, output is C-style order (row-first), i.e. rows in input file &amp;lt;br&amp;gt;become dimension-1 columns in output. Output encoding is native.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d1=1.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d2=1.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;debug=n&#039;&#039;&#039; ||  [y/n] || 	Extra verbosity for debugging&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;delimiter=,&#039;&#039;&#039; ||   || 	Separator between values in input file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;dtype=float&#039;&#039;&#039; ||   || 	Input type&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;help=n&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label1=unknown&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label2=unknown&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;o1=0.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;o2=0.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;trunc=n&#039;&#039;&#039; ||  [y/n] || 	Truncate or add zeros if nr elems in rows differs&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit1=unknown&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit2=unknown&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	Whether to echo n1, n2, infill/truncation&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
A small usage example follow below. First, create an input file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
$ echo -e &#039;5,6,8,9.2\n11,124,5,0,1&#039; | tee file.csv&lt;br /&gt;
5,6,8,9.2&lt;br /&gt;
11,124,5,0,1&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You may notice that the number of values in each row is different.&lt;br /&gt;
&lt;br /&gt;
Run &amp;lt;tt&amp;gt;sfcsv2rsf&amp;lt;/tt&amp;gt;. Notice that no options are needed. By default, zeros will be appended to make the rows equal length:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
$ &amp;lt;file.csv sfcsv2rsf &amp;gt; junk.rsf ; sfdisfil &amp;lt; junk.rsf &lt;br /&gt;
   0:             5            6            8          9.2            0&lt;br /&gt;
   5:            11          124            5            0            1&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that sfdisfil displays in column order (i.e. matrix is transposed if the number of rows is right). The dimensions of the file are actually transposed on disk:&lt;br /&gt;
&lt;br /&gt;
$ sfin junk.rsf&lt;br /&gt;
junk.rsf:&lt;br /&gt;
    in=&amp;quot;/data/path/junk.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=5           d1=1           o1=0          unit1=&amp;quot;unknown&amp;quot; &lt;br /&gt;
    n2=2           d2=1           o2=0          unit2=&amp;quot;unknown&amp;quot; &lt;br /&gt;
	10 elements 40 bytes&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You may want to run the output through &amp;lt;tt&amp;gt;sftransp&amp;lt;/tt&amp;gt;, depending on your needs. However, if creating an input for &amp;lt;tt&amp;gt;sfmatmult&amp;lt;/tt&amp;gt;, this will not be necessary, because &amp;lt;tt&amp;gt;sfmatmult&amp;lt;/tt&amp;gt; is made to work with matrices that are displayed with &amp;lt;tt&amp;gt;sfdisfil&amp;lt;/tt&amp;gt;, and takes as input a transpose matrix.&lt;br /&gt;
&lt;br /&gt;
Pipes can be used, of course, to skip the creation of intermediary files:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
$ &amp;lt;file.csv sfcsv2rsf | sfdisfil&lt;br /&gt;
   0:             5            6            8          9.2            0&lt;br /&gt;
   5:            11          124            5            0            1&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that since this program does not need any arguments (just stdin and stdout), when called with no arguments it will not display the man page. In order to consult the automatically generated documentation, you need to pass the option &amp;lt;tt&amp;gt;help=y&amp;lt;/tt&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
=user/jennings programs=&lt;br /&gt;
==sfsizes==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Display the size of RSF files.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfsizes files=y human=n file1.rsf file2.rsf ...&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Prints the element size, number of elements, and number of bytes&amp;lt;br&amp;gt;for a list of RSF files.  Non-RSF files are ignored.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;files=y&#039;&#039;&#039; ||  [y/n] || 	If y, print size of each file.  If n, print only total.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;human=n&#039;&#039;&#039; ||  [y/n] || 	If y, print human-readable file size.  If n, print byte count.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This program computes the &amp;quot;theoretical&amp;quot; size in bytes of the data fork of RSF files.  The actual space occupied on disk may be different and machine dependent due to disk blocking factors, etc.  This theoretical array size should be reproducible.  It is also fast because the program only reads the RSF headers files, not the actual data.&lt;br /&gt;
&lt;br /&gt;
For example, to get the total size of all RSF files in a directory, in human readable format, without listing each file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfsizes files=n human=y *.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will also work because sfsizes simply skips any non-RSF file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfsizes files=n human=y *&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==sffiglist==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Compare Vplot files in Fig and Lock directories&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sffiglist figdir= lockdir= list= show=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; |&lt;br /&gt;
Parameter &#039;&#039;&#039;figdir&#039;&#039;&#039; is path to Fig directory, default is ./Fig.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Parameter &#039;&#039;&#039;lockdir&#039;&#039;&#039; is path to Lock directory:&lt;br /&gt;
&amp;lt;br&amp;gt;    If &#039;&#039;&#039;figdir&#039;&#039;&#039; is in $RSFSRC/book/[book]/[chapter]/[section],&lt;br /&gt;
&amp;lt;br&amp;gt;        then default &#039;&#039;&#039;lockdir&#039;&#039;&#039; is $RSFFIGS/[book]/[chapter]/[section].&lt;br /&gt;
&amp;lt;br&amp;gt;    If &#039;&#039;&#039;figdir&#039;&#039;&#039; is not in $RSFSRC/book/[book]/[chapter]/[section],&lt;br /&gt;
&amp;lt;br&amp;gt;        then default &#039;&#039;&#039;lockdir&#039;&#039;&#039; is $RSFALTFIGS/[book]/[chapter]/[section].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Parameter &#039;&#039;&#039;list&#039;&#039;&#039; controls files to list, default is all.&lt;br /&gt;
&amp;lt;br&amp;gt;Parameter &#039;&#039;&#039;show&#039;&#039;&#039; controls files to flip with sfpen, default is none.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&#039;&#039;&#039;list|show&#039;&#039;&#039; = none (No files, print only summary.)&lt;br /&gt;
&amp;lt;br&amp;gt;&#039;&#039;&#039;list|show&#039;&#039;&#039; = diff (Files that are different, determined by sfvplotdiff.)&lt;br /&gt;
&amp;lt;br&amp;gt;&#039;&#039;&#039;list|show&#039;&#039;&#039; = miss (Files missing from figdir or lockdir, and different files.)&lt;br /&gt;
&amp;lt;br&amp;gt;&#039;&#039;&#039;list|show&#039;&#039;&#039; = all (All files.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;File list codes:&lt;br /&gt;
&amp;lt;br&amp;gt;space   indicates files that are the same.&lt;br /&gt;
&amp;lt;br&amp;gt;  -     indicates file in lockdir that is missing from figdir.&lt;br /&gt;
&amp;lt;br&amp;gt;  +     indicates extra file in figdir that is missing from lockdir.&lt;br /&gt;
&amp;lt;br&amp;gt;number  is return code from sfvplotdiff indicating different files.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;figdir=&#039;&#039;&#039; ||   || 	fig directory, default = ./Fig&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;list=&#039;&#039;&#039; ||   || 	how much to list [none,diff,miss,all], default = all&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;lockdir=&#039;&#039;&#039; ||   || 	lock directory, default = lock counterpart of figdir&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;show=&#039;&#039;&#039; ||   || 	how much to show [none,diff,miss,all], default = none&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This tool lists Vplot files in &amp;quot;Fig&amp;quot; and &amp;quot;Lock&amp;quot; directories and compares them using sfvplotdiff.&lt;br /&gt;
&lt;br /&gt;
The Fig directory defaults to ./Fig and the Lock directory defaults to the  &lt;br /&gt;
corresponding directory where &amp;quot;scons lock&amp;quot; puts things, but either  &lt;br /&gt;
default can be overridden with the user parameters &#039;&#039;&#039;figdir&#039;&#039;&#039; and &#039;&#039;&#039;lockdir&#039;&#039;&#039; so that, for example,  &lt;br /&gt;
files in two different Fig directories can be compared.&lt;br /&gt;
&lt;br /&gt;
The default for the Lock directory has some logic to look in $RSFFIGS  &lt;br /&gt;
when Fig is in $RSFSRC/book, or to look in $RSFALTFIGS when Fig is not  &lt;br /&gt;
in $RSFSRC/book because I like to keep two different Lock directories:  &lt;br /&gt;
one for stuff in book and another for my own stuff that is not in  &lt;br /&gt;
book.  However, I tried to make the code default to reasonable things  &lt;br /&gt;
if any of these environment variables are not defined.&lt;br /&gt;
&lt;br /&gt;
The tool gives a summary count of files that are the same, files that  &lt;br /&gt;
are different, files in Fig that are missing from Lock, and files in  &lt;br /&gt;
Lock that are missing from Fig.&lt;br /&gt;
&lt;br /&gt;
The parameters &#039;&#039;&#039;list&#039;&#039;&#039; (default=all) and &#039;&#039;&#039;show&#039;&#039;&#039; (default=none) control which files are listed or &amp;quot;flipped&amp;quot; with sfpen.  The file listing indicates which files are the same, which are different, and which are missing from Fig or Lock.&lt;br /&gt;
&lt;br /&gt;
For example, to list all the Vplot files in Fig and Lock:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sffiglist list=all&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To list all Vplot files and flip only files that are different:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sffiglist list=all show=diff&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=user/psava programs=&lt;br /&gt;
&lt;br /&gt;
==sfawefd==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | acoustic time-domain FD modeling &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfawefd &amp;lt; Fwav.rsf vel=Fvel.rsf sou=Fsou.rsf rec=Frec.rsf wfl=Fwfl.rsf &amp;gt; Fdat.rsf den=Fden.rsf ompchunk=1 ompnth=0 verb=n snap=n free=n expl=n jdata=1 jsnap=nt nq1=sf_n(a1) nq2=sf_n(a2) oq1=sf_o(a1) oq2=sf_o(a2)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;den=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;expl=n&#039;&#039;&#039; ||  [y/n] || 	&amp;quot;exploding reflector&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;free=n&#039;&#039;&#039; ||  [y/n] || 	free surface flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;jdata=1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;jsnap=nt&#039;&#039;&#039; ||   || 	save wavefield every *jsnap* time steps&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nq1=sf_n(a1)&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nq2=sf_n(a2)&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ompchunk=1&#039;&#039;&#039; ||   || 	OpenMP data chunk size&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ompnth=0&#039;&#039;&#039; ||   || 	OpenMP available threads&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;oq1=sf_o(a1)&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;oq2=sf_o(a2)&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;rec=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;snap=n&#039;&#039;&#039; ||  [y/n] || 	wavefield snapshots flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;sou=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;vel=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	verbosity flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;wfl=&#039;&#039;&#039; ||   || 	auxiliary output file name&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
An example will be demonstrated below on a model with nx=nz=200, dx=dz=4m (size: 800x800m). There are two layers: the first one is 100x200 samples in (z,x) and the velocity is 1500m/s; the second layer has the same dimension and the velocity is 3000m/s. Density is set to 1 for the whole grid. A source and a receiver are co-located at x=400 and z=100. The full wavefield for the entire model aperture will be saved every 10th time step.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
# Velocity model:&lt;br /&gt;
sfspike &amp;gt;Fvel.rsf mag=1500,3000 nsp=2 k1=1,101 l1=100,200 d1=4 d2=4 \&lt;br /&gt;
label1=z label2=x n1=200 n2=200 o1=2 o2=2 unit1=m unit2=m&lt;br /&gt;
&lt;br /&gt;
# Density model:&lt;br /&gt;
sfspike &amp;gt;Fden.rsf mag=1 nsp=1 k1=1 l1=200 d1=4 d2=4 label1=z \&lt;br /&gt;
label2=x n1=200 n2=200 o1=2 o2=2 unit1=m unit2=m&lt;br /&gt;
&lt;br /&gt;
# Source position (x,z):&lt;br /&gt;
sfspike n1=2 nsp=2 k1=1,2 mag=400,100 o1=0 o2=0 &amp;gt;Fsou.rsf&lt;br /&gt;
&lt;br /&gt;
# Receiver position (x,z):&lt;br /&gt;
sfspike n1=2 nsp=2 k1=1,2 mag=400,100 o1=0 o2=0 &amp;gt;Frec.rsf&lt;br /&gt;
&lt;br /&gt;
# Source wavelet:&lt;br /&gt;
sfspike nsp=1 n1=2000 d1=0.0005 k1=200 | sfricker1 frequency=20 |\&lt;br /&gt;
sftransp &amp;gt;Fwav.rsf&lt;br /&gt;
&lt;br /&gt;
# Creating data at specified receiver + saving full wavefield every 10th step:&lt;br /&gt;
sfawefd2d &amp;lt;Fwav.rsf vel=Fvel.rsf sou=Fsou.rsf rec=Frec.rsf wfl=Fwfl.rsf \&lt;br /&gt;
den=Fden.rsf &amp;gt;Fdat.rsf verb=y free=y expl=y snap=y dabc=y jdata=1 jsnap=10&lt;br /&gt;
echo &#039;label1=z unit1=m label2=x unit2=m&#039; &amp;gt;&amp;gt; Fwfl.rsf&lt;br /&gt;
&lt;br /&gt;
# View the wavefield movie:&lt;br /&gt;
&amp;lt; Fwfl.rsf sfgrey gainpanel=a pclip=99 color=j scalebar=y | sfpen &lt;br /&gt;
&lt;br /&gt;
# View a wavefield snapshot:&lt;br /&gt;
&amp;lt; Fwfl.rsf sfwindow f3=80 n3=1 |\&lt;br /&gt;
sfgrey pclip=99 color=j title=&#039;snapshot at t=0.4s&#039; |\&lt;br /&gt;
sfpen &lt;br /&gt;
&lt;br /&gt;
# View the data recorded at receiver:&lt;br /&gt;
&amp;lt;Fdat.rsf sfwindow |\&lt;br /&gt;
sfgraph title=&#039;Data recorded at receiver&#039; unit2=&#039;&#039; label2=amplitude |\&lt;br /&gt;
sfpen&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:sfawefd_wfld.jpg|frame|center|sfawefd wavefield screenshot]]&lt;br /&gt;
[[Image:sfawefd_dat.png|frame|center|sfawefd data screenshot]]&lt;br /&gt;
&lt;br /&gt;
Attention: time steps that are too large can result in numerical instability.&lt;br /&gt;
&lt;br /&gt;
==sfsrmig3==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | 3-D S/R migration with extended SSF&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfsrmig3 slo=Fs_s.rsf sls=Fs_r.rsf &amp;lt; Fw_s.rsf rwf=Fw_r.rsf &amp;gt; Fi.rsf cig=Fc.rsf ompchunk=1 ompnth=0 verb=y eps=0.01 twoway=n nrmax=1 dtmax=0.004 pmx=0 pmy=0 tmx=0 tmy=0 vpvs=1. hsym=n nht=1 oht=0 dht=0.1 nht=1 oht=0 dht=0.1 hsym=n nhh=1 ohh=0 dhh=0.1 nha=180 oha=0 dha=2.0 nhb=180 ohb=0 dhb=2.0 itype=&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;cig=&#039;&#039;&#039; ||   ||     auxiliary output file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dha=2.0&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dhb=2.0&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dhh=0.1&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dht=0.1&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dtmax=0.004&#039;&#039;&#039; ||   ||      max time error&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;eps=0.01&#039;&#039;&#039; ||   ||         stability parameter&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;hsym=n&#039;&#039;&#039; ||  [y/n] ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;itype=&#039;&#039;&#039; ||   ||   imaging condition type&lt;br /&gt;
:o = zero lag (default)&lt;br /&gt;
:e = extended&lt;br /&gt;
:x = space-lags&lt;br /&gt;
:h = space-lags magnitude&lt;br /&gt;
:t = time-lag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nha=180&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nhb=180&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nhh=1&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nht=1&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nrmax=1&#039;&#039;&#039; ||   ||  max number of refs&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;oha=0&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;ohb=0&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;ohh=0&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;oht=0&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ompchunk=1&#039;&#039;&#039; ||   ||       OpenMP data chunk size&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ompnth=0&#039;&#039;&#039; ||   ||         OpenMP available threads&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;pmx=0&#039;&#039;&#039; ||   ||    padding on x&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;pmy=0&#039;&#039;&#039; ||   ||    padding on y&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;rwf=&#039;&#039;&#039; ||   ||     auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;slo=&#039;&#039;&#039; ||   ||     auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;sls=&#039;&#039;&#039; ||   ||     auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;tmx=0&#039;&#039;&#039; ||   ||    taper on x&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;tmy=0&#039;&#039;&#039; ||   ||    taper on y&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;twoway=n&#039;&#039;&#039; ||  [y/n] ||    two-way traveltime&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=y&#039;&#039;&#039; ||  [y/n] ||      verbosity flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;vpvs=1.&#039;&#039;&#039; ||   ||  Vp/Vs ratio&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This program performs 3-D and 2-D shot-record (a.k.a. shot-profile) migration with an extended Split-Step Fourier (SSF) extrapolator with multiple reference velocities (hence &amp;quot;extended&amp;quot;). It takes as input a shot wavefield (&amp;lt;tt&amp;gt;stdin&amp;lt;/tt&amp;gt;), receiver wavefield (&amp;lt;tt&amp;gt;rwf=&amp;lt;/tt&amp;gt;) and slowness model (&amp;lt;tt&amp;gt;slo=&amp;lt;/tt&amp;gt;). Outputs are an image (&amp;lt;tt&amp;gt;stdout&amp;lt;/tt&amp;gt;) and a cube of Common Image Gathers (&amp;lt;tt&amp;gt;cig=&amp;lt;/tt&amp;gt;). An important parameter is &amp;lt;tt&amp;gt;nrmax&amp;lt;/tt&amp;gt;, the number of reference velocities. Its default value is 1, but for reasonable results it should be 5 or so. It is also good to specify nonzero taper values (&amp;lt;tt&amp;gt;tmx&amp;lt;/tt&amp;gt; and, for 3-D, &amp;lt;tt&amp;gt;tmy&amp;lt;/tt&amp;gt; as well). The values of padding parameters &amp;lt;tt&amp;gt;pmx&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;pmy&amp;lt;/tt&amp;gt; are split in two by the program, i.e. if your data x axis is 501-points long, specify pmx=11 to get a value of 512 that will result in fast Fourier Transforms. &lt;br /&gt;
&lt;br /&gt;
The program will also migrate converted-wave data if a file with the S-wave slowness model (&amp;lt;tt&amp;gt;sls=&amp;lt;/tt&amp;gt;) is provided.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;vpvs&amp;lt;/tt&amp;gt; parameter is only used when &amp;lt;tt&amp;gt;itype=h&amp;lt;/tt&amp;gt;. Do not specify a &amp;lt;tt&amp;gt;vpvs&amp;lt;/tt&amp;gt; value unless you know really well what you are doing.&lt;br /&gt;
&lt;br /&gt;
===Usage example===&lt;br /&gt;
The commands below, slightly modified from [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/book/data/sigsbee/ptest/SConstruct?revision=3993&amp;amp;view=markup RSFSRC/book/data/sigsbee/ptest], show how to prepare the [http://www.reproducibility.org/RSF/book/data/sigsbee Sigsbee 2A] data and velocity for migration.&lt;br /&gt;
&lt;br /&gt;
Convert input data (shots) from SEG-Y to RSF:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfsegyread tape=sigsbee2a_nfs.segy tfile=tdata.rsf hfile=/dev/null bfile=/dev/null &amp;gt; ddata.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Convert trace headers to float (required by &amp;lt;tt&amp;gt;sfheadermath&amp;lt;/tt&amp;gt;):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; tdata.rsf sfdd type=float &amp;gt; trchdr.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Shot positions:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; trchdr.rsf sfheadermath output=&amp;quot;fldr + 10925/150&amp;quot; | sfwindow squeeze=y &amp;gt; tsi.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Extract offset positions from the trace header files, eliminate length-1 axis, scale, create a header for binning (required by &amp;lt;tt&amp;gt;sfintbin&amp;lt;/tt&amp;gt;):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; trchdr.rsf sfheadermath output=&amp;quot;offset&amp;quot; |\&lt;br /&gt;
sfwindow squeeze=y |\&lt;br /&gt;
sfmath output=&amp;quot;input/75&amp;quot; |\&lt;br /&gt;
sfcat axis=2 space=n tsi.rsf |\&lt;br /&gt;
sftransp |\&lt;br /&gt;
sfdd type=int &amp;gt; tos.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Binning and muting:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; ddata.rsf sfintbin head=tos.rsf xkey=0 ykey=1 |\&lt;br /&gt;
sfput label1=Time unit1=s d2=0.075 o2=0.0 label2=hx d3=0.150 o3=10.925 label3=sx |\&lt;br /&gt;
sfmutter half=false t0=1.0 v0=6.0 |\&lt;br /&gt;
sfput d2=0.02286 o2=0 unit2=km d3=0.04572 o3=3.32994 unit3=km &amp;gt; shots.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Keeping only 20 shots so that this 1-node job will not take forever, FFT-ing, decimating frequency slices (same as shortening the time axis), and creating y and hy axes of length 1:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; shots.rsf sfwindow n3=20 f3=10 j3=20 |\&lt;br /&gt;
sffft1 |\&lt;br /&gt;
sfwindow n1=200 min1=1 j1=3 |\&lt;br /&gt;
sfspray axis=3 n=1 o=0 d=1 label=hy |\&lt;br /&gt;
sfspray axis=5 n=1 o=0 d=1 label=sy &amp;gt; rfft.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The dimensions of the cube thus created are:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sfin rfft.rsf trail=n&lt;br /&gt;
rfft.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/rfft.rsf@&amp;quot;&lt;br /&gt;
    esize=8 type=complex form=native&lt;br /&gt;
    n1=200         d1=0.25        o1=1          label1=&amp;quot;Frequency&amp;quot; unit1=&amp;quot;Hz&amp;quot;&lt;br /&gt;
    n2=348         d2=0.02286     o2=0          label2=&amp;quot;hx&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
    n3=1           d3=1           o3=0          label3=&amp;quot;hy&amp;quot; unit3=&amp;quot;km&amp;quot;&lt;br /&gt;
    n4=20          d4=0.9144      o4=3.78714    label4=&amp;quot;sx&amp;quot; unit4=&amp;quot;km&amp;quot;&lt;br /&gt;
        1392000 elements 11136000 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Create the source wavelet (limited to the same frequency band as the data) and Fourier transform it:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfspike k1=1 n1=1500 d1=0.008 |\&lt;br /&gt;
sfbandpass flo=15 fhi=25 |\&lt;br /&gt;
sffft1 |\&lt;br /&gt;
sfwindow n1=200 min1=1 j1=3 |\&lt;br /&gt;
sfput label1=freq &amp;gt; sfft.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
This creates a frequency-domain wavelet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sfin sfft.rsf&lt;br /&gt;
sfft.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/sfft.rsf@&amp;quot;&lt;br /&gt;
    esize=8 type=complex form=native&lt;br /&gt;
    n1=200         d1=0.25        o1=1          label1=&amp;quot;freq&amp;quot; unit1=&amp;quot;Hz&amp;quot;&lt;br /&gt;
        200 elements 1600 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Create &amp;quot;synched&amp;quot; source and receiver wavefields with &amp;lt;tt&amp;gt;srsyn&amp;lt;/tt&amp;gt; from wavelet and data frequency slices. Basically both the receiver and shot frequency slices are &amp;quot;placed&amp;quot; at the right location and padded with zeros up to the dimension of the x axis specified below.&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; rfft.rsf sfsrsyn nx=1067 dx=0.02286 ox=3.05562 wav=sfft.rsf swf=swav.rsf &amp;gt; rwav.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
This creates frequency slices ready for migration for both source and receiver, only axis 1 (frequency) must become axis 3, for both datasets:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; swav.rsf sftransp plane=12 | sftransp plane=23 &amp;gt; stra.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; rwav.rsf sftransp plane=12 | sftransp plane=23 &amp;gt; rtra.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
This creates a surface receiver wavefield ready for input to migration. Axis 4 is shot number. The values of axis 4 are arbitrary because each shot has been padded with zeros so that it covers the entire velocity model. Therefore the aperture of the downward continuation for each shot will be as large as the survey.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfin trail=n rtra.rsf&lt;br /&gt;
rtra.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/rtra.rsf@&amp;quot;&lt;br /&gt;
    esize=8 type=complex form=native&lt;br /&gt;
    n1=1067        d1=0.02286     o1=3.05562    label1=&amp;quot;x&amp;quot; unit1=&amp;quot;km&amp;quot;&lt;br /&gt;
    n2=1           d2=1           o2=0          label2=&amp;quot;y&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
    n3=200         d3=0.25        o3=1          label3=&amp;quot;w&amp;quot; unit3=&amp;quot;Hz&amp;quot;&lt;br /&gt;
    n4=20          d4=1           o4=0          label4=&amp;quot;e&amp;quot; unit4=&amp;quot;km&amp;quot;&lt;br /&gt;
        4268000 elements 34144000 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Convert the velocity model from SEG-Y to RSF, decimate, convert from feet to km, transpose, convert to slowness and insert an additional axis:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfsegyread tape=sigsbee2a_migvel.sgy tfile=/dev/null hfile=/dev/null bfile=/dev/null |\&lt;br /&gt;
sfput o1=0 d1=0.00762 label1=z unit1=km o2=3.05562 d2=0.01143 label2=x unit2=km |\&lt;br /&gt;
sfwindow j1=4 j2=2 |\&lt;br /&gt;
sfscale rscale=0.0003048 |\&lt;br /&gt;
sftransp |\&lt;br /&gt;
sfmath output=&amp;quot;1/input&amp;quot; |\&lt;br /&gt;
sfspray axis=2 n=1 d=1 o=0 |\&lt;br /&gt;
sfput label2=y &amp;gt; slow.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
This creates a slowness file ready for input to migration, with an x axis identical to the x axis of the wavefield files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sfin slow.rsf&lt;br /&gt;
slow.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/slow.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=1067        d1=0.02286     o1=3.05562    label1=&amp;quot;x&amp;quot; unit1=&amp;quot;km&amp;quot;&lt;br /&gt;
    n2=1           d2=1           o2=0          label2=&amp;quot;y&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
    n3=301         d3=0.03048     o3=0          label3=&amp;quot;z&amp;quot; unit3=&amp;quot;km&amp;quot;&lt;br /&gt;
        321167 elements 1284668 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finally, the migration command (for a 4-processor machine, hence the &amp;lt;tt&amp;gt;ompnth&amp;lt;/tt&amp;gt; value). We choose not to compute any image gathers (&amp;lt;tt&amp;gt;itype=o&amp;lt;/tt&amp;gt;), but due to the construction of the program we still have to explicitly assign the &amp;lt;tt&amp;gt;cig&amp;lt;/tt&amp;gt; tag, or else a RSF file with the name of the tag and no rsf extension will be created:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; stra.rsf sfsrmig3 nrmax=20 dtmax=5e-05 eps=0.01 verb=y ompnth=4 \&lt;br /&gt;
tmx=16 rwf=rtra.rsf slo=slow.rsf itype=o cig=/dev/null &amp;gt; img.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The migration of 20 shots takes approximately 3 hours on a 4-processor machine (1 shot=9 minutes). Without the frequency slice decimation by a factor of 3 and the depth axis decimation by a factor of 4, it would have taken twelve times as much. The resulting image has a y axis of length 1:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sfin img.rsf trail=n&lt;br /&gt;
img.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/img.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=1067        d1=0.02286     o1=3.05562    label1=&amp;quot;x&amp;quot; unit1=&amp;quot;km&amp;quot;&lt;br /&gt;
    n2=1           d2=1           o2=0          label2=&amp;quot;y&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
    n3=301         d3=0.03048     o3=0          label3=&amp;quot;z&amp;quot; unit3=&amp;quot;km&amp;quot;&lt;br /&gt;
        321167 elements 1284668 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To properly visualize the image, we need to eliminate the axis of length 1, then transpose the x and z axes to their natural position:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt;img.rsf sfwindow squeeze=y | sftransp | sfgrey &amp;gt; img.vpl&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Vnikitin</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Adding_new_programs_to_Madagascar&amp;diff=1961</id>
		<title>Adding new programs to Madagascar</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Adding_new_programs_to_Madagascar&amp;diff=1961"/>
		<updated>2011-07-29T03:55:41Z</updated>

		<summary type="html">&lt;p&gt;Vnikitin: /* Vim customization */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_800161_XS.jpg|right|]]&lt;br /&gt;
Whether you want to share your work with the world or keep it for yourself, madagascar is fully extensible. The following instructions explain the simplest way to add your own programs to the package.&lt;br /&gt;
&lt;br /&gt;
==How to add your program==&lt;br /&gt;
  &lt;br /&gt;
#Create a directory for yourself or your group under &amp;lt;tt&amp;gt;RSFSRC/user&amp;lt;/tt&amp;gt;, where &amp;lt;tt&amp;gt;RSFSRC&amp;lt;/tt&amp;gt; is the top source directory. Put your programs there.&lt;br /&gt;
#The following conventions are adopted:&lt;br /&gt;
#*Files containing main programs start with &amp;lt;tt&amp;gt;M&amp;lt;/tt&amp;gt;, i.e. &amp;lt;tt&amp;gt;Mmyprog.c&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;Mmyprog.py&amp;lt;/tt&amp;gt;. Each main program file should start with a short one-line comment describing its purpose. &lt;br /&gt;
#*Files containing subroutines start with small letters. A header/interface file &amp;lt;tt&amp;gt;myprog.h&amp;lt;/tt&amp;gt; is automatically generated from &amp;lt;tt&amp;gt;myprog.c&amp;lt;/tt&amp;gt;. By using header files, dependencies between different functions will be figured out automatically. Include a comment of the form &amp;lt;font color=&amp;quot;#cd4b19&amp;quot;&amp;gt;/*^*/&amp;lt;/font&amp;gt; after any block of text that you want to be included in the header file. &#039;&#039;Such blocks must not contain any all-whitespace lines.&#039;&#039; Include a comment of the form &amp;lt;font color=&amp;quot;#cd4b19&amp;quot;&amp;gt;/*&amp;lt; My function description &amp;gt;*/&amp;lt;/font&amp;gt; after a function definition if you want its interface included in the header file.  It is a good habit to comment interfaces to all your functions. &lt;br /&gt;
#Create a &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file in your directory by following examples from other &amp;lt;tt&amp;gt;user&amp;lt;/tt&amp;gt; directories. Inside the triple quotation marks after &amp;lt;tt&amp;gt;progs=&amp;lt;/tt&amp;gt;, replace the names of their programs with the names of your programs with spaces between the names. &lt;br /&gt;
#Note that running &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt; inside your &amp;lt;tt&amp;gt;user&amp;lt;/tt&amp;gt; directory compiles programs with debugging flags to make them suitable for debugging with common debuggers such as [http://www.gnu.org/software/gdb/ gdb], dbx, or [http://www.etnus.com/ TotalView]. Running  &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; inside the top source directory will compile your programs with optimization flags and install them in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==How to share your program with others==&lt;br /&gt;
&lt;br /&gt;
Follow the guide on [[Contributing new programs to Madagascar]].&lt;br /&gt;
&lt;br /&gt;
==How to document your program==&lt;br /&gt;
There are three levels of documentation. From the most simple to the most complex, they are: in-code documentation, the Wiki, and reproducible papers. &lt;br /&gt;
===In-code documentation===&lt;br /&gt;
Of course, do comment your code -- focusing on &amp;quot;why&amp;quot; (the code itself describes the &amp;quot;how&amp;quot;). Keep comments sparse so that as much code as possible can be kept in mind at the same time by the human reader. Use the other levels for more information.&lt;br /&gt;
 &lt;br /&gt;
If you follow a certain syntax for some of your comments, then the scripts in the Madagascar framework will be able to automatically produce a self-doc page for your program. This page will be displayed in the terminal (using basic text-mode formatting) when the program is invoked without any arguments, and a HTML version will be automatically generated in $RSFDOC (default: $RSFROOT/doc). The self-doc page has the following sections: &amp;lt;tt&amp;gt;Name&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Description&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Synopsis&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Comments&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Parameters&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Used in&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Source&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;Version&amp;lt;/tt&amp;gt;. &lt;br /&gt;
====Self-doc for C programs====&lt;br /&gt;
To automatically populate the &amp;lt;tt&amp;gt;Description&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;Comments&amp;lt;/tt&amp;gt; sections, use the following syntax. Start the file with:&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
/* Short description line&lt;br /&gt;
Comments here blablabla lorem ipsum dolores sit amet...&lt;br /&gt;
&lt;br /&gt;
You can use several paragraphs for comments, no problem.*/&lt;br /&gt;
&lt;br /&gt;
/* Copyright notice */&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
Notice that: (1) the description line is the first line in the file; (2) Comments are closed and then open again on a new line for Copyright (so that Copyright does not show up in the documentation).&lt;br /&gt;
&lt;br /&gt;
To make input parameters and their default values (if they exist) automatically appear in the &amp;lt;tt&amp;gt;Synopsis&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;Parameters&amp;lt;/tt&amp;gt; sections, make sure to read the parameters in the code like in the following example:&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
if (!sf_getbool(&amp;quot;su&amp;quot;,&amp;amp;su)) su=false;&lt;br /&gt;
/* y if input is SU, n if input is SEGY */&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
Notice that there are no complex logical operations inside the &amp;lt;tt&amp;gt;if&amp;lt;/tt&amp;gt;, that there is no space between the equal sign and the right and left hand, and that a short comment follows immediately. If by necessity the parameter is read in a complex fashion, use angular brackets inside the short line following the read block, i.e.:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
... sf_getfloat ... complex stuff ...&lt;br /&gt;
/*&amp;lt; parameter_name parameter meaning &amp;gt;*/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Self-doc for Python programs====&lt;br /&gt;
To automatically populate the &amp;lt;tt&amp;gt;Description&amp;lt;/tt&amp;gt; page, and &amp;lt;tt&amp;gt;Comments&amp;lt;/tt&amp;gt; sections, use the following syntax. Start the file with:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
#! /usr/bin/env python&lt;br /&gt;
&#039;&#039;&#039;My one-line description of this program&lt;br /&gt;
If I have comments, put them in the lines below.&lt;br /&gt;
&lt;br /&gt;
I can use several paragraphs for that&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
# Copyright notice...&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
Then, make sure to&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import rsfprog&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
To make input parameters and their default values (if they exist) automatically appear in the &amp;lt;tt&amp;gt;Synopsis&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;Parameters&amp;lt;/tt&amp;gt; sections, make sure to follow each argument read with a comment, and call &amp;lt;tt&amp;gt;selfdoc&amp;lt;/tt&amp;gt; if no argument was given. Here is an example from &amp;lt;tt&amp;gt;user/ivlad/Mpclip.py&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
    par = rsf.Par(argv)&lt;br /&gt;
&lt;br /&gt;
    inp = par.string(&#039;inp&#039;) # input file&lt;br /&gt;
    out = par.string(&#039;out&#039;) # output file&lt;br /&gt;
    if None in (inp, out):&lt;br /&gt;
        rsfprog.selfdoc()   # self-doc&lt;br /&gt;
        return error&lt;br /&gt;
&lt;br /&gt;
    verb = par.bool(&#039;verb&#039;, False) # if y, print system commands, outputs&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Self-doc for Fortran 90 programs====&lt;br /&gt;
To automatically populate the &amp;lt;tt&amp;gt;Description&amp;lt;/tt&amp;gt; section (&amp;lt;tt&amp;gt;Comments&amp;lt;/tt&amp;gt; is not available), use the following syntax. Start the file with:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
! One-line short description, leave a blank line after it&lt;br /&gt;
&lt;br /&gt;
! Copyright notice...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To make input parameters and their default values (if they exist) automatically appear in the &amp;lt;tt&amp;gt;Synopsis&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;Parameters&amp;lt;/tt&amp;gt; sections, make sure to read the parameters in the code like in the following example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
call from_par( &amp;quot;n1&amp;quot;, nt, 512 ) ! Param description on same line or first line after&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Wiki documentation===&lt;br /&gt;
The self-doc is good as a reminder of what the parameters mean and what their default values are, but more is usually needed for someone who never used the tool. This is what the [[Guide to madagascar programs|Guide to programs]] is for. Whenever you change or create a program, make sure to add a section for it in there too, if possible with an implementation section. Documenting programs that already exist is also a great idea.&lt;br /&gt;
&lt;br /&gt;
You may have noticed that each program section on that page starts with a table that has the same content as the self-doc. That is created automatically the following way. Say you want to create this table for &amp;lt;tt&amp;gt;sfattr&amp;lt;/tt&amp;gt;. At a command line, type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfdoc -m $HOME attr&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will create the file &amp;lt;tt&amp;gt;$HOME/sfattr.wiki&amp;lt;/tt&amp;gt;. Its content can be copied and pasted into the Madagascar wiki, as they already are in the MediaWiki format. Another directory can be used instead of $HOME.&lt;br /&gt;
&lt;br /&gt;
If your program/script reads an environment variable, make sure you check [[Advanced Installation#Environment variables|the list of environment variables used by Madagascar]] and add your new variable or your peculiar usage of an existing variable.&lt;br /&gt;
&lt;br /&gt;
After creating the appropriate section in the [[Guide to madagascar programs|Guide to programs]], add your program name without the &amp;lt;tt&amp;gt;sf&amp;lt;/tt&amp;gt; prefix to the &amp;lt;tt&amp;gt;docprogs&amp;lt;/tt&amp;gt; list at the beginning of &amp;lt;tt&amp;gt;RSFSRC/framework/rsfdoc.py&amp;lt;/tt&amp;gt; . This will ensure that a link to the wiki section is created in the auto-generated HTML program page in &amp;lt;tt&amp;gt;$RSFDOC&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Add your program to the [[Task-centric program list]] so that it can be found by those users who do not already know they need it.&lt;br /&gt;
&lt;br /&gt;
===Reproducible documents===&lt;br /&gt;
&amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; programs are tested and illustrated by means of [[Reproducible_Documents|reproducible documents]]. See the [[Reproducible computational experiments using SCons|Guide to SCons interface for reproducible computations]] for a brief explanation of what a reproducible paper is and how to produce one.&lt;br /&gt;
&lt;br /&gt;
==Style guide==&lt;br /&gt;
* Use components (macros, types, functions) from the Madagascar library to maximize component reuse and to make sure you do not reinvent the wheel. Be familiar with the [[Library Reference]].&lt;br /&gt;
* User interface convention: if your program provides a verbosity option, use &amp;lt;tt&amp;gt;verb=n [y/n]&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Do not keep commented code in your program. This does not refer to writing comments about code, but to commenting out actual code. You can always use the version control system to retrieve the older version&lt;br /&gt;
* Initialize all pointers (including variables of type &amp;lt;tt&amp;gt;sf_file&amp;lt;/tt&amp;gt;) with NULL&lt;br /&gt;
* If you have one or more calls to &amp;lt;tt&amp;gt;sf_input&amp;lt;/tt&amp;gt; in your program, call &amp;lt;tt&amp;gt;sf_close&amp;lt;/tt&amp;gt; before exit to avoid file leaks (temporary files left in $DATAPATH after an operation involving pipes)&lt;br /&gt;
&lt;br /&gt;
==How to test your program==&lt;br /&gt;
The testing mechanism is semi-automatic. Testing can be done for any program that is used in a reproducible document in the &amp;lt;tt&amp;gt;RSF/book&amp;lt;/tt&amp;gt; directory. To test whether the change you made in a program called, say, &amp;lt;tt&amp;gt;sfmyprog&amp;lt;/tt&amp;gt; introduced any new bugs, make sure you have the latest set of stored figures from the [[Installation#RSF_reproducible_figures|figures repository]] and do the following:&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;tt&amp;gt;cd RSF/book&amp;lt;/tt&amp;gt;&lt;br /&gt;
#Run &amp;lt;pre&amp;gt;scons sfmyprog.test&amp;lt;/pre&amp;gt; If the error messages are not helpful you can omit them from the console, but keep them in a file like this (sh): &amp;lt;pre&amp;gt;scons sfmyprog.test 2&amp;gt; sfmyprog.test.err&amp;lt;/pre&amp;gt; or like this (csh): &amp;lt;pre&amp;gt;(scons sfmyprog.test &amp;gt; /dev/stdin) &amp;gt;&amp;amp; sfmyprog.test.err&amp;lt;/pre&amp;gt;&lt;br /&gt;
#If testing fails, find the directory and figure where failure happened from the &amp;quot;&amp;lt;tt&amp;gt;Comparing ... and ...&amp;lt;/tt&amp;gt;&amp;quot; statement just before the beginning of the error messages. The directory name will appear before that in a line &amp;quot;&amp;lt;tt&amp;gt; Testing in ...&amp;lt;/tt&amp;gt;&amp;quot;. &amp;lt;tt&amp;gt;cd&amp;lt;/tt&amp;gt; to that directory. Let&#039;s say the figure that failed is called &amp;lt;tt&amp;gt;myfig.vpl&amp;lt;/tt&amp;gt;. Run &amp;lt;pre&amp;gt;scons myfig.flip&amp;lt;/pre&amp;gt; That will open a graphical display window that will quickly alternate between the stored figure and your figure. &lt;br /&gt;
#* If the figures look identical, then it means the differences are due to rounding errors and other insignificant differences between platforms (work is done on improving the comparison mechanism). Load your figure into your copy of the figures repository with &amp;lt;pre&amp;gt;scons myfig.lock&amp;lt;/pre&amp;gt;&lt;br /&gt;
#* If you see differences between the two figures, then it is time to debug your program.&lt;br /&gt;
&lt;br /&gt;
==Tips and tricks==&lt;br /&gt;
===Backups===&lt;br /&gt;
You may want to back up only your developer directory, not the entire Madagascar source tree. If you do not want to or do not have the permissions to change the backup scripts, you will need to make your RSF user directory a link to somewhere else. To get that to work, you need to modify your &amp;lt;tt&amp;gt;username/SConstruct&amp;lt;/tt&amp;gt;. First thing in the file, define &lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
RSF_src_root = &#039;/path/to/madagascar/source/root/&#039;&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
Then, replace &amp;lt;tt&amp;gt;../..&amp;lt;/tt&amp;gt; throughout the SConstruct with&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
os.path.join(RSF_src_root,&#039;whatever_followed_after_dotdots&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
===External libraries===&lt;br /&gt;
To link your programs to an external library, add to the &amp;lt;tt&amp;gt;env.Prepend&amp;lt;/tt&amp;gt; statement in &amp;lt;tt&amp;gt;username/Sconstruct&amp;lt;/tt&amp;gt;&lt;br /&gt;
the paths to its &amp;lt;tt&amp;gt;include&amp;lt;/tt&amp;gt; dir, &amp;lt;tt&amp;gt;lib&amp;lt;/tt&amp;gt; dir and the name of the library you are linking to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Emacs customization===&lt;br /&gt;
&lt;br /&gt;
If you use [http://www.gnu.org/software/emacs/ Emacs], the following might be helpful.&lt;br /&gt;
&lt;br /&gt;
* Install the [http://www.emacswiki.org/cgi-bin/wiki/PythonMode python mode] (if you don&#039;t have it installed already) and put &lt;br /&gt;
&amp;lt;lisp&amp;gt;&lt;br /&gt;
(setq auto-mode-alist&lt;br /&gt;
      (cons &#039;(&amp;quot;SConstruct&amp;quot; . python-mode) auto-mode-alist))&lt;br /&gt;
&amp;lt;/lisp&amp;gt; &lt;br /&gt;
:in your &amp;lt;tt&amp;gt;.emacs&amp;lt;/tt&amp;gt; file to enable it on &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; files.&lt;br /&gt;
&lt;br /&gt;
* Put &lt;br /&gt;
&amp;lt;lisp&amp;gt;&lt;br /&gt;
(set-default &#039;compile-command &amp;quot;scons&amp;quot;)&lt;br /&gt;
&amp;lt;/lisp&amp;gt; &lt;br /&gt;
:in your &amp;lt;tt&amp;gt;.emacs&amp;lt;/tt&amp;gt; file to have &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt; as the default compile command.&lt;br /&gt;
&lt;br /&gt;
* Use &lt;br /&gt;
&amp;lt;lisp&amp;gt;&lt;br /&gt;
(add-hook &#039;c-mode-common-hook&lt;br /&gt;
   &#039;(lambda () (c-set-style &amp;quot;linux&amp;quot;)&lt;br /&gt;
        (c-set-offset &#039;case-label 4)&lt;br /&gt;
        (setq c-basic-offset 4)))&lt;br /&gt;
&amp;lt;/lisp&amp;gt; &lt;br /&gt;
:to make sure that the identation in C files follows the previously adopted convention.&lt;br /&gt;
&lt;br /&gt;
=== Vim customization ===&lt;br /&gt;
&lt;br /&gt;
To enable syntax highlighting on SConstruct files in vim, add the following to your &amp;lt;tt&amp;gt;~/.vimrc&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
au BufRead,BufNewFile SConstruct setfiletype python&lt;br /&gt;
&lt;br /&gt;
syntax enable&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;/div&gt;</summary>
		<author><name>Vnikitin</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Adding_new_programs_to_Madagascar&amp;diff=1960</id>
		<title>Adding new programs to Madagascar</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Adding_new_programs_to_Madagascar&amp;diff=1960"/>
		<updated>2011-07-29T03:54:58Z</updated>

		<summary type="html">&lt;p&gt;Vnikitin: /* Emacs customization */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_800161_XS.jpg|right|]]&lt;br /&gt;
Whether you want to share your work with the world or keep it for yourself, madagascar is fully extensible. The following instructions explain the simplest way to add your own programs to the package.&lt;br /&gt;
&lt;br /&gt;
==How to add your program==&lt;br /&gt;
  &lt;br /&gt;
#Create a directory for yourself or your group under &amp;lt;tt&amp;gt;RSFSRC/user&amp;lt;/tt&amp;gt;, where &amp;lt;tt&amp;gt;RSFSRC&amp;lt;/tt&amp;gt; is the top source directory. Put your programs there.&lt;br /&gt;
#The following conventions are adopted:&lt;br /&gt;
#*Files containing main programs start with &amp;lt;tt&amp;gt;M&amp;lt;/tt&amp;gt;, i.e. &amp;lt;tt&amp;gt;Mmyprog.c&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;Mmyprog.py&amp;lt;/tt&amp;gt;. Each main program file should start with a short one-line comment describing its purpose. &lt;br /&gt;
#*Files containing subroutines start with small letters. A header/interface file &amp;lt;tt&amp;gt;myprog.h&amp;lt;/tt&amp;gt; is automatically generated from &amp;lt;tt&amp;gt;myprog.c&amp;lt;/tt&amp;gt;. By using header files, dependencies between different functions will be figured out automatically. Include a comment of the form &amp;lt;font color=&amp;quot;#cd4b19&amp;quot;&amp;gt;/*^*/&amp;lt;/font&amp;gt; after any block of text that you want to be included in the header file. &#039;&#039;Such blocks must not contain any all-whitespace lines.&#039;&#039; Include a comment of the form &amp;lt;font color=&amp;quot;#cd4b19&amp;quot;&amp;gt;/*&amp;lt; My function description &amp;gt;*/&amp;lt;/font&amp;gt; after a function definition if you want its interface included in the header file.  It is a good habit to comment interfaces to all your functions. &lt;br /&gt;
#Create a &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file in your directory by following examples from other &amp;lt;tt&amp;gt;user&amp;lt;/tt&amp;gt; directories. Inside the triple quotation marks after &amp;lt;tt&amp;gt;progs=&amp;lt;/tt&amp;gt;, replace the names of their programs with the names of your programs with spaces between the names. &lt;br /&gt;
#Note that running &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt; inside your &amp;lt;tt&amp;gt;user&amp;lt;/tt&amp;gt; directory compiles programs with debugging flags to make them suitable for debugging with common debuggers such as [http://www.gnu.org/software/gdb/ gdb], dbx, or [http://www.etnus.com/ TotalView]. Running  &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; inside the top source directory will compile your programs with optimization flags and install them in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==How to share your program with others==&lt;br /&gt;
&lt;br /&gt;
Follow the guide on [[Contributing new programs to Madagascar]].&lt;br /&gt;
&lt;br /&gt;
==How to document your program==&lt;br /&gt;
There are three levels of documentation. From the most simple to the most complex, they are: in-code documentation, the Wiki, and reproducible papers. &lt;br /&gt;
===In-code documentation===&lt;br /&gt;
Of course, do comment your code -- focusing on &amp;quot;why&amp;quot; (the code itself describes the &amp;quot;how&amp;quot;). Keep comments sparse so that as much code as possible can be kept in mind at the same time by the human reader. Use the other levels for more information.&lt;br /&gt;
 &lt;br /&gt;
If you follow a certain syntax for some of your comments, then the scripts in the Madagascar framework will be able to automatically produce a self-doc page for your program. This page will be displayed in the terminal (using basic text-mode formatting) when the program is invoked without any arguments, and a HTML version will be automatically generated in $RSFDOC (default: $RSFROOT/doc). The self-doc page has the following sections: &amp;lt;tt&amp;gt;Name&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Description&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Synopsis&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Comments&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Parameters&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Used in&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Source&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;Version&amp;lt;/tt&amp;gt;. &lt;br /&gt;
====Self-doc for C programs====&lt;br /&gt;
To automatically populate the &amp;lt;tt&amp;gt;Description&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;Comments&amp;lt;/tt&amp;gt; sections, use the following syntax. Start the file with:&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
/* Short description line&lt;br /&gt;
Comments here blablabla lorem ipsum dolores sit amet...&lt;br /&gt;
&lt;br /&gt;
You can use several paragraphs for comments, no problem.*/&lt;br /&gt;
&lt;br /&gt;
/* Copyright notice */&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
Notice that: (1) the description line is the first line in the file; (2) Comments are closed and then open again on a new line for Copyright (so that Copyright does not show up in the documentation).&lt;br /&gt;
&lt;br /&gt;
To make input parameters and their default values (if they exist) automatically appear in the &amp;lt;tt&amp;gt;Synopsis&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;Parameters&amp;lt;/tt&amp;gt; sections, make sure to read the parameters in the code like in the following example:&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
if (!sf_getbool(&amp;quot;su&amp;quot;,&amp;amp;su)) su=false;&lt;br /&gt;
/* y if input is SU, n if input is SEGY */&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
Notice that there are no complex logical operations inside the &amp;lt;tt&amp;gt;if&amp;lt;/tt&amp;gt;, that there is no space between the equal sign and the right and left hand, and that a short comment follows immediately. If by necessity the parameter is read in a complex fashion, use angular brackets inside the short line following the read block, i.e.:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
... sf_getfloat ... complex stuff ...&lt;br /&gt;
/*&amp;lt; parameter_name parameter meaning &amp;gt;*/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Self-doc for Python programs====&lt;br /&gt;
To automatically populate the &amp;lt;tt&amp;gt;Description&amp;lt;/tt&amp;gt; page, and &amp;lt;tt&amp;gt;Comments&amp;lt;/tt&amp;gt; sections, use the following syntax. Start the file with:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
#! /usr/bin/env python&lt;br /&gt;
&#039;&#039;&#039;My one-line description of this program&lt;br /&gt;
If I have comments, put them in the lines below.&lt;br /&gt;
&lt;br /&gt;
I can use several paragraphs for that&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
# Copyright notice...&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
Then, make sure to&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import rsfprog&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
To make input parameters and their default values (if they exist) automatically appear in the &amp;lt;tt&amp;gt;Synopsis&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;Parameters&amp;lt;/tt&amp;gt; sections, make sure to follow each argument read with a comment, and call &amp;lt;tt&amp;gt;selfdoc&amp;lt;/tt&amp;gt; if no argument was given. Here is an example from &amp;lt;tt&amp;gt;user/ivlad/Mpclip.py&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
    par = rsf.Par(argv)&lt;br /&gt;
&lt;br /&gt;
    inp = par.string(&#039;inp&#039;) # input file&lt;br /&gt;
    out = par.string(&#039;out&#039;) # output file&lt;br /&gt;
    if None in (inp, out):&lt;br /&gt;
        rsfprog.selfdoc()   # self-doc&lt;br /&gt;
        return error&lt;br /&gt;
&lt;br /&gt;
    verb = par.bool(&#039;verb&#039;, False) # if y, print system commands, outputs&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Self-doc for Fortran 90 programs====&lt;br /&gt;
To automatically populate the &amp;lt;tt&amp;gt;Description&amp;lt;/tt&amp;gt; section (&amp;lt;tt&amp;gt;Comments&amp;lt;/tt&amp;gt; is not available), use the following syntax. Start the file with:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
! One-line short description, leave a blank line after it&lt;br /&gt;
&lt;br /&gt;
! Copyright notice...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To make input parameters and their default values (if they exist) automatically appear in the &amp;lt;tt&amp;gt;Synopsis&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;Parameters&amp;lt;/tt&amp;gt; sections, make sure to read the parameters in the code like in the following example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
call from_par( &amp;quot;n1&amp;quot;, nt, 512 ) ! Param description on same line or first line after&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Wiki documentation===&lt;br /&gt;
The self-doc is good as a reminder of what the parameters mean and what their default values are, but more is usually needed for someone who never used the tool. This is what the [[Guide to madagascar programs|Guide to programs]] is for. Whenever you change or create a program, make sure to add a section for it in there too, if possible with an implementation section. Documenting programs that already exist is also a great idea.&lt;br /&gt;
&lt;br /&gt;
You may have noticed that each program section on that page starts with a table that has the same content as the self-doc. That is created automatically the following way. Say you want to create this table for &amp;lt;tt&amp;gt;sfattr&amp;lt;/tt&amp;gt;. At a command line, type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfdoc -m $HOME attr&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will create the file &amp;lt;tt&amp;gt;$HOME/sfattr.wiki&amp;lt;/tt&amp;gt;. Its content can be copied and pasted into the Madagascar wiki, as they already are in the MediaWiki format. Another directory can be used instead of $HOME.&lt;br /&gt;
&lt;br /&gt;
If your program/script reads an environment variable, make sure you check [[Advanced Installation#Environment variables|the list of environment variables used by Madagascar]] and add your new variable or your peculiar usage of an existing variable.&lt;br /&gt;
&lt;br /&gt;
After creating the appropriate section in the [[Guide to madagascar programs|Guide to programs]], add your program name without the &amp;lt;tt&amp;gt;sf&amp;lt;/tt&amp;gt; prefix to the &amp;lt;tt&amp;gt;docprogs&amp;lt;/tt&amp;gt; list at the beginning of &amp;lt;tt&amp;gt;RSFSRC/framework/rsfdoc.py&amp;lt;/tt&amp;gt; . This will ensure that a link to the wiki section is created in the auto-generated HTML program page in &amp;lt;tt&amp;gt;$RSFDOC&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Add your program to the [[Task-centric program list]] so that it can be found by those users who do not already know they need it.&lt;br /&gt;
&lt;br /&gt;
===Reproducible documents===&lt;br /&gt;
&amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; programs are tested and illustrated by means of [[Reproducible_Documents|reproducible documents]]. See the [[Reproducible computational experiments using SCons|Guide to SCons interface for reproducible computations]] for a brief explanation of what a reproducible paper is and how to produce one.&lt;br /&gt;
&lt;br /&gt;
==Style guide==&lt;br /&gt;
* Use components (macros, types, functions) from the Madagascar library to maximize component reuse and to make sure you do not reinvent the wheel. Be familiar with the [[Library Reference]].&lt;br /&gt;
* User interface convention: if your program provides a verbosity option, use &amp;lt;tt&amp;gt;verb=n [y/n]&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Do not keep commented code in your program. This does not refer to writing comments about code, but to commenting out actual code. You can always use the version control system to retrieve the older version&lt;br /&gt;
* Initialize all pointers (including variables of type &amp;lt;tt&amp;gt;sf_file&amp;lt;/tt&amp;gt;) with NULL&lt;br /&gt;
* If you have one or more calls to &amp;lt;tt&amp;gt;sf_input&amp;lt;/tt&amp;gt; in your program, call &amp;lt;tt&amp;gt;sf_close&amp;lt;/tt&amp;gt; before exit to avoid file leaks (temporary files left in $DATAPATH after an operation involving pipes)&lt;br /&gt;
&lt;br /&gt;
==How to test your program==&lt;br /&gt;
The testing mechanism is semi-automatic. Testing can be done for any program that is used in a reproducible document in the &amp;lt;tt&amp;gt;RSF/book&amp;lt;/tt&amp;gt; directory. To test whether the change you made in a program called, say, &amp;lt;tt&amp;gt;sfmyprog&amp;lt;/tt&amp;gt; introduced any new bugs, make sure you have the latest set of stored figures from the [[Installation#RSF_reproducible_figures|figures repository]] and do the following:&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;tt&amp;gt;cd RSF/book&amp;lt;/tt&amp;gt;&lt;br /&gt;
#Run &amp;lt;pre&amp;gt;scons sfmyprog.test&amp;lt;/pre&amp;gt; If the error messages are not helpful you can omit them from the console, but keep them in a file like this (sh): &amp;lt;pre&amp;gt;scons sfmyprog.test 2&amp;gt; sfmyprog.test.err&amp;lt;/pre&amp;gt; or like this (csh): &amp;lt;pre&amp;gt;(scons sfmyprog.test &amp;gt; /dev/stdin) &amp;gt;&amp;amp; sfmyprog.test.err&amp;lt;/pre&amp;gt;&lt;br /&gt;
#If testing fails, find the directory and figure where failure happened from the &amp;quot;&amp;lt;tt&amp;gt;Comparing ... and ...&amp;lt;/tt&amp;gt;&amp;quot; statement just before the beginning of the error messages. The directory name will appear before that in a line &amp;quot;&amp;lt;tt&amp;gt; Testing in ...&amp;lt;/tt&amp;gt;&amp;quot;. &amp;lt;tt&amp;gt;cd&amp;lt;/tt&amp;gt; to that directory. Let&#039;s say the figure that failed is called &amp;lt;tt&amp;gt;myfig.vpl&amp;lt;/tt&amp;gt;. Run &amp;lt;pre&amp;gt;scons myfig.flip&amp;lt;/pre&amp;gt; That will open a graphical display window that will quickly alternate between the stored figure and your figure. &lt;br /&gt;
#* If the figures look identical, then it means the differences are due to rounding errors and other insignificant differences between platforms (work is done on improving the comparison mechanism). Load your figure into your copy of the figures repository with &amp;lt;pre&amp;gt;scons myfig.lock&amp;lt;/pre&amp;gt;&lt;br /&gt;
#* If you see differences between the two figures, then it is time to debug your program.&lt;br /&gt;
&lt;br /&gt;
==Tips and tricks==&lt;br /&gt;
===Backups===&lt;br /&gt;
You may want to back up only your developer directory, not the entire Madagascar source tree. If you do not want to or do not have the permissions to change the backup scripts, you will need to make your RSF user directory a link to somewhere else. To get that to work, you need to modify your &amp;lt;tt&amp;gt;username/SConstruct&amp;lt;/tt&amp;gt;. First thing in the file, define &lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
RSF_src_root = &#039;/path/to/madagascar/source/root/&#039;&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
Then, replace &amp;lt;tt&amp;gt;../..&amp;lt;/tt&amp;gt; throughout the SConstruct with&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
os.path.join(RSF_src_root,&#039;whatever_followed_after_dotdots&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
===External libraries===&lt;br /&gt;
To link your programs to an external library, add to the &amp;lt;tt&amp;gt;env.Prepend&amp;lt;/tt&amp;gt; statement in &amp;lt;tt&amp;gt;username/Sconstruct&amp;lt;/tt&amp;gt;&lt;br /&gt;
the paths to its &amp;lt;tt&amp;gt;include&amp;lt;/tt&amp;gt; dir, &amp;lt;tt&amp;gt;lib&amp;lt;/tt&amp;gt; dir and the name of the library you are linking to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Emacs customization===&lt;br /&gt;
&lt;br /&gt;
If you use [http://www.gnu.org/software/emacs/ Emacs], the following might be helpful.&lt;br /&gt;
&lt;br /&gt;
* Install the [http://www.emacswiki.org/cgi-bin/wiki/PythonMode python mode] (if you don&#039;t have it installed already) and put &lt;br /&gt;
&amp;lt;lisp&amp;gt;&lt;br /&gt;
(setq auto-mode-alist&lt;br /&gt;
      (cons &#039;(&amp;quot;SConstruct&amp;quot; . python-mode) auto-mode-alist))&lt;br /&gt;
&amp;lt;/lisp&amp;gt; &lt;br /&gt;
:in your &amp;lt;tt&amp;gt;.emacs&amp;lt;/tt&amp;gt; file to enable it on &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; files.&lt;br /&gt;
&lt;br /&gt;
* Put &lt;br /&gt;
&amp;lt;lisp&amp;gt;&lt;br /&gt;
(set-default &#039;compile-command &amp;quot;scons&amp;quot;)&lt;br /&gt;
&amp;lt;/lisp&amp;gt; &lt;br /&gt;
:in your &amp;lt;tt&amp;gt;.emacs&amp;lt;/tt&amp;gt; file to have &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt; as the default compile command.&lt;br /&gt;
&lt;br /&gt;
* Use &lt;br /&gt;
&amp;lt;lisp&amp;gt;&lt;br /&gt;
(add-hook &#039;c-mode-common-hook&lt;br /&gt;
   &#039;(lambda () (c-set-style &amp;quot;linux&amp;quot;)&lt;br /&gt;
        (c-set-offset &#039;case-label 4)&lt;br /&gt;
        (setq c-basic-offset 4)))&lt;br /&gt;
&amp;lt;/lisp&amp;gt; &lt;br /&gt;
:to make sure that the identation in C files follows the previously adopted convention.&lt;br /&gt;
&lt;br /&gt;
== Vim customization ==&lt;br /&gt;
&lt;br /&gt;
To enable syntax highlighting on SConstruct files in vim, add the following to your &amp;lt;tt&amp;gt;~/.vimrc&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
au BufRead,BufNewFile SConstruct setfiletype python&lt;br /&gt;
&lt;br /&gt;
syntax enable&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;/div&gt;</summary>
		<author><name>Vnikitin</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Windows&amp;diff=1959</id>
		<title>Windows</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Windows&amp;diff=1959"/>
		<updated>2011-07-29T03:20:14Z</updated>

		<summary type="html">&lt;p&gt;Vnikitin: /* Troubleshooting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; has been run on Microsoft Windows machines under various types of environments:&lt;br /&gt;
&lt;br /&gt;
==Cygwin==&lt;br /&gt;
&lt;br /&gt;
[[Image:cygwin-icon.gif|left|]] &amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; can run under [http://cygwin.com Cygwin], which provides a Unix environment under Windows.&lt;br /&gt;
&lt;br /&gt;
To obtain Cygwin, go to its web page, download and run the installer. This should create a Cygwin program, which when run, creates a POSIX shell window similar-looking to the Windows command window but which behaves in a more Unix-like way.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE&#039;&#039;&#039;: If you are unfamiliar with Unix-like systems, a good place to start is Greg Wilson&#039;s [http://www.osl.iu.edu/~lums/swc/www/shell.html Software Carpentry] course. &lt;br /&gt;
&lt;br /&gt;
You will need to install several additional Cygwin components before Madagascar can run. To get these, rerun the installer program (called &#039;&#039;&#039;Setup&#039;&#039;&#039; and represented by an icon with a black &amp;quot;C&amp;quot; shape enclosing a green arrow). &lt;br /&gt;
&lt;br /&gt;
# Start &#039;&#039;&#039;Setup&#039;&#039;&#039; program. &lt;br /&gt;
# Keep clicking (defaults should work, but you can choose a mirror on your own continent) until you see a collapsed list (boxed &amp;quot;+&amp;quot; signs) in a selection box. &lt;br /&gt;
# Choose the following before downloading.&lt;br /&gt;
## Open the &#039;&#039;&#039;Devel&#039;&#039;&#039; section and select&lt;br /&gt;
##* gcc&lt;br /&gt;
## If you want to use the development version of &amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt;, also choose&lt;br /&gt;
##* subversion&lt;br /&gt;
## If you have a favorite unix editor, choose it under &#039;&#039;&#039;Editors&#039;&#039;&#039; (novices may wish to work with Notepad for a while). Both &amp;lt;tt&amp;gt;vim&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;emacs&amp;lt;/tt&amp;gt; are available.&lt;br /&gt;
## Open &#039;&#039;&#039;Interpreters&#039;&#039;&#039; and select&lt;br /&gt;
##* python&lt;br /&gt;
## Open &#039;&#039;&#039;Net&#039;&#039;&#039; and select&lt;br /&gt;
##* sunrpc&lt;br /&gt;
## Open &#039;&#039;&#039;Libs&#039;&#039;&#039; and select&lt;br /&gt;
##* opengl&lt;br /&gt;
## If you intend to use X-window, open &#039;&#039;&#039;X11&#039;&#039;&#039; and select&lt;br /&gt;
##* libX11-devel&lt;br /&gt;
##* libXaw-devel&lt;br /&gt;
## If you intend to use LaTeX, open &#039;&#039;&#039;Publishing&#039;&#039;&#039; and select&lt;br /&gt;
##* tetex&lt;br /&gt;
## If you intend to use &amp;lt;tt&amp;gt;ppmpen&amp;lt;/tt&amp;gt;, open &#039;&#039;&#039;Graphics&#039;&#039;&#039; and select&lt;br /&gt;
##* libnetpbm-devel&lt;br /&gt;
## If you intend to use &amp;lt;tt&amp;gt;tiffpen&amp;lt;/tt&amp;gt;, open &#039;&#039;&#039;Graphics&#039;&#039;&#039; and select&lt;br /&gt;
##* libtiff-devel&lt;br /&gt;
## If you intend to use &amp;lt;tt&amp;gt;gdpen&amp;lt;/tt&amp;gt;, open &#039;&#039;&#039;Graphics&#039;&#039;&#039; and select&lt;br /&gt;
##* libgd-devel&lt;br /&gt;
# Next, click &#039;&#039;&#039;Next&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
#: Your download will proceed.&lt;br /&gt;
# When done, click &#039;&#039;&#039;Finish&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
After performing this steps, proceed to a normal Madagascar [[Installation]].&lt;br /&gt;
&lt;br /&gt;
For running X applications such as &#039;&#039;&#039;xtpen&#039;&#039;&#039;, make sure to run &#039;&#039;&#039;startx&#039;&#039;&#039; first to open an X terminal window.&lt;br /&gt;
&lt;br /&gt;
===Troubleshooting===&lt;br /&gt;
&lt;br /&gt;
If you get errors &amp;quot;unable to remap...&amp;quot;, note the following:&lt;br /&gt;
&lt;br /&gt;
A proper work of a Cygwin installation may require running &#039;&#039;&#039;rebaseall&#039;&#039;&#039;, a program that fixes library dependencies. You only need to run it once.&lt;br /&gt;
# Quit all Cygwin processes&lt;br /&gt;
# Start &#039;&#039;&#039;ash&#039;&#039;&#039; (&amp;lt;tt&amp;gt;&amp;lt;cygroot&amp;gt;\bin\ash.exe&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Execute &amp;lt;tt&amp;gt;/usr/bin/rebaseall&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Pictures===&lt;br /&gt;
&lt;br /&gt;
* Running Cygwin&#039;s &#039;&#039;&#039;setup&#039;&#039;&#039; program&lt;br /&gt;
&lt;br /&gt;
[[Image:setup.png|600px]]&lt;br /&gt;
&lt;br /&gt;
* Selecting packages&lt;br /&gt;
&lt;br /&gt;
[[Image:select.png|600px]]&lt;br /&gt;
&lt;br /&gt;
* Running Cygwin&#039;s &#039;&#039;&#039;bash&#039;&#039;&#039; program&lt;br /&gt;
&lt;br /&gt;
[[Image:bash.png|600px]]&lt;br /&gt;
&lt;br /&gt;
* Testing &amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; installation&lt;br /&gt;
&lt;br /&gt;
[[Image:test.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[Image:welcome.png|600px]]&lt;br /&gt;
&lt;br /&gt;
==Interix==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Interix Interix] is the name of the Unix environment for Windows provided by Microsoft through the following software packages:&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Microsoft_Windows_Services_for_UNIX Services For Unix] (SFU), available as a [http://www.microsoft.com/downloads/details.aspx?FamilyID=896c9688-601b-44f1-81a4-02878ff11778&amp;amp;DisplayLang=en free download] for the Windows NT family of operating systems up to and including Windows XP Professional ([http://www.reproducibility.org/rsflog/uploads/PS0001.jpg screenshot of m8r running on SFU] from an [http://www.reproducibility.org/rsflog/index.php?/archives/68-RSFMadagascar-on-Windows-using-SFU.html April 2006 entry on the m8r blog]). SFU availability was discontinued in 2009.&lt;br /&gt;
* [http://technet.microsoft.com/en-us/library/cc779522.aspx Subsystem for UNIX-based Applications] (SUA), included with Windows Server 2003 R2 and Windows Vista.&lt;br /&gt;
&lt;br /&gt;
==SSH + X server==&lt;br /&gt;
If you can count on a network connection to a full UNIX machine while you run Madagascar, you actually need to install under MS Windows just a SSH client and a X server, and just run the Madagascar installed on the UNIX machine. Cygwin provides both, but it is big and slow. Faster and more lightweight alternatives are:&lt;br /&gt;
* [http://mobaxterm.mobatek.net/en/ MobaXterm], an enhanced terminal with an X server and a set of Unix commands (GNU/Cygwin) packaged in a single portable exe file;&lt;br /&gt;
* [http://sourceforge.net/projects/xming/ Xming] as X server and [http://en.wikipedia.org/wiki/PuTTY PuTTY] as SSH client (remember to check the &amp;quot;Tunnel X11 connections&amp;quot; box when saving the session configuration).&lt;/div&gt;</summary>
		<author><name>Vnikitin</name></author>
	</entry>
</feed>