<?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=Fomels</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=Fomels"/>
	<link rel="alternate" type="text/html" href="https://ahay.org/wiki/Special:Contributions/Fomels"/>
	<updated>2026-06-07T19:11:29Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.42.7</generator>
	<entry>
		<id>https://ahay.org/index.php?title=Conferences&amp;diff=5624</id>
		<title>Conferences</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Conferences&amp;diff=5624"/>
		<updated>2024-11-26T15:41:48Z</updated>

		<summary type="html">&lt;p&gt;Fomels: links&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Conferences.png|right|]]&lt;br /&gt;
In reverse chronological order.&lt;br /&gt;
&lt;br /&gt;
==Schools, Workshops, and Working Workshops==&lt;br /&gt;
[[PuertoVallarta_2023|Madagascar Workshop at RAUGM, Puerto Vallarta 2023]]&lt;br /&gt;
&lt;br /&gt;
[[Hefei_2020|Madagascar School on Open-Source Geophysics in Hefei 2020]]&lt;br /&gt;
&lt;br /&gt;
[[HoustonWW2018|SEG Working Workshop - Python and Julia for Geophysics, Houston August 8-11, 2018]]&lt;br /&gt;
&lt;br /&gt;
[[HoustonWW2017|SEG Working Workshop in Houston 2017]]&lt;br /&gt;
&lt;br /&gt;
[[Shanghai_2017|Madagascar School of Reproducible Computational Geophysics Shanghai 2017]]&lt;br /&gt;
&lt;br /&gt;
[[Houston_2017|Madagascar School at the University of Houston 2017]]&lt;br /&gt;
&lt;br /&gt;
[[SEG_3D_Seismic_Processing_Working_Workshop_Houston_2016-_Land_3D|SEG Land 3D Seismic Processing Working Workshop Houston 2016]]&lt;br /&gt;
&lt;br /&gt;
[[Zurich 2016|Madagascar School on Reproducible Computational Geophysics in Zürich 2016]]&lt;br /&gt;
&lt;br /&gt;
[[Vienna_2016|Workshop - Open-source Software in Applied Geosciences Vienna 2016]]&lt;br /&gt;
&lt;br /&gt;
[[Qingdao_2015|Madagascar School for Advanced Users in Qingdao 2015]]&lt;br /&gt;
&lt;br /&gt;
[[SEG 3D Seismic Processing Working Workshop Houston 2015- Land 3D|SEG 3D Land Seismic Processing Working Workshop Houston 2015]]&lt;br /&gt;
&lt;br /&gt;
[[Harbin_2015|School in Harbin 2015]]&lt;br /&gt;
&lt;br /&gt;
[[Houston_2014|Second Madagascar Working Workshop Houston 2014]]&lt;br /&gt;
&lt;br /&gt;
[[Petersburg_2014|Workshop at EAGE/St. Petersburg 2014]]&lt;br /&gt;
&lt;br /&gt;
[[Melbourne_2013|Workshop at ASEG 2013]]&lt;br /&gt;
&lt;br /&gt;
[[Austin_2013|First Madagascar Working Workshop Austin 2013]]&lt;br /&gt;
&lt;br /&gt;
[[Austin_2012|Madagascar School and Workshop on Reproducible Computational Geophysics Austin 2012]]&lt;br /&gt;
&lt;br /&gt;
[[Copenhagen_2012|Workshop - Open-source E&amp;amp;P Software - Six Years Later Copenhagen 2012]]&lt;br /&gt;
&lt;br /&gt;
[[Beijing_2011|Madagascar School of Reproducible Computational Geophysics Beijing 2011]]&lt;br /&gt;
&lt;br /&gt;
[[Houston_2011|Workshop - Open Software Tools for Reproducible Computational Geophysics Houston 2011]]&lt;br /&gt;
&lt;br /&gt;
[[Houston_2010|Madagascar School of Reproducible Computational Geophysics and Hands-On School Houston 2010]]&lt;br /&gt;
&lt;br /&gt;
[[Salvador_2009|Madagascar School on Reproducible Computational Geophysics Salvador 2009]]&lt;br /&gt;
&lt;br /&gt;
[[Delft_2009|Madagascar School on Reproducible Computational Geophysics Delft 2009]]&lt;br /&gt;
&lt;br /&gt;
[[2008_Implementation_Workshop|Towards full automation and better robustness Coding Sprint Golden 2008]] &lt;br /&gt;
&lt;br /&gt;
[[RSF_Austin_School_2007|Using and Extending RSF/Madagascar School Austin 2007]].&lt;br /&gt;
&lt;br /&gt;
[[RSF_School_and_Workshop%2C_Vancouver_2006|Reproducible Research in Computational Geophysics School and Workshop Vancouver 2006]].&lt;br /&gt;
&lt;br /&gt;
==Conference presentations==&lt;br /&gt;
&lt;br /&gt;
===Online 2021 (SPE)===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; was presented in the session on &#039;&#039;&#039;Open Source - Geomodelling and Reservoir Characterization&#039;&#039;&#039; at the [https://www.spe.org/events/en/2021/workshop/21av01/open-subsurface.html SPE Virtual Workshop: Open Subsurface] on May 19, 2021. See presentation [https://ahay.org/wikilocal/docs/Madagascar-SPE.pdf slides] and the [https://www.spe.org/events/en/2021/workshop/21av01/schedule-overview.html workshop program].&lt;br /&gt;
&lt;br /&gt;
===Lausanne 2016 (PASC)===&lt;br /&gt;
&lt;br /&gt;
Two presentations about &amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; were presented in the mini-symposium on &#039;&#039;&#039;Open Source Software (OSS) and High-Performance Computing (HPC)&#039;&#039;&#039; at the [http://www.pasc16.org/ Platform for Advanced Scientific Computing] conference in Lausanne, Switzerland, on June 9, 2016. See presentation slides: &lt;br /&gt;
* [http://ahay.org/wikilocal/docs/FOMEL-PASC2016.pdf Data-Parallel Processing Using Madagascar Open-Source Software Package] &lt;br /&gt;
* [http://ahay.org/wikilocal/docs/POTTER-SHRAGGE-PASC2016.pdf Leveraging the Madagascar Framework for Reproducible Large-scale Cluster and Cloud Computing]&lt;br /&gt;
&lt;br /&gt;
===San Francisco 2015 (AGU)===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; was presented in the session on &#039;&#039;&#039;Informatics and Intelligent Systems in Reproducible Geoscience Research&#039;&#039;&#039; at the [http://fallmeeting.agu.org/2015/ AGU Fall Meeting] in San Francisco, California, on December 17, 2015. See presentation [http://ahay.org/wikilocal/docs/Madagascar-AGU-2015.pdf slides] and the [https://agu.confex.com/agu/fm15/meetingapp.cgi/Session/10540 session program].&lt;br /&gt;
&lt;br /&gt;
===Stanford 2015 (SIAM Geosciences)===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; was presented in the mini-symposium on &#039;&#039;&#039;Advances in Software for Computational Geosciences&#039;&#039;&#039; at the [http://www.siam.org/meetings/gs15/ SIAM Conference on Mathematical &amp;amp; Computational Issues in the Geosciences] in Stanford, California, on June 30, 2015. See presentation [http://ahay.org/wikilocal/docs/Fomel-SIAM-Geosciences-2015.pdf slides] and the [http://meetings.siam.org/sess/dsp_programsess.cfm?SESSIONCODE=21097 mini-symposium program].&lt;br /&gt;
&lt;br /&gt;
===New York 2013 (NYU Poly)===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; was presented at the workshop on [http://www.reproduciblescience.org/index.php/Workshop_on_Software_Infrastructure_for_Reproducibility_in_Science_--_May_30th-31st,_2013 Software Infrastructure for Reproducibility in Science] at the Polytechnic Institute of New York University in Brooklyn, New York, on May 30, 2013. See presentation [http://ahay.org/wikilocal/docs/Madagascar-NYC.pdf slides]. &lt;br /&gt;
&lt;br /&gt;
The workshop was supported by the [http://www.sloan.org/ Alfred P. Sloan Foundation]. Juliana Freire provides the complete [http://vgc.poly.edu/~juliana/ReproducibleScience/SoftwareInfrastructure/agenda.pdf  workshop program].&lt;br /&gt;
&lt;br /&gt;
===Providence 2012 (ICERM)===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; was presented at the [http://icerm.brown.edu/tw12-5-rcem Reproducibility in Computational and Experimental Mathematics] Workshop at the Institute for Computational and Experimental Research in Mathematics (ICERM) in Providence, Rhode Island, on December 13, 2012.&lt;br /&gt;
&lt;br /&gt;
See presentation [http://ahay.org/wikilocal/docs/ICERM.pptx slides], the complete [http://icerm.brown.edu/tw12-5-rcem workshop program], and Victoria Stodden&#039;s [http://wiki.stodden.net/ICERM_Reproducibility_in_Computational_and_Experimental_Mathematics:_Readings_and_References wiki page].&lt;br /&gt;
&lt;br /&gt;
===Austin 2012 (SciPy)===&lt;br /&gt;
&lt;br /&gt;
The Python interface to &amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; was presented at the [http://conference.scipy.org/scipy2012/ Scientific Computing with Python Conference] in Austin, Texas, on July 19, 2012. See the poster by clicking on the image below&lt;br /&gt;
.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:SciPy2012Poster.png|link=http://www.ahay.org/wikilocal/docs/SciPy2012Poster.pdf]]&lt;br /&gt;
&lt;br /&gt;
===Cary 2011 (Interface)===&lt;br /&gt;
&amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; was presented in the special session on &#039;&#039;&#039;Reproducible Research&#039;&#039;&#039; at the [http://www.interfacesymposia.org/Interface2011/ 42nd Symposium on the Interface] (Statistical, Machine Learning, and Visualization Algorithms) in Cary, North Carolina, on June 1, 2011. See the [http://www.interfacesymposia.org/Interface2011/Program.pdf symposium program].&lt;br /&gt;
&lt;br /&gt;
===Long Beach 2011 (SIAM Geosciences)===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; was presented in the mini-symposium on &#039;&#039;&#039;Reproducible Science and Open-Source Software in the Geosciences&#039;&#039;&#039; at the [http://www.siam.org/meetings/gs11/ SIAM Conference on Mathematical &amp;amp; Computational Issues in the Geosciences] in Long Beach, California, on March 23, 2011. See presentation [https://ahay.org/wikilocal/docs/longbeach2011.pdf slides] and the mini-symposium program: [http://meetings.siam.org/sess/dsp_programsess.cfm?SESSIONCODE=11822 Part 1] and [http://meetings.siam.org/sess/dsp_programsess.cfm?SESSIONCODE=11823 Part 2].&lt;br /&gt;
&lt;br /&gt;
===Reno 2011 (SIAM CS&amp;amp;E)===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; was presented in the mini-symposium on &#039;&#039;&#039;Verifiable, Reproducible Research and Computational Science&#039;&#039;&#039; at the [http://www.siam.org/meetings/cse11/ SIAM Conference on Computational Science and Engineering] in Reno, Nevada, on March 4, 2011. See presentation [http://ahay.org/wikilocal/docs/reno2011.pdf slides]. &lt;br /&gt;
&lt;br /&gt;
Jarrod Millman provides a complete [http://jarrodmillman.com/events/siam2011.html session program].&lt;br /&gt;
&lt;br /&gt;
===Austin 2010 (SciPy)===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; was presented at the [http://conference.scipy.org/scipy2010/ Python in Scientific Computing Conference] in Austin, Texas, on July 1, 2010. See the presentation [http://ahay.org/wikilocal/docs/scipy2010.pdf slides] and [http://conference.scipy.org/scipy2010/schedule.html complete program].&lt;br /&gt;
&lt;br /&gt;
===Salt Lake City 2010 (NSF Archive Workshop)===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; was presented at the [http://users.emulab.net/trac/archive10/ NSF Workshop on Archiving Experiments to Raise Scientific Standards] in Salt Lake City on May 25, 2010. See the presentation [http://ahay.org/wikilocal/docs/slc.pdf slides] and [http://users.emulab.net/trac/archive10/wiki/WorkshopSchedule complete program].&lt;br /&gt;
&lt;br /&gt;
===Düsseldorf 2008 (Berlin 6) ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; was mentioned in the special session on &#039;&#039;&#039;Open Data and Reproducible Research&#039;&#039;&#039; at the [http://www.berlin6.org/ Berlin 6 Open Access Conference] in Düsseldorf, Germany, on November 12, 2008. See presentation [https://ahay.org/wikilocal/docs/Berlin-6.ppt slides]. &lt;br /&gt;
&lt;br /&gt;
Mark Liberman provides a complete [http://ldc.upenn.edu/myl/Berlin6Session5/Overview.html session program].&lt;br /&gt;
&lt;br /&gt;
===Austin 2008 (Texas Python Unconference)===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;New Directions in Literate Programming with Madagascar&#039;&#039; was presented at the Second Annual Texas Python Unconference hosted by Enthought Corporation on the UT campus on October 4, 2008. See presentation [http://www.ig.utexas.edu/people/staff/tobis/MadLiter/madliter.html slides].&lt;br /&gt;
&lt;br /&gt;
===Austin 2008 (Scientific Software Days)===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; was presented at the Second Annual Scientific Software Days at the University of Texas at Austin on May 15, 2008. See the presentation [http://ahay.org/wikilocal/docs/ssd2.pdf slides] and [http://www.tacc.utexas.edu/softwareday/ complete program].&lt;br /&gt;
&lt;br /&gt;
===Rio de Janeiro 2007 (SBGf)===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; and reproducible scientific computing were presented at the 2007  [http://www.sbgf.org.br Congress of the Brazilian Geophysical Society] in Rio de Janeiro. See presentation [https://ahay.org/wikilocal/docs/2007_SBGf_ReproducibleScientificComputingUsingMadagascar.pdf slides].&lt;br /&gt;
&lt;br /&gt;
===Vancouver 2007 (AIP)===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; was presented at a mini-symposium on &#039;&#039;&#039;Software for Inverse Problems&#039;&#039;&#039; at the [http://www.pims.math.ca/science/2007/07aip/ Conference on Applied Inverse Problems] in Vancouver on June 29, 2007. See presentation [https://ahay.org/wikilocal/docs/Fomel-AIP.ppt slides].&lt;br /&gt;
&lt;br /&gt;
===Honolulu 2007 (ICASSP)===&lt;br /&gt;
&lt;br /&gt;
The paper [https://ahay.org/wikilocal/docs/scons.pdf Reproducible computational experiments using SCons] was presented in the [http://www.icassp2007.org/Papers/PublicSessionIndex3.asp?Sessionid=1168 special session] on &#039;&#039;&#039;Reproducible Signal Processing Research&#039;&#039;&#039; at the [http://www.icassp2007.org/ International Conference on Acoustics, Speech, and Signal Processing] in Honolulu on April 18, 2007. See presentation [http://ahay.org/wikilocal/docs/SCons.ppt slides].&lt;br /&gt;
&lt;br /&gt;
Patrick Vandewalle provides a complete [http://lcavwww.epfl.ch/reproducible_research/ICASSP07/ session program].&lt;br /&gt;
&lt;br /&gt;
===Austin 2007 (Scientific Software Day)===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; was presented at the First Annual Scientific Software Day at the University of Texas at Austin on April 2, 2007. See presentation [http://ahay.org/wikilocal/docs/Madagascar-SSD.ppt slides].&lt;br /&gt;
&lt;br /&gt;
===New Orleans 2006 (SEG)===&lt;br /&gt;
&lt;br /&gt;
These advertising posters were prepared for the SEG Annual Meeting in New Orleans. Gilles Hennenfent had the idea, and Scott Rodgers implemented it.&lt;br /&gt;
&lt;br /&gt;
[[Image:Poker_comp_BEG.png]] [[Image:Poker_comp_CSM.png]] [[Image:Poker_comp_UBC.png]]&lt;br /&gt;
&lt;br /&gt;
===Vienna 2006 (EAGE)===&lt;br /&gt;
&lt;br /&gt;
RSF/Madagascar was first presented at the EAGE Workshop [http://www.eage.org/events/index.php?evp=274&amp;amp;eventid=1&amp;amp;ActiveMenu=16&amp;amp;Opendivs=s2,s11,s13 Open Source E&amp;amp;P Software – Putting the Pieces Together] in Vienna on June 11, 2006. See presentation [http://ahay.org/wikilocal/docs/vienna.pdf slides].&lt;br /&gt;
&lt;br /&gt;
Joe Dellinger provides a complete [http://sepwww.stanford.edu/oldsep/joe/Vienna/ workshop program with abstracts].&lt;/div&gt;</summary>
		<author><name>Fomels</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Guide_to_programming_with_madagascar&amp;diff=5623</id>
		<title>Guide to programming with madagascar</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Guide_to_programming_with_madagascar&amp;diff=5623"/>
		<updated>2024-11-26T15:34:35Z</updated>

		<summary type="html">&lt;p&gt;Fomels: typos&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 [https://github.com/ahay/src/blob/master/book/rsf/rsf/demo.tex book/rsf/rsf/demo.tex] using [[latex2wiki]]&#039;&#039;&amp;lt;/font&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This guide demonstrates a simple time-domain&lt;br /&gt;
finite-differences modeling code in RSF.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
This section presents time-domain &lt;br /&gt;
finite-difference modeling &amp;lt;ref&amp;gt;&amp;quot;Hello world&amp;quot; of seismic imaging.&amp;lt;/ref&amp;gt;&lt;br /&gt;
written with the RSF library.&lt;br /&gt;
The C, C++, and Fortran 90 interfaces demonstrate the program.&lt;br /&gt;
The acoustic wave-equation&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\Delta U - \frac{1}{v^2} \frac{\partial^2 U}{\partial t^2} = f(t)&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
can be written as&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\left[ \Delta U - f(t) \right] v^2 =&lt;br /&gt;
\frac{\partial^2 U}{\partial t^2} \;.&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; is the Laplacian symbol,&lt;br /&gt;
&amp;lt;math&amp;gt;f(t)&amp;lt;/math&amp;gt; is the source wavelet,&lt;br /&gt;
&amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is the velocity, and&lt;br /&gt;
&amp;lt;math&amp;gt;U&amp;lt;/math&amp;gt; is a scalar wavefield.&lt;br /&gt;
A discrete-time step involves the following computations:&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
U_{i+1} = \left[ \Delta U -f(t) \right] v^2 \Delta t^2 + 2 U_{i} - U_{i-1} \;,&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;U_{i-1}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;U_{i}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;U_{i+1}&amp;lt;/math&amp;gt;&lt;br /&gt;
represent the propagating wavefield at various time steps.&lt;br /&gt;
&lt;br /&gt;
==C program==&lt;br /&gt;
&lt;br /&gt;
[[Image:wavec.png|frame|center|Wave propagation snapshot.]]&lt;br /&gt;
&lt;br /&gt;
==C program==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/* time-domain acoustic FD modeling */&lt;br /&gt;
#include &amp;lt;rsf.h&amp;gt;&lt;br /&gt;
int main(int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
    /* Laplacian coefficients */&lt;br /&gt;
    float c0=-30./12.,c1=+16./12.,c2=- 1./12.;&lt;br /&gt;
&lt;br /&gt;
    bool verb;           /* verbose flag */&lt;br /&gt;
    sf_file Fw=NULL,Fv=NULL,Fr=NULL,Fo=NULL; /* I/O files */&lt;br /&gt;
    sf_axis at,az,ax;    /* cube axes */&lt;br /&gt;
    int it,iz,ix;        /* index variables */&lt;br /&gt;
    int nt,nz,nx;&lt;br /&gt;
    float dt,dz,dx,idx,idz,dt2;&lt;br /&gt;
&lt;br /&gt;
    float  *ww,**vv,**rr;     /* I/O arrays*/&lt;br /&gt;
    float **um,**uo,**up,**ud;/* tmp arrays */&lt;br /&gt;
&lt;br /&gt;
    sf_init(argc,argv);&lt;br /&gt;
    if(! sf_getbool(&amp;quot;verb&amp;quot;,&amp;amp;verb)) verb=0; /* verbose flag */&lt;br /&gt;
&lt;br /&gt;
    /* setup I/O files */&lt;br /&gt;
    Fw = sf_input (&amp;quot;in&amp;quot; );&lt;br /&gt;
    Fo = sf_output(&amp;quot;out&amp;quot;);&lt;br /&gt;
    Fv = sf_input (&amp;quot;vel&amp;quot;);&lt;br /&gt;
    Fr = sf_input (&amp;quot;ref&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    /* Read/Write axes */&lt;br /&gt;
    at = sf_iaxa(Fw,1); nt = sf_n(at); dt = sf_d(at);&lt;br /&gt;
    az = sf_iaxa(Fv,1); nz = sf_n(az); dz = sf_d(az);&lt;br /&gt;
    ax = sf_iaxa(Fv,2); nx = sf_n(ax); dx = sf_d(ax);&lt;br /&gt;
&lt;br /&gt;
    sf_oaxa(Fo,az,1); &lt;br /&gt;
    sf_oaxa(Fo,ax,2); &lt;br /&gt;
    sf_oaxa(Fo,at,3);&lt;br /&gt;
&lt;br /&gt;
    dt2 =    dt*dt;&lt;br /&gt;
    idz = 1/(dz*dz);&lt;br /&gt;
    idx = 1/(dx*dx);&lt;br /&gt;
&lt;br /&gt;
    /* read wavelet, velocity &amp;amp; reflectivity */&lt;br /&gt;
    ww=sf_floatalloc(nt);     sf_floatread(ww   ,nt   ,Fw);&lt;br /&gt;
    vv=sf_floatalloc2(nz,nx); sf_floatread(vv[0],nz*nx,Fv);&lt;br /&gt;
    rr=sf_floatalloc2(nz,nx); sf_floatread(rr[0],nz*nx,Fr);&lt;br /&gt;
&lt;br /&gt;
    /* allocate temporary arrays */&lt;br /&gt;
    um=sf_floatalloc2(nz,nx);&lt;br /&gt;
    uo=sf_floatalloc2(nz,nx);&lt;br /&gt;
    up=sf_floatalloc2(nz,nx);&lt;br /&gt;
    ud=sf_floatalloc2(nz,nx);&lt;br /&gt;
&lt;br /&gt;
    for (ix=0; ix&amp;lt;nx; ix++) {&lt;br /&gt;
	for (iz=0; iz&amp;lt;nz; iz++) {&lt;br /&gt;
	    um[ix][iz]=0;&lt;br /&gt;
	    uo[ix][iz]=0;&lt;br /&gt;
	    up[ix][iz]=0;&lt;br /&gt;
	    ud[ix][iz]=0;&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /* MAIN LOOP */&lt;br /&gt;
    if(verb) fprintf(stderr,&amp;quot;&lt;br /&gt;
&amp;quot;);&lt;br /&gt;
    for (it=0; it&amp;lt;nt; it++) {&lt;br /&gt;
	if(verb) fprintf(stderr,&amp;quot;\b\b\b\b\b %d&amp;quot;,it);&lt;br /&gt;
	&lt;br /&gt;
	/* 4th order laplacian */&lt;br /&gt;
	for (ix=2; ix&amp;lt;nx-2; ix++) {&lt;br /&gt;
	    for (iz=2; iz&amp;lt;nz-2; iz++) {&lt;br /&gt;
		ud[ix][iz] = &lt;br /&gt;
		    c0* uo[ix  ][iz  ] * (idx+idz) + &lt;br /&gt;
		    c1*(uo[ix-1][iz  ] + uo[ix+1][iz  ])*idx +&lt;br /&gt;
		    c2*(uo[ix-2][iz  ] + uo[ix+2][iz  ])*idx +&lt;br /&gt;
		    c1*(uo[ix  ][iz-1] + uo[ix  ][iz+1])*idz +&lt;br /&gt;
		    c2*(uo[ix  ][iz-2] + uo[ix  ][iz+2])*idz;	  &lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/* inject wavelet */&lt;br /&gt;
	for (ix=0; ix&amp;lt;nx; ix++) {&lt;br /&gt;
	    for (iz=0; iz&amp;lt;nz; iz++) {&lt;br /&gt;
		ud[ix][iz] -= ww[it] * rr[ix][iz];&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/* scale by velocity */&lt;br /&gt;
	for (ix=0; ix&amp;lt;nx; ix++) {&lt;br /&gt;
	    for (iz=0; iz&amp;lt;nz; iz++) {&lt;br /&gt;
		ud[ix][iz] *= vv[ix][iz]*vv[ix][iz];&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	/* time step */&lt;br /&gt;
	for (ix=0; ix&amp;lt;nx; ix++) {&lt;br /&gt;
	    for (iz=0; iz&amp;lt;nz; iz++) {&lt;br /&gt;
		up[ix][iz] = &lt;br /&gt;
		    2*uo[ix][iz] &lt;br /&gt;
		    - um[ix][iz] &lt;br /&gt;
		    + ud[ix][iz] * dt2; &lt;br /&gt;
		&lt;br /&gt;
		um[ix][iz] = uo[ix][iz];&lt;br /&gt;
		uo[ix][iz] = up[ix][iz];&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	/* write wavefield to output */&lt;br /&gt;
	sf_floatwrite(uo[0],nz*nx,Fo);&lt;br /&gt;
    }&lt;br /&gt;
    if(verb) fprintf(stderr,&amp;quot;\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    exit (0);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#Declare input, output and auxiliary file tags: &amp;lt;tt&amp;gt;Fw&amp;lt;/tt&amp;gt; for input wavelet,  &amp;lt;tt&amp;gt;Fv&amp;lt;/tt&amp;gt; for velocity, &amp;lt;tt&amp;gt;Fr&amp;lt;/tt&amp;gt; for reflectivity, and &amp;lt;tt&amp;gt;Fo&amp;lt;/tt&amp;gt; for output wavefield.  &amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
    sf_file Fw=NULL,Fv=NULL,Fr=NULL,Fo=NULL; /* I/O files */&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;    &lt;br /&gt;
#Declare RSF cube axes: &amp;lt;tt&amp;gt;at&amp;lt;/tt&amp;gt; time axis, &amp;lt;tt&amp;gt;ax&amp;lt;/tt&amp;gt; space axis, &amp;lt;tt&amp;gt;az&amp;lt;/tt&amp;gt; depth axis. \tiny &amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
    sf_axis at,az,ax;    /* cube axes */&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;  &lt;br /&gt;
#Declare multi-dimensional arrays for input, output, and computations.  &amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    float  *ww,**vv,**rr;     /* I/O arrays*/&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;  &lt;br /&gt;
#Open files for input/output.  &amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
    Fw = sf_input (&amp;quot;in&amp;quot; );&lt;br /&gt;
    Fo = sf_output(&amp;quot;out&amp;quot;);&lt;br /&gt;
    Fv = sf_input (&amp;quot;vel&amp;quot;);&lt;br /&gt;
    Fr = sf_input (&amp;quot;ref&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;   &lt;br /&gt;
#Read axes from input files; write axes to output file. &amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
    at = sf_iaxa(Fw,1); nt = sf_n(at); dt = sf_d(at);&lt;br /&gt;
    az = sf_iaxa(Fv,1); nz = sf_n(az); dz = sf_d(az);&lt;br /&gt;
    ax = sf_iaxa(Fv,2); nx = sf_n(ax); dx = sf_d(ax);&lt;br /&gt;
&lt;br /&gt;
    sf_oaxa(Fo,az,1); &lt;br /&gt;
    sf_oaxa(Fo,ax,2); &lt;br /&gt;
    sf_oaxa(Fo,at,3);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;   &lt;br /&gt;
#Allocate arrays and read wavelet, velocity, and reflectivity. &amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
    ww=sf_floatalloc(nt);     sf_floatread(ww   ,nt   ,Fw);&lt;br /&gt;
    vv=sf_floatalloc2(nz,nx); sf_floatread(vv[0],nz*nx,Fv);&lt;br /&gt;
    rr=sf_floatalloc2(nz,nx); sf_floatread(rr[0],nz*nx,Fr);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;    &lt;br /&gt;
#Allocate temporary arrays. &amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
    um=sf_floatalloc2(nz,nx);&lt;br /&gt;
    uo=sf_floatalloc2(nz,nx);&lt;br /&gt;
    up=sf_floatalloc2(nz,nx);&lt;br /&gt;
    ud=sf_floatalloc2(nz,nx);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;  &lt;br /&gt;
#Loop over time. &amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
    for (it=0; it&amp;lt;nt; it++) {&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;  &lt;br /&gt;
#Compute Laplacian: &amp;lt;math&amp;gt;\Delta U&amp;lt;/math&amp;gt;. &amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
	for (ix=2; ix&amp;lt;nx-2; ix++) {&lt;br /&gt;
	    for (iz=2; iz&amp;lt;nz-2; iz++) {&lt;br /&gt;
		ud[ix][iz] = &lt;br /&gt;
		    c0* uo[ix  ][iz  ] * (idx+idz) + &lt;br /&gt;
		    c1*(uo[ix-1][iz  ] + uo[ix+1][iz  ])*idx +&lt;br /&gt;
		    c2*(uo[ix-2][iz  ] + uo[ix+2][iz  ])*idx +&lt;br /&gt;
		    c1*(uo[ix  ][iz-1] + uo[ix  ][iz+1])*idz +&lt;br /&gt;
		    c2*(uo[ix  ][iz-2] + uo[ix  ][iz+2])*idz;	  &lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;  &lt;br /&gt;
#Inject source wavelet: &amp;lt;math&amp;gt;\left[ \Delta U - f(t) \right]&amp;lt;/math&amp;gt; &amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
	for (ix=0; ix&amp;lt;nx; ix++) {&lt;br /&gt;
	    for (iz=0; iz&amp;lt;nz; iz++) {&lt;br /&gt;
		ud[ix][iz] -= ww[it] * rr[ix][iz];&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;  &lt;br /&gt;
#Scale by velocity: &amp;lt;math&amp;gt;\left[ \Delta U - f(t) \right] v^2&amp;lt;/math&amp;gt; &amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
	for (ix=0; ix&amp;lt;nx; ix++) {&lt;br /&gt;
	    for (iz=0; iz&amp;lt;nz; iz++) {&lt;br /&gt;
		ud[ix][iz] *= vv[ix][iz]*vv[ix][iz];&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;  &lt;br /&gt;
#Time step:  &amp;lt;math&amp;gt;U_{i+1} = \left[ \Delta U -f(t) \right] v^2 \Delta t^2 + 2 U_{i} - U_{i-1}&amp;lt;/math&amp;gt;  &amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
	for (ix=0; ix&amp;lt;nx; ix++) {&lt;br /&gt;
	    for (iz=0; iz&amp;lt;nz; iz++) {&lt;br /&gt;
		up[ix][iz] = &lt;br /&gt;
		    2*uo[ix][iz] &lt;br /&gt;
		    - um[ix][iz] &lt;br /&gt;
		    + ud[ix][iz] * dt2; &lt;br /&gt;
		&lt;br /&gt;
		um[ix][iz] = uo[ix][iz];&lt;br /&gt;
		uo[ix][iz] = up[ix][iz];&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
\newpage&lt;br /&gt;
==C++ program==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// time-domain acoustic FD modeling&lt;br /&gt;
#include &amp;lt;valarray&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;rsf.hh&amp;gt;&lt;br /&gt;
#include &amp;lt;cub.hh&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;vai.hh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
using namespace std;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
    // Laplacian coefficients&lt;br /&gt;
    float c0=-30./12.,c1=+16./12.,c2=- 1./12.;&lt;br /&gt;
&lt;br /&gt;
    sf_init(argc,argv);// init RSF&lt;br /&gt;
    bool verb;         // vebose flag&lt;br /&gt;
    if(! sf_getbool(&amp;quot;verb&amp;quot;,&amp;amp;verb)) verb=0;&lt;br /&gt;
&lt;br /&gt;
    // setup I/O files&lt;br /&gt;
    CUB Fw(&amp;quot;in&amp;quot;, &amp;quot;i&amp;quot;); Fw.headin(); //Fw.report();&lt;br /&gt;
    CUB Fv(&amp;quot;vel&amp;quot;,&amp;quot;i&amp;quot;); Fv.headin(); //Fv.report();&lt;br /&gt;
    CUB Fr(&amp;quot;ref&amp;quot;,&amp;quot;i&amp;quot;); Fr.headin(); //Fr.report();&lt;br /&gt;
    CUB Fo(&amp;quot;out&amp;quot;,&amp;quot;o&amp;quot;); Fo.setup(3); &lt;br /&gt;
&lt;br /&gt;
    // Read/Write axes&lt;br /&gt;
    sf_axis at = Fw.getax(0); int nt = sf_n(at); float dt = sf_d(at);&lt;br /&gt;
    sf_axis az = Fv.getax(0); int nz = sf_n(az); float dz = sf_d(az);&lt;br /&gt;
    sf_axis ax = Fv.getax(1); int nx = sf_n(ax); float dx = sf_d(ax);&lt;br /&gt;
&lt;br /&gt;
    Fo.putax(0,az); &lt;br /&gt;
    Fo.putax(1,ax); &lt;br /&gt;
    Fo.putax(2,at);&lt;br /&gt;
    Fo.headou();&lt;br /&gt;
&lt;br /&gt;
    float dt2 =    dt*dt;&lt;br /&gt;
    float idz = 1/(dz*dz);&lt;br /&gt;
    float idx = 1/(dx*dx);&lt;br /&gt;
&lt;br /&gt;
    // read wavelet, velocity and reflectivity&lt;br /&gt;
    valarray&amp;lt;float&amp;gt; ww( nt    ); ww=0; Fw &amp;gt;&amp;gt; ww;&lt;br /&gt;
    valarray&amp;lt;float&amp;gt; vv( nz*nx ); vv=0; Fv &amp;gt;&amp;gt; vv;&lt;br /&gt;
    valarray&amp;lt;float&amp;gt; rr( nz*nx ); rr=0; Fr &amp;gt;&amp;gt; rr;&lt;br /&gt;
   &lt;br /&gt;
    // allocate temporary arrays&lt;br /&gt;
    valarray&amp;lt;float&amp;gt; um(nz*nx); um=0;&lt;br /&gt;
    valarray&amp;lt;float&amp;gt; uo(nz*nx); uo=0;&lt;br /&gt;
    valarray&amp;lt;float&amp;gt; up(nz*nx); up=0;&lt;br /&gt;
    valarray&amp;lt;float&amp;gt; ud(nz*nx); ud=0;&lt;br /&gt;
&lt;br /&gt;
    // init ValArray Index counter&lt;br /&gt;
    VAI k(nz,nx);&lt;br /&gt;
&lt;br /&gt;
    // MAIN LOOP&lt;br /&gt;
    if(verb) cerr &amp;lt;&amp;lt; endl;&lt;br /&gt;
    for (int it=0; it&amp;lt;nt; it++) {&lt;br /&gt;
	if(verb) cerr &amp;lt;&amp;lt; &amp;quot;\b\b\b\b\b&amp;quot; &amp;lt;&amp;lt; it;&lt;br /&gt;
&lt;br /&gt;
	// 4th order laplacian&lt;br /&gt;
	for (int ix=2; ix&amp;lt;nx-2; ix++) {&lt;br /&gt;
	    for (int iz=2; iz&amp;lt;nz-2; iz++) {&lt;br /&gt;
		ud[k(iz,ix)] = &lt;br /&gt;
		    c0* uo[ k(iz  ,ix  )] * (idx+idz) +&lt;br /&gt;
		    c1*(uo[ k(iz  ,ix-1)]+uo[ k(iz  ,ix+1)]) * idx + &lt;br /&gt;
		    c1*(uo[ k(iz-1,ix  )]+uo[ k(iz+1,ix  )]) * idz + &lt;br /&gt;
		    c2*(uo[ k(iz  ,ix-2)]+uo[ k(iz  ,ix+2)]) * idx + &lt;br /&gt;
		    c2*(uo[ k(iz-2,ix  )]+uo[ k(iz+2,ix  )]) * idz;&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	// inject wavelet&lt;br /&gt;
	ud -= ww[it] * rr;&lt;br /&gt;
	&lt;br /&gt;
	// scale by velocity&lt;br /&gt;
	ud *= vv*vv;&lt;br /&gt;
	&lt;br /&gt;
	// time step&lt;br /&gt;
	up=(float)2 * uo - um + ud * dt2;&lt;br /&gt;
	um =   uo;&lt;br /&gt;
	uo =   up;&lt;br /&gt;
	&lt;br /&gt;
	// write wavefield to output output&lt;br /&gt;
	Fo &amp;lt;&amp;lt; uo;&lt;br /&gt;
    }&lt;br /&gt;
    if(verb) cerr &amp;lt;&amp;lt; endl;&lt;br /&gt;
&lt;br /&gt;
    exit(0);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#Declare input, output, and auxiliary file cubes  (of type &amp;lt;tt&amp;gt;CUB&amp;lt;/tt&amp;gt;). &amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    CUB Fw(&amp;quot;in&amp;quot;, &amp;quot;i&amp;quot;); Fw.headin(); //Fw.report();&lt;br /&gt;
    CUB Fv(&amp;quot;vel&amp;quot;,&amp;quot;i&amp;quot;); Fv.headin(); //Fv.report();&lt;br /&gt;
    CUB Fr(&amp;quot;ref&amp;quot;,&amp;quot;i&amp;quot;); Fr.headin(); //Fr.report();&lt;br /&gt;
    CUB Fo(&amp;quot;out&amp;quot;,&amp;quot;o&amp;quot;); Fo.setup(3); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;  &lt;br /&gt;
#Declare, read and write RSF cube axes: &amp;lt;tt&amp;gt;at&amp;lt;/tt&amp;gt; time axis, &amp;lt;tt&amp;gt;ax&amp;lt;/tt&amp;gt; space axis, &amp;lt;tt&amp;gt;az&amp;lt;/tt&amp;gt; depth axis.  &amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    sf_axis at = Fw.getax(0); int nt = sf_n(at); float dt = sf_d(at);&lt;br /&gt;
    sf_axis az = Fv.getax(0); int nz = sf_n(az); float dz = sf_d(az);&lt;br /&gt;
    sf_axis ax = Fv.getax(1); int nx = sf_n(ax); float dx = sf_d(ax);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;   &lt;br /&gt;
#Declare multi-dimensional  &amp;lt;tt&amp;gt;valarrays&amp;lt;/tt&amp;gt; for input, output and read data. &amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    valarray&amp;lt;float&amp;gt; ww( nt    ); ww=0; Fw &amp;gt;&amp;gt; ww;&lt;br /&gt;
    valarray&amp;lt;float&amp;gt; vv( nz*nx ); vv=0; Fv &amp;gt;&amp;gt; vv;&lt;br /&gt;
    valarray&amp;lt;float&amp;gt; rr( nz*nx ); rr=0; Fr &amp;gt;&amp;gt; rr;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;    &lt;br /&gt;
#Declare multi-dimensional  &amp;lt;tt&amp;gt;valarrays&amp;lt;/tt&amp;gt; for temporary storage. &amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    valarray&amp;lt;float&amp;gt; um(nz*nx); um=0;&lt;br /&gt;
    valarray&amp;lt;float&amp;gt; uo(nz*nx); uo=0;&lt;br /&gt;
    valarray&amp;lt;float&amp;gt; up(nz*nx); up=0;&lt;br /&gt;
    valarray&amp;lt;float&amp;gt; ud(nz*nx); ud=0;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;   &lt;br /&gt;
#Initialize multidimensional &amp;lt;tt&amp;gt;valarray&amp;lt;/tt&amp;gt;  index counter (of type &amp;lt;tt&amp;gt;VAI&amp;lt;/tt&amp;gt;). &amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    VAI k(nz,nx);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;   &lt;br /&gt;
#Loop over time. &amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    for (int it=0; it&amp;lt;nt; it++) {&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;    &lt;br /&gt;
#Compute Laplacian: &amp;lt;math&amp;gt;\Delta U&amp;lt;/math&amp;gt;. &amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
	for (int ix=2; ix&amp;lt;nx-2; ix++) {&lt;br /&gt;
	    for (int iz=2; iz&amp;lt;nz-2; iz++) {&lt;br /&gt;
		ud[k(iz,ix)] = &lt;br /&gt;
		    c0* uo[ k(iz  ,ix  )] * (idx+idz) +&lt;br /&gt;
		    c1*(uo[ k(iz  ,ix-1)]+uo[ k(iz  ,ix+1)]) * idx + &lt;br /&gt;
		    c1*(uo[ k(iz-1,ix  )]+uo[ k(iz+1,ix  )]) * idz + &lt;br /&gt;
		    c2*(uo[ k(iz  ,ix-2)]+uo[ k(iz  ,ix+2)]) * idx + &lt;br /&gt;
		    c2*(uo[ k(iz-2,ix  )]+uo[ k(iz+2,ix  )]) * idz;&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;   &lt;br /&gt;
#Inject source wavelet: &amp;lt;math&amp;gt;\left[ \Delta U - f(t) \right]&amp;lt;/math&amp;gt; &amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
	ud -= ww[it] * rr;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;    &lt;br /&gt;
#Scale by velocity: &amp;lt;math&amp;gt;\left[ \Delta U - f(t) \right] v^2&amp;lt;/math&amp;gt; &amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
	ud *= vv*vv;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;  &lt;br /&gt;
#Time step:  &amp;lt;math&amp;gt;U_{i+1} = \left[ \Delta U -f(t) \right] v^2 \Delta t^2 + 2 U_{i} - U_{i-1}&amp;lt;/math&amp;gt; &amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
	up=(float)2 * uo - um + ud * dt2;&lt;br /&gt;
	um =   uo;&lt;br /&gt;
	uo =   up;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
==Fortran 90 program==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
! time-domain acoustic FD modeling&lt;br /&gt;
program AFDMf90&lt;br /&gt;
  use rsf&lt;br /&gt;
&lt;br /&gt;
  implicit none&lt;br /&gt;
&lt;br /&gt;
  ! Laplacian coefficients&lt;br /&gt;
  real :: c0=-30./12.,c1=+16./12.,c2=- 1./12.&lt;br /&gt;
&lt;br /&gt;
  logical    :: verb         ! verbose flag&lt;br /&gt;
  type(file) :: Fw,Fv,Fr,Fo  ! I/O files&lt;br /&gt;
  type(axa)  :: at,az,ax     ! cube axes&lt;br /&gt;
  integer    :: it,iz,ix     ! index variables&lt;br /&gt;
  integer    :: nt,nz,nx&lt;br /&gt;
  real       :: dt,dz,dx&lt;br /&gt;
  real       :: idx,idz,dt2&lt;br /&gt;
&lt;br /&gt;
  real, allocatable :: vv(:,:),rr(:,:),ww(:)           ! I/O arrays&lt;br /&gt;
  real, allocatable :: um(:,:),uo(:,:),up(:,:),ud(:,:) ! tmp arrays&lt;br /&gt;
&lt;br /&gt;
  call sf_init() ! init RSF&lt;br /&gt;
  call from_par(&amp;quot;verb&amp;quot;,verb,.false.)&lt;br /&gt;
&lt;br /&gt;
  ! Setup I/O files&lt;br /&gt;
  Fw=rsf_input (&amp;quot;in&amp;quot;)&lt;br /&gt;
  Fv=rsf_input (&amp;quot;vel&amp;quot;)&lt;br /&gt;
  Fr=rsf_input (&amp;quot;ref&amp;quot;)&lt;br /&gt;
  Fo=rsf_output(&amp;quot;out&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
  ! Read/Write axes&lt;br /&gt;
  call iaxa(Fw,at,1); nt = at%n; dt = at%d&lt;br /&gt;
  call iaxa(Fv,az,1); nz = az%n; dz = az%d&lt;br /&gt;
  call iaxa(Fv,ax,2); nx = ax%n; dx = ax%d&lt;br /&gt;
  &lt;br /&gt;
  call oaxa(Fo,az,1)&lt;br /&gt;
  call oaxa(Fo,ax,2)&lt;br /&gt;
  call oaxa(Fo,at,3)&lt;br /&gt;
&lt;br /&gt;
  dt2 =    dt*dt&lt;br /&gt;
  idz = 1/(dz*dz)&lt;br /&gt;
  idx = 1/(dx*dx) &lt;br /&gt;
&lt;br /&gt;
  ! read wavelet, velocity &amp;amp; reflectivity&lt;br /&gt;
  allocate(ww(nt));    call rsf_read(Fw,ww)&lt;br /&gt;
  allocate(vv(nz,nx)); call rsf_read(Fv,vv)&lt;br /&gt;
  allocate(rr(nz,nx)); call rsf_read(Fr,rr)&lt;br /&gt;
&lt;br /&gt;
  ! allocate temporary arrays&lt;br /&gt;
  allocate(um(nz,nx)); um=0.&lt;br /&gt;
  allocate(uo(nz,nx)); uo=0.&lt;br /&gt;
  allocate(up(nz,nx)); up=0.&lt;br /&gt;
  allocate(ud(nz,nx)); ud=0.&lt;br /&gt;
&lt;br /&gt;
  ! MAIN LOOP&lt;br /&gt;
  do it=1,nt&lt;br /&gt;
     if(verb) write (0,*) it&lt;br /&gt;
&lt;br /&gt;
     ud(3:nz-2,3:nx-2) = &amp;amp;&lt;br /&gt;
          c0* uo(3:nz-2,3:nx-2) * (idx + idz)            + &amp;amp;&lt;br /&gt;
          c1*(uo(3:nz-2,2:nx-3) + uo(3:nz-2,4:nx-1))*idx + &amp;amp;&lt;br /&gt;
          c2*(uo(3:nz-2,1:nx-4) + uo(3:nz-2,5:nx  ))*idx + &amp;amp;&lt;br /&gt;
          c1*(uo(2:nz-3,3:nx-2) + uo(4:nz-1,3:nx-2))*idz + &amp;amp;&lt;br /&gt;
          c2*(uo(1:nz-4,3:nx-2) + uo(5:nz  ,3:nx-2))*idz&lt;br /&gt;
&lt;br /&gt;
     ! inject wavelet&lt;br /&gt;
     ud = ud - ww(it) * rr&lt;br /&gt;
&lt;br /&gt;
     ! scale by velocity&lt;br /&gt;
     ud= ud *vv*vv&lt;br /&gt;
&lt;br /&gt;
     ! time step&lt;br /&gt;
     up = 2*uo - um + ud * dt2&lt;br /&gt;
     um =   uo&lt;br /&gt;
     uo =   up&lt;br /&gt;
&lt;br /&gt;
     ! write wavefield to output&lt;br /&gt;
     call rsf_write(Fo,uo)&lt;br /&gt;
  end do&lt;br /&gt;
&lt;br /&gt;
  call exit(0)&lt;br /&gt;
end program AFDMf90&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#Declare input, output, and auxiliary file tags. &amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
  type(file) :: Fw,Fv,Fr,Fo  ! I/O files&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;   &lt;br /&gt;
#Declare RSF cube axes: &amp;lt;tt&amp;gt;at&amp;lt;/tt&amp;gt; time axis, &amp;lt;tt&amp;gt;ax&amp;lt;/tt&amp;gt; space axis, &amp;lt;tt&amp;gt;az&amp;lt;/tt&amp;gt; depth axis. &amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
  type(axa)  :: at,az,ax     ! cube axes&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;    &lt;br /&gt;
#Declare multi-dimensional arrays for input, output, and computations. &amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
  real, allocatable :: vv(:,:),rr(:,:),ww(:)           ! I/O arrays&lt;br /&gt;
  real, allocatable :: um(:,:),uo(:,:),up(:,:),ud(:,:) ! tmp arrays&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;  &lt;br /&gt;
#Open files for input/output. &amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
  Fw=rsf_input (&amp;quot;in&amp;quot;)&lt;br /&gt;
  Fv=rsf_input (&amp;quot;vel&amp;quot;)&lt;br /&gt;
  Fr=rsf_input (&amp;quot;ref&amp;quot;)&lt;br /&gt;
  Fo=rsf_output(&amp;quot;out&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;  &lt;br /&gt;
#Read axes from input files; write axes to output file. &amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
  call iaxa(Fw,at,1); nt = at%n; dt = at%d&lt;br /&gt;
  call iaxa(Fv,az,1); nz = az%n; dz = az%d&lt;br /&gt;
  call iaxa(Fv,ax,2); nx = ax%n; dx = ax%d&lt;br /&gt;
  &lt;br /&gt;
  call oaxa(Fo,az,1)&lt;br /&gt;
  call oaxa(Fo,ax,2)&lt;br /&gt;
  call oaxa(Fo,at,3)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;   &lt;br /&gt;
#Allocate arrays and read wavelet, velocity, and reflectivity. &amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
  allocate(ww(nt));    call rsf_read(Fw,ww)&lt;br /&gt;
  allocate(vv(nz,nx)); call rsf_read(Fv,vv)&lt;br /&gt;
  allocate(rr(nz,nx)); call rsf_read(Fr,rr)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;   &lt;br /&gt;
#Allocate temporary arrays. &amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
  allocate(um(nz,nx)); um=0.&lt;br /&gt;
  allocate(uo(nz,nx)); uo=0.&lt;br /&gt;
  allocate(up(nz,nx)); up=0.&lt;br /&gt;
  allocate(ud(nz,nx)); ud=0.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;   &lt;br /&gt;
#Loop over time. &amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
  do it=1,nt&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;    &lt;br /&gt;
#Compute Laplacian: &amp;lt;math&amp;gt;\Delta U&amp;lt;/math&amp;gt;. &amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
     ud(3:nz-2,3:nx-2) = &amp;amp;&lt;br /&gt;
          c0* uo(3:nz-2,3:nx-2) * (idx + idz)            + &amp;amp;&lt;br /&gt;
          c1*(uo(3:nz-2,2:nx-3) + uo(3:nz-2,4:nx-1))*idx + &amp;amp;&lt;br /&gt;
          c2*(uo(3:nz-2,1:nx-4) + uo(3:nz-2,5:nx  ))*idx + &amp;amp;&lt;br /&gt;
          c1*(uo(2:nz-3,3:nx-2) + uo(4:nz-1,3:nx-2))*idz + &amp;amp;&lt;br /&gt;
          c2*(uo(1:nz-4,3:nx-2) + uo(5:nz  ,3:nx-2))*idz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;  &lt;br /&gt;
#Inject source wavelet: &amp;lt;math&amp;gt;\left[ \Delta U - f(t) \right]&amp;lt;/math&amp;gt; &amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
     ud = ud - ww(it) * rr&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;  &lt;br /&gt;
#Scale by velocity: &amp;lt;math&amp;gt;\left[ \Delta U - f(t) \right] v^2&amp;lt;/math&amp;gt; &amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
     ud= ud *vv*vv&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;  &lt;br /&gt;
#Time step:  &amp;lt;math&amp;gt;U_{i+1} = \left[ \Delta U -f(t) \right] v^2 \Delta t^2 + 2 U_{i} - U_{i-1}&amp;lt;/math&amp;gt; &amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
     up = 2*uo - um + ud * dt2&lt;br /&gt;
     um =   uo&lt;br /&gt;
     uo =   up&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
==Python program==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
import sys&lt;br /&gt;
import numpy&lt;br /&gt;
import m8r&lt;br /&gt;
&lt;br /&gt;
c0=-30./12.&lt;br /&gt;
c1=+16./12.&lt;br /&gt;
c2=- 1./12.&lt;br /&gt;
&lt;br /&gt;
par = m8r.Par()&lt;br /&gt;
verb = par.bool(&amp;quot;verb&amp;quot;,False) # verbosity&lt;br /&gt;
&lt;br /&gt;
# setup I/O files&lt;br /&gt;
Fw=m8r.Input()&lt;br /&gt;
Fv=m8r.Input (&amp;quot;vel&amp;quot;)&lt;br /&gt;
Fr=m8r.Input (&amp;quot;ref&amp;quot;)&lt;br /&gt;
Fo=m8r.Output()&lt;br /&gt;
&lt;br /&gt;
# Read/Write axes&lt;br /&gt;
at = Fw.axis(1); nt = at[&#039;n&#039;]; dt = at[&#039;d&#039;]&lt;br /&gt;
az = Fv.axis(1); nz = az[&#039;n&#039;]; dz = az[&#039;d&#039;]&lt;br /&gt;
ax = Fv.axis(2); nx = ax[&#039;n&#039;]; dx = ax[&#039;d&#039;]&lt;br /&gt;
&lt;br /&gt;
Fo.putaxis(az,1)&lt;br /&gt;
Fo.putaxis(ax,2)&lt;br /&gt;
Fo.putaxis(at,3)&lt;br /&gt;
&lt;br /&gt;
dt2 =    dt*dt&lt;br /&gt;
idz = 1/(dz*dz)&lt;br /&gt;
idx = 1/(dx*dx) &lt;br /&gt;
&lt;br /&gt;
# read wavelet, velocity &amp;amp; reflectivity&lt;br /&gt;
ww = numpy.zeros(nt,&#039;f&#039;);      Fw.read(ww)&lt;br /&gt;
vv = numpy.zeros([nz,nx],&#039;f&#039;); Fv.read(vv)&lt;br /&gt;
rr = numpy.zeros([nz,nx],&#039;f&#039;); Fr.read(rr)&lt;br /&gt;
&lt;br /&gt;
# allocate temporary arrays&lt;br /&gt;
um = numpy.zeros([nz,nx],&#039;f&#039;)&lt;br /&gt;
uo = numpy.zeros([nz,nx],&#039;f&#039;)&lt;br /&gt;
up = numpy.zeros([nz,nx],&#039;f&#039;)&lt;br /&gt;
ud = numpy.zeros([nz,nx],&#039;f&#039;)&lt;br /&gt;
&lt;br /&gt;
# MAIN LOOP&lt;br /&gt;
for it in range(nt):&lt;br /&gt;
    if verb:&lt;br /&gt;
        sys.stderr.write(&amp;quot;\b\b\b\b\b %d&amp;quot; % it)&lt;br /&gt;
&lt;br /&gt;
    ud[2:-2,2:-2] = \&lt;br /&gt;
    c0* uo[2:-2,2:-2] * (idx + idz)        + \&lt;br /&gt;
    c1*(uo[2:-2,1:-3] + uo[2:-2,3:-1])*idx + \&lt;br /&gt;
    c2*(uo[2:-2, :-4] + uo[2:-2,4:  ])*idx + \&lt;br /&gt;
    c1*(uo[1:-3,2:-2] + uo[3:-1,2:-2])*idz + \&lt;br /&gt;
    c2*(uo[ :-4,2:-2] + uo[4:  ,2:-2])*idz&lt;br /&gt;
&lt;br /&gt;
    # inject wavelet&lt;br /&gt;
    ud = ud - ww[it] * rr&lt;br /&gt;
&lt;br /&gt;
    # scale by velocity&lt;br /&gt;
    ud= ud *vv*vv&lt;br /&gt;
&lt;br /&gt;
    # time step&lt;br /&gt;
    up = 2*uo - um + ud * dt2&lt;br /&gt;
    um =   uo&lt;br /&gt;
    uo =   up&lt;br /&gt;
&lt;br /&gt;
if verb:&lt;br /&gt;
    sys.stderr.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
    Fo.write(uo)&lt;br /&gt;
&lt;br /&gt;
sys.exit(0)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:wavepython.png|frame|center|Wave propagation snapshot.]]&lt;br /&gt;
&lt;br /&gt;
#Open files for input/output. &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
Fw=m8r.Input()&lt;br /&gt;
Fv=m8r.Input (&amp;quot;vel&amp;quot;)&lt;br /&gt;
Fr=m8r.Input (&amp;quot;ref&amp;quot;)&lt;br /&gt;
Fo=m8r.Output()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;  &lt;br /&gt;
#Read axes from input files; write axes to output file. &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
at = Fw.axis(1); nt = at[&#039;n&#039;]; dt = at[&#039;d&#039;]&lt;br /&gt;
az = Fv.axis(1); nz = az[&#039;n&#039;]; dz = az[&#039;d&#039;]&lt;br /&gt;
ax = Fv.axis(2); nx = ax[&#039;n&#039;]; dx = ax[&#039;d&#039;]&lt;br /&gt;
&lt;br /&gt;
Fo.putaxis(az,1)&lt;br /&gt;
Fo.putaxis(ax,2)&lt;br /&gt;
Fo.putaxis(at,3)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;   &lt;br /&gt;
#Allocate arrays and read wavelet, velocity, and reflectivity. &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
ww = numpy.zeros(nt,&#039;f&#039;);      Fw.read(ww)&lt;br /&gt;
vv = numpy.zeros([nz,nx],&#039;f&#039;); Fv.read(vv)&lt;br /&gt;
rr = numpy.zeros([nz,nx],&#039;f&#039;); Fr.read(rr)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;   &lt;br /&gt;
#Allocate temporary arrays. &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
um = numpy.zeros([nz,nx],&#039;f&#039;)&lt;br /&gt;
uo = numpy.zeros([nz,nx],&#039;f&#039;)&lt;br /&gt;
up = numpy.zeros([nz,nx],&#039;f&#039;)&lt;br /&gt;
ud = numpy.zeros([nz,nx],&#039;f&#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;   &lt;br /&gt;
#Loop over time. &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
for it in range(nt):&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;   &lt;br /&gt;
#Compute Laplacian: &amp;lt;math&amp;gt;\Delta U&amp;lt;/math&amp;gt;. &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    ud[2:-2,2:-2] = \&lt;br /&gt;
    c0* uo[2:-2,2:-2] * (idx + idz)        + \&lt;br /&gt;
    c1*(uo[2:-2,1:-3] + uo[2:-2,3:-1])*idx + \&lt;br /&gt;
    c2*(uo[2:-2, :-4] + uo[2:-2,4:  ])*idx + \&lt;br /&gt;
    c1*(uo[1:-3,2:-2] + uo[3:-1,2:-2])*idz + \&lt;br /&gt;
    c2*(uo[ :-4,2:-2] + uo[4:  ,2:-2])*idz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;   &lt;br /&gt;
#Inject source wavelet: &amp;lt;math&amp;gt;\left[ \Delta U - f(t) \right]&amp;lt;/math&amp;gt; &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    ud = ud - ww[it] * rr&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;   &lt;br /&gt;
#Scale by velocity: &amp;lt;math&amp;gt;\left[ \Delta U - f(t) \right] v^2&amp;lt;/math&amp;gt; &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    ud= ud *vv*vv&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;   &lt;br /&gt;
#Time step:  &amp;lt;math&amp;gt;U_{i+1} = \left[ \Delta U -f(t) \right] v^2 \Delta t^2 + 2 U_{i} - U_{i-1}&amp;lt;/math&amp;gt;  &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    up = 2*uo - um + ud * dt2&lt;br /&gt;
    um =   uo&lt;br /&gt;
    uo =   up&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Fomels</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Guide_to_madagascar_API&amp;diff=5581</id>
		<title>Guide to madagascar API</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Guide_to_madagascar_API&amp;diff=5581"/>
		<updated>2024-11-26T04:05:20Z</updated>

		<summary type="html">&lt;p&gt;Fomels: typos&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 [https://github.com/ahay/src/blob/master/book/m8r/api/paper.tex book/m8r/api/paper.tex] using [[latex2wiki]]&#039;&#039;&amp;lt;/font&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Fotolia_555071_XS.jpg|right|]]&lt;br /&gt;
&lt;br /&gt;
This guide explains the RSF programming interface. For more information on how to use the particular APIs, see the &#039;&#039;&#039;[[Library_Reference | Library Reference]]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
You may need to use an appropriate programming interface to work with RSF files in your own programs. We will demonstrate the interface in&lt;br /&gt;
different languages using a simple example. Our example is a clipping program.&lt;br /&gt;
It reads and writes RSF files and accesses parameters both from the input file&lt;br /&gt;
and the command line. The input is processed trace by trace. This is not&lt;br /&gt;
necessarily the most efficient approach&amp;lt;ref&amp;gt;Compare with the [https://github.com/ahay/src/blob/master/system/generic/Mclip.c library clip program].&amp;lt;/ref&amp;gt; but it suffices for a simple demonstration.&lt;br /&gt;
&lt;br /&gt;
==Installation== &lt;br /&gt;
Only the C interface is installed by default. To install other APIs, use &amp;lt;tt&amp;gt;API=&amp;lt;/tt&amp;gt;&lt;br /&gt;
parameter in the RSF configuration. For example, to install C++ and&lt;br /&gt;
Fortran-90 API bindings, in addition to the basic package, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./configure API=c++,fortran-90&lt;br /&gt;
scons install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The configuration parameters are stored in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/share/madagascar/etc/config.py&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==C interface==&lt;br /&gt;
&lt;br /&gt;
The C clip function is listed below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/* Clip the data. */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;rsf.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
    int n1, n2, i1, i2;&lt;br /&gt;
    float clip, *trace=NULL;&lt;br /&gt;
    sf_file in=NULL, out=NULL; /* Input and output files */&lt;br /&gt;
&lt;br /&gt;
    /* Initialize RSF */&lt;br /&gt;
    sf_init(argc,argv);&lt;br /&gt;
    /* standard input */&lt;br /&gt;
    in = sf_input(&amp;quot;in&amp;quot;);&lt;br /&gt;
    /* standard output */&lt;br /&gt;
    out = sf_output(&amp;quot;out&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    /* check that the input is float */&lt;br /&gt;
    if (SF_FLOAT != sf_gettype(in)) &lt;br /&gt;
	sf_error(&amp;quot;Need float input&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    /* n1 is the fastest dimension (trace length) */&lt;br /&gt;
    if (!sf_histint(in,&amp;quot;n1&amp;quot;,&amp;amp;n1)) &lt;br /&gt;
	sf_error(&amp;quot;No n1= in input&amp;quot;);&lt;br /&gt;
    /* leftsize gets n2*n3*n4*... (the number of traces) */&lt;br /&gt;
    n2 = sf_leftsize(in,1);&lt;br /&gt;
&lt;br /&gt;
    /* parameter from the command line (i.e., clip=1.5 ) */&lt;br /&gt;
    if (!sf_getfloat(&amp;quot;clip&amp;quot;,&amp;amp;clip)) sf_error(&amp;quot;Need clip=&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    /* allocate floating point array */&lt;br /&gt;
    trace = sf_floatalloc (n1);&lt;br /&gt;
&lt;br /&gt;
    /* loop over traces */&lt;br /&gt;
    for (i2=0; i2 &amp;lt; n2; i2++) {&lt;br /&gt;
&lt;br /&gt;
	/*read a trace */&lt;br /&gt;
	sf_floatread(trace,n1,in);&lt;br /&gt;
&lt;br /&gt;
	/* loop over samples */&lt;br /&gt;
	for (i1=0; i1 &amp;lt; n1; i1++) {&lt;br /&gt;
	    if      (trace[i1] &amp;gt;  clip) trace[i1]= clip;&lt;br /&gt;
	    else if (trace[i1] &amp;lt; -clip) trace[i1]=-clip;&lt;br /&gt;
	}&lt;br /&gt;
    &lt;br /&gt;
	/* write a trace */&lt;br /&gt;
	sf_floatwrite(trace,n1,out);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    free(trace);&lt;br /&gt;
    sf_close();&lt;br /&gt;
    exit(0);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it in detail. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;rsf.h&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;include&amp;lt;/tt&amp;gt; preprocessing directive is required to access the RSF interface. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
    sf_file in=NULL, out=NULL; /* Input and output files */&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RSF data files are defined with an abstract &amp;lt;tt&amp;gt;sf_file&amp;lt;/tt&amp;gt; data type. An&lt;br /&gt;
abstract data type means that the contents of it are not publicly declared,&lt;br /&gt;
and all operations on &amp;lt;tt&amp;gt;sf_file&amp;lt;/tt&amp;gt; objects should be performed with&lt;br /&gt;
library functions. This is analogous to &amp;lt;tt&amp;gt;FILE *&amp;lt;/tt&amp;gt; data type used in&lt;br /&gt;
&amp;lt;tt&amp;gt;stdio.h&amp;lt;/tt&amp;gt; and as close as C gets to an object-oriented style of&lt;br /&gt;
programming (Roberts, 1998&amp;lt;ref&amp;gt;Roberts, E. S.,  1998, Programming abstractions in C: Addison-Wesley.&amp;lt;/ref&amp;gt;).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
    /* Initialize RSF */&lt;br /&gt;
    sf_init(argc,argv);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before using any of the other functions, you must call&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_init&amp;lt;/tt&amp;gt;. This function parses the command line and&lt;br /&gt;
initializes an internally stored table of command-line parameters.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
    /* standard input */&lt;br /&gt;
    in = sf_input(&amp;quot;in&amp;quot;);&lt;br /&gt;
    /* standard output */&lt;br /&gt;
    out = sf_output(&amp;quot;out&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The input and output RSF file objects are created with &amp;lt;tt&amp;gt;sf_input&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_output&amp;lt;/tt&amp;gt; constructor functions. Both these functions take a string&lt;br /&gt;
argument. The string may refer to a file name or a file tag. For example, if&lt;br /&gt;
the command line contains &amp;lt;tt&amp;gt;vel=velocity.rsf&amp;lt;/tt&amp;gt;, then both&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_input(&amp;quot;velocity.rsf&amp;quot;)&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_input(&amp;quot;vel&amp;quot;)&amp;lt;/tt&amp;gt; are&lt;br /&gt;
acceptable. Two tags are special: &amp;lt;tt&amp;gt;&amp;quot;in&amp;quot;&amp;lt;/tt&amp;gt; refers to the file in the&lt;br /&gt;
standard input and &amp;lt;tt&amp;gt;&amp;quot;out&amp;quot;&amp;lt;/tt&amp;gt; refers to the file in the standard&lt;br /&gt;
output. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
    /* check that the input is float */&lt;br /&gt;
    if (SF_FLOAT != sf_gettype(in)) &lt;br /&gt;
	sf_error(&amp;quot;Need float input&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
RSF files can store data of different types (character, integer,&lt;br /&gt;
floating point, complex). We extract the data type of the input file&lt;br /&gt;
with the library &amp;lt;tt&amp;gt;sf_gettype&amp;lt;/tt&amp;gt; function and check if it&lt;br /&gt;
represents floating point numbers. If not, the program is aborted with&lt;br /&gt;
an error message, using the &amp;lt;tt&amp;gt;sf_error&amp;lt;/tt&amp;gt; function.  It is generally a good idea to check the input for user errors and, if they cannot be corrected, to take a safe exit.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
    /* n1 is the fastest dimension (trace length) */&lt;br /&gt;
    if (!sf_histint(in,&amp;quot;n1&amp;quot;,&amp;amp;n1)) &lt;br /&gt;
	sf_error(&amp;quot;No n1= in input&amp;quot;);&lt;br /&gt;
    /* leftsize gets n2*n3*n4*... (the number of traces) */&lt;br /&gt;
    n2 = sf_leftsize(in,1);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Conceptually, the RSF data model is a multidimensional hypercube. By&lt;br /&gt;
convention, the dimensions of the cube are stored in &amp;lt;tt&amp;gt;n1=&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n2=&amp;lt;/tt&amp;gt;, etc. parameters. The &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; parameter refers to the&lt;br /&gt;
fastest axis. If the input dataset is a collection of traces,&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; refers to the trace length. We extract it using the&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_histint&amp;lt;/tt&amp;gt; function (integer parameter from history) and&lt;br /&gt;
abort if no value for &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; is found. We could proceed similarly, extracting &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc. If we are&lt;br /&gt;
interested in the total number of traces like in the clip example, a&lt;br /&gt;
shortcut is to use the &amp;lt;tt&amp;gt;sf_leftsize&amp;lt;/tt&amp;gt; function. Calling&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_leftsize(in,0)&amp;lt;/tt&amp;gt; returns the total number of elements in&lt;br /&gt;
the hypercube (the product of &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, etc.), calling&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_leftsize(in,1)&amp;lt;/tt&amp;gt; returns the number of traces (the product&lt;br /&gt;
of &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc.), calling&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_leftsize(in,2)&amp;lt;/tt&amp;gt; returns the product of &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n4&amp;lt;/tt&amp;gt;, etc. By calling &amp;lt;tt&amp;gt;sf_leftsize&amp;lt;/tt&amp;gt;, we avoid the need&lt;br /&gt;
to extract additional parameters for the hypercube dimensions that we&lt;br /&gt;
are not interested in.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
    /* parameter from the command line (i.e., clip=1.5 ) */&lt;br /&gt;
    if (!sf_getfloat(&amp;quot;clip&amp;quot;,&amp;amp;clip)) sf_error(&amp;quot;Need clip=&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The clip parameter is read from the command line, where it can be&lt;br /&gt;
specified, for example, as &amp;lt;tt&amp;gt;clip=10&amp;lt;/tt&amp;gt;. The parameter has the&lt;br /&gt;
&amp;lt;tt&amp;gt;float&amp;lt;/tt&amp;gt; type; therefore, we read it with the&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_getfloat&amp;lt;/tt&amp;gt; function. If no &amp;lt;tt&amp;gt;clip=&amp;lt;/tt&amp;gt; parameter is&lt;br /&gt;
found among the command line arguments, the program is aborted with an&lt;br /&gt;
error message using the &amp;lt;tt&amp;gt;sf_error&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
    /* allocate floating point array */&lt;br /&gt;
    trace = sf_floatalloc (n1);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Next, we allocate an array of floating-point numbers to store a trace&lt;br /&gt;
with the library &amp;lt;tt&amp;gt;sf_floatalloc&amp;lt;/tt&amp;gt; function. Unlike the standard&lt;br /&gt;
&amp;lt;tt&amp;gt;malloc&amp;lt;/tt&amp;gt;, the RSF allocation function checks for errors and&lt;br /&gt;
either terminates the program or returns a valid pointer.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
    /* loop over traces */&lt;br /&gt;
    for (i2=0; i2 &amp;lt; n2; i2++) {&lt;br /&gt;
&lt;br /&gt;
	/*read a trace */&lt;br /&gt;
	sf_floatread(trace,n1,in);&lt;br /&gt;
&lt;br /&gt;
	/* loop over samples */&lt;br /&gt;
	for (i1=0; i1 &amp;lt; n1; i1++) {&lt;br /&gt;
	    if      (trace[i1] &amp;gt;  clip) trace[i1]= clip;&lt;br /&gt;
	    else if (trace[i1] &amp;lt; -clip) trace[i1]=-clip;&lt;br /&gt;
	}&lt;br /&gt;
    &lt;br /&gt;
	/* write a trace */&lt;br /&gt;
	sf_floatwrite(trace,n1,out);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The rest of the program is straightforward. We loop over all available&lt;br /&gt;
traces, read each trace, clip it, and write the output. The syntax&lt;br /&gt;
of &amp;lt;tt&amp;gt;sf_floatread&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_floatwrite&amp;lt;/tt&amp;gt; functions is&lt;br /&gt;
similar to the syntax of the C standard &amp;lt;tt&amp;gt;fread&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;fwrite&amp;lt;/tt&amp;gt; function, except that the type of the element is&lt;br /&gt;
specified explicitly in the function name and that the input and&lt;br /&gt;
output files have the RSF type &amp;lt;tt&amp;gt;sf_file&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
sf_close();&lt;br /&gt;
exit(0)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We explicitly close the input file to avoid leaving a stale temporary file in &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; if the program is called in a pipe sequence. Then, we close the program by sending the shell the Unix code that tells it no errors were encountered. &lt;br /&gt;
&lt;br /&gt;
Note that this is an introductory example optimized for clarity, not execution speed. For advanced techniques, see [[Madagascar Code Patterns]].&lt;br /&gt;
&lt;br /&gt;
===Compiling===&lt;br /&gt;
To compile the &amp;lt;tt&amp;gt;clip&amp;lt;/tt&amp;gt; program, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cc clip.c -I&amp;amp;#36;RSFROOT/include -L&amp;amp;#36;RSFROOT/lib -lrsf -lm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Change &amp;lt;tt&amp;gt;cc&amp;lt;/tt&amp;gt; to the C compiler appropriate for your system and include&lt;br /&gt;
additional compiler flags if necessary. RSF typically uses flags&lt;br /&gt;
in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/share/madagascar/etc/config.py&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==C++ interface==&lt;br /&gt;
&lt;br /&gt;
The C++ clip function is listed below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
/* Clip the data. */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;valarray&amp;gt;&lt;br /&gt;
#include &amp;lt;rsf.hh&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
    sf_init(argc,argv); // Initialize RSF&lt;br /&gt;
    &lt;br /&gt;
    iRSF par(0), in; // input parameter, file&lt;br /&gt;
    oRSF out;        // output file&lt;br /&gt;
&lt;br /&gt;
    int n1, n2;      // trace length, number of traces&lt;br /&gt;
    float clip;&lt;br /&gt;
    &lt;br /&gt;
    in.get(&amp;quot;n1&amp;quot;,n1);&lt;br /&gt;
    n2=in.size(1);&lt;br /&gt;
&lt;br /&gt;
    par.get(&amp;quot;clip&amp;quot;,clip); // parameter from the command line&lt;br /&gt;
&lt;br /&gt;
    std::valarray&amp;lt;float&amp;gt; trace(n1);&lt;br /&gt;
&lt;br /&gt;
    for (int i2=0; i2 &amp;lt; n2; i2++) { // loop over traces&lt;br /&gt;
	in &amp;gt;&amp;gt; trace; // read a trace&lt;br /&gt;
&lt;br /&gt;
	for (int i1=0; i1 &amp;lt; n1; i1++) { // loop over samples&lt;br /&gt;
	    if      (trace[i1] &amp;gt;  clip) trace[i1]=clip;&lt;br /&gt;
	    else if (trace[i1] &amp;lt; -clip) trace[i1]=-clip;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	out &amp;lt;&amp;lt; trace; // write a trace&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    exit(0);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it line by line. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;rsf.hh&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Including &amp;quot;&amp;lt;tt&amp;gt;rsf.hh&amp;lt;/tt&amp;gt;&amp;quot; is required for accessing the RSF C++&lt;br /&gt;
interface.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    sf_init(argc,argv); // Initialize RSF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A call to &amp;lt;tt&amp;gt;sf_init&amp;lt;/tt&amp;gt; is required to initialize the internally stored&lt;br /&gt;
table of command-line arguments.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    iRSF par(0), in; // input parameter, file&lt;br /&gt;
    oRSF out;        // output file&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Two classes, &amp;lt;tt&amp;gt;iRSF&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;oRSF&amp;lt;/tt&amp;gt;, are used to define input and&lt;br /&gt;
output files. For simplicity, the command-line parameters are also handled &lt;br /&gt;
as an &amp;lt;tt&amp;gt;iRSF&amp;lt;/tt&amp;gt; object, initialized with zero.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    in.get(&amp;quot;n1&amp;quot;,n1);&lt;br /&gt;
    n2=in.size(1);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we read the data dimensions from the input RSF file object called&lt;br /&gt;
&amp;lt;tt&amp;gt;in&amp;lt;/tt&amp;gt;: the trace length is a parameter called &amp;quot;&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;&amp;quot; and the&lt;br /&gt;
number of traces is the size of &amp;lt;tt&amp;gt;in&amp;lt;/tt&amp;gt; remaining after excluding the&lt;br /&gt;
first dimension. It is extracted with the &amp;lt;tt&amp;gt;size&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    par.get(&amp;quot;clip&amp;quot;,clip); // parameter from the command line&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The clip parameter should be specified on the command line, for&lt;br /&gt;
example, as &amp;lt;tt&amp;gt;clip=10&amp;lt;/tt&amp;gt;. It is extracted with the &amp;lt;tt&amp;gt;get&amp;lt;/tt&amp;gt;&lt;br /&gt;
method of &amp;lt;tt&amp;gt;iRSF&amp;lt;/tt&amp;gt; class from the &amp;lt;tt&amp;gt;par&amp;lt;/tt&amp;gt; object.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    std::valarray&amp;lt;float&amp;gt; trace(n1);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The trace object has the single-precision floating-point type and is a&lt;br /&gt;
1-D array of length &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;. It is declared and allocated using&lt;br /&gt;
the &amp;lt;tt&amp;gt;valarray&amp;lt;/tt&amp;gt; template class from the standard C++ library.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    for (int i2=0; i2 &amp;lt; n2; i2++) { // loop over traces&lt;br /&gt;
	in &amp;gt;&amp;gt; trace; // read a trace&lt;br /&gt;
&lt;br /&gt;
	for (int i1=0; i1 &amp;lt; n1; i1++) { // loop over samples&lt;br /&gt;
	    if      (trace[i1] &amp;gt;  clip) trace[i1]=clip;&lt;br /&gt;
	    else if (trace[i1] &amp;lt; -clip) trace[i1]=-clip;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	out &amp;lt;&amp;lt; trace; // write a trace&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we loop through the traces, read each trace from &amp;lt;tt&amp;gt;in&amp;lt;/tt&amp;gt;, clip it, and write the output to &amp;lt;tt&amp;gt;out&amp;lt;/tt&amp;gt;.&lt;br /&gt;
===Compiling===&lt;br /&gt;
To compile the C++ program, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
c++ clip.cc -I&amp;amp;#36;RSFROOT/include -L&amp;amp;#36;RSFROOT/lib -lrsf++ -lrsf -lm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Change &amp;lt;tt&amp;gt;c++&amp;lt;/tt&amp;gt; to the C++ compiler appropriate for your system and&lt;br /&gt;
include additional compiler flags if necessary. RSF typically uses flags in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/share/madagascar/etc/config.py&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Fortran-77 interface==&lt;br /&gt;
&lt;br /&gt;
The Fortran-77 clip function is listed below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
	program Clipit&lt;br /&gt;
	implicit none&lt;br /&gt;
	integer n1, n2, i1, i2, in, out&lt;br /&gt;
	integer sf_input, sf_output, sf_leftsize, sf_gettype&lt;br /&gt;
	logical sf_getfloat, sf_histint&lt;br /&gt;
	real clip, trace(1000)&lt;br /&gt;
&lt;br /&gt;
	call sf_init()&lt;br /&gt;
	in = sf_input(&amp;quot;in&amp;quot;)&lt;br /&gt;
	out = sf_output(&amp;quot;out&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	if (3 .ne. sf_gettype(in)) &lt;br /&gt;
     &amp;amp;  call sf_error(&amp;quot;Need float input&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	if (.not. sf_histint(in,&amp;quot;n1&amp;quot;,n1)) then&lt;br /&gt;
	   call sf_error(&amp;quot;No n1= in input&amp;quot;)&lt;br /&gt;
	else if (n1 &amp;gt; 1000) then&lt;br /&gt;
	   call sf_error(&amp;quot;n1 is too long&amp;quot;)&lt;br /&gt;
	end if&lt;br /&gt;
	n2 = sf_leftsize(in,1)&lt;br /&gt;
&lt;br /&gt;
	if (.not. sf_getfloat(&amp;quot;clip&amp;quot;,clip)) &lt;br /&gt;
     &amp;amp;  call sf_error(&amp;quot;Need clip=&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	do 10 i2=1, n2&lt;br /&gt;
	   call sf_floatread(trace,n1,in)&lt;br /&gt;
&lt;br /&gt;
	   do 20 i1=1, n1&lt;br /&gt;
	      if (trace(i1) &amp;gt;  clip) then&lt;br /&gt;
		 trace(i1)=clip&lt;br /&gt;
	      else if (trace(i1) &amp;lt; -clip) then&lt;br /&gt;
		 trace(i1)=-clip&lt;br /&gt;
	      end if&lt;br /&gt;
 20	   continue&lt;br /&gt;
&lt;br /&gt;
	   call sf_floatwrite(trace,n1,out)&lt;br /&gt;
 10	continue&lt;br /&gt;
&lt;br /&gt;
	stop&lt;br /&gt;
	end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it in detail.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
	call sf_init()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The program starts with a call to &amp;lt;tt&amp;gt;sf_init&amp;lt;/tt&amp;gt;, which initializes the&lt;br /&gt;
command-line interface.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
	in = sf_input(&amp;quot;in&amp;quot;)&lt;br /&gt;
	out = sf_output(&amp;quot;out&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The input and output files are created with calls to&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_output&amp;lt;/tt&amp;gt;. Because of the absence of&lt;br /&gt;
derived types in Fortran-77, we use simple integer pointers to&lt;br /&gt;
represent RSF files. Both &amp;lt;tt&amp;gt;sf_input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_output&amp;lt;/tt&amp;gt;&lt;br /&gt;
accept a character string, which may refer to a file name or a file&lt;br /&gt;
tag. For example, if the command line contains&lt;br /&gt;
&amp;lt;tt&amp;gt;vel=velocity.rsf&amp;lt;/tt&amp;gt;, then both&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_input(&amp;quot;velocity.rsf&amp;quot;)&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_input(&amp;quot;vel&amp;quot;)&amp;lt;/tt&amp;gt; are&lt;br /&gt;
acceptable. Two tags are special: &amp;lt;tt&amp;gt;&amp;quot;in&amp;quot;&amp;lt;/tt&amp;gt; refers to the file in&lt;br /&gt;
the standard input, and &amp;lt;tt&amp;gt;&amp;quot;out&amp;quot;&amp;lt;/tt&amp;gt; refers to the file in the&lt;br /&gt;
standard output.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
	if (3 .ne. sf_gettype(in)) &lt;br /&gt;
     &amp;amp;  call sf_error(&amp;quot;Need float input&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RSF files can store data of different types (character, integer,&lt;br /&gt;
floating point, complex). The function &amp;lt;tt&amp;gt;sf_gettype&amp;lt;/tt&amp;gt; checks the&lt;br /&gt;
type of data stored in the RSF file. We make sure that the type&lt;br /&gt;
corresponds to floating-point numbers. If not, the program is aborted&lt;br /&gt;
with an error message using the &amp;lt;tt&amp;gt;sf_error&amp;lt;/tt&amp;gt; function. It is&lt;br /&gt;
generally a good idea to check the input for user errors and, if they&lt;br /&gt;
cannot be corrected, to take a safe exit.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
	if (.not. sf_histint(in,&amp;quot;n1&amp;quot;,n1)) then&lt;br /&gt;
	   call sf_error(&amp;quot;No n1= in input&amp;quot;)&lt;br /&gt;
	else if (n1 &amp;gt; 1000) then&lt;br /&gt;
	   call sf_error(&amp;quot;n1 is too long&amp;quot;)&lt;br /&gt;
	end if&lt;br /&gt;
	n2 = sf_leftsize(in,1)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Conceptually, the RSF data model is a multidimensional hypercube. By&lt;br /&gt;
convention, the dimensions of the cube are stored in &amp;lt;tt&amp;gt;n1=&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n2=&amp;lt;/tt&amp;gt;, etc. parameters. The &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; parameter refers to the&lt;br /&gt;
fastest axis. If the input dataset is a collection of traces,&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; refers to the trace length. We extract it using the&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_histint&amp;lt;/tt&amp;gt; function (integer parameter from history) and&lt;br /&gt;
abort if no value for &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; is found. Since Fortran-77 cannot&lt;br /&gt;
easily handle dynamic allocation, we also need to check that&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; is not larger than the size of the statically allocated&lt;br /&gt;
array. We could proceed similarly, extracting &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc. If we are interested in the total number of traces&lt;br /&gt;
like in the clip example, a shortcut is to use the&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_leftsize&amp;lt;/tt&amp;gt; function. Calling &amp;lt;tt&amp;gt;sf_leftsize(in,0)&amp;lt;/tt&amp;gt;&lt;br /&gt;
returns the total number of elements in the hypercube (the product of&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, etc.), calling &amp;lt;tt&amp;gt;sf_leftsize(in,1)&amp;lt;/tt&amp;gt;&lt;br /&gt;
returns the number of traces (the product of &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;,&lt;br /&gt;
etc.), calling &amp;lt;tt&amp;gt;sf_leftsize(in,2)&amp;lt;/tt&amp;gt; returns the product of&lt;br /&gt;
&amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n4&amp;lt;/tt&amp;gt;, etc. By calling &amp;lt;tt&amp;gt;sf_leftsize&amp;lt;/tt&amp;gt;, we&lt;br /&gt;
avoid the need to extract additional parameters for the hypercube&lt;br /&gt;
dimensions that we are not interested in.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
	if (.not. sf_getfloat(&amp;quot;clip&amp;quot;,clip)) &lt;br /&gt;
     &amp;amp;  call sf_error(&amp;quot;Need clip=&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The clip parameter is read from the command line, where it can be&lt;br /&gt;
specified, for example, as &amp;lt;tt&amp;gt;clip=10&amp;lt;/tt&amp;gt;. The parameter has the&lt;br /&gt;
&amp;lt;tt&amp;gt;float&amp;lt;/tt&amp;gt; type; therefore, we read it with the&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_getfloat&amp;lt;/tt&amp;gt; function. If no &amp;lt;tt&amp;gt;clip=&amp;lt;/tt&amp;gt; parameter is&lt;br /&gt;
found among the command line arguments, the program is aborted with an&lt;br /&gt;
error message using the &amp;lt;tt&amp;gt;sf_error&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
	do 10 i2=1, n2&lt;br /&gt;
	   call sf_floatread(trace,n1,in)&lt;br /&gt;
&lt;br /&gt;
	   do 20 i1=1, n1&lt;br /&gt;
	      if (trace(i1) &amp;gt;  clip) then&lt;br /&gt;
		 trace(i1)=clip&lt;br /&gt;
	      else if (trace(i1) &amp;lt; -clip) then&lt;br /&gt;
		 trace(i1)=-clip&lt;br /&gt;
	      end if&lt;br /&gt;
 20	   continue&lt;br /&gt;
&lt;br /&gt;
	   call sf_floatwrite(trace,n1,out)&lt;br /&gt;
 10	continue&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we do the actual work: loop over input traces, reading,&lt;br /&gt;
clipping, and writing out each trace.&lt;br /&gt;
===Compiling===&lt;br /&gt;
To compile the Fortran-77 program, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
f77 clip.f -L$RSFROOT/lib -lrsff -lrsf -lm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Change &amp;lt;tt&amp;gt;f77&amp;lt;/tt&amp;gt; to the Fortran compiler appropriate for your system and&lt;br /&gt;
include additional compiler flags if necessary. RSF typically uses flags in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/share/madagascar/etc/config.py&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Fortran-90 interface==&lt;br /&gt;
&lt;br /&gt;
The Fortran-90 clip function is listed below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
program Clipit&lt;br /&gt;
  use rsf&lt;br /&gt;
&lt;br /&gt;
  implicit none&lt;br /&gt;
  type (file)                      :: in, out&lt;br /&gt;
  integer                          :: n1, n2, i1, i2&lt;br /&gt;
  real                             :: clip&lt;br /&gt;
  real, dimension (:), allocatable :: trace&lt;br /&gt;
&lt;br /&gt;
  call sf_init()            ! initialize RSF&lt;br /&gt;
  in = rsf_input()&lt;br /&gt;
  out = rsf_output()&lt;br /&gt;
&lt;br /&gt;
  if (sf_float /= gettype(in)) call sf_error(&amp;quot;Need float type&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
  call from_par(in,&amp;quot;n1&amp;quot;,n1)&lt;br /&gt;
  n2 = filesize(in,1)&lt;br /&gt;
&lt;br /&gt;
  call from_par(&amp;quot;clip&amp;quot;,clip) ! command-line parameter &lt;br /&gt;
&lt;br /&gt;
  allocate (trace (n1))&lt;br /&gt;
&lt;br /&gt;
  do i2=1, n2                ! loop over traces&lt;br /&gt;
     call rsf_read(in,trace)&lt;br /&gt;
     &lt;br /&gt;
     where (trace &amp;gt;  clip) trace =  clip&lt;br /&gt;
     where (trace &amp;lt; -clip) trace = -clip&lt;br /&gt;
&lt;br /&gt;
     call rsf_write(out,trace)&lt;br /&gt;
  end do&lt;br /&gt;
&lt;br /&gt;
  deallocate (trace)&lt;br /&gt;
&lt;br /&gt;
end program Clipit&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it in detail.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
  use rsf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The program starts with importing the &amp;lt;tt&amp;gt;rsf&amp;lt;/tt&amp;gt; module.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
  call sf_init()            ! initialize RSF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A call to &amp;lt;tt&amp;gt;sf_init&amp;lt;/tt&amp;gt; is needed to initialize the command-line&lt;br /&gt;
interface.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
  in = rsf_input()&lt;br /&gt;
  out = rsf_output()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The standard input and output files are initialized with&lt;br /&gt;
&amp;lt;tt&amp;gt;rsf_input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;rsf_output&amp;lt;/tt&amp;gt; functions. Both functions&lt;br /&gt;
accept optional arguments. For example, if the command line contains&lt;br /&gt;
&amp;lt;tt&amp;gt;vel=velocity.rsf&amp;lt;/tt&amp;gt;, then both&lt;br /&gt;
&amp;lt;tt&amp;gt;rsf_input(&amp;quot;velocity.rsf&amp;quot;)&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;rsf_input(&amp;quot;vel&amp;quot;)&amp;lt;/tt&amp;gt; are&lt;br /&gt;
acceptable.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
  if (sf_float /= gettype(in)) call sf_error(&amp;quot;Need float type&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A call to &amp;lt;tt&amp;gt;from_par&amp;lt;/tt&amp;gt; extracts the &amp;quot;&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;&amp;quot; parameter&lt;br /&gt;
from the input file. Conceptually, the RSF data model is a&lt;br /&gt;
multidimensional hypercube. The &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; parameter refers to the&lt;br /&gt;
fastest axis. If the input dataset is a collection of traces,&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; corresponds to the trace length. We could proceed similarly, extracting &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc. If we are&lt;br /&gt;
interested in the total number of traces like in the clip example, a&lt;br /&gt;
shortcut is to use the &amp;lt;tt&amp;gt;filesize&amp;lt;/tt&amp;gt; function. Calling&lt;br /&gt;
&amp;lt;tt&amp;gt;filesize(in)&amp;lt;/tt&amp;gt; returns the total number of elements in the&lt;br /&gt;
hypercube (the product of &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, etc.), calling&lt;br /&gt;
&amp;lt;tt&amp;gt;filesize(in,1)&amp;lt;/tt&amp;gt; returns the number of traces (the product of&lt;br /&gt;
&amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc.), calling &amp;lt;tt&amp;gt;filesize(in,2)&amp;lt;/tt&amp;gt;&lt;br /&gt;
returns the product of &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n4&amp;lt;/tt&amp;gt;, etc. By calling&lt;br /&gt;
&amp;lt;tt&amp;gt;filesize&amp;lt;/tt&amp;gt;, we avoid the need to extract additional parameters&lt;br /&gt;
for the hypercube dimensions that we are not interested in.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
  n2 = filesize(in,1)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The clip parameter is read from the command line, where it can be&lt;br /&gt;
specified, for example, as &amp;lt;tt&amp;gt;clip=10&amp;lt;/tt&amp;gt;. If we knew a good default&lt;br /&gt;
value for &amp;lt;tt&amp;gt;clip&amp;lt;/tt&amp;gt;, we could specify it with an optional&lt;br /&gt;
argument, i.e. &amp;lt;tt&amp;gt;call~from_par(&amp;quot;clip&amp;quot;,clip,default)&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
  allocate (trace (n1))&lt;br /&gt;
&lt;br /&gt;
  do i2=1, n2                ! loop over traces&lt;br /&gt;
     call rsf_read(in,trace)&lt;br /&gt;
     &lt;br /&gt;
     where (trace &amp;gt;  clip) trace =  clip&lt;br /&gt;
     where (trace &amp;lt; -clip) trace = -clip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we do the actual work: loop over input traces, reading,&lt;br /&gt;
clipping, and writing out each trace.&lt;br /&gt;
===Compiling===&lt;br /&gt;
To compile the Fortran-90 program, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
f90 clip.f90 -I&amp;amp;#36;RSFROOT/include -L&amp;amp;#36;RSFROOT/lib -lrsff90 -lrsf -lm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Change &amp;lt;tt&amp;gt;f90&amp;lt;/tt&amp;gt; to the Fortran-90 compiler appropriate for your system and&lt;br /&gt;
include additional compiler flags if necessary. RSF typically uses flags in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/share/madagasacar/etc/config.py&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The complete specification for the F90 API can be found [[Library_Reference#Fortran_90_API | on the Library Reference page]].&lt;br /&gt;
&lt;br /&gt;
==Python interface==&lt;br /&gt;
The Python interface examples are in the directory $RSFSRC/API/python/test.&lt;br /&gt;
&lt;br /&gt;
The Python script clip.py is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
import numpy&lt;br /&gt;
import m8r&lt;br /&gt;
&lt;br /&gt;
par = m8r.Par()&lt;br /&gt;
inp  = m8r.Input()&lt;br /&gt;
output = m8r.Output()&lt;br /&gt;
assert &#039;float&#039; == inp.type&lt;br /&gt;
&lt;br /&gt;
n1 = inp.int(&amp;quot;n1&amp;quot;)&lt;br /&gt;
n2 = inp.size(1)&lt;br /&gt;
assert n1&lt;br /&gt;
&lt;br /&gt;
clip = par.float(&amp;quot;clip&amp;quot;)&lt;br /&gt;
assert clip&lt;br /&gt;
&lt;br /&gt;
trace = numpy.zeros(n1,&#039;f&#039;)&lt;br /&gt;
&lt;br /&gt;
for i2 in xrange(n2): # loop over traces&lt;br /&gt;
    inp.read(trace)&lt;br /&gt;
    trace = numpy.clip(trace,-clip,clip)&lt;br /&gt;
    output.write(trace)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it in detail. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import numpy&lt;br /&gt;
import m8r&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The script starts with importing the &amp;lt;tt&amp;gt;numpy&amp;lt;/tt&amp;gt; module and the&lt;br /&gt;
&amp;lt;tt&amp;gt;m8r&amp;lt;/tt&amp;gt; API.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
par = m8r.Par()&lt;br /&gt;
inp  = m8r.Input()&lt;br /&gt;
output = m8r.Output()&lt;br /&gt;
assert &#039;float&#039; == inp.type&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we initialize the command line interface and the standard input and&lt;br /&gt;
output files. We also make sure that the input file type is floating point.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
n1 = input.int(&amp;quot;n1&amp;quot;)&lt;br /&gt;
n2 = input.size(1)&lt;br /&gt;
assert n1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We extract the &amp;quot;&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;&amp;quot; parameter from the input file.&lt;br /&gt;
Conceptually, the RSF data model is a multidimensional hypercube. The&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; parameter refers to the fastest axis. If the input dataset&lt;br /&gt;
is a collection of traces, &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; corresponds to the trace&lt;br /&gt;
length. We could proceed similarly, extracting &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc. If we are interested in the total number of traces,&lt;br /&gt;
like in the clip example, a shortcut is to use the &amp;lt;tt&amp;gt;size&amp;lt;/tt&amp;gt;&lt;br /&gt;
method of the &amp;lt;tt&amp;gt;Input&amp;lt;/tt&amp;gt; class.  Calling &amp;lt;tt&amp;gt;size(0)&amp;lt;/tt&amp;gt; returns&lt;br /&gt;
the total number of elements in the hypercube (the product of&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, etc.), calling &amp;lt;tt&amp;gt;size(1)&amp;lt;/tt&amp;gt; returns the&lt;br /&gt;
number of traces (the product of &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc.),&lt;br /&gt;
calling &amp;lt;tt&amp;gt;size(2)&amp;lt;/tt&amp;gt; returns the product of &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n4&amp;lt;/tt&amp;gt;, etc.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
clip = par.float(&amp;quot;clip&amp;quot;)&lt;br /&gt;
assert clip&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The clip parameter is read from the command line, where it can be specified,&lt;br /&gt;
for example, as &amp;lt;tt&amp;gt;clip=10&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
trace = numpy.zeros(n1,&#039;f&#039;)&lt;br /&gt;
for i2 in xrange(n2): # loop over traces&lt;br /&gt;
    inp.read(trace)&lt;br /&gt;
    trace = numpy.clip(trace,-clip,clip)&lt;br /&gt;
    output.write(trace)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we do the actual work: allocate an array to hold a trace and  loop &lt;br /&gt;
over input traces, reading, clipping, and writing out each trace.&lt;br /&gt;
&lt;br /&gt;
Alternative code uses inp.trace to allocate an array and read &lt;br /&gt;
the whole file into memory. The loop is no longer needed:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
alltraces=inp.read()&lt;br /&gt;
alltraces = numpy.clip(alltraces,-clip,clip)&lt;br /&gt;
output.write(alltraces)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Compiling===&lt;br /&gt;
The Python script does not require compilation. Simply make sure that&lt;br /&gt;
&amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/lib&amp;lt;/tt&amp;gt; is in &amp;lt;tt&amp;gt;PYTHONPATH&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;LD_LIBRARY_PATH&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Using the Python API for interactive development in Jupyter notebooks===&lt;br /&gt;
Jupyter notebooks are an excellent way to prototype Python code, explore data, and  &lt;br /&gt;
integrate rich text to describe your code. There are four example notebooks in &lt;br /&gt;
$RSFSRC/api/python/test that demonstrate how to use Jupyter notebooks. These are:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
 |-&lt;br /&gt;
 | clip.ipynb || clip.py converted to a Jupyter notebook&lt;br /&gt;
 |-&lt;br /&gt;
 |simple_m8r_create_write_filter_read.ipynb || numpy, write rsf, Madagascar commands, read rsf, plot&lt;br /&gt;
 |-&lt;br /&gt;
 | tle_edge_preserve.ipynb || reproduces a paper from TLE with numpy and matplotlib&lt;br /&gt;
 |-&lt;br /&gt;
 | file_filter_scons_example.ipynb || advanced m8r options;  File, filter, and scons from python  &lt;br /&gt;
|} &lt;br /&gt;
They can be started from the command line with the commands:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd $RSFSRC/api/python/test&lt;br /&gt;
jupyter notebook clip.ipynb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Interactive mode usage without graphics===&lt;br /&gt;
Madagascar&#039;s Python API can also be used interactively. Create an input dataset with&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfmath  n1=10 n2=9 output=x1+x2  &amp;gt; test.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, start the Python interpreter and paste the following to its command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import numpy, m8r&lt;br /&gt;
&lt;br /&gt;
inp = m8r.Input(&#039;test.rsf&#039;)&lt;br /&gt;
n1 = inp.int(&amp;quot;n1&amp;quot;)&lt;br /&gt;
n2 = inp.int(&amp;quot;n2&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
data =inp.read(shape=(n2,n1))&lt;br /&gt;
data = data.transpose() # Example of numpy in action&lt;br /&gt;
&lt;br /&gt;
print data&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will get&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[[ 0.  1.  2.  3.  4.  5.  6.  7.  8.]&lt;br /&gt;
 [ 1.  2.  3.  4.  5.  6.  7.  8.  9.]&lt;br /&gt;
 [ 2.  3.  4.  5.  6.  7.  8.  9. 10.]&lt;br /&gt;
 [ 3.  4.  5.  6.  7.  8.  9. 10. 11.]&lt;br /&gt;
 [ 4.  5.  6.  7.  8.  9. 10. 11. 12.]&lt;br /&gt;
 [ 5.  6.  7.  8.  9. 10. 11. 12. 13.]&lt;br /&gt;
 [ 6.  7.  8.  9. 10. 11. 12. 13. 14.]&lt;br /&gt;
 [ 7.  8.  9. 10. 11. 12. 13. 14. 15.]&lt;br /&gt;
 [ 8.  9. 10. 11. 12. 13. 14. 15. 16.]&lt;br /&gt;
 [ 9. 10. 11. 12. 13. 14. 15. 16. 17.]]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code will also work in batch mode in a Python script, not only pasted to the interpreter&#039;s command line. &lt;br /&gt;
&lt;br /&gt;
===Graphics with Matplotlib===&lt;br /&gt;
Python can plot arrays directly from memory without first writing a file to disk. [https://matplotlib.org/ Matplotlib] is one of the [http://en.wikipedia.org/wiki/Category:Free_plotting_software several] packages that accomplish this. To create a figure, execute the code in the previous section, followed by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from pylab import *&lt;br /&gt;
imshow(data)&lt;br /&gt;
xlabel(&#039;X (m)&#039;)&lt;br /&gt;
ylabel(&#039;Y (m)&#039;)&lt;br /&gt;
title(&#039;Matplotlib example&#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to pop up a figure in an interactive session, after pasting to a Python command line the code shown before, also paste:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
show()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will get Figure 1. The figure will pop up if you run the code in a script, too, and the script will stop until the figure is manually closed. You must press the floppy disk button to save it. To have the image written to disk automatically, instead of &amp;lt;tt&amp;gt;show()&amp;lt;/tt&amp;gt; use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
savefig(&#039;myfile.png&#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:matplotlib_imshow.png]]&lt;br /&gt;
&lt;br /&gt;
Putting it all together, here is a sample script reading an RSF file from stdin and printing out a figure:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import m8r, numpy, sys, pylab&lt;br /&gt;
&lt;br /&gt;
inp = m8r.Input(&#039;test.rsf&#039;)&lt;br /&gt;
n1 = inp.int(&amp;quot;n1&amp;quot;)&lt;br /&gt;
n2 = inp.int(&amp;quot;n2&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
data=input.read()&lt;br /&gt;
&lt;br /&gt;
pylab.imshow(data)&lt;br /&gt;
pylab.savefig(&#039;out.png&#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
===Python interfaces to the standalone programs===&lt;br /&gt;
The &amp;lt;tt&amp;gt;m8r&amp;lt;/tt&amp;gt; module offers a way to call Madagascar standalone programs (including graphics) elegantly from inside a Python program, interactively or in batch mode. The blog contains examples of running the &amp;lt;tt&amp;gt;m8r&amp;lt;/tt&amp;gt; module [http://www.ahay.org/rsflog/index.php?/archives/173-Extending-Python-interface.html from inside a SAGE notebook] or [http://www.ahay.org/rsflog/index.php?/archives/264-Running-Madagascar-in-an-interactive-console.html from inside an iPython shell].&lt;br /&gt;
&lt;br /&gt;
==MATLAB interface==&lt;br /&gt;
&lt;br /&gt;
The MATLAB clip function is listed below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;matlab&amp;quot;&amp;gt;&lt;br /&gt;
function clip(in,out,clip)&lt;br /&gt;
%CLIP Clip the data&lt;br /&gt;
&lt;br /&gt;
dims = rsf_dim(in);&lt;br /&gt;
n1 = dims(1);           % trace length&lt;br /&gt;
n2 = prod(dims(2:end)); % number of traces&lt;br /&gt;
trace = 1:n1;           % allocate trace&lt;br /&gt;
rsf_create(out,in)      % create an output file&lt;br /&gt;
&lt;br /&gt;
for i2 = 1:n2           % loop over traces&lt;br /&gt;
    rsf_read(trace,in,&#039;same&#039;);&lt;br /&gt;
    trace(trace &amp;gt;   clip) =  clip;&lt;br /&gt;
    trace(trace &amp;lt; - clip) = -clip;&lt;br /&gt;
    rsf_write(trace,out,&#039;same&#039;);&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it in detail. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;matlab&amp;quot;&amp;gt;&lt;br /&gt;
dims = rsf_dim(in);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We start by figuring out the input file dimensions.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;matlab&amp;quot;&amp;gt;&lt;br /&gt;
n1 = dims(1);           % trace length&lt;br /&gt;
n2 = prod(dims(2:end)); % number of traces&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first dimension is the trace length, the product of all other&lt;br /&gt;
dimensions correspond to the number of traces.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;matlab&amp;quot;&amp;gt;&lt;br /&gt;
trace = 1:n1;           % allocate trace&lt;br /&gt;
rsf_create(out,in)      % create an output file&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we allocate the trace array and create an output file.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;matlab&amp;quot;&amp;gt;&lt;br /&gt;
for i2 = 1:n2           % loop over traces&lt;br /&gt;
    rsf_read(trace,in,&#039;same&#039;);&lt;br /&gt;
    trace(trace &amp;gt;   clip) =  clip;&lt;br /&gt;
    trace(trace &amp;lt; - clip) = -clip;&lt;br /&gt;
    rsf_write(trace,out,&#039;same&#039;);&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we do the actual work: loop over input traces, reading,&lt;br /&gt;
clipping, and writing out each trace.&lt;br /&gt;
===Available functions===&lt;br /&gt;
Only some of the functions in the &amp;lt;tt&amp;gt;rsf&amp;lt;/tt&amp;gt; library have received a MATLAB interface. These functions are &amp;lt;tt&amp;gt;rsf_par&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;rsf_dim&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;rsf_read&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;rsf_write&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;rsf_create&amp;lt;/tt&amp;gt;. The example above illustrates all these functions except &amp;lt;tt&amp;gt;rsf_par&amp;lt;/tt&amp;gt;.&lt;br /&gt;
===Compiling===&lt;br /&gt;
The MATLAB script does not require compilation. Simply make sure that&lt;br /&gt;
&amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/lib&amp;lt;/tt&amp;gt; is in &amp;lt;tt&amp;gt;MATLABPATH&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;LD_LIBRARY_PATH&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Java Interface==&lt;br /&gt;
Two Java interfaces are available. New codes should be written to use the SWIG interface ONLY. The older interface (using the MINES JTK) is deprecated and is only provided while users migrate their code to the new interface.&lt;br /&gt;
&lt;br /&gt;
===SWIG===&lt;br /&gt;
&lt;br /&gt;
To install the SWIG interface:&lt;br /&gt;
&lt;br /&gt;
1. Download the Java Standard Development Kit (JDK). Installation varies by platform.&lt;br /&gt;
&lt;br /&gt;
2. Create the JAVA_HOME environment variable for your shell. This should point to the directory where the JDK was installed. Example (for Ubuntu 10.04):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
export JAVA_HOME=/usr/lib/jvm/java-6-opensdk&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Reconfigure Madagascar:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./configure API=java&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Reinstall Madagascar (Ignore the compilation warnings for Java files):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
scons; scons install&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The installation creates two files: &amp;lt;tt&amp;gt;$RSFROOT/lib/libjrsf.so&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;$RSFROOT/lib/rsf.jar&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Ensure you set your LD_LIBRARY_PATH to include &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
A short demonstration of the interface follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import rsf.RSF;&lt;br /&gt;
import rsf.Input;&lt;br /&gt;
import rsf.Output;&lt;br /&gt;
&lt;br /&gt;
/* A simple Java program to clip a dataset. */&lt;br /&gt;
&lt;br /&gt;
public class Clip {&lt;br /&gt;
    static {&lt;br /&gt;
        System.loadLibrary(&amp;quot;jrsf&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String[] args){&lt;br /&gt;
        // Initialize command line argument passing&lt;br /&gt;
         RSF par = new RSF(args);&lt;br /&gt;
         // Get the input file name.&lt;br /&gt;
         Input input = new Input(&amp;quot;in&amp;quot;);&lt;br /&gt;
         Output output = new Output(&amp;quot;out&amp;quot;);&lt;br /&gt;
        // Get the value to clip to.&lt;br /&gt;
         float clip = par.getFloat(&amp;quot;clip&amp;quot;,0.0f);&lt;br /&gt;
        // Read our input header&lt;br /&gt;
        int n3 = input.getN(3);&lt;br /&gt;
        int n2 = input.getN(2);&lt;br /&gt;
        int n1 = input.getN(1);&lt;br /&gt;
        //Perform clipping operation on a single trace and write out.&lt;br /&gt;
        float[] data = new float[n1];&lt;br /&gt;
         for(int i = 0; i &amp;lt; n3; ++i){&lt;br /&gt;
            for(int j = 0; j &amp;lt; n2; ++j){&lt;br /&gt;
                input.read(data);&lt;br /&gt;
                for(int k = 0; k &amp;lt; n1; ++k){&lt;br /&gt;
                    if (data[k] &amp;gt; clip) data[k] = clip;&lt;br /&gt;
                    else if (data[k] &amp;lt; -clip) data[k] = -clip;&lt;br /&gt;
                }&lt;br /&gt;
                output.write(data);&lt;br /&gt;
            }&lt;br /&gt;
         }&lt;br /&gt;
         output.setN(1,n1);&lt;br /&gt;
         output.setN(2,n2);&lt;br /&gt;
         output.setN(3,n3);&lt;br /&gt;
         input.close();&lt;br /&gt;
         output.close();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are only three classes in the interface:&lt;br /&gt;
&lt;br /&gt;
1.&#039;&#039;&#039;RSF&#039;&#039;&#039; - The command line argument parser and the initializer for the native interface. An RSF object MUST be instantiated BEFORE instantiating an Input or Output object.&lt;br /&gt;
&lt;br /&gt;
2. &#039;&#039;&#039;Input&#039;&#039;&#039; - An object that provides read access to an RSF file.  &lt;br /&gt;
&lt;br /&gt;
3. &#039;&#039;&#039;Output&#039;&#039;&#039; - An object that provides write access to an RSF file.&lt;br /&gt;
&lt;br /&gt;
Additionally, the shared library (libjrsf.so or libjrsf.dll) must be included via the System.loadLibrary(&amp;quot;jrsf&amp;quot;); as the first command in the file.&lt;br /&gt;
&lt;br /&gt;
To compile on the command line:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
javac -cp $RSFROOT/lib Clip.java&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To include this as part of a SCons script (SConstruct):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&lt;br /&gt;
# Compiles Clip.class&lt;br /&gt;
project.Java(&#039;.&#039;,&#039;Clip.java&#039;)&lt;br /&gt;
&lt;br /&gt;
Flow(&#039;dat&#039;,None,&#039;spike n1=1000 n2=100 n3=10 nsp=1 k1=500 l1=1000&#039;)&lt;br /&gt;
Flow(&#039;clipd&#039;,&#039;dat Clip.class&#039;,&lt;br /&gt;
    &#039;&#039;&#039;&lt;br /&gt;
    %s Clip clip=0.5&lt;br /&gt;
    &#039;&#039;&#039; % WhereIs(&#039;java&#039;))&lt;br /&gt;
Flow(&#039;test.attr&#039;,&#039;clipd&#039;,&#039;sfattr&#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that we compile &amp;lt;tt&amp;gt;Clip.java&amp;lt;/tt&amp;gt; using the SCons Java builder. To execute the command, we have to locate the &amp;quot;java&amp;quot; command, which we do using &amp;lt;tt&amp;gt;WhereIs(&#039;java&#039;)&amp;lt;/tt&amp;gt;. Then, we execute the class name and pass any command line arguments as usual. The files are read from standard in for this program and written to standard out.  &lt;br /&gt;
&lt;br /&gt;
Please see the [[Library Reference]] for more details on the functions available in the SWIG API.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note: Additional Java packages can included in SCons automatically by setting the CLASSPATH environment variable to point to the JAR files that they are contained in.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Mines JTK===&lt;br /&gt;
&#039;&#039;&#039;THIS INTERFACE IS DEPRECATED AND ONLY PROVIDED AS A REFERENCE. THIS INTERFACE IS NO LONGER SUPPORTED AND WILL BE REMOVED&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This interface may still be compiled by specifying the MINESJTK environment variable. &lt;br /&gt;
&lt;br /&gt;
The interface to Java is less full-featured than others. It only allows you to read RSF files with fewer than four dimensions into Java and then export RSF files. &#039;&#039;&#039;The Java interface does not support reading from standard in or writing from standard out. Therefore, the Java Interface does not support piping either.&#039;&#039;&#039; Currently, The Java interface treats all values as floats and does not support complex numbers. Java programs are not parsed for self-doc information like other programs are either. Using javadoc may be a viable alternative to creating a parsing engine for Java programs.&lt;br /&gt;
&lt;br /&gt;
Once the build is complete, the JAR file rsf.jar will be added to your $RSFROOT/lib folder.  &lt;br /&gt;
&lt;br /&gt;
There are two ways to access the API:&lt;br /&gt;
&lt;br /&gt;
1. From the command line:  point the classpath at BOTH compile and runtime to this location on the command line.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
javac -cp $MINESJTK:$RSFROOT/lib/rsf.jar:. Test.java &lt;br /&gt;
java -cp $MINESJTK:$RSFROOT/lib/rsf.jar:. Test arg1=... arg2=... arg3=...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. From within a SConstruct script:  BOTH the path for the API ($RSFROOT/lib) and the path to the Mines JTK ($MINESJTK) are automatically added to the environment variable CLASSPATH and JAVACLASSPATH for executions made within an SConstruct. Additionally, any classes already in the CLASSPATH environmental variable in the shell you launch from will be added to your classpath. This allows you to include additional libraries automatically within your Java programs. The local directory (.) is also included in the CLASSPATH.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&lt;br /&gt;
# Compiles Clip.class&lt;br /&gt;
project.Java(&#039;.&#039;,&#039;Clip.java&#039;)&lt;br /&gt;
&lt;br /&gt;
Flow(&#039;dat&#039;,None,&#039;spike n1=1000 n2=100 n3=10 nsp=1 k1=500&#039;)&lt;br /&gt;
Flow(&#039;clipd&#039;,&#039;Clip.class dat&#039;,&lt;br /&gt;
    &#039;&#039;&#039;&lt;br /&gt;
    %s ${SOURCES[0].filebase} clip=0.5 &lt;br /&gt;
    in=${SOURCES[1]} out=$TARGET &lt;br /&gt;
    &#039;&#039;&#039; % WhereIs(&#039;java&#039;),stdin=0,stdout=-1)&lt;br /&gt;
Flow(&#039;test.attr&#039;,&#039;clipd&#039;,&#039;sfattr&#039;)&lt;br /&gt;
&lt;br /&gt;
End()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface itself is fairly straightforward. The [[Library_Reference#Java_API | Library Reference]] provides more details on the methods exposed by the API.&lt;br /&gt;
&lt;br /&gt;
Data clipping, argument parsing, and IO example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import rsf.Par;&lt;br /&gt;
import rsf.Reader;&lt;br /&gt;
import rsf.Writer;&lt;br /&gt;
import rsf.Header;&lt;br /&gt;
&lt;br /&gt;
/* A simple Java program to clip a dataset.&lt;br /&gt;
&lt;br /&gt;
Presently, there is no automatic self-documentation generation for use&lt;br /&gt;
with sfdoc. Javadoc may be a better way to generate self-doc for Java&lt;br /&gt;
programs.&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
public class Clip {&lt;br /&gt;
    public static void main(String[] args){&lt;br /&gt;
        // Initialize command line argument passing&lt;br /&gt;
         Par par = new Par(args);&lt;br /&gt;
         // Get the input file name.&lt;br /&gt;
         String input = par.getString(&amp;quot;in&amp;quot;,&amp;quot;&amp;quot;);&lt;br /&gt;
         // If the input file name is nothing, then quit!&lt;br /&gt;
         if (input.equals(&amp;quot;&amp;quot;)){&lt;br /&gt;
                System.out.println(&amp;quot;Did not find input file!&amp;quot;);&lt;br /&gt;
                System.exit(1);&lt;br /&gt;
         }&lt;br /&gt;
         //If the output file name is nothing, then quit!&lt;br /&gt;
         String output = par.getString(&amp;quot;out&amp;quot;,&amp;quot;&amp;quot;);&lt;br /&gt;
         if (output.equals(&amp;quot;&amp;quot;)){&lt;br /&gt;
                System.out.println(&amp;quot;Did not find output file!&amp;quot;);&lt;br /&gt;
                System.exit(1);&lt;br /&gt;
         }&lt;br /&gt;
        // Get the value to clip to.&lt;br /&gt;
         float clip = par.getFloat(&amp;quot;clip&amp;quot;,0.0f);&lt;br /&gt;
        //Read our header file.&lt;br /&gt;
         Header header = Reader.readHeader(input);&lt;br /&gt;
        // Read our binary data.&lt;br /&gt;
         float[][][] data = Reader.readBinary3D(header);&lt;br /&gt;
        //Initialize our array values.&lt;br /&gt;
         int n3 = header.getN(3);&lt;br /&gt;
         int n2 = header.getN(2);&lt;br /&gt;
         int n1 = header.getN(1);&lt;br /&gt;
        //Perform clipping operation.&lt;br /&gt;
         for(int i = 0; i &amp;lt; n3; ++i){&lt;br /&gt;
            for(int j = 0; j &amp;lt; n2; ++j){&lt;br /&gt;
                for(int k = 0; k &amp;lt; n1; ++k){&lt;br /&gt;
                    float trace = data[i][j][k];&lt;br /&gt;
                    if (trace &amp;gt; clip) data[i][j][k] = clip;&lt;br /&gt;
                    else if (trace &amp;lt; -clip) data[i][j][k] = -clip;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
         }&lt;br /&gt;
        //Write our data out using the same header values as the file&lt;br /&gt;
        //located at output.&lt;br /&gt;
         Writer.writeRSF(header,data,output);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
How to read a file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import rsf.Header;&lt;br /&gt;
import rsf.Reader;&lt;br /&gt;
import rsf.Writer;&lt;br /&gt;
&lt;br /&gt;
public class Test {&lt;br /&gt;
      public static void main(String[] args){&lt;br /&gt;
&lt;br /&gt;
                Header header = Reader.readHeader(&amp;quot;junk.rsf&amp;quot;); //To read the header file, just feed in the path relative to the execution directory&lt;br /&gt;
                System.out.println(header); //The header file will print out if you ask it to; this is good for debugging&lt;br /&gt;
&lt;br /&gt;
                float[][] data = Reader.readBinary2D(header); //Now I can manipulate my data&lt;br /&gt;
       }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
How to write a file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import rsf.Header;&lt;br /&gt;
import rsf.Reader;&lt;br /&gt;
import rsf.Writer;&lt;br /&gt;
&lt;br /&gt;
public class Test {&lt;br /&gt;
      public static void main(String[] args){&lt;br /&gt;
                &lt;br /&gt;
                Header header = Reader.readHeader(&amp;quot;test.rsf&amp;quot;); //To read the header file, just feed in the path relative to the execution directory&lt;br /&gt;
                System.out.println(header); //The header file will print out if you ask it to; this is good for debugging&lt;br /&gt;
&lt;br /&gt;
                float[][] data = Reader.readBinary2D(header); //Now I can manipulate my data&lt;br /&gt;
&lt;br /&gt;
                //...Do something&lt;br /&gt;
                Writer.writeRSF(header,data,&amp;quot;test2.rsf&amp;quot;); //Write out my data!&lt;br /&gt;
       }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to create a dataset from scratch from within Java, then you can create an array of data, modify the values, create a header, and then write it out to rsf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import rsf.Header;&lt;br /&gt;
import rsf.Reader;&lt;br /&gt;
import rsf.Writer;&lt;br /&gt;
&lt;br /&gt;
public class Test {&lt;br /&gt;
      public static void main(String[] args){&lt;br /&gt;
&lt;br /&gt;
                int n1 = 20;&lt;br /&gt;
                int n2 = 40;&lt;br /&gt;
                float[][] data = new float[n2][n1]; &lt;br /&gt;
                //The order for dimensions is reversed because RSF stores them as column-major arrays (see Python API).&lt;br /&gt;
&lt;br /&gt;
                //...Do something&lt;br /&gt;
&lt;br /&gt;
                Header header = new Header();&lt;br /&gt;
                header.setN(1,n1);&lt;br /&gt;
                /* We set the values using the proper RSF number for the dimension, instead of the Java array index.&lt;br /&gt;
                   Example:  RSF Dimension 1 corresponds to array index 0 in Java.&lt;br /&gt;
                             However, we set the values using index 1. The mapping is handled behind the scenes.&lt;br /&gt;
                 */&lt;br /&gt;
                header.setN(2,n2); &lt;br /&gt;
                header.setDelta(1,0.0);&lt;br /&gt;
                header.setLabel(1,&amp;quot;time&amp;quot;);&lt;br /&gt;
                header.setUnits(1,&amp;quot;s&amp;quot;);&lt;br /&gt;
                Writer.writeRSF(header,data,&amp;quot;junk2.rsf&amp;quot;); //Write out my data!&lt;br /&gt;
       }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Fomels</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Contributing_new_programs_to_Madagascar&amp;diff=5576</id>
		<title>Contributing new programs to Madagascar</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Contributing_new_programs_to_Madagascar&amp;diff=5576"/>
		<updated>2024-11-26T03:32:27Z</updated>

		<summary type="html">&lt;p&gt;Fomels: /* Static code checks */ links&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you want to share your code with other Madagascar users:   &lt;br /&gt;
# Follow the guide on [[Adding new programs to Madagascar]].&lt;br /&gt;
# If your employer holds the copyright for your software, obtain permission to distribute under a [http://www.gnu.org/copyleft/gpl.html GPL license] and place a copyright and GPL license notice in each file with code. &lt;br /&gt;
# [https://github.com/ Sign up at GitHub].&lt;br /&gt;
# Upload your directory to the [https://github.com/ahay/src Github repository] by making a pull request.&lt;br /&gt;
# Announce your changes in the release notes for the upcoming stable version ([https://github.com/ahay/src/blob/master/NEWS.txt $RSFSRC/NEWS.txt])&lt;br /&gt;
# Make sure to add reproducible examples of using your program under the &amp;lt;tt&amp;gt;$RSFSRC/book&amp;lt;/tt&amp;gt; tree. Create new directories if necessary and commit them to the repository. As a rule, the release version does not include programs without examples.&lt;br /&gt;
&lt;br /&gt;
Some additional helpful information is included below.&lt;br /&gt;
&lt;br /&gt;
==Repository procedure suggestions==&lt;br /&gt;
&lt;br /&gt;
Please try to do [http://en.wikipedia.org/wiki/Atomic_commit atomic commits]. For coding style suggestions, please see [[Adding_new_programs_to_Madagascar#Style_guide | the &amp;quot;Adding new programs&amp;quot; section]].&lt;br /&gt;
&lt;br /&gt;
==Backward compatibility features==&lt;br /&gt;
If you introduce or notice a feature that is used solely for backward compatibility with an old version of a dependency, please document it here so that the feature can be eliminated when the Madagascar community stops supporting that version of that dependency&amp;lt;ref&amp;gt;This could be more elegantly done by using a special string to flag a backward compatibility comment in the code, then have the documentation builder build this list automatically. This would make it more likely for this page to be kept in sync with the codebase.&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Mitigating missing dependencies==&lt;br /&gt;
The main idea is to attempt to provide [http://en.wikipedia.org/wiki/Graceful_degradation graceful degradation] when facing a missing dependency. Quoting the Wikipedia page on fault-tolerant systems, this &amp;quot;enables a system to continue operating properly in the event of the failure of (or one or more faults within) some of its components. If its operating quality decreases at all, the decrease is proportional to the severity of the failure, as compared to a naively-designed system in which even a small failure can cause total breakdown.&amp;quot;&lt;br /&gt;
==Reasons for the existence of certain features==&lt;br /&gt;
===Why pyc files are generated during the install step===&lt;br /&gt;
Python bytecode files, with the pyc extensions, are created during the &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; to:&lt;br /&gt;
* Register them in SCons&#039; dependency tree so that &amp;lt;tt&amp;gt; scons remove them -c install&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Avoid a situation where a user tries to execute a Madagascar Python program but creates the pyc file during a module import fails because of lack of write access to &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==cfortran.h==&lt;br /&gt;
This source code file provides a machine-independent interface between C procedures, Fortran procedures, and global data (more details [http://www-zeus.desy.de/~burow/cfortran/ on the website of its initial author]). It is a dependency of the F77 and F90 APIs, as well as of vplot. It is included in m8r in &amp;lt;tt&amp;gt;api/f90&amp;lt;/tt&amp;gt; with a link in &amp;lt;tt&amp;gt;api/f77&amp;lt;/tt&amp;gt;. Version 4.3 (2002) is still distributed through the original author&#039;s website. Another version (fork?) is [http://root.cern.ch/viewvc/trunk/montecarlo/eg/inc/cfortran.h?view=log maintained at CERN] and distributed in the include directory of the interface to event generators in the Monte Carlo libraries in the [http://cernlib.web.cern.ch/cernlib/ CERN Program Library] (CERNlib). Debian distributes the Free Software part of this package as &amp;lt;tt&amp;gt;cernlib&amp;lt;/tt&amp;gt;. Under Fedora, &amp;lt;tt&amp;gt;cfortran.h&amp;lt;/tt&amp;gt; is included in &amp;lt;tt&amp;gt;cernlib-g77-devel&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;cernlib-devel&amp;lt;/tt&amp;gt;, which happily overwrite each other&#039;s files and create copies of &amp;lt;tt&amp;gt;cfortran.h&amp;lt;/tt&amp;gt; in two different locations deeply nested under &amp;lt;tt&amp;gt;/usr/include&amp;lt;/tt&amp;gt;. CERNlib&#039;s Debian maintainer states that [http://people.debian.org/~kmccarty/cernlib/index.html &amp;quot;CERNlib is an ancient mass of mostly Fortran code&amp;quot;] and that [http://people.debian.org/~kmccarty/physics-software-rant.html &amp;quot;Most components of CERNLIB are completely broken on modern 64-bit architectures&amp;quot;], so m8r developers should be aware that CERNlib will probably be superseded in the future by [http://en.wikipedia.org/wiki/ROOT ROOT], with upstream &amp;lt;tt&amp;gt;cfortran.h&amp;lt;/tt&amp;gt; maintenance possibly continuing this way.&lt;br /&gt;
&lt;br /&gt;
==Static code checks==&lt;br /&gt;
Madagascar contains the beginning of an implementation of static code checks for security vulnerabilities and coding mistakes with [http://www.splint.org/ Splint]. This is visible in the code through the presence of comments like &amp;lt;tt&amp;gt;/*@out@*/&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/*@null@*/&amp;lt;/tt&amp;gt;, which instruct Splint about the intent of different variables and function return values. Plans include dynamic checking by [http://valgrind.org/ Valgrind] or IBM&#039;s [http://www-306.ibm.com/software/awdtools/purify/ Rational Purify]. Madagascar code metrics are [https://openhub.net/p/m8r assessed periodically by Open Hub].&lt;br /&gt;
&lt;br /&gt;
==Maintaining the maintenance tools==&lt;br /&gt;
Please document scripts that maintain the Madagascar codebase and save them in &amp;lt;tt&amp;gt;$RSFSRC/admin&amp;lt;/tt&amp;gt;. Cleanup procedures may need to be repeated in the future, as authors are human and can make the same mistakes again.&lt;br /&gt;
&lt;br /&gt;
==Information flow map==&lt;br /&gt;
The vector graphics original of this map in [http://en.wikipedia.org/wiki/Dia_(software) Dia] format is available upon request through the rsf-devel mailing list.&lt;br /&gt;
[[Image:M8rmap.png]]&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
==Dual licensing Madagascar code==&lt;br /&gt;
In a contractual work relationship, you may find it handy to reuse some of your existing public code for which you own the copyright. This may also apply if you are doing contract work for a client on behalf of your employer, who owns the copyright.&lt;br /&gt;
&lt;br /&gt;
If your code does not have any GPL-ed dependencies, and the copyright owner agrees to release the code under a different license than the GPL, then you are free to go ahead and do it. However, make sure that in every file you state the following:&lt;br /&gt;
* who is the copyright owner,&lt;br /&gt;
* what are the terms of the proprietary license that it is being released under,&lt;br /&gt;
* that the code has already been licensed to the public under the GNU GPL before this as part of the Madagascar package&lt;br /&gt;
It is important to specify all these items, lest years later, someone in your client&#039;s company finds the code, realizes that similar code is part of Madagascar, and wrongly believes that the copyright belonged to his company and that you infringed it by releasing the code under the GPL.&lt;br /&gt;
&lt;br /&gt;
Ensure that proper copyright and licensing statements are in place in case of dual licensing, even if you are on excellent terms with your client and are confident they will not falsely accuse you of wrongdoing. Companies get acquired, employees and even owners leave companies, policies and business strategies change, and old contracts, licenses, and legal documents get discarded or lost in a mass of old junk. Each source code file should contain all the relevant copyright and licensing information.&lt;/div&gt;</summary>
		<author><name>Fomels</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Contributing_new_programs_to_Madagascar&amp;diff=5575</id>
		<title>Contributing new programs to Madagascar</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Contributing_new_programs_to_Madagascar&amp;diff=5575"/>
		<updated>2024-11-26T03:30:19Z</updated>

		<summary type="html">&lt;p&gt;Fomels: /* Repository procedure suggestions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you want to share your code with other Madagascar users:   &lt;br /&gt;
# Follow the guide on [[Adding new programs to Madagascar]].&lt;br /&gt;
# If your employer holds the copyright for your software, obtain permission to distribute under a [http://www.gnu.org/copyleft/gpl.html GPL license] and place a copyright and GPL license notice in each file with code. &lt;br /&gt;
# [https://github.com/ Sign up at GitHub].&lt;br /&gt;
# Upload your directory to the [https://github.com/ahay/src Github repository] by making a pull request.&lt;br /&gt;
# Announce your changes in the release notes for the upcoming stable version ([https://github.com/ahay/src/blob/master/NEWS.txt $RSFSRC/NEWS.txt])&lt;br /&gt;
# Make sure to add reproducible examples of using your program under the &amp;lt;tt&amp;gt;$RSFSRC/book&amp;lt;/tt&amp;gt; tree. Create new directories if necessary and commit them to the repository. As a rule, the release version does not include programs without examples.&lt;br /&gt;
&lt;br /&gt;
Some additional helpful information is included below.&lt;br /&gt;
&lt;br /&gt;
==Repository procedure suggestions==&lt;br /&gt;
&lt;br /&gt;
Please try to do [http://en.wikipedia.org/wiki/Atomic_commit atomic commits]. For coding style suggestions, please see [[Adding_new_programs_to_Madagascar#Style_guide | the &amp;quot;Adding new programs&amp;quot; section]].&lt;br /&gt;
&lt;br /&gt;
==Backward compatibility features==&lt;br /&gt;
If you introduce or notice a feature that is used solely for backward compatibility with an old version of a dependency, please document it here so that the feature can be eliminated when the Madagascar community stops supporting that version of that dependency&amp;lt;ref&amp;gt;This could be more elegantly done by using a special string to flag a backward compatibility comment in the code, then have the documentation builder build this list automatically. This would make it more likely for this page to be kept in sync with the codebase.&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Mitigating missing dependencies==&lt;br /&gt;
The main idea is to attempt to provide [http://en.wikipedia.org/wiki/Graceful_degradation graceful degradation] when facing a missing dependency. Quoting the Wikipedia page on fault-tolerant systems, this &amp;quot;enables a system to continue operating properly in the event of the failure of (or one or more faults within) some of its components. If its operating quality decreases at all, the decrease is proportional to the severity of the failure, as compared to a naively-designed system in which even a small failure can cause total breakdown.&amp;quot;&lt;br /&gt;
==Reasons for the existence of certain features==&lt;br /&gt;
===Why pyc files are generated during the install step===&lt;br /&gt;
Python bytecode files, with the pyc extensions, are created during the &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; to:&lt;br /&gt;
* Register them in SCons&#039; dependency tree so that &amp;lt;tt&amp;gt; scons remove them -c install&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Avoid a situation where a user tries to execute a Madagascar Python program but creates the pyc file during a module import fails because of lack of write access to &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==cfortran.h==&lt;br /&gt;
This source code file provides a machine-independent interface between C procedures, Fortran procedures, and global data (more details [http://www-zeus.desy.de/~burow/cfortran/ on the website of its initial author]). It is a dependency of the F77 and F90 APIs, as well as of vplot. It is included in m8r in &amp;lt;tt&amp;gt;api/f90&amp;lt;/tt&amp;gt; with a link in &amp;lt;tt&amp;gt;api/f77&amp;lt;/tt&amp;gt;. Version 4.3 (2002) is still distributed through the original author&#039;s website. Another version (fork?) is [http://root.cern.ch/viewvc/trunk/montecarlo/eg/inc/cfortran.h?view=log maintained at CERN] and distributed in the include directory of the interface to event generators in the Monte Carlo libraries in the [http://cernlib.web.cern.ch/cernlib/ CERN Program Library] (CERNlib). Debian distributes the Free Software part of this package as &amp;lt;tt&amp;gt;cernlib&amp;lt;/tt&amp;gt;. Under Fedora, &amp;lt;tt&amp;gt;cfortran.h&amp;lt;/tt&amp;gt; is included in &amp;lt;tt&amp;gt;cernlib-g77-devel&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;cernlib-devel&amp;lt;/tt&amp;gt;, which happily overwrite each other&#039;s files and create copies of &amp;lt;tt&amp;gt;cfortran.h&amp;lt;/tt&amp;gt; in two different locations deeply nested under &amp;lt;tt&amp;gt;/usr/include&amp;lt;/tt&amp;gt;. CERNlib&#039;s Debian maintainer states that [http://people.debian.org/~kmccarty/cernlib/index.html &amp;quot;CERNlib is an ancient mass of mostly Fortran code&amp;quot;] and that [http://people.debian.org/~kmccarty/physics-software-rant.html &amp;quot;Most components of CERNLIB are completely broken on modern 64-bit architectures&amp;quot;], so m8r developers should be aware that CERNlib will probably be superseded in the future by [http://en.wikipedia.org/wiki/ROOT ROOT], with upstream &amp;lt;tt&amp;gt;cfortran.h&amp;lt;/tt&amp;gt; maintenance possibly continuing this way.&lt;br /&gt;
&lt;br /&gt;
==Static code checks==&lt;br /&gt;
Madagascar contains the beginning of an implementation of static code checks for security vulnerabilities and coding mistakes with [http://www.splint.org/ Splint]. This is visible in the code through the presence of comments like &amp;lt;tt&amp;gt;/*@out@*/&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/*@null@*/&amp;lt;/tt&amp;gt;, which instruct Splint about the intent of different variables and function return values. Plans include dynamic checking by [http://valgrind.org/ Valgrind] or IBM&#039;s [http://www-306.ibm.com/software/awdtools/purify/ Rational Purify]. Madagascar code metrics are [http://www.ohloh.net/p/m8r/analyses/latest assessed periodically by Ohloh].&lt;br /&gt;
&lt;br /&gt;
==Maintaining the maintenance tools==&lt;br /&gt;
Please document scripts that maintain the Madagascar codebase and save them in &amp;lt;tt&amp;gt;$RSFSRC/admin&amp;lt;/tt&amp;gt;. Cleanup procedures may need to be repeated in the future, as authors are human and can make the same mistakes again.&lt;br /&gt;
&lt;br /&gt;
==Information flow map==&lt;br /&gt;
The vector graphics original of this map in [http://en.wikipedia.org/wiki/Dia_(software) Dia] format is available upon request through the rsf-devel mailing list.&lt;br /&gt;
[[Image:M8rmap.png]]&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
==Dual licensing Madagascar code==&lt;br /&gt;
In a contractual work relationship, you may find it handy to reuse some of your existing public code for which you own the copyright. This may also apply if you are doing contract work for a client on behalf of your employer, who owns the copyright.&lt;br /&gt;
&lt;br /&gt;
If your code does not have any GPL-ed dependencies, and the copyright owner agrees to release the code under a different license than the GPL, then you are free to go ahead and do it. However, make sure that in every file you state the following:&lt;br /&gt;
* who is the copyright owner,&lt;br /&gt;
* what are the terms of the proprietary license that it is being released under,&lt;br /&gt;
* that the code has already been licensed to the public under the GNU GPL before this as part of the Madagascar package&lt;br /&gt;
It is important to specify all these items, lest years later, someone in your client&#039;s company finds the code, realizes that similar code is part of Madagascar, and wrongly believes that the copyright belonged to his company and that you infringed it by releasing the code under the GPL.&lt;br /&gt;
&lt;br /&gt;
Ensure that proper copyright and licensing statements are in place in case of dual licensing, even if you are on excellent terms with your client and are confident they will not falsely accuse you of wrongdoing. Companies get acquired, employees and even owners leave companies, policies and business strategies change, and old contracts, licenses, and legal documents get discarded or lost in a mass of old junk. Each source code file should contain all the relevant copyright and licensing information.&lt;/div&gt;</summary>
		<author><name>Fomels</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Contributing_new_programs_to_Madagascar&amp;diff=5574</id>
		<title>Contributing new programs to Madagascar</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Contributing_new_programs_to_Madagascar&amp;diff=5574"/>
		<updated>2024-11-26T03:29:32Z</updated>

		<summary type="html">&lt;p&gt;Fomels: typos&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you want to share your code with other Madagascar users:   &lt;br /&gt;
# Follow the guide on [[Adding new programs to Madagascar]].&lt;br /&gt;
# If your employer holds the copyright for your software, obtain permission to distribute under a [http://www.gnu.org/copyleft/gpl.html GPL license] and place a copyright and GPL license notice in each file with code. &lt;br /&gt;
# [https://github.com/ Sign up at GitHub].&lt;br /&gt;
# Upload your directory to the [https://github.com/ahay/src Github repository] by making a pull request.&lt;br /&gt;
# Announce your changes in the release notes for the upcoming stable version ([https://github.com/ahay/src/blob/master/NEWS.txt $RSFSRC/NEWS.txt])&lt;br /&gt;
# Make sure to add reproducible examples of using your program under the &amp;lt;tt&amp;gt;$RSFSRC/book&amp;lt;/tt&amp;gt; tree. Create new directories if necessary and commit them to the repository. As a rule, the release version does not include programs without examples.&lt;br /&gt;
&lt;br /&gt;
Some additional helpful information is included below.&lt;br /&gt;
&lt;br /&gt;
==Repository procedure suggestions==&lt;br /&gt;
Please try to:&lt;br /&gt;
* Do [http://en.wikipedia.org/wiki/Atomic_commit atomic commits].&lt;br /&gt;
* If you use Subversion, run  &amp;lt;pre&amp;gt;svn commit -m &amp;quot;your message here&amp;quot;&amp;lt;/pre&amp;gt; to let others know what changed.&lt;br /&gt;
** Alternatively, set the &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;SVN_EDITOR&amp;lt;/tt&amp;gt; environmental variables to your favorite editor and edit your message there.&lt;br /&gt;
&lt;br /&gt;
For coding style suggestions, please see [[Adding_new_programs_to_Madagascar#Style_guide | the &amp;quot;Adding new programs&amp;quot; section]].&lt;br /&gt;
&lt;br /&gt;
==Backward compatibility features==&lt;br /&gt;
If you introduce or notice a feature that is used solely for backward compatibility with an old version of a dependency, please document it here so that the feature can be eliminated when the Madagascar community stops supporting that version of that dependency&amp;lt;ref&amp;gt;This could be more elegantly done by using a special string to flag a backward compatibility comment in the code, then have the documentation builder build this list automatically. This would make it more likely for this page to be kept in sync with the codebase.&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Mitigating missing dependencies==&lt;br /&gt;
The main idea is to attempt to provide [http://en.wikipedia.org/wiki/Graceful_degradation graceful degradation] when facing a missing dependency. Quoting the Wikipedia page on fault-tolerant systems, this &amp;quot;enables a system to continue operating properly in the event of the failure of (or one or more faults within) some of its components. If its operating quality decreases at all, the decrease is proportional to the severity of the failure, as compared to a naively-designed system in which even a small failure can cause total breakdown.&amp;quot;&lt;br /&gt;
==Reasons for the existence of certain features==&lt;br /&gt;
===Why pyc files are generated during the install step===&lt;br /&gt;
Python bytecode files, with the pyc extensions, are created during the &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; to:&lt;br /&gt;
* Register them in SCons&#039; dependency tree so that &amp;lt;tt&amp;gt; scons remove them -c install&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Avoid a situation where a user tries to execute a Madagascar Python program but creates the pyc file during a module import fails because of lack of write access to &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==cfortran.h==&lt;br /&gt;
This source code file provides a machine-independent interface between C procedures, Fortran procedures, and global data (more details [http://www-zeus.desy.de/~burow/cfortran/ on the website of its initial author]). It is a dependency of the F77 and F90 APIs, as well as of vplot. It is included in m8r in &amp;lt;tt&amp;gt;api/f90&amp;lt;/tt&amp;gt; with a link in &amp;lt;tt&amp;gt;api/f77&amp;lt;/tt&amp;gt;. Version 4.3 (2002) is still distributed through the original author&#039;s website. Another version (fork?) is [http://root.cern.ch/viewvc/trunk/montecarlo/eg/inc/cfortran.h?view=log maintained at CERN] and distributed in the include directory of the interface to event generators in the Monte Carlo libraries in the [http://cernlib.web.cern.ch/cernlib/ CERN Program Library] (CERNlib). Debian distributes the Free Software part of this package as &amp;lt;tt&amp;gt;cernlib&amp;lt;/tt&amp;gt;. Under Fedora, &amp;lt;tt&amp;gt;cfortran.h&amp;lt;/tt&amp;gt; is included in &amp;lt;tt&amp;gt;cernlib-g77-devel&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;cernlib-devel&amp;lt;/tt&amp;gt;, which happily overwrite each other&#039;s files and create copies of &amp;lt;tt&amp;gt;cfortran.h&amp;lt;/tt&amp;gt; in two different locations deeply nested under &amp;lt;tt&amp;gt;/usr/include&amp;lt;/tt&amp;gt;. CERNlib&#039;s Debian maintainer states that [http://people.debian.org/~kmccarty/cernlib/index.html &amp;quot;CERNlib is an ancient mass of mostly Fortran code&amp;quot;] and that [http://people.debian.org/~kmccarty/physics-software-rant.html &amp;quot;Most components of CERNLIB are completely broken on modern 64-bit architectures&amp;quot;], so m8r developers should be aware that CERNlib will probably be superseded in the future by [http://en.wikipedia.org/wiki/ROOT ROOT], with upstream &amp;lt;tt&amp;gt;cfortran.h&amp;lt;/tt&amp;gt; maintenance possibly continuing this way.&lt;br /&gt;
&lt;br /&gt;
==Static code checks==&lt;br /&gt;
Madagascar contains the beginning of an implementation of static code checks for security vulnerabilities and coding mistakes with [http://www.splint.org/ Splint]. This is visible in the code through the presence of comments like &amp;lt;tt&amp;gt;/*@out@*/&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/*@null@*/&amp;lt;/tt&amp;gt;, which instruct Splint about the intent of different variables and function return values. Plans include dynamic checking by [http://valgrind.org/ Valgrind] or IBM&#039;s [http://www-306.ibm.com/software/awdtools/purify/ Rational Purify]. Madagascar code metrics are [http://www.ohloh.net/p/m8r/analyses/latest assessed periodically by Ohloh].&lt;br /&gt;
&lt;br /&gt;
==Maintaining the maintenance tools==&lt;br /&gt;
Please document scripts that maintain the Madagascar codebase and save them in &amp;lt;tt&amp;gt;$RSFSRC/admin&amp;lt;/tt&amp;gt;. Cleanup procedures may need to be repeated in the future, as authors are human and can make the same mistakes again.&lt;br /&gt;
&lt;br /&gt;
==Information flow map==&lt;br /&gt;
The vector graphics original of this map in [http://en.wikipedia.org/wiki/Dia_(software) Dia] format is available upon request through the rsf-devel mailing list.&lt;br /&gt;
[[Image:M8rmap.png]]&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
==Dual licensing Madagascar code==&lt;br /&gt;
In a contractual work relationship, you may find it handy to reuse some of your existing public code for which you own the copyright. This may also apply if you are doing contract work for a client on behalf of your employer, who owns the copyright.&lt;br /&gt;
&lt;br /&gt;
If your code does not have any GPL-ed dependencies, and the copyright owner agrees to release the code under a different license than the GPL, then you are free to go ahead and do it. However, make sure that in every file you state the following:&lt;br /&gt;
* who is the copyright owner,&lt;br /&gt;
* what are the terms of the proprietary license that it is being released under,&lt;br /&gt;
* that the code has already been licensed to the public under the GNU GPL before this as part of the Madagascar package&lt;br /&gt;
It is important to specify all these items, lest years later, someone in your client&#039;s company finds the code, realizes that similar code is part of Madagascar, and wrongly believes that the copyright belonged to his company and that you infringed it by releasing the code under the GPL.&lt;br /&gt;
&lt;br /&gt;
Ensure that proper copyright and licensing statements are in place in case of dual licensing, even if you are on excellent terms with your client and are confident they will not falsely accuse you of wrongdoing. Companies get acquired, employees and even owners leave companies, policies and business strategies change, and old contracts, licenses, and legal documents get discarded or lost in a mass of old junk. Each source code file should contain all the relevant copyright and licensing information.&lt;/div&gt;</summary>
		<author><name>Fomels</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Adding_new_programs_to_Madagascar&amp;diff=5486</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=5486"/>
		<updated>2024-11-25T02:28:59Z</updated>

		<summary type="html">&lt;p&gt;Fomels: typos&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_800161_XS.jpg|right|]]&lt;br /&gt;
Madagascar is fully extensible, so you can share your work with the world or keep it for yourself. 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;&amp;amp;#36;RSFSRC/user&amp;lt;/tt&amp;gt;, where &amp;lt;tt&amp;gt;&amp;amp;#36;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 them. &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 standard 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 &amp;lt;tt&amp;gt;&amp;amp;#36;RSFSRC&amp;lt;/tt&amp;gt; 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: in-code documentation, the Wiki, and reproducible papers. &lt;br /&gt;
===In-code documentation===&lt;br /&gt;
Of course, comment your code, focusing on &amp;quot;why&amp;quot; (the code itself describes the &amp;quot;how&amp;quot;). Keep comments sparse so the human reader can simultaneously absorb as much code as possible. 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 produce a self-doc page for your program automatically. This page will be displayed in the terminal (using basic text-mode formatting) when the program is invoked without any arguments, and an 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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;python&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
Then, make sure to&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import rsfprog&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;python&amp;quot;&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;/syntaxhighlight&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 the 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 their default values, but more is usually needed for someone who has never used the tool. This is what the [[Guide to Madagascar programs|Guide to programs]] is for. Whenever you change or create a program, add a section for it, 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 with 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 because it is already in MediaWiki format. Another directory can be used instead of $HOME.&lt;br /&gt;
&lt;br /&gt;
If your program/script reads an environment variable, 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/rsf/doc.py&amp;lt;/tt&amp;gt; . This will ensure 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 users who do not already know they need it can find 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 a reproducible paper 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 ensure 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 code comments but to commenting out actual code. You can always use the version control system to retrieve the older version&lt;br /&gt;
* Use standard C: declare all variables at the beginning of the program, use C-style comments &amp;lt;tt&amp;gt;/* */&amp;lt;/tt&amp;gt;. Some compilers do not allow C++-style variable declarations and comments in C programs.&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 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 out where the 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 the 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 quickly alternates between the stored figure and your figure. &lt;br /&gt;
#* If the figures look identical, then 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, 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 must 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;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
RSF_src_root = &#039;/path/to/madagascar/source/root/&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
os.path.join(RSF_src_root,&#039;whatever_followed_after_dotdots&#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;lisp&amp;quot;&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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;lisp&amp;quot;&amp;gt;&lt;br /&gt;
(set-default &#039;compile-command &amp;quot;scons&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;lisp&amp;quot;&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;/syntaxhighlight&amp;gt; &lt;br /&gt;
:to ensure that the indentation 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
au BufRead,BufNewFile SConstruct set filetype=python&lt;br /&gt;
&lt;br /&gt;
syntax enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Fomels</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Reproducible_computational_experiments_using_SCons&amp;diff=5423</id>
		<title>Reproducible computational experiments using SCons</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Reproducible_computational_experiments_using_SCons&amp;diff=5423"/>
		<updated>2024-11-20T23:42:00Z</updated>

		<summary type="html">&lt;p&gt;Fomels: typos&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://sourceforge.net/p/rsf/code/HEAD/tree/trunk/book/rsf/scons/paper.tex book/rsf/scons/paper.tex] using [[latex2wiki]]&#039;&#039;&amp;lt;/font&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SCons (from Software Construction) is a well-known open-source&lt;br /&gt;
program designed primarily for building software. This paper describes our method of extending SCons for managing data processing&lt;br /&gt;
flows and reproducible computational experiments. We demonstrate our&lt;br /&gt;
usage of SCons with a couple of simple examples.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
This paper introduces an environment for reproducible computational&lt;br /&gt;
experiments developed as part of the &amp;quot;Madagascar&amp;quot; software package.&lt;br /&gt;
To reproduce the example experiments in this paper, you can download&lt;br /&gt;
Madagascar from https://www.ahay.org . At the moment, the&lt;br /&gt;
main Madagascar interface is the Unix shell command line so that you&lt;br /&gt;
will need a Unix/POSIX system (Linux, Mac OS X, Solaris, etc.) or Unix&lt;br /&gt;
emulation under Windows (Cygwin, SFU, etc.)&lt;br /&gt;
Our focus, however, is not only on particular tools we use in our research but also on the general philosophy of&lt;br /&gt;
reproducible computations.&lt;br /&gt;
===Reproducible research philosophy===&lt;br /&gt;
Peer review is the backbone of scientific progress. From the ancient&lt;br /&gt;
alchemists who worked secretly on magic solutions to insolvable&lt;br /&gt;
problems, modern science has come a long way to become a social&lt;br /&gt;
enterprise where the community openly publishes and verifies hypotheses, theories, and experimental results. By reproducing and&lt;br /&gt;
verifying previously published research, a researcher can take new&lt;br /&gt;
steps to advance the progress of science.&lt;br /&gt;
Traditionally, scientific disciplines are divided into theoretical and&lt;br /&gt;
experimental studies. The reproduction and verification of theoretical&lt;br /&gt;
results usually require only imagination (apart from pencils and&lt;br /&gt;
paper), and experimental results are verified in laboratories using&lt;br /&gt;
equipment and materials similar to those described in the publication.&lt;br /&gt;
During the last century, computational studies emerged as a new&lt;br /&gt;
scientific discipline. Computational experiments are carried out on a&lt;br /&gt;
computer by applying numerical algorithms to digital data. How&lt;br /&gt;
reproducible are such experiments? On one hand, reproducing the result&lt;br /&gt;
of a numerical experiment is difficult. The reader needs&lt;br /&gt;
to have access to precisely the same kind of input data, software, and&lt;br /&gt;
hardware as the publication&#039;s author to reproduce the&lt;br /&gt;
published result. It is often difficult or impossible to provide&lt;br /&gt;
detailed specifications for these components. On the other hand, essential&lt;br /&gt;
computational system components such as operating systems and&lt;br /&gt;
file formats are getting increasingly standardized. New components&lt;br /&gt;
can be shared in principle because they represent digital&lt;br /&gt;
information transferable over the Internet.&lt;br /&gt;
The practice of software sharing has fueled the miraculously efficient&lt;br /&gt;
development of Linux, Apache, and many other open-source software&lt;br /&gt;
projects. Its proponents often refer to this ideology as an analog of&lt;br /&gt;
the scientific peer review tradition. Eric Raymond, a well-known&lt;br /&gt;
open-source advocate writes (Raymond, 2004&amp;lt;ref&amp;gt;Raymond, E. S.,  2004, The art of UNIX programming: Addison-Wesley.&amp;lt;/ref&amp;gt;):&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Abandoning the habit of secrecy in favor of process transparency and&lt;br /&gt;
peer review was the crucial step by which alchemy became chemistry.&lt;br /&gt;
In the same way, it is beginning to appear that open-source&lt;br /&gt;
development may signal the long-awaited maturation of software&lt;br /&gt;
development as a discipline.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
While software development tries to imitate science, computational&lt;br /&gt;
science must borrow from the open-source model to sustain&lt;br /&gt;
itself as a fully scientific discipline. In the words of Randy LeVeque, a&lt;br /&gt;
prominent mathematician (LeVeque, 2006&amp;lt;ref&amp;gt;LeVeque, R. J.,  to appear, 2006, Wave propagation software, computational science, and reproducible research: Presented at the Proc. International  Congress of Mathematicians.&amp;lt;/ref&amp;gt;),&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Within the world of science, computation is now rightly seen as a&lt;br /&gt;
third vertex of a triangle, complementing experiment and&lt;br /&gt;
theory. However, as it is now often practiced, one can make a good case that computing is the last refuge of the scientific scoundrel&lt;br /&gt;
[...]  Where else in science can one get away with publishing&lt;br /&gt;
observations that are claimed to prove a theory or illustrate the&lt;br /&gt;
success of a technique without having to give a careful description of&lt;br /&gt;
the methods used in sufficient detail that others can attempt to&lt;br /&gt;
repeat the experiment? [...]  Scientific and mathematical journals are&lt;br /&gt;
filled with pretty pictures these days of computational experiments&lt;br /&gt;
that the reader has no hope of repeating. Even brilliant and well-intentioned computational scientists often do a poor job of presenting&lt;br /&gt;
their work in a reproducible manner. The methods are often very&lt;br /&gt;
vaguely defined, and even if they are carefully defined, they would&lt;br /&gt;
normally have to be implemented from scratch by the reader in order to&lt;br /&gt;
test them.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
In computer science, the concept of publishing and explaining computer programs goes back to the idea of &#039;&#039;literate programming&#039;&#039;  promoted&lt;br /&gt;
by Knuth (1984&amp;lt;ref&amp;gt;Knuth, D. E.,  1984, Literate programming: Computer Journal, &#039;&#039;&#039;27&#039;&#039;&#039;, 97--111.&amp;lt;/ref&amp;gt;) and expended by many other researchers&lt;br /&gt;
(Thimbleby, 2003&amp;lt;ref&amp;gt;Thimbleby, H.,  2003, Explaining code for publication: Software - Practice &amp;amp;  Experience, &#039;&#039;&#039;33&#039;&#039;&#039;, 975--908.&amp;lt;/ref&amp;gt;). In his 2004 lecture on &amp;quot;Better Programming,&amp;quot;&lt;br /&gt;
Harold Thimbleby notes&amp;lt;ref&amp;gt;http://www.uclic.ucl.ac.uk/harold/&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
We want ideas, and in particular programs, that work in one place to&lt;br /&gt;
work elsewhere. One form of objectivity is that published science&lt;br /&gt;
must work elsewhere than just in the author&#039;s laboratory or even&lt;br /&gt;
just in the author&#039;s imagination; this requirement is called&lt;br /&gt;
&#039;&#039;reproducibility&#039;&#039; .&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
The quest for peer review and reproducibility is vital&lt;br /&gt;
for computational geosciences and computational geophysics in&lt;br /&gt;
particular. The very first paper published in &#039;&#039;Geophysics&#039;&#039;  was&lt;br /&gt;
titled &amp;quot;Black Magic in Geophysical Prospecting&amp;quot;&lt;br /&gt;
() and presented an account&lt;br /&gt;
of different &amp;quot;magical&amp;quot; methods of oil explorations promoted by&lt;br /&gt;
entrepreneurs in the early days of the geophysical exploration industry.&lt;br /&gt;
Although none of these methods exist today, it is not a secret that&lt;br /&gt;
industrial practice is full of nearly magical tricks, often hidden&lt;br /&gt;
besides a scientific appearance. Only a scrutiny of peer review and&lt;br /&gt;
result verification can help us distinguish magic from science and&lt;br /&gt;
advance the latter.&lt;br /&gt;
 --&amp;gt;&lt;br /&gt;
Nearly ten years ago, the technology of reproducible research in&lt;br /&gt;
geophysics was pioneered by Jon Claerbout and his students at the&lt;br /&gt;
Stanford Exploration Project (SEP). SEP&#039;s system of reproducible&lt;br /&gt;
research requires the author of a publication to document the creation of&lt;br /&gt;
numerical results from the input data and software sources to let&lt;br /&gt;
others test and verify the reproducibility of the results&lt;br /&gt;
(Claerbout, 1992a&amp;lt;ref&amp;gt;Claerbout, J.,  1992a, Electronic documents give reproducible research a new meaning: 62nd Ann. Internat. Mtg, 601--604, Soc. of Expl. Geophys.&amp;lt;/ref&amp;gt;;Schwab et al., 2000&amp;lt;ref&amp;gt;Schwab, M., M. Karrenbach, and J. Claerbout,  2000, Making scientific computations reproducible: Computing in Science &amp;amp; Engineering, &#039;&#039;&#039;2&#039;&#039;&#039;,  61--67.&amp;lt;/ref&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
The discipline of reproducible research was also adopted and&lt;br /&gt;
popularized in the statistics and wavelet theory community by&lt;br /&gt;
Buckheit and Donoho (1995&amp;lt;ref&amp;gt;Buckheit, J. and D. L. Donoho,  1995, Wavelab and reproducible research, &#039;&#039;in&#039;&#039; Wavelets and Statistics, volume &#039;&#039;&#039;103&#039;&#039;&#039;,  55--81. Springer-Verlag.&amp;lt;/ref&amp;gt;). It is referenced in several popular wavelet theory&lt;br /&gt;
books (Hubbard, 1998&amp;lt;ref&amp;gt;Hubbard, B. B.,  1998, The world according to wavelets: The story of a mathematical technique in the making: AK Peters.&amp;lt;/ref&amp;gt;;Mallat, 1999&amp;lt;ref&amp;gt;Mallat, S.,  1999, A wavelet tour of signal processing: Academic Press.&amp;lt;/ref&amp;gt;). Pledges for reproducible research&lt;br /&gt;
appear nowadays in fields as diverse as &lt;br /&gt;
bioinformatics&lt;br /&gt;
(Gentleman et al., 2004&amp;lt;ref&amp;gt;Gentleman, R. C., V. J. Carey, D. M. Bates, B. Bolstad, M. Dettling, S. Dudoit,  B. Ellis, L. Gautier, Y. Ge, J. Gentry, K. Hornik, T. Hothorn, W. Huber, S.  Iacus, R. Irizarry, F. Leisch, C. Li, M. Maechler, A. J. Rossini, G.  Sawitzki, C. Smith, G. Smyth, L. Tierney, J. Y. Yang, and J. Zhang,  2004,  Bioconductor: open software development for computational biology and bioinformatics: Genome Biology, &#039;&#039;&#039;5&#039;&#039;&#039;, R80.&amp;lt;/ref&amp;gt;), &lt;br /&gt;
geoinformatics (Bivand, 2006&amp;lt;ref&amp;gt;Bivand, R.,  2006, Implementing spatial data analysis software tools in r:  Geographical Analysis, &#039;&#039;&#039;38&#039;&#039;&#039;, 23--40.&amp;lt;/ref&amp;gt;), and computational wave propagation (LeVeque, 2006&amp;lt;ref&amp;gt;LeVeque, R. J.,  to appear, 2006, Wave propagation software, computational science, and reproducible research: Presented at the Proc. International  Congress of Mathematicians.&amp;lt;/ref&amp;gt;). However, computational scientists&#039; adoption of reproducible research practice has been slow.&lt;br /&gt;
Partially, this is caused by complicated and inadequate tools.&lt;br /&gt;
&lt;br /&gt;
===Tools for reproducible research===&lt;br /&gt;
The reproducible research system developed at Stanford is based on&lt;br /&gt;
&amp;quot;make&amp;quot; (Stallman et al., 2004&amp;lt;ref&amp;gt;Stallman, R. M., R. McGrath, and P. D. Smith,  2004, GNU make: A program for directing recompilation: GNU Press.&amp;lt;/ref&amp;gt;), a Unix software construction utility.&lt;br /&gt;
Initially, SEP used &amp;quot;cake,&amp;quot; a dialect of &amp;quot;make&amp;quot;&lt;br /&gt;
(Nichols and Cole, 1989&amp;lt;ref&amp;gt;Nichols, D. and S. Cole,  1989, Device independent software installation with  CAKE, &#039;&#039;in&#039;&#039; SEP-61,  341--344. Stanford Exploration Project.&amp;lt;/ref&amp;gt;;Claerbout and Nichols, 1990&amp;lt;ref&amp;gt;Claerbout, J. F. and D. Nichols,  1990, Why active documents need cake, &#039;&#039;in&#039;&#039; SEP-67,  145--148. Stanford Exploration Project.&amp;lt;/ref&amp;gt;;Claerbout, 1992b&amp;lt;ref&amp;gt;-------- 1992b, How to use Cake with interactive documents, &#039;&#039;in&#039;&#039; SEP-73,  451--460. Stanford Exploration Project.&amp;lt;/ref&amp;gt;;Claerbout and Karrenbach, 1993&amp;lt;ref&amp;gt;Claerbout, J. F. and M. Karrenbach,  1993, How to use cake with interactive  documents, &#039;&#039;in&#039;&#039; SEP-77,  427--444. Stanford Exploration Project.&amp;lt;/ref&amp;gt;).&lt;br /&gt;
The system was converted to &amp;quot;GNU make,&amp;quot; a more standard dialect, by&lt;br /&gt;
Schwab and Schroeder (1995&amp;lt;ref&amp;gt;Schwab, M. and J. Schroeder,  1995, Reproducible research documents using  GNUmake, &#039;&#039;in&#039;&#039; SEP-89,  217--226. Stanford Exploration Project.&amp;lt;/ref&amp;gt;). The &amp;quot;make&amp;quot; program keeps track of dependencies between different&lt;br /&gt;
components of the system and the software construction targets, which,&lt;br /&gt;
in the case of a reproducible research system, turn into figures and&lt;br /&gt;
manuscripts. The author specifies the targets and commands for their construction in &amp;quot;makefiles,&amp;quot; which serve as databases for&lt;br /&gt;
defining source and target dependencies. A dependency-based system&lt;br /&gt;
leads to rapid development because when one of the sources changes,&lt;br /&gt;
only parts that depend on this source get recomputed. Buckheit and Donoho (1995&amp;lt;ref&amp;gt;Buckheit, J. and D. L. Donoho,  1995, Wavelab and reproducible research, &#039;&#039;in&#039;&#039; Wavelets and Statistics, volume &#039;&#039;&#039;103&#039;&#039;&#039;,  55--81. Springer-Verlag.&amp;lt;/ref&amp;gt;)&lt;br /&gt;
based their system on MATLAB, a popular integrated development&lt;br /&gt;
environment produced by MathWorks (Sigmon and Davis, 2001&amp;lt;ref&amp;gt;Sigmon, K. and T. A. Davis,  2001, MATLAB primer, sixth edition: Chapman &amp;amp;  Hall.&amp;lt;/ref&amp;gt;). While MATLAB is an adequate tool for prototyping numerical algorithms, it may not be&lt;br /&gt;
sufficient for large-scale computations typical for many applications&lt;br /&gt;
in computational geophysics.&lt;br /&gt;
&amp;quot;Make&amp;quot; is a handy utility employed by thousands of&lt;br /&gt;
software development projects. Unfortunately, it is not&lt;br /&gt;
well designed from the perspective of user experience. &amp;quot;Make&amp;quot; employs&lt;br /&gt;
an obscure and limited special language (a mixture of Unix shell&lt;br /&gt;
and special-purpose commands), which often appears confusing&lt;br /&gt;
to inexperienced users. According to Peter van der Linden, a software&lt;br /&gt;
expert from Sun Microsystems (van der Linden, 1994&amp;lt;ref&amp;gt;van der Linden, P.,  1994, Expert C programming: Prentice Hall.&amp;lt;/ref&amp;gt;),&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;quot;Sendmail&amp;quot; and &amp;quot;make&amp;quot; are two well-known programs that are&lt;br /&gt;
pretty widely regarded as originally being debugged into existence.&lt;br /&gt;
That&#039;s why their command languages are so poorly thought out and&lt;br /&gt;
difficult to learn. It&#039;s not just you -- everyone finds them&lt;br /&gt;
troublesome.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The inconvenience of the &amp;quot;make&amp;quot; command language is also in its limited&lt;br /&gt;
capabilities. The reproducible research system developed by&lt;br /&gt;
Schwab et al. (2000&amp;lt;ref&amp;gt;Schwab, M., M. Karrenbach, and J. Claerbout,  2000, Making scientific computations reproducible: Computing in Science &amp;amp; Engineering, &#039;&#039;&#039;2&#039;&#039;&#039;,  61--67.&amp;lt;/ref&amp;gt;) includes not only custom &amp;quot;make&amp;quot; rules but also an obscure and hardly portable agglomeration of shell and Perl scripts that extend &amp;quot;make&amp;quot; (Fomel et al., 1997&amp;lt;ref&amp;gt;Fomel, S., M. Schwab, and J. Schroeder,  1997, Empowering SEP&#039;s documents,  &#039;&#039;in&#039;&#039; SEP-94,  339--361. Stanford Exploration Project.&amp;lt;/ref&amp;gt;).&lt;br /&gt;
Several alternative systems for dependency-checking software&lt;br /&gt;
construction have been developed in recent years. One of the most&lt;br /&gt;
promising new tools is SCons, enthusiastically endorsed by&lt;br /&gt;
Dubois (2003&amp;lt;ref&amp;gt;Dubois, P. F.,  2003, Why Johnny can&#039;t build: Computing in Science &amp;amp;  Engineering, &#039;&#039;&#039;5&#039;&#039;&#039;, 83--88.&amp;lt;/ref&amp;gt;). The SCons initial design won the Software Carpentry competition sponsored by Los Alamos National Laboratory in 2000 in the category of &amp;quot;a dependency management tool to replace make.&amp;quot; Some of the main advantages of SCons are:&lt;br /&gt;
  &lt;br /&gt;
*SCons configuration files are Python scripts. Python is a modern programming language praised for its readability, elegance, simplicity, and power (Rossum, 2000a&amp;lt;ref&amp;gt;Rossum, G. V.,  2000a, Python reference manual: Iuniverse Inc.&amp;lt;/ref&amp;gt;;Rossum, 2000b&amp;lt;ref&amp;gt;-------- 2000b, Python tutorial: Iuniverse Inc.&amp;lt;/ref&amp;gt;). Scales and Ecke (2002&amp;lt;ref&amp;gt;Scales, J. A. and H. Ecke,  2002, What programming languages should we teach our undergraduates?: The Leading Edge, &#039;&#039;&#039;21&#039;&#039;&#039;, 260--267.&amp;lt;/ref&amp;gt;) recommend Python as the first programming language for geophysics students. &lt;br /&gt;
*SCons offers reliable, automatic, and extensible dependency analysis and creates a global view of all dependencies—no more &amp;quot;make depend,&amp;quot; &amp;quot;make clean,&amp;quot; or multiple build passes of touching and reordering targets to get all the dependencies. &lt;br /&gt;
*SCons has built-in support for many programming languages and systems, including C, C++, Fortran, Java, and LaTeX. &lt;br /&gt;
*While &amp;quot;make&amp;quot; relies on timestamps to detect file changes (creating numerous problems on platforms with different system clocks), SCons uses a more reliable detection mechanism, employing MD5 signatures by default. It can detect changes not only in files but also in commands used to build them. &lt;br /&gt;
*SCons provides integrated support for parallel builds. &lt;br /&gt;
*SCons provides configuration support analogous to the &amp;quot;autoconf&amp;quot; utility for testing the environment on different platforms. &lt;br /&gt;
*SCons is designed from the ground up as a cross-platform tool. It works equally well on POSIX systems (Linux, Mac OS X, Solaris, etc.) and Windows. &lt;br /&gt;
*The stability of SCons is assured by an incremental development methodology utilizing comprehensive regression tests. &lt;br /&gt;
*SCons is publicly released under a liberal open-source license&amp;lt;ref&amp;gt;As of this writing, SCons is in a beta version of 0.96, approaching the 1.0 official release. See http://www.scons.org/.&amp;lt;/ref&amp;gt;.&lt;br /&gt;
In this paper, we propose to adopt SCons as a new platform for&lt;br /&gt;
reproducible research in scientific computing.&lt;br /&gt;
&lt;br /&gt;
===Paper organization===&lt;br /&gt;
To demonstrate our adoption of SCons for reproducible research, we first describe a couple of simple examples of computational&lt;br /&gt;
experiments and then show how SCons helps us document our&lt;br /&gt;
computational results.&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
\newpage&lt;br /&gt;
==Madagascar open-source code==&lt;br /&gt;
&lt;br /&gt;
Madagascar&#039;s homepage is http://rsf.sourceforge.net. Madagascar&lt;br /&gt;
source code is proposed in two versions:&lt;br /&gt;
[https://sourceforge.net/project/showfiles.php?group_id=162909 stable]&lt;br /&gt;
and&lt;br /&gt;
[http://rsf.sourceforge.net/wiki/index.php/Svn-url development].&lt;br /&gt;
The stable version is a snapshot of Madagascar at a given time. It was&lt;br /&gt;
installed on different platforms and tested before being released.&lt;br /&gt;
Updates are typically done every few months as opposed to the&lt;br /&gt;
development version, which is updated every few hours or days by a&lt;br /&gt;
dynamic team of developers. As such, there is no guarantee that the&lt;br /&gt;
development version will be fully functional and stable at any given&lt;br /&gt;
time. In the remainder of this paper, we assume that you have&lt;br /&gt;
successfully installed Madagascar stable version and that you have an&lt;br /&gt;
Internet connection\footnote{XXX provide alternate means to download&lt;br /&gt;
Lena.img if no Internet connection XXX}.&lt;br /&gt;
 --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example experiments==&lt;br /&gt;
&lt;br /&gt;
The main &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; commands defined in our reproducible research environment are collected in the table.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Basic methods of an &amp;lt;tt&amp;gt;rsf.proj&amp;lt;/tt&amp;gt; object.&lt;br /&gt;
|- &lt;br /&gt;
|style=&amp;quot;background-color:#ffdead;&amp;quot;| &#039;&#039;&#039;&amp;lt;tt&amp;gt;Fetch(data_file,dir[,ftp_server_info])&amp;lt;/tt&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| A rule to download &amp;lt;tt&amp;gt;&amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;data_file&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;&amp;lt;/tt&amp;gt; from a specific directory &amp;lt;tt&amp;gt;&amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;dir&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;&amp;lt;/tt&amp;gt; of an FTP server&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background-color:#ffdead;&amp;quot;| &#039;&#039;&#039;&amp;lt;tt&amp;gt;Flow(target[s],source[s],command[s][,stdin][,stdout])&amp;lt;/tt&amp;gt; &#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| A rule to generate &amp;lt;tt&amp;gt;&amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;target[s]&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;&amp;lt;/tt&amp;gt; from &amp;lt;tt&amp;gt;&amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;source[s]&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;&amp;lt;/tt&amp;gt; using &amp;lt;tt&amp;gt;&amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;command[s]&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;&amp;lt;/tt&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background-color:#ffdead;&amp;quot;| &#039;&#039;&#039;&amp;lt;tt&amp;gt;Plot(intermediate_plot[,source],plot_command)&amp;lt;/tt&amp;gt;&#039;&#039;&#039; or&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;tt&amp;gt;Plot(intermediate_plot,intermediate_plots,combination)&amp;lt;/tt&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
|-  &lt;br /&gt;
| A rule to generate &amp;lt;tt&amp;gt;&amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;intermediate_plot&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;&amp;lt;/tt&amp;gt; in the working directory. &lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background-color:#ffdead;&amp;quot;| &#039;&#039;&#039;&amp;lt;tt&amp;gt;Result(plot[,source],plot_command)&amp;lt;/tt&amp;gt;&#039;&#039;&#039; or&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;tt&amp;gt;Result(plot,intermediate_plots,combination)&amp;lt;/tt&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
|- &lt;br /&gt;
| A rule to generate a final &amp;lt;tt&amp;gt;&amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;plot&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;&amp;lt;/tt&amp;gt; in the special &amp;lt;tt&amp;gt;Fig&amp;lt;/tt&amp;gt; folder of the working directory. &lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background-color:#ffdead;&amp;quot;| &#039;&#039;&#039;&amp;lt;tt&amp;gt;End()&amp;lt;/tt&amp;gt;&#039;&#039;&#039; &lt;br /&gt;
|- &lt;br /&gt;
| A rule to collect default targets. &lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These commands are defined in &amp;lt;tt&amp;gt;&amp;amp;#36;PYTHONPATH/rsf/proj.py&amp;lt;/tt&amp;gt; where&lt;br /&gt;
&amp;lt;tt&amp;gt;RSFROOT&amp;lt;/tt&amp;gt; is the environmental variable to the Madagascar&lt;br /&gt;
installation directory. The source of this file is in&lt;br /&gt;
[http://sourceforge.net/p/rsf/code/HEAD/tree/trunk/framework/rsf/proj.py framework/rsf/proj.py].&lt;br /&gt;
&lt;br /&gt;
===Example 1===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To follow the first example, select a working project directory and&lt;br /&gt;
copy the following code&lt;br /&gt;
to a file named &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt;&amp;lt;ref&amp;gt;The source of this file is also accessible at [http://sourceforge.net/p/rsf/code/HEAD/tree/trunk/book/rsf/scons/easystart/SConstruct $RSFSRC/book/rsf/scons/easystart/SConstruct].&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&lt;br /&gt;
# Download the input data file&lt;br /&gt;
Fetch(&#039;lena.img&#039;,&#039;imgs&#039;)&lt;br /&gt;
&lt;br /&gt;
# Create RSF header&lt;br /&gt;
Flow(&#039;lena.hdr&#039;,&#039;lena.img&#039;,&lt;br /&gt;
     &#039;echo n1=512 n2=513 in=$SOURCE data_format=native_uchar&#039;,&lt;br /&gt;
     stdin=0)&lt;br /&gt;
&lt;br /&gt;
# Convert to floating point and window out the first trace&lt;br /&gt;
Flow(&#039;lena&#039;,&#039;lena.hdr&#039;,&#039;dd type=float | window f2=1&#039;)&lt;br /&gt;
&lt;br /&gt;
# Display&lt;br /&gt;
Result(&#039;lena&#039;,&lt;br /&gt;
       &#039;&#039;&#039;&lt;br /&gt;
       sfgrey title=&amp;quot;Hello, World!&amp;quot; transp=n color=b bias=128&lt;br /&gt;
       clip=100 screenratio=1 &lt;br /&gt;
       &#039;&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
# Wrap up&lt;br /&gt;
End()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is our &amp;quot;hello world&amp;quot; example that illustrates the basic use of&lt;br /&gt;
some of the commands presented in Table~(tbl:commands). The plan&lt;br /&gt;
for this experiment is to download data from a public data&lt;br /&gt;
server, convert it to an appropriate file format, and generate a&lt;br /&gt;
figure for publication. But let us look at the&lt;br /&gt;
&amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; script and try to decorticate it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
is a standard Python command that loads the Madagascar project&lt;br /&gt;
management module &amp;lt;tt&amp;gt;rsf/proj.py&amp;lt;/tt&amp;gt; which provides our extension to&lt;br /&gt;
SCons.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
Fetch(&#039;lena.img&#039;,&#039;imgs&#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
instructs SCons to connect to a public data server (the default server&lt;br /&gt;
if no FTP server information is provided) and to fetch the data file&lt;br /&gt;
&amp;lt;tt&amp;gt;lena.img&amp;lt;/tt&amp;gt; from the &amp;lt;tt&amp;gt;data/imgs&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
Note that&lt;br /&gt;
Madagascar expects a &amp;lt;tt&amp;gt;data&amp;lt;/tt&amp;gt; folder on top of the specified&lt;br /&gt;
directory (i.e.  &amp;lt;tt&amp;gt;imgs&amp;lt;/tt&amp;gt;). In the directory where you have your&lt;br /&gt;
SConstruct, running &amp;lt;tt&amp;gt;scons lena.img&amp;lt;/tt&amp;gt; on the command line will&lt;br /&gt;
download the file &amp;lt;tt&amp;gt;lena.img&amp;lt;/tt&amp;gt;.  The equivalent command line is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; wget http://www.ahay.org/data/imgs/lena.img&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Try running &amp;quot;&amp;lt;tt&amp;gt;scons lena.img&amp;lt;/tt&amp;gt;&amp;quot; on the command line. The successful output should look like&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; scons lena.img&lt;br /&gt;
scons: Reading SConscript files ...&lt;br /&gt;
scons: done reading SConscript files.&lt;br /&gt;
scons: Building targets ...&lt;br /&gt;
retrieve([&amp;quot;lena.img&amp;quot;], [])&lt;br /&gt;
scons: done building targets.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
with the target file &amp;lt;tt&amp;gt;lena.img&amp;lt;/tt&amp;gt; appearing in your directory.&lt;br /&gt;
In the following examples, we will use &amp;lt;tt&amp;gt;-Q&amp;lt;/tt&amp;gt; (quiet) option of&lt;br /&gt;
&amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt; to suppress the verbose output.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
Flow(&#039;lena.hdr&#039;,&#039;lena.img&#039;,&lt;br /&gt;
     &#039;echo n1=512 n2=513 in=$SOURCE data_format=native_uchar&#039;,&lt;br /&gt;
     stdin=0)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
prepares the Madagascar header file &amp;lt;tt&amp;gt;lena.hdr&amp;lt;/tt&amp;gt; using the&lt;br /&gt;
standard Unix command &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; scons -Q lena.hdr&lt;br /&gt;
echo n1=512 n2=513 in=lena.img data_format=native_uchar &amp;gt; lena.hdr&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; does not take a standard input, stdin is set to 0&lt;br /&gt;
in the Flow command; otherwise, the first source is the standard input.&lt;br /&gt;
Likewise, the first target is the standard output unless otherwise&lt;br /&gt;
specified. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that&lt;br /&gt;
&amp;lt;tt&amp;gt;lena.img&amp;lt;/tt&amp;gt; is referred as &amp;lt;tt&amp;gt;&amp;amp;#36;SOURCE&amp;lt;/tt&amp;gt; in the command. This&lt;br /&gt;
allows us to change the source file&#039;s name without changing the command.&lt;br /&gt;
The data format of the &amp;lt;tt&amp;gt;lena.img&amp;lt;/tt&amp;gt; image file is &amp;lt;tt&amp;gt;uchar&amp;lt;/tt&amp;gt;&lt;br /&gt;
(unsigned character), the image consists of 513 traces with 512&lt;br /&gt;
samples per trace. Our next step is to convert the image&lt;br /&gt;
representation to floating point numbers and to window out the first&lt;br /&gt;
trace so that the final image is 512 by 512 square. The two&lt;br /&gt;
transformations are conveniently combined into one with the help of a Unix pipe.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
Flow(&#039;lena&#039;,&#039;lena.hdr&#039;,&#039;dd type=float | window f2=1&#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  bash&amp;amp;#36; scons -Q lena&lt;br /&gt;
  scons: *** Do not know how to make target `lena&#039;. Stop.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
What happened? In the absence of the file suffix, the &amp;lt;tt&amp;gt;Flow&amp;lt;/tt&amp;gt;&lt;br /&gt;
command assumes that the target file suffix is &amp;quot;&amp;lt;tt&amp;gt;.rsf&amp;lt;/tt&amp;gt;&amp;quot;. Let us try again.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scons -Q lena.rsf&lt;br /&gt;
&amp;lt; lena.hdr /RSF/bin/sfdd type=float | /RSF/bin/sfwindow f2=1 &amp;gt; lena.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Notice that Madagascar modules &amp;lt;tt&amp;gt;sfdd&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sfwindow&amp;lt;/tt&amp;gt; get&lt;br /&gt;
substituted for the corresponding short names in the&lt;br /&gt;
&amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file. The file &amp;lt;tt&amp;gt;lena.rsf&amp;lt;/tt&amp;gt; is in a regularly&lt;br /&gt;
sampled format&amp;lt;ref&amp;gt;See [[Guide to RSF file format]]&amp;lt;/ref&amp;gt; and can be examined, for example, with &amp;lt;tt&amp;gt;sfin lena.rsf&amp;lt;/tt&amp;gt;&amp;lt;ref&amp;gt;See [[Guide_to_madagascar_programs#sfin]].&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfin lena.rsf&lt;br /&gt;
lena.rsf:&lt;br /&gt;
    in=&amp;quot;/datapath/lena.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=512         d1=1           o1=0&lt;br /&gt;
    n2=512         d2=1           o2=1&lt;br /&gt;
        262144 elements 1048576 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In the last step, we will create a plot file to display the image&lt;br /&gt;
on the screen and for including it in the publication.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
Result(&#039;lena&#039;,&lt;br /&gt;
       &#039;&#039;&#039;&lt;br /&gt;
       sfgrey title=&amp;quot;Hello, World!&amp;quot; transp=n color=b bias=128&lt;br /&gt;
       clip=100 screenratio=1 &lt;br /&gt;
       &#039;&#039;&#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notice that we broke the long command string into multiple lines by&lt;br /&gt;
using Python&#039;s triple quote syntax. All the extra white space will be&lt;br /&gt;
ignored when the multiple-line string gets translated into the command&lt;br /&gt;
line. The &amp;lt;tt&amp;gt;Result&amp;lt;/tt&amp;gt; command has special targets associated with&lt;br /&gt;
it. Try, for example, &amp;quot;&amp;lt;tt&amp;gt;scons lena.view&amp;lt;/tt&amp;gt;&amp;quot; to observe the&lt;br /&gt;
figure &amp;lt;tt&amp;gt;Fig/lena.vpl&amp;lt;/tt&amp;gt; generated in a specially created&lt;br /&gt;
&amp;lt;tt&amp;gt;Fig&amp;lt;/tt&amp;gt; directory and displayed on the screen. The output should&lt;br /&gt;
look like this figure.&lt;br /&gt;
&lt;br /&gt;
[[Image:lena.png|frame|center|The output of the first numerical experiment.]]&lt;br /&gt;
&lt;br /&gt;
The reproducible script ends with&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
End()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ready to experiment? Try some of the following:&lt;br /&gt;
  &lt;br /&gt;
#Run &amp;lt;tt&amp;gt;scons -c&amp;lt;/tt&amp;gt;. The &amp;lt;tt&amp;gt;-c&amp;lt;/tt&amp;gt; (clean) option tells SCons to remove all default targets (the &amp;lt;tt&amp;gt;Fig/lena.vpl&amp;lt;/tt&amp;gt; image file in our case) and also all intermediate targets that it generated.  &lt;br /&gt;
&amp;lt;pre&amp;gt; bash&amp;amp;#36; scons -c -Q &lt;br /&gt;
Removed lena.img &lt;br /&gt;
Removed lena.hdr &lt;br /&gt;
Removed lena.rsf &lt;br /&gt;
Removed /datapath/lena.rsf@ &lt;br /&gt;
Removed Fig/lena.vpl &lt;br /&gt;
&amp;lt;/pre&amp;gt; Run &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt; again, and the default target will be regenerated. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; scons -Q &lt;br /&gt;
retrieve([&amp;quot;lena.img&amp;quot;], []) &lt;br /&gt;
echo n1=512 n2=513 in=lena.img data_format=native_uchar &amp;gt; lena.hdr &lt;br /&gt;
&amp;lt; lena.hdr /RSF/bin/sfdd type=float | /RSF/bin/sfwindow f2=1 &amp;gt; lena.rsf &lt;br /&gt;
&amp;lt; lena.rsf /RSF/bin/sfgrey title=&amp;quot;Hello, World!&amp;quot; transp=n color=b  bias=128 clip=100 screenratio=1 &amp;gt; Fig/lena.vpl &amp;lt;/pre&amp;gt; &lt;br /&gt;
#Edit your &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file and change some of the plotting parameters. For example, change the value of &amp;lt;tt&amp;gt;clip&amp;lt;/tt&amp;gt; from &amp;lt;tt&amp;gt;clip=100&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;clip=50&amp;lt;/tt&amp;gt;. Run &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt; again and observe that only the last part of the processing flow (precisely, the part affected by the parameter change) is being run: &lt;br /&gt;
&amp;lt;pre&amp;gt; bash&amp;amp;#36; scons -Q view &lt;br /&gt;
&amp;lt; lena.rsf /RSF/bin/sfgrey title=&amp;quot;Hello, World!&amp;quot; transp=n color=b  bias=128 clip=50 screenratio=1 &amp;gt; Fig/lena.vpl &lt;br /&gt;
sfpen Fig/lena.vpl &lt;br /&gt;
&amp;lt;/pre&amp;gt; SCons is smart enough to recognize that your editing did not affect any of the previous results in the data flow chain! Keeping track of dependencies is the main feature that separates data processing and computational experimenting with SCons from using linear shell scripts. This feature can save you a lot of time for computationally demanding data processing and make your experiments more interactive and enjoyable. &lt;br /&gt;
#A special parameter to SCons (defined in &amp;lt;tt&amp;gt;rsfproj.py&amp;lt;/tt&amp;gt;) can time the execution of each step in the processing flow. Try running &amp;lt;tt&amp;gt;scons TIMER=y&amp;lt;/tt&amp;gt;. &lt;br /&gt;
#The &amp;lt;tt&amp;gt;rsfproj&amp;lt;/tt&amp;gt; module has direct access to the database that stores the parameters of all Madagascar modules. Try running &amp;lt;tt&amp;gt;scons CHECKPAR=y&amp;lt;/tt&amp;gt; to see parameter checking enforced before computations\footnote{This feature is new and experimental and may not work correctly yet}. &lt;br /&gt;
The summary of our SCons commands is given in the table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+SCons commands and options defined in &amp;lt;tt&amp;gt;rsfproj&amp;lt;/tt&amp;gt;.&lt;br /&gt;
|- &lt;br /&gt;
|style=&amp;quot;background-color:#ffdead;&amp;quot;| &#039;&#039;&#039;&amp;lt;tt&amp;gt;scons &amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;file&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;&amp;lt;/tt&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Generate &amp;lt;tt&amp;gt;&amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;file&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;&amp;lt;/tt&amp;gt; (usually requires &amp;lt;tt&amp;gt;.rsf&amp;lt;/tt&amp;gt; suffix for &amp;lt;tt&amp;gt;Flow&amp;lt;/tt&amp;gt; targets and &amp;lt;tt&amp;gt;.vpl&amp;lt;/tt&amp;gt; suffix for &amp;lt;tt&amp;gt;Plot&amp;lt;/tt&amp;gt; targets.)&lt;br /&gt;
|- &lt;br /&gt;
|style=&amp;quot;background-color:#ffdead;&amp;quot;| &#039;&#039;&#039;&amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Generate default targets (usually figures specified in &amp;lt;tt&amp;gt;Result&amp;lt;/tt&amp;gt;.) &lt;br /&gt;
|- &lt;br /&gt;
|style=&amp;quot;background-color:#ffdead;&amp;quot;| &#039;&#039;&#039;&amp;lt;tt&amp;gt;scons view&amp;lt;/tt&amp;gt;&#039;&#039;&#039; or &#039;&#039;&#039;&amp;lt;tt&amp;gt;scons &amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;result&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;.view&amp;lt;/tt&amp;gt; &#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Generate &amp;lt;tt&amp;gt;Result&amp;lt;/tt&amp;gt; figures and display them on the screen. &lt;br /&gt;
|- &lt;br /&gt;
|style=&amp;quot;background-color:#ffdead;&amp;quot;| &#039;&#039;&#039;&amp;lt;tt&amp;gt;scons print&amp;lt;/tt&amp;gt;&#039;&#039;&#039; or &#039;&#039;&#039;&amp;lt;tt&amp;gt;scons &amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;result&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;.print&amp;lt;/tt&amp;gt;&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| Generate &amp;lt;tt&amp;gt;Result&amp;lt;/tt&amp;gt; figures and print them. &lt;br /&gt;
|- &lt;br /&gt;
|style=&amp;quot;background-color:#ffdead;&amp;quot;| &#039;&#039;&#039;&amp;lt;tt&amp;gt;scons lock&amp;lt;/tt&amp;gt;&#039;&#039;&#039; or &#039;&#039;&#039;&amp;lt;tt&amp;gt;scons &amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;result&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;.lock&amp;lt;/tt&amp;gt; &#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| Generate &amp;lt;tt&amp;gt;Result&amp;lt;/tt&amp;gt; figures and install them in a separate location. &lt;br /&gt;
|- &lt;br /&gt;
|style=&amp;quot;background-color:#ffdead;&amp;quot;| &#039;&#039;&#039;&amp;lt;tt&amp;gt;scons test&amp;lt;/tt&amp;gt;&#039;&#039;&#039; or &#039;&#039;&#039;&amp;lt;tt&amp;gt;scons &amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;result&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;.test&amp;lt;/tt&amp;gt;&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| Generate &amp;lt;tt&amp;gt;Result&amp;lt;/tt&amp;gt; figures and compare them with the corresponding &amp;quot;locked&amp;quot; figures stored in a separate location (regression testing). &lt;br /&gt;
|- &lt;br /&gt;
|style=&amp;quot;background-color:#ffdead;&amp;quot;| &#039;&#039;&#039;&amp;lt;tt&amp;gt;scons &amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;result&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;.flip&amp;lt;/tt&amp;gt;&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| Generate the &amp;lt;tt&amp;gt;&amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;result&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;&amp;lt;/tt&amp;gt; figure and compare it with the corresponding &amp;quot;locked&amp;quot; figure stored in a separate location by flipping between the two figures on the screen. &lt;br /&gt;
|- &lt;br /&gt;
|style=&amp;quot;background-color:#ffdead;&amp;quot;| &#039;&#039;&#039;&amp;lt;tt&amp;gt;scons TIMER=y ...&amp;lt;/tt&amp;gt; &#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| Time the execution of each step in the processing flow (using the Unix &amp;lt;tt&amp;gt;time&amp;lt;/tt&amp;gt; utility.) &lt;br /&gt;
|- &lt;br /&gt;
|style=&amp;quot;background-color:#ffdead;&amp;quot;| &#039;&#039;&#039;&amp;lt;tt&amp;gt;scons CHECKPAR=y ...&amp;lt;/tt&amp;gt; &#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| Check the names and values of all parameters supplied to Madagascar modules in the processing flow before executing anything (guards against incorrect input.) This option is new and experimental.  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Example 2===&lt;br /&gt;
&lt;br /&gt;
The plan for this experiment is to add random noise to the test&lt;br /&gt;
&amp;quot;Lena&amp;quot; image and then attempt removing it by low-pass filtering&lt;br /&gt;
and hard thresholding of coefficients in the Fourier domain. The&lt;br /&gt;
resultant images are shown in the figures.&lt;br /&gt;
&lt;br /&gt;
[[Image:panel1.png|frame|center|Top left: original image. Top right: random noise added. Bottom left: original image spectrum in the Fourier (&amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;-&amp;lt;math&amp;gt;X&amp;lt;/math&amp;gt;) domain. Bottom right: noisy image spectrum in the Fourier (&amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;-&amp;lt;math&amp;gt;X&amp;lt;/math&amp;gt;) domain.]]&lt;br /&gt;
&lt;br /&gt;
[[Image:panel2.png|frame|center|Left: denoising by low-pass filtering.  Right: denoising by hard thresholding in the Fourier domain.]]&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;tt&amp;gt;SConstruct|&amp;lt;/tt&amp;gt; file is a Python script, we can also use all the&lt;br /&gt;
flexibility and power of the Python language in our Madagascar&lt;br /&gt;
reproducible scripts. A demo script is available in the&lt;br /&gt;
&amp;lt;tt&amp;gt;rsf/scons/rsfpy&amp;lt;/tt&amp;gt; subdirectory of the Madagascar &amp;lt;tt&amp;gt;book&amp;lt;/tt&amp;gt;&lt;br /&gt;
directory. Rather than commenting on it line-by-line, we select some&lt;br /&gt;
parts of interest.&lt;br /&gt;
In the &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; script, we can declare&lt;br /&gt;
Python variables&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
bias = 128&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and use them later, for example, to define our customized plot&lt;br /&gt;
command as a Python function&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
def grey(title,transp=&#039;n&#039;,bias=bias):&lt;br /&gt;
    return &#039;&#039;&#039;&lt;br /&gt;
    sfgrey title=&amp;quot;%s&amp;quot; transp=%s bias=%g clip=100&lt;br /&gt;
    screenht=10 screenwd=10 crowd2=0.85 crowd1=0.8&lt;br /&gt;
    label1= label2= &lt;br /&gt;
    &#039;&#039;&#039; % (title,transp,bias)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This Python function, named &amp;lt;tt&amp;gt;grey()&amp;lt;/tt&amp;gt;, can then be called in Plot or Result&lt;br /&gt;
commands, e.g.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
Plot(&#039;lplena&#039;,grey(&#039;Noisy Lena LP filtered&#039;))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can define a Python dictionary, e.g.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
titles = {&#039;lena&#039;:&#039;Lena&#039;,&lt;br /&gt;
          &#039;nlena&#039;:&#039;Noisy Lena&#039;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
and loop over its entries, e.g.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
for name in titles.keys():&lt;br /&gt;
    Plot(name,grey(titles[name]) )&lt;br /&gt;
    cftitle = titles[name]+&#039; in FX domain&#039;&lt;br /&gt;
    Flow(&#039;fx&#039;+name,name,&#039;sfspectra&#039;)&lt;br /&gt;
    Plot(&#039;fx&#039;+name,grey(cftitle,&#039;y&#039;,100))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note that the title of the plots is obtained by concatenating Python&lt;br /&gt;
strings.&lt;br /&gt;
Python strings can also be used to define sequences of commands used&lt;br /&gt;
in several Flows, e.g.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# 2-D FFT&lt;br /&gt;
fft2 = &#039;sffft1 sym=y | sffft3 sym=y&#039;&lt;br /&gt;
Flow(&#039;fnlena&#039;,&#039;nlena&#039;,fft2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, in our Madagascar reproducible script, we may want the option&lt;br /&gt;
to pass command line arguments when running SCons or use default&lt;br /&gt;
values otherwise, e.g.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# denoising using thresholding in the Fourier domain&lt;br /&gt;
fthr = float(ARGUMENTS.get(&#039;fthr&#039;, 70))&lt;br /&gt;
Flow(&#039;fthrlena&#039;,&#039;fnlena&#039;,&#039;sfthr thr=%f mode=&amp;quot;hard&amp;quot;&#039; % fthr)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt; only, the default value set for fthr (i.e. 70)&lt;br /&gt;
is used whereas running &amp;lt;tt&amp;gt;scons fthr=68&amp;lt;/tt&amp;gt; set fthr to a command&lt;br /&gt;
line specified value.&lt;br /&gt;
This is by no means an exhaustive list of options, but hopefully, it&lt;br /&gt;
will give you a flavor of the powerful tool you have in your hands. Enjoy!&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
===Useful SCons commands for reproducible scripts===&lt;br /&gt;
On top of SCons standard options (&amp;lt;tt&amp;gt;scons --help&amp;lt;/tt&amp;gt; for more&lt;br /&gt;
details), Madagascar has its own SCons options. We already saw&lt;br /&gt;
&amp;lt;tt&amp;gt;scons plot.view&amp;lt;/tt&amp;gt; that displays &amp;lt;tt&amp;gt;plot.vpl&amp;lt;/tt&amp;gt; (in the&lt;br /&gt;
&amp;lt;tt&amp;gt;Fig&amp;lt;/tt&amp;gt; folder) obtained in a Result command. &amp;lt;tt&amp;gt;scons view&amp;lt;/tt&amp;gt;&lt;br /&gt;
displays the result plots one after the other.&lt;br /&gt;
It is also possible to check the parameters for Madagascar programs in&lt;br /&gt;
SCons Flow commands using the CHECKPAR option (\texttt{scons&lt;br /&gt;
CHECKPAR=y target}). Note that CHECKPAR is an experimental option&lt;br /&gt;
and will be enhanced in the future to include parameter ranges and&lt;br /&gt;
other safety checks.&lt;br /&gt;
To time the execution of processing flows in a SConstruct, use the&lt;br /&gt;
TIMER option (&amp;lt;tt&amp;gt;scons TIMER=y target&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&amp;lt;tt&amp;gt;scons lock&amp;lt;/tt&amp;gt; is used to secure result plots and copy them from&lt;br /&gt;
the &amp;lt;tt&amp;gt;Fig&amp;lt;/tt&amp;gt; folder of your working directory to your&lt;br /&gt;
&amp;lt;tt&amp;gt;&amp;amp;#36;RSFFIGS&amp;lt;/tt&amp;gt; folder where &amp;lt;tt&amp;gt;RSFFIGS&amp;lt;/tt&amp;gt; is the environmental&lt;br /&gt;
variable to the directory where you want Madagascar to put your key&lt;br /&gt;
Madagascar result plots. Note that this is a necessary step before&lt;br /&gt;
creating reproducible documentation. &amp;lt;tt&amp;gt;scons plot.flip&amp;lt;/tt&amp;gt; runs&lt;br /&gt;
&amp;lt;tt&amp;gt;xtpen Fig/plot.vpl /locked/figures/plot.vpl&amp;lt;/tt&amp;gt; to flip between&lt;br /&gt;
the new and locked figure. This is useful when detecting changes.&lt;br /&gt;
 --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Creating reproducible documentation==&lt;br /&gt;
&lt;br /&gt;
You are done with computational experiments and want to communicate&lt;br /&gt;
them in a paper. SCons helps us create high-quality papers where&lt;br /&gt;
computational results (figures) are integrated with papers written in&lt;br /&gt;
L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX\. &lt;br /&gt;
The corresponding SCons extension is defined in  &amp;lt;tt&amp;gt;&amp;amp;#36;PYTHONPATH/rsf/tex.py&amp;lt;/tt&amp;gt; where&lt;br /&gt;
&amp;lt;tt&amp;gt;RSFROOT&amp;lt;/tt&amp;gt; is the environmental variable to the Madagascar&lt;br /&gt;
installation directory. The source of this file is in&lt;br /&gt;
[http://sourceforge.net/p/rsf/code/HEAD/tree/trunk/framework/rsf/tex.py framework/rsf/tex.py].&lt;br /&gt;
We summarize the basic methods and commands in the tables.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+Basic methods of an &amp;lt;tt&amp;gt;rsf.tex&amp;lt;/tt&amp;gt; object.&lt;br /&gt;
|- &lt;br /&gt;
|style=&amp;quot;background-color:#ffdead;&amp;quot;| &#039;&#039;&#039;&amp;lt;tt&amp;gt;Paper(paper_name,[,lclass][,use][,include][,options])&amp;lt;/tt&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| A rule to compile &amp;lt;tt&amp;gt;&amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;paper_name&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;.tex&amp;lt;/tt&amp;gt; L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX\ document using the L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX2e class specified in &amp;lt;tt&amp;gt;lclass&amp;lt;/tt&amp;gt; (default is &amp;lt;tt&amp;gt;geophysics.cls&amp;lt;/tt&amp;gt; from the [[SEGTeX]] package) with additional options specified in &amp;lt;tt&amp;gt;options&amp;lt;/tt&amp;gt;,  additional packages specified in &amp;lt;tt&amp;gt;use&amp;lt;/tt&amp;gt;, and additional preamble specified in &amp;lt;tt&amp;gt;include&amp;lt;/tt&amp;gt;. &lt;br /&gt;
|- &lt;br /&gt;
|style=&amp;quot;background-color:#ffdead;&amp;quot;| &#039;&#039;&#039;&amp;lt;tt&amp;gt;End()&amp;lt;/tt&amp;gt; &#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| A rule to collect default targets (referring to &amp;lt;tt&amp;gt;paper.tex&amp;lt;/tt&amp;gt; document).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+SCons commands defined in &amp;lt;tt&amp;gt;rsftex&amp;lt;/tt&amp;gt;.&lt;br /&gt;
|- &lt;br /&gt;
|style=&amp;quot;background-color:#ffdead;&amp;quot;| &#039;&#039;&#039;&amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Generate the default target (usually the PDF file &amp;lt;tt&amp;gt;paper.pdf&amp;lt;/tt&amp;gt; from the source L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX file &amp;lt;tt&amp;gt;paper.tex&amp;lt;/tt&amp;gt;.) &lt;br /&gt;
|- &lt;br /&gt;
|style=&amp;quot;background-color:#ffdead;&amp;quot;| &#039;&#039;&#039;&amp;lt;tt&amp;gt;scons pdf&amp;lt;/tt&amp;gt;&#039;&#039;&#039; or &#039;&#039;&#039;&amp;lt;tt&amp;gt;scons &amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;paper_name&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;.pdf&amp;lt;/tt&amp;gt; &#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Generate PDF files from L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX sources &amp;lt;tt&amp;gt;paper.tex&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;&amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;paper_name&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;.tex&amp;lt;/tt&amp;gt;. &lt;br /&gt;
|- &lt;br /&gt;
|style=&amp;quot;background-color:#ffdead;&amp;quot;| &#039;&#039;&#039;&amp;lt;tt&amp;gt;scons read&amp;lt;/tt&amp;gt;&#039;&#039;&#039; or &#039;&#039;&#039;&amp;lt;tt&amp;gt;scons &amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;paper_name&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;.read&amp;lt;/tt&amp;gt; &#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Generate PDF files from L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX sources &amp;lt;tt&amp;gt;paper.tex&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;&amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;paper_name&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;.tex&amp;lt;/tt&amp;gt; and display them on the screen. &lt;br /&gt;
|- &lt;br /&gt;
|style=&amp;quot;background-color:#ffdead;&amp;quot;| &#039;&#039;&#039;&amp;lt;tt&amp;gt;scons print&amp;lt;/tt&amp;gt;&#039;&#039;&#039; or &#039;&#039;&#039;&amp;lt;tt&amp;gt;scons &amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;paper_name&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;.print&amp;lt;/tt&amp;gt; &#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Generate PDF files from L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX sources &amp;lt;tt&amp;gt;paper.tex&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;&amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;paper_name&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;.tex&amp;lt;/tt&amp;gt; and print them. &lt;br /&gt;
|- &lt;br /&gt;
|style=&amp;quot;background-color:#ffdead;&amp;quot;| &#039;&#039;&#039;&amp;lt;tt&amp;gt;scons html&amp;lt;/tt&amp;gt;&#039;&#039;&#039; or &#039;&#039;&#039;&amp;lt;tt&amp;gt;scons &amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;paper_name&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;.html&amp;lt;/tt&amp;gt; &#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Generate HTML files from L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX sources &amp;lt;tt&amp;gt;paper.tex&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;&amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;paper_name&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;.tex&amp;lt;/tt&amp;gt; using L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEXtoHTML. The directory &amp;lt;tt&amp;gt;&amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;paper_name&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;_html&amp;lt;/tt&amp;gt; gets created. &lt;br /&gt;
|- &lt;br /&gt;
|style=&amp;quot;background-color:#ffdead;&amp;quot;| &#039;&#039;&#039;&amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt;&#039;&#039;&#039; or &#039;&#039;&#039;&amp;lt;tt&amp;gt;scons &amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;paper_name&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;.install&amp;lt;/tt&amp;gt; &#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Generate PDF and HTML files from L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX sources &amp;lt;tt&amp;gt;paper.tex&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;&amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;paper_name&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;.tex&amp;lt;/tt&amp;gt; and install them in a separate location (used for publishing on a web site).&lt;br /&gt;
|- &lt;br /&gt;
|style=&amp;quot;background-color:#ffdead;&amp;quot;| &#039;&#039;&#039;&amp;lt;tt&amp;gt;scons wiki&amp;lt;/tt&amp;gt;&#039;&#039;&#039; or &#039;&#039;&#039;&amp;lt;tt&amp;gt;scons &amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;paper_name&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;.wiki&amp;lt;/tt&amp;gt; &#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Convert L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX sources &amp;lt;tt&amp;gt;paper.tex&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;&amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;paper_name&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;.tex&amp;lt;/tt&amp;gt; to the &amp;lt;tt&amp;gt;MediaWiki&amp;lt;/tt&amp;gt; format (used for publishing on a Wiki web site). &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
A Madagascar reproducible paper is a paper written in L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX and&lt;br /&gt;
whose figures are either generated by Madagascar reproducible scripts&lt;br /&gt;
or available for download, e.g., this paper!  (&amp;lt;tt&amp;gt;paper.tex&amp;lt;/tt&amp;gt;&lt;br /&gt;
available in the &amp;lt;tt&amp;gt;rsf/scons/&amp;lt;/tt&amp;gt; directory of Madagascar book&lt;br /&gt;
section).&lt;br /&gt;
&lt;br /&gt;
The main SConstruct command set in our reproducible research&lt;br /&gt;
environment and related to documentation is&lt;br /&gt;
&lt;br /&gt;
This command is defined in &amp;lt;tt&amp;gt;&amp;amp;#36;PYTHONPATH/rsf/tex.py&amp;lt;/tt&amp;gt;.&lt;br /&gt;
 --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
This paper by itself is an example of a reproducible document. It is&lt;br /&gt;
generated using the following &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file which is place&lt;br /&gt;
in the directory above the projects directories.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from rsf.tex import *&lt;br /&gt;
Paper(&#039;velan&#039;,use=&#039;hyperref,listings,color&#039;)&lt;br /&gt;
End(use=&#039;hyperref,listings,color&#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; generates this paper, but it can also compile&lt;br /&gt;
&amp;lt;tt&amp;gt;velan.tex&amp;lt;/tt&amp;gt; in the same directory. Note that there is no&lt;br /&gt;
&amp;lt;tt&amp;gt;Paper&amp;lt;/tt&amp;gt; command for &amp;lt;tt&amp;gt;paper.tex&amp;lt;/tt&amp;gt; since it is the default&lt;br /&gt;
documentation name. Optional L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX packages and style used in&lt;br /&gt;
&amp;lt;tt&amp;gt;paper.tex&amp;lt;/tt&amp;gt; are passed in the End command.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s now take a closer look at &amp;lt;tt&amp;gt;paper.tex&amp;lt;/tt&amp;gt; to understand how&lt;br /&gt;
the figures of the documentation are linked to the reproducible&lt;br /&gt;
scripts that created them. First of all, note that &amp;lt;tt&amp;gt;paper.tex&amp;lt;/tt&amp;gt;&lt;br /&gt;
is not a regular L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX document but only its body (no&lt;br /&gt;
&amp;lt;math&amp;gt;\backslash&amp;lt;/math&amp;gt;documentclass, &amp;lt;math&amp;gt;\backslash&amp;lt;/math&amp;gt;usepackage, etc.). In our&lt;br /&gt;
paper, the first figure was created in the project folder&lt;br /&gt;
&amp;lt;tt&amp;gt;easystart&amp;lt;/tt&amp;gt; (sub-folder of our documentation folder) by the&lt;br /&gt;
resulting plot &amp;lt;tt&amp;gt;lena.vpl&amp;lt;/tt&amp;gt;. In the L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX source code, it&lt;br /&gt;
translates as&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;latex&amp;quot;&amp;gt;&lt;br /&gt;
\inputdir{easystart} &lt;br /&gt;
\sideplot{lena}{height=.25\textheight}{The output of the first numerical experiment.}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\backslash&amp;lt;/math&amp;gt;inputdir command points to the project directory and&lt;br /&gt;
the &amp;lt;math&amp;gt;\backslash&amp;lt;/math&amp;gt;sideplot command calls &amp;lt;tt&amp;gt;&amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;result_name&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;&amp;lt;/tt&amp;gt;. The&lt;br /&gt;
L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX tag of the figure is &amp;lt;tt&amp;gt;fig:&amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;result_name&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;&amp;lt;/tt&amp;gt;. The&lt;br /&gt;
first time the paper is compiled, the result file is automatically&lt;br /&gt;
converted to PDF format. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
===Useful SCons commands for reproducible documentation===&lt;br /&gt;
&lt;br /&gt;
To compile this paper, you first need to run and lock the&lt;br /&gt;
&amp;lt;tt&amp;gt;easystart&amp;lt;/tt&amp;gt; project. Go in the &amp;lt;tt&amp;gt;easystart&amp;lt;/tt&amp;gt; folder and&lt;br /&gt;
run &amp;lt;tt&amp;gt;scons lock&amp;lt;/tt&amp;gt;. Go back to the documentation folder and run&lt;br /&gt;
&amp;lt;tt&amp;gt;scons pdf&amp;lt;/tt&amp;gt; (alternatively \texttt{scons&lt;br /&gt;
  &amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;paper_name&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;.pdf}). Use &amp;lt;tt&amp;gt;scons read&amp;lt;/tt&amp;gt; (alternatively&lt;br /&gt;
&amp;lt;tt&amp;gt;scons &amp;lt;math&amp;gt;&amp;lt;&amp;lt;/math&amp;gt;paper_name&amp;lt;math&amp;gt;&amp;gt;&amp;lt;/math&amp;gt;.read&amp;lt;/tt&amp;gt;) or your favorite PDF reader to&lt;br /&gt;
read this paper reproduced by yourself...&lt;br /&gt;
 --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Fomels</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Guide_to_RSF_file_format&amp;diff=5420</id>
		<title>Guide to RSF file format</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Guide_to_RSF_file_format&amp;diff=5420"/>
		<updated>2024-11-20T19:58:19Z</updated>

		<summary type="html">&lt;p&gt;Fomels: typos&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 [https://github.com/ahay/src/blob/master/book/rsf/rsf/format.tex book/rsf/rsf/format.tex] using [[latex2wiki]]&#039;&#039;&amp;lt;/font&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:Fotolia_9592362_XS.jpg|right|]]&lt;br /&gt;
&lt;br /&gt;
==Principles==&lt;br /&gt;
The main design principle behind the RSF data format is [http://en.wikipedia.org/wiki/KISS_principle KISS] (&amp;quot;Keep It&lt;br /&gt;
Short and Simple&amp;quot;). The RSF format is borrowed from the SEPlib data format&lt;br /&gt;
initially designed at the Stanford Exploration Project&lt;br /&gt;
(Claerbout, 1991&amp;lt;ref&amp;gt;Claerbout, J. F.,  1991, Introduction to Seplib and SEP utility software,  &#039;&#039;in&#039;&#039; SEP-70,  413--436. Stanford Exploration Project.&amp;lt;/ref&amp;gt;). The format is made as simple as possible for maximum convenience, transparency, and flexibility.&lt;br /&gt;
According to the Unix tradition, standard file formats should be in a readable&lt;br /&gt;
textual form to be easily examined and processed with universal&lt;br /&gt;
tools. Raymond (2004&amp;lt;ref&amp;gt;Raymond, E. S.,  2004, The art of UNIX programming: Addison-Wesley.&amp;lt;/ref&amp;gt;) writes:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
To design a perfect anti-Unix, make all file formats binary and opaque and&lt;br /&gt;
require heavyweight tools to read and edit them.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
If you feel an urge to design a complex binary file format or a complex&lt;br /&gt;
binary application protocol, it is generally wise to lie down until the&lt;br /&gt;
feeling passes.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
Storing large-scale datasets in a text format may not be economical. RSF&lt;br /&gt;
chooses the next best thing: it allows data values to be stored in a binary&lt;br /&gt;
format but puts all data attributes in text files that humans can read&lt;br /&gt;
and processed with universal text-processing utilities.&lt;br /&gt;
===Example===&lt;br /&gt;
Let us first create some synthetic RSF data.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=1000 output=&#039;sin(0.5*x1)&#039; &amp;gt; sin.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Open and read the file &amp;lt;tt&amp;gt;sin.rsf&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ cat sin.rsf&lt;br /&gt;
sfmath  rsf/rsf/rsftour:        fomels@egl      Sun Jul 31 07:18:48 2005&lt;br /&gt;
&lt;br /&gt;
        o1=0&lt;br /&gt;
        data_format=&amp;quot;native_float&amp;quot;&lt;br /&gt;
        esize=4&lt;br /&gt;
        in=&amp;quot;/tmp/sin.rsf@&amp;quot;&lt;br /&gt;
        x1=0&lt;br /&gt;
        d1=1&lt;br /&gt;
        n1=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The file contains nine lines with simple, readable text. The first line&lt;br /&gt;
shows the name of the program, the working directory, the user, and&lt;br /&gt;
computer that created the file and the time it was created (that&lt;br /&gt;
information is recorded for accounting purposes). Other lines contain&lt;br /&gt;
parameter-value pairs separated by the &amp;quot;=&amp;quot; sign. The &amp;quot;in&amp;quot;&lt;br /&gt;
parameter points to the location of the binary data. Before we discuss the meaning of parameters in more detail, let us plot the data.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; sin.rsf  sfwiggle title=&#039;One Trace&#039; | sfpen&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You should see a plot similar to the figure below on your screen.&lt;br /&gt;
[[Image:sin1.png|frame|center|An example sinusoid plot.]]&lt;br /&gt;
Suppose you want to reformat the data so that instead of one trace of a thousand samples, it contains twenty traces with fifty samples each. Try&lt;br /&gt;
running&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; sin.rsf sed &#039;s/n1=1000/n1=50 n2=20/&#039; &amp;gt; sin10.rsf &lt;br /&gt;
bash$ &amp;lt; sin10.rsf sfwiggle title=Traces | sfpen&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or (using pipes)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; sin.rsf sed &#039;s/n1=1000/n1=50 n2=20/&#039; | sfwiggle title=Traces | sfpen&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On your screen, you should see a plot similar to the figure below:&lt;br /&gt;
[[Image:sin2.png|frame|center|An example sinusoid plot, with data reformatted to twenty traces.]]&lt;br /&gt;
What happened? We used &amp;lt;tt&amp;gt;sed&amp;lt;/tt&amp;gt;, a standard Unix line editing utility, to&lt;br /&gt;
change the parameters describing the data dimensions. Because of the&lt;br /&gt;
simplicity of this operation, there is no need to create specialized data&lt;br /&gt;
formatting tools or to make the &amp;lt;tt&amp;gt;sfwiggle&amp;lt;/tt&amp;gt; program accept additional&lt;br /&gt;
formatting parameters. Other general-purpose Unix tools that can be applied on&lt;br /&gt;
RSF files include &amp;lt;tt&amp;gt;cat&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;grep&amp;lt;/tt&amp;gt;, etc. &lt;br /&gt;
An alternative way to obtain the previous result is to run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ ( cat sin.rsf; echo n1=50 n2=20 ) &amp;gt; sin10.rsf &lt;br /&gt;
bash$ &amp;lt; sin10.rsf sfwiggle title=Traces | sfpen&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this case, the &amp;lt;tt&amp;gt;cat&amp;lt;/tt&amp;gt; utility copies the contents of the&lt;br /&gt;
previous file, and the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; utility appends a new line &amp;quot;&amp;lt;tt&amp;gt;n1=50&lt;br /&gt;
n2=20&amp;lt;/tt&amp;gt;&amp;quot;. A new value of the &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; parameter overwrites the old value&lt;br /&gt;
of &amp;lt;tt&amp;gt;n1=1000&amp;lt;/tt&amp;gt;, and we achieve the same result as before.&lt;br /&gt;
Of course, one could also edit the file by hand with one of the general-purpose text editors. For recording the history of data processing, it is&lt;br /&gt;
usually preferable to be able to process files with non-interactive tools.&lt;br /&gt;
&lt;br /&gt;
==Header and Data files==&lt;br /&gt;
A simple way to check the layout of an RSF file is with the &amp;lt;tt&amp;gt;sfin&amp;lt;/tt&amp;gt;&lt;br /&gt;
program.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfin sin10.rsf&lt;br /&gt;
sin10.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/sin.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=50          d1=1           o1=0&lt;br /&gt;
    n2=20          d2=?           o2=?&lt;br /&gt;
        1000 elements 4000 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The program reports the following information: the location of the data file&lt;br /&gt;
(&amp;lt;tt&amp;gt;/tmp/sin.rsf\@&amp;lt;/tt&amp;gt;), the element size (4 bytes), the element&lt;br /&gt;
type (floating point), the element form (native), the hypercube dimensions&lt;br /&gt;
(&amp;lt;math&amp;gt;50 \times 20&amp;lt;/math&amp;gt;), axis scaling (1 and unspecified), and axis origin (0 and&lt;br /&gt;
unspecified). It also checks the total number of elements and bytes in the&lt;br /&gt;
data file.&lt;br /&gt;
Let us examine this information in detail. First, we can verify that the data&lt;br /&gt;
file exists and contains the specified number of bytes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ ls -l /tmp/sin.rsf@&lt;br /&gt;
-rw-r--r--  1 sergey users 4000 2004-10-04 00:35 /tmp/sin.rsf@&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
4000 bytes in this file are required to store &amp;lt;math&amp;gt;50 \times 20&amp;lt;/math&amp;gt; floating-point&lt;br /&gt;
4-byte numbers in a binary form. Thus, the data file contains only the&lt;br /&gt;
raw data in a contiguous binary form.&lt;br /&gt;
===Datapath===&lt;br /&gt;
How did the RSF program (&amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt;) decide where to put the data file?&lt;br /&gt;
In the order of priority, the rules for selecting the data file name and the&lt;br /&gt;
data file directory are as follows:&lt;br /&gt;
  &lt;br /&gt;
#Check &amp;lt;tt&amp;gt;--out=&amp;lt;/tt&amp;gt; parameter on the command line. The parameter specifies the output data file location explicitly. &lt;br /&gt;
#Specify the path and the file name separately.    &lt;br /&gt;
#*The rules for the path selection are:   &lt;br /&gt;
#*#Check &amp;lt;tt&amp;gt;datapath=&amp;lt;/tt&amp;gt; parameter on the command line. The parameter specifies a string to prepend to the file name. The string may contain the file directory. &lt;br /&gt;
#*#Check &amp;lt;tt&amp;gt;DATAPATH&amp;lt;/tt&amp;gt; environmental variable. It has the same meaning as the parameter specified with &amp;lt;tt&amp;gt;datapath=&amp;lt;/tt&amp;gt;. &lt;br /&gt;
#*#Check for &amp;lt;tt&amp;gt;.datapath&amp;lt;/tt&amp;gt; file in the current directory. The file may contain a line  &amp;lt;pre&amp;gt; datapath=/path/to_file/ &amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt; machine_name datapath=/path/to_file/ &amp;lt;/pre&amp;gt; if you intend to use different paths on different platforms. &lt;br /&gt;
#*#Check for &amp;lt;tt&amp;gt;.datapath&amp;lt;/tt&amp;gt; file in the user&#039;s home directory. &lt;br /&gt;
#*#Put the data file in the current directory (similar to &amp;lt;tt&amp;gt;datapath=./&amp;lt;/tt&amp;gt;). &lt;br /&gt;
#*: &lt;br /&gt;
#*The rules for the filename selection are:   &lt;br /&gt;
#*#If the output RSF file is in the current directory, the name of the data file is made by appending \@. &lt;br /&gt;
#*#If the output file is not in the current directory or is created temporarily by a program, the name is made by appending random characters to the program&#039;s name and selected to be unique. &lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=10 --out=test1 &amp;gt; spike.rsf &lt;br /&gt;
bash$ grep in spike.rsf         &lt;br /&gt;
in=&amp;quot;test1&amp;quot; &lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=10 datapath=/tmp/ &amp;gt; spike.rsf &lt;br /&gt;
bash$ grep in spike.rsf         &lt;br /&gt;
in=&amp;quot;/tmp/spike.rsf@&amp;quot; &lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ DATAPATH=/tmp/ sfspike n1=10 &amp;gt; spike.rsf &lt;br /&gt;
bash$ grep in spike.rsf         &lt;br /&gt;
in=&amp;quot;/tmp/spike.rsf@&amp;quot; &lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=10 datapath=/tmp/ &amp;gt; /tmp/spike.rsf &lt;br /&gt;
bash$ grep in /tmp/spike.rsf &lt;br /&gt;
in=&amp;quot;/tmp/sfspikejcARVf&amp;quot; &lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
====Packing header and data together====&lt;br /&gt;
While the header and data files are separated by default, it is also possible&lt;br /&gt;
to pack them together into one file. To do that, specify the program&#039;s&lt;br /&gt;
&amp;quot;&amp;lt;tt&amp;gt;--out&amp;lt;/tt&amp;gt;&amp;quot; parameter as &amp;lt;tt&amp;gt;--out=stdout&amp;lt;/tt&amp;gt;. Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=10 --out=stdout &amp;gt; spike.rsf&lt;br /&gt;
bash$ grep in spike.rsf&lt;br /&gt;
Binary file spike.rsf matches&lt;br /&gt;
bash$ sfin spike.rsf&lt;br /&gt;
spike.rsf:&lt;br /&gt;
    in=&amp;quot;stdin&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$ ls -l spike.rsf&lt;br /&gt;
-rw-r--r--  1 sergey users 196 2004-11-10 21:39 spike.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you examine the contents of &amp;lt;tt&amp;gt;spike.rsf&amp;lt;/tt&amp;gt;, you will find that it&lt;br /&gt;
starts with the text header information, followed by special&lt;br /&gt;
symbols, followed by binary data. &lt;br /&gt;
Packing headers and data together may not be a good idea for data processing, but it works well for storing data: it is easier to move the packed file&lt;br /&gt;
around than to move two different files (header and binary) together while&lt;br /&gt;
remembering to preserve their connection. Packing the header and data together is also the current mechanism used to push RSF files through Unix pipes.&lt;br /&gt;
&lt;br /&gt;
===Type===&lt;br /&gt;
The data stored with RSF can have different types: character, unsigned&lt;br /&gt;
character, integer, floating point, or complex. By default, single precision&lt;br /&gt;
is used for numbers (&amp;lt;tt&amp;gt;int&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;float&amp;lt;/tt&amp;gt; data types in the C&lt;br /&gt;
programming language), but double precision and other&lt;br /&gt;
integer types (&amp;lt;tt&amp;gt;short&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;long&amp;lt;/tt&amp;gt;) are also&lt;br /&gt;
supported. The number of bytes required to represent these&lt;br /&gt;
numbers may depend on the platform.&lt;br /&gt;
===Form===&lt;br /&gt;
The data stored with RSF can also be in different forms: ASCII, native&lt;br /&gt;
binary, and XDR binary. Native binary is often used by default. It is the&lt;br /&gt;
binary format employed by the machine running the application. On&lt;br /&gt;
Linux-running PC, the native binary format will typically correspond to the&lt;br /&gt;
so-called little-endian byte ordering. On some other platforms, it might be&lt;br /&gt;
big-endian ordering. XDR is a binary format designed by Sun for exchanging&lt;br /&gt;
files over the network. It typically corresponds to big-endian byte ordering. It&lt;br /&gt;
is more efficient to process RSF files in the native binary format, but storing the corresponding file in an XDR format might be a good idea if you intend to access data from different platforms. RSF also allows for an ASCII&lt;br /&gt;
(plain text) form of data files. &lt;br /&gt;
Conversion between different types and forms is accomplished with&lt;br /&gt;
&amp;lt;tt&amp;gt;sfdd&amp;lt;/tt&amp;gt; program. Here are some examples. First, let us create synthetic data.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=10 output=&#039;10*sin(0.5*x1)&#039; &amp;gt; sin.rsf&lt;br /&gt;
bash$ sfin sin.rsf&lt;br /&gt;
sin.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/sin.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=10          d1=1           o1=0&lt;br /&gt;
        10 elements 40 bytes&lt;br /&gt;
bash$ &amp;lt; sin.rsf sfdisfil&lt;br /&gt;
   0:             0        4.794        8.415        9.975        9.093&lt;br /&gt;
   5:         5.985        1.411       -3.508       -7.568       -9.775&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Converting the data to the integer type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; sin.rsf sfdd type=int &amp;gt; isin.rsf&lt;br /&gt;
bash$ sfin isin.rsf&lt;br /&gt;
isin.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/isin.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=int form=native&lt;br /&gt;
    n1=10          d1=1           o1=0&lt;br /&gt;
        10 elements 40 bytes&lt;br /&gt;
bash$ &amp;lt; isin.rsf sfdisfil&lt;br /&gt;
   0:    0    4    8    9    9    5    1   -3   -7   -9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Converting the data to the ASCII form:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; sin.rsf sfdd form=ascii &amp;gt; asin.rsf&lt;br /&gt;
bash$ &amp;lt; asin.rsf sfdisfil&lt;br /&gt;
   0:             0        4.794        8.415        9.975        9.093&lt;br /&gt;
   5:         5.985        1.411       -3.508       -7.568       -9.775&lt;br /&gt;
bash$ sfin asin.rsf&lt;br /&gt;
asin.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/asin.rsf@&amp;quot;&lt;br /&gt;
    esize=0 type=float form=ascii&lt;br /&gt;
    n1=10          d1=1           o1=0&lt;br /&gt;
        10 elements&lt;br /&gt;
bash$ cat /tmp/asin.rsf@&lt;br /&gt;
0 4.79426 8.41471 9.97495 9.09297 5.98472 1.4112 -3.50783&lt;br /&gt;
-7.56803 -9.7753&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Hypercube===&lt;br /&gt;
While RSF stores binary data in a contiguous 1-D array, the conceptual&lt;br /&gt;
data model is a multidimensional hypercube. By convention, the&lt;br /&gt;
dimensions of the cube are defined with parameters &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc. The fastest axis is &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Additionally, the grid sampling can be given by parameters&lt;br /&gt;
&amp;lt;tt&amp;gt;d1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;d2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;d3&amp;lt;/tt&amp;gt;, etc. The axes origins are given&lt;br /&gt;
by parameters &amp;lt;tt&amp;gt;o1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;o2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;o3&amp;lt;/tt&amp;gt;, etc. Optionally,&lt;br /&gt;
you can also supply the axis label strings: &amp;lt;tt&amp;gt;label1&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;label2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;label3&amp;lt;/tt&amp;gt;, etc., and axis units strings:&lt;br /&gt;
&amp;lt;tt&amp;gt;unit1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;unit2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;unit3&amp;lt;/tt&amp;gt;, etc. &lt;br /&gt;
==Compatibility with other file formats==&lt;br /&gt;
It is possible to exchange RSF-formatted data with several other popular data formats.&lt;br /&gt;
===Compatibility with SEPlib===&lt;br /&gt;
RSF is mostly compatible with its predecessor, the SEPlib file format.&lt;br /&gt;
However, there are several significant differences:&lt;br /&gt;
  &lt;br /&gt;
#SEPlib programs typically use the element size (&amp;lt;tt&amp;gt;esize=&amp;lt;/tt&amp;gt; parameter) to distinguish between different data types: &amp;lt;tt&amp;gt;esize=4&amp;lt;/tt&amp;gt; corresponds to floating point data, while &amp;lt;tt&amp;gt;esize=8&amp;lt;/tt&amp;gt; corresponds to complex data. The RSF type handling mechanism is different: data types are determined from the value of the &amp;lt;tt&amp;gt;data_format&amp;lt;/tt&amp;gt; parameter. Madagascar computational programs typically output files with &amp;lt;tt&amp;gt;data_format=&amp;quot;native_float&amp;quot;&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;native_complex&amp;lt;/tt&amp;gt;.&lt;br /&gt;
#The default data form in SEPlib programs is typically XDR and not native as it is in RSF. Thus, to make a dataset created with SEPlib readable by Madagascar programs, you would typically need to add to the history file &amp;lt;tt&amp;gt;data_format=&amp;quot;xdr_float&amp;quot;&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;data_format=&amp;quot;xdr_complex&amp;quot;&amp;lt;/tt&amp;gt; . &amp;lt;ref group=&amp;quot;note&amp;quot;&amp;gt;For SEPlib 6.5.3 and older: Note that xdr_complex is not a valid SEPlib value, so for datasets of complex numbers encoded as pairs of floats, a dataset cannot be at the same time valid in both SEPlib and Madagascar. A valid SEPlib dataset will have esize=8 and data_format=&amp;quot;xdr_float&amp;quot;, but sfin will show it as having &amp;quot;200% of expected&amp;quot; data. Adding data_format=&amp;quot;xdr_complex&amp;quot; to such a dataset will make sfin work as expected, but SEPlib&#039;s In or In3d will give a segmentation fault because of an unknown data type. To patch SEPlib to accept &amp;lt;tt&amp;gt;native_complex&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;xdr_complex&amp;lt;/tt&amp;gt; data, the following changes must be made:&lt;br /&gt;
* In &amp;lt;tt&amp;gt;$SEPSRC/seplib_base/lib/corelibs/sep/strformats.c&amp;lt;/tt&amp;gt;:&lt;br /&gt;
** Add &amp;quot;xdr_complex&amp;quot; and &amp;quot;native_complex&amp;quot; to the str_fmt_names structure&lt;br /&gt;
** Set FMT_LENGTH to 15&lt;br /&gt;
* In &amp;lt;tt&amp;gt;$SEPSRC/seplib_base/lib/corelibs/include/strformats.h&amp;lt;/tt&amp;gt;:&lt;br /&gt;
** Add preprocessor directives to define FMT_XDR_COMPLEX as 8 and FMT_NATIVE_COMPLEX as 9&lt;br /&gt;
** Set NUM_FMT to 10&lt;br /&gt;
&amp;lt;/ref&amp;gt;&lt;br /&gt;
#It is possible to pipe the output of Madagascar programs to SEPlib: &amp;lt;pre&amp;gt;bash$ sfspike n1=1 | Attr want=min&amp;lt;/pre&amp;gt; (output should be: &amp;lt;tt&amp;gt;minimum value = 1 at 1&amp;lt;/tt&amp;gt;). However, piping the output of SEPlib programs to RSF (or, for that matter, any other non-SEPlib programs) will result in an unterminated process. For example, the command &amp;lt;pre&amp;gt; bash$ Spike n1=1 | sfattr want=min &amp;lt;/pre&amp;gt; will hang. This is because SEPlib uses sockets for piping and expects a socket connection from the receiving program, while Madagascar passes data through regular Unix pipes. &lt;br /&gt;
#SEP3D is an extension of SEPlib for operating with irregularly sampled data (Biondi et al., 1996&amp;lt;ref&amp;gt;Biondi, B., R. Clapp, and S. Crawley,  1996, SEPlib90: SEPlib for 3-D  prestack data, &#039;&#039;in&#039;&#039; SEP-92,  343--364. Stanford Exploration Project.&amp;lt;/ref&amp;gt;). There is no equivalent of it in RSF for the reasons explained at the beginning of this guide. Operations with irregular datasets are supported using auxiliary input files representing the geometry information.&lt;br /&gt;
&lt;br /&gt;
;Notes&lt;br /&gt;
&amp;lt;references group=&amp;quot;note&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Reading and writing SEG-Y and SU files===&lt;br /&gt;
The SEG-Y format is based on the proposal of Barry et al. (1975&amp;lt;ref&amp;gt;[http://www.seg.org/SEGportalWEBproject/prod/SEG-Publications/Pub-Technical-Standards/Documents/seg_y_rev0.pdf Barry, K. M., D. A. Cavers, and C. W. Kneale,  1975, Report on recommended standards for digital tape formats: Geophysics, &#039;&#039;&#039;40&#039;&#039;&#039;, 344--352]&amp;lt;/ref&amp;gt;).&lt;br /&gt;
It was revised in 2002&amp;lt;ref&amp;gt;See http://www.seg.org/SEGportalWEBproject/prod/SEG-Publications/Pub-Technical-Standards/Documents/seg_y_rev1.pdf&amp;lt;/ref&amp;gt;. The&lt;br /&gt;
SU format is a modification of SEG-Y used in Seismic Unix&lt;br /&gt;
(Stockwell, 1997&amp;lt;ref&amp;gt;Stockwell, J. W.,  1997, Free software in education: A case study of  CWP/SU: Seismic Unix: The Leading Edge, &#039;&#039;&#039;16&#039;&#039;&#039;, 1045--1049.&amp;lt;/ref&amp;gt;).&lt;br /&gt;
To convert files from SEG-Y or SU format to RSF, use the &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt;&lt;br /&gt;
program. Let us first manufacture an example file using SU utilities&lt;br /&gt;
(Stockwell, 1999&amp;lt;ref&amp;gt;-------- 1999, The CWP/SU: Seismic Un*x package: Computers and  Geosciences, &#039;&#039;&#039;25&#039;&#039;&#039;, 415--419.&amp;lt;/ref&amp;gt;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ suplane &amp;gt; plane.su&lt;br /&gt;
bash$ segyhdrs &amp;lt; plane.su | segywrite tape=plane.segy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To convert it to RSF, use either&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfsuread &amp;lt; plane.su tfile=tfile.rsf endian=0 &amp;gt; plane.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$ sfsegyread &amp;lt; plane.segy tfile=tfile.rsf \&lt;br /&gt;
hfile=file.asc bfile=file.bin &amp;gt; plane.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The endian flag is needed if the SU file originated from a little-endian machine like a Linux PC.&lt;br /&gt;
Several files are generated. The standard output contains an RSF file with the&lt;br /&gt;
data (32 traces with 64 samples each):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfin plane.rsf&lt;br /&gt;
plane.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/plane.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=64          d1=0.004       o1=0&lt;br /&gt;
    n2=32          d2=?           o2=?&lt;br /&gt;
        2048 elements 8192 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The contents of this file are displayed in the figure.&lt;br /&gt;
[[Image:plane.png|frame|center|The output of suplane, converted to RSF and&lt;br /&gt;
displayed with &amp;lt;tt&amp;gt;sfwiggle&amp;lt;/tt&amp;gt;.]]&lt;br /&gt;
The &amp;lt;tt&amp;gt;tfile&amp;lt;/tt&amp;gt; is an RSF integer-type file with the trace headers (32&lt;br /&gt;
headers with 71 traces each):&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;
The contents of trace headers can be quickly examined with the &lt;br /&gt;
&amp;lt;tt&amp;gt;sfheaderattr&amp;lt;/tt&amp;gt; program.&lt;br /&gt;
The &amp;lt;tt&amp;gt;file.asc&amp;lt;/tt&amp;gt; is the ASCII header file for the whole record.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ head -c 242 file.asc&lt;br /&gt;
C      This tape was made at the&lt;br /&gt;
C                                                                              &lt;br /&gt;
C      Center for Wave Phenomena                         &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The  &amp;lt;tt&amp;gt;file.bin&amp;lt;/tt&amp;gt; is the binary header file.&lt;br /&gt;
&lt;br /&gt;
To convert files back from RSF to SEG-Y or SU, use the &amp;lt;tt&amp;gt;sfsegywrite&amp;lt;/tt&amp;gt;&lt;br /&gt;
program and reverse the input and output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfsuwrite &amp;gt; plane.su tfile=tfile.rsf endian=0 &amp;lt; plane.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$ sfsegywrite &amp;gt; plane.segy tfile=tfile.rsf \&lt;br /&gt;
hfile=file.asc bfile=file.bin &amp;lt; plane.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;tt&amp;gt;hfile=&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;bfile=&amp;lt;/tt&amp;gt; are not supplied to &amp;lt;tt&amp;gt;sfsegywrite&amp;lt;/tt&amp;gt;, the corresponding headers will be generated on the fly. The trace header file can be generated with &amp;lt;tt&amp;gt;sfsegyheader&amp;lt;/tt&amp;gt;. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfheadermath &amp;lt; plane.rsf output=N+1 | sfdd type=int &amp;gt; tracl.rsf&lt;br /&gt;
bash$ sfsegyheader &amp;lt; plane.rsf tracl=tracl.rsf &amp;gt; tfile.rsf&lt;br /&gt;
bash$ sfsegywrite  &amp;lt; plane.rsf tfile=tfile.rsf &amp;gt; plane.segy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Unusual trace header keys====&lt;br /&gt;
Sometimes, SEG-Y files deviate from the standard by creating additional&lt;br /&gt;
trace header keys. If, for example, you find out that the SEG-Y file&lt;br /&gt;
contains an additional trace header key stored in bytes 225-226, you can either remap one of the standard two-byte keys&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfsegyread &amp;lt; file.segy tfile=tfile.rsf gut=224 &amp;gt; file.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or create a new key&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfsegyread &amp;lt; file.segy tfile=tfile.rsf \&lt;br /&gt;
key1=mykey key1_len=2 mykey=224 &amp;gt; file.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Any number of additional keys can be created this way.&lt;br /&gt;
&lt;br /&gt;
===Reading and writing ASCII files===&lt;br /&gt;
Reading and writing ASCII files can be accomplished with the &amp;lt;tt&amp;gt;sfdd&amp;lt;/tt&amp;gt;&lt;br /&gt;
program. For example, let us take an ASCII file with numbers&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ cat file.asc&lt;br /&gt;
1.0 1.5 3.0&lt;br /&gt;
4.8 9.1 7.3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Converting it to RSF is as simple as&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ echo in=file.asc n1=3 n2=2 data_format=ascii_float &amp;gt; file.rsf&lt;br /&gt;
bash$ sfin file.rsf&lt;br /&gt;
file.rsf:&lt;br /&gt;
    in=&amp;quot;file.asc&amp;quot;&lt;br /&gt;
    esize=0 type=float form=ascii&lt;br /&gt;
    n1=3           d1=?           o1=?&lt;br /&gt;
    n2=2           d2=?           o2=?&lt;br /&gt;
        6 elements&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
For more efficient input/output operations, it might be advantageous to&lt;br /&gt;
convert the data type to native binary, as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ echo in=file.asc n1=3 n2=2 data_format=ascii_float | \&lt;br /&gt;
sfdd form=native &amp;gt; file.rsf&lt;br /&gt;
bash$ sfin file.rsf&lt;br /&gt;
file.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/file.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=3           d1=?           o1=?&lt;br /&gt;
    n2=2           d2=?           o2=?&lt;br /&gt;
        6 elements 24 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Converting from RSF to ASCII is equally simple:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfdd form=ascii --out=file.asc &amp;lt; file.rsf &amp;gt; /dev/null&lt;br /&gt;
bash$ cat file.asc&lt;br /&gt;
1 1.5 3 4.8 9.1 7.3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can use the &amp;lt;tt&amp;gt;line=&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;format=&amp;lt;/tt&amp;gt; parameters in&lt;br /&gt;
&amp;lt;tt&amp;gt;sfdd&amp;lt;/tt&amp;gt; to control the ASCII formatting:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfdd form=ascii --out=file.asc \&lt;br /&gt;
line=3 format=&amp;quot;%3.1f &amp;quot; &amp;lt; file.rsf &amp;gt; /dev/null&lt;br /&gt;
bash$ cat file.asc&lt;br /&gt;
1.0 1.5 3.0&lt;br /&gt;
4.8 9.1 7.3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An alternative is to use &amp;lt;tt&amp;gt;sfdisfil&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfdisfil &amp;gt; file.asc col=3 format=&amp;quot;%3.1f &amp;quot; number=n &amp;lt; file.rsf&lt;br /&gt;
bash$ cat file.asc&lt;br /&gt;
1.0 1.5 3.0&lt;br /&gt;
4.8 9.1 7.3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Reading and writing CSV files===&lt;br /&gt;
CSV (Comma-separated values) is a particular example of an ASCII&lt;br /&gt;
format, where commas separate values on different rows or&lt;br /&gt;
other symbols. To convert from CSV to RSF, you can use the&lt;br /&gt;
&amp;lt;tt&amp;gt;sfcsv2rsf&amp;lt;/tt&amp;gt; utility.&lt;br /&gt;
For example, let us take an ASCII file with numbers separated by commas&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; cat file.csv&lt;br /&gt;
1.0,1.5,3.0&lt;br /&gt;
4.8,9.1,7.3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Converting it to RSF:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfcsv2rsf &amp;lt; file.csv &amp;gt; file.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin file.rsf&lt;br /&gt;
file.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/file.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=3           d1=1           o1=0          label1=&amp;quot;unknown&amp;quot; unit1=&amp;quot;unknown&amp;quot; &lt;br /&gt;
    n2=2           d2=1           o2=0          label2=&amp;quot;unknown&amp;quot; unit2=&amp;quot;unknown&amp;quot; &lt;br /&gt;
	6 elements 24 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To convert from RSF to CSV, we can use formatting parameters in &amp;lt;tt&amp;gt;sfdd&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfdd form=ascii --out=file.csv \&lt;br /&gt;
line=3 strip=1 format=&amp;quot;%3.1f,&amp;quot; &amp;lt; file.rsf &amp;gt;/dev/null&lt;br /&gt;
bash&amp;amp;#36; cat file.csv&lt;br /&gt;
1.0,1.5,3.0&lt;br /&gt;
4.8,9.1,7.3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Some CSV files contain headers with definitions for different columns.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; cat file.csv&lt;br /&gt;
height,width,weight&lt;br /&gt;
1.0,1.5,3.0&lt;br /&gt;
4.8,9.1,7.3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To read a file like that, use &amp;lt;tt&amp;gt;header=&amp;lt;/tt&amp;gt; parameter in &amp;lt;tt&amp;gt;sfcsv2rsf&amp;lt;/tt&amp;gt;, as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfcsv2rsf &amp;lt; file.csv header=y &amp;gt; file.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After that, different columns can be accessed by keywords.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; file.rsf sfheaderattr segy=n&lt;br /&gt;
3 headers, 2 traces&lt;br /&gt;
*******************************************************************************&lt;br /&gt;
     key                    min                       max                 mean&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
height      0              1 @ 0                   4.8 @ 1                 2.9&lt;br /&gt;
width       1            1.5 @ 0                   9.1 @ 1                 5.3&lt;br /&gt;
weight      2              3 @ 0                   7.3 @ 1                5.15&lt;br /&gt;
*******************************************************************************&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Reading LAS files===&lt;br /&gt;
LAS (Log ASCII Standard) is a text format used for storing&lt;br /&gt;
well-logging data (Heslop et al., 1999&amp;lt;ref&amp;gt;Heslop, K., J. Karst, S. Prensky, D. Schmitt, et al.,  1999, Log ASCII  standard LAS version 3.0: The Log Analyst, 40.&amp;lt;/ref&amp;gt;). LAS files can be converted to the RSF format using&lt;br /&gt;
&amp;lt;tt&amp;gt;sflas2rsf&amp;lt;/tt&amp;gt; utility.&lt;br /&gt;
Let us try an example file from one of the SEG tutorials:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; tutorials=https://raw.githubusercontent.com/seg/tutorials-2014/master&lt;br /&gt;
bash&amp;amp;#36; wget &amp;amp;#36;tutorials/1406_Make_a_synthetic/L-30.las&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Converting to RSF, we can detect 15 different logs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sflas2rsf L-30.las L-30.rsf&lt;br /&gt;
(base) sergey@DESKTOP-80QRDA0:~/all/fomels/nnint&amp;amp;#36; sfin L-30.rsf&lt;br /&gt;
L-30.rsf:&lt;br /&gt;
    in=&amp;quot;/home/sergey/RSFROOT/data/L-30.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=15          d1=?           o1=?&lt;br /&gt;
    n2=25621       d2=0.5         o2=1140&lt;br /&gt;
        384315 elements 1537260 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Individual logs are accessible by their keys and can be used in programs like &amp;lt;tt&amp;gt;sfheadermath&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; L-30.rsf sfheaderattr segy=n desc=y&lt;br /&gt;
15 headers, 25621 traces&lt;br /&gt;
*******************************************************************************&lt;br /&gt;
     key                    min                       max                 mean&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
DEPTH       0           1140 @ 0                 13950 @ 25620            7545&lt;br /&gt;
[Depth]&lt;br /&gt;
CALD        1           -999 @ 0                19.811 @ 3909         -140.356&lt;br /&gt;
[Caliper Caliper - Density]&lt;br /&gt;
CALS        2           -999 @ 0                 14.84 @ 23096         7.43849&lt;br /&gt;
[Caliper Caliper - Sonic]&lt;br /&gt;
DEPT        3           1140 @ 0                 13950 @ 25620            7545&lt;br /&gt;
[Depth]&lt;br /&gt;
DRHO        4           -999 @ 0                 0.254 @ 23667         -149.67&lt;br /&gt;
[Drho Delta Rho]&lt;br /&gt;
DT          5           -999 @ 0               199.263 @ 1462          90.0167&lt;br /&gt;
[Sonic Delta-T]&lt;br /&gt;
GRD         6           -999 @ 0               178.416 @ 21788        -100.952&lt;br /&gt;
[GammaRay Gamma Ray - Density]&lt;br /&gt;
GRS         7           -999 @ 0               140.148 @ 23376         53.8002&lt;br /&gt;
[GammaRay Gamma Ray - Sonic]&lt;br /&gt;
ILD         8           -999 @ 0               2022.95 @ 20            34.5917&lt;br /&gt;
[DeepRes Deep Induction Standard Processed Resistivity]&lt;br /&gt;
ILM         9           -999 @ 0               2196.26 @ 20661         40.5595&lt;br /&gt;
[MedRes Medium Induction Standard Processed Resistivity]&lt;br /&gt;
LL8        10           -999 @ 0               2097.76 @ 20213         35.6343&lt;br /&gt;
[ShalRes Latero-Log 8]&lt;br /&gt;
NPHILS     11           -999 @ 0                  0.45 @ 23039        -776.522&lt;br /&gt;
[Neutron Neutron Porosity - Ls Mtx]&lt;br /&gt;
NPHISS     12           -999 @ 0                 0.615 @ 5215         -373.244&lt;br /&gt;
[Neutron Neutron Porosity - Ss Mtx]&lt;br /&gt;
RHOB       13           -999 @ 0                 2.811 @ 23941        -147.773&lt;br /&gt;
[Density Bulk Density]&lt;br /&gt;
SP         14           -999 @ 0               -19.065 @ 20570        -105.029&lt;br /&gt;
[SP Spontaneous Potential]&lt;br /&gt;
*******************************************************************************&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; L-30.rsf sfheadermath output=RHOB segy=n &amp;gt; RHOB.rsf&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; RHOB.rsf sfwindow min2=4000 max2=13000 | sfgraph title=Density&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:rhob.png|frame|center|Density log.]]&lt;br /&gt;
&lt;br /&gt;
==Other documentation==&lt;br /&gt;
This note should give you a general understanding of the RSF file format. See the [[RSF Comprehensive Description]] if you want minutia. Other relevant documentation is: &lt;br /&gt;
  &lt;br /&gt;
*[[Why Madagascar]]&lt;br /&gt;
*[[Installation|Installation instructions]]&lt;br /&gt;
*[https://ahay.org/RSF/ Madagascar self-documentation] &lt;br /&gt;
*[[Guide to madagascar programs]]&lt;br /&gt;
*[[Guide to madagascar API|Guide to the Madagascar programming interface]]&lt;br /&gt;
*[[Guide to programming with madagascar]]&lt;br /&gt;
*[[Revisiting SEP tour with Madagascar and SCons]]&lt;br /&gt;
*[[Reproducible computational experiments using SCons]]&lt;br /&gt;
&lt;br /&gt;
==About this document==&lt;br /&gt;
This page was created from the LaTeX source in [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/book/rsf/rsf/format.tex?view=markup book/rsf/rsf/format.tex] using [[latex2wiki]].&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Fomels</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Programs_of_the_Month&amp;diff=5417</id>
		<title>Programs of the Month</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Programs_of_the_Month&amp;diff=5417"/>
		<updated>2024-11-20T18:53:37Z</updated>

		<summary type="html">&lt;p&gt;Fomels: https&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Randomly-selected Madagascar programs get featured every month on the [https://ahay.org/blog/ Madagascar blog]. This page provides a summary list with links.&lt;br /&gt;
&lt;br /&gt;
==2019==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;border:1px&amp;quot;&lt;br /&gt;
| August&lt;br /&gt;
| [https://ahay.org/blog/2019/08/10/program-of-the-month-sfsnr2/ sfsnr2]&lt;br /&gt;
| Compute signal-noise-ratio.&lt;br /&gt;
|-&lt;br /&gt;
| July&lt;br /&gt;
| [https://ahay.org/blog/2019/07/09/program-of-the-month-sflpf/ sflpf]&lt;br /&gt;
| Local prediction filter (n-dimensional).&lt;br /&gt;
|-&lt;br /&gt;
| June&lt;br /&gt;
| [https://ahay.org/blog/2019/06/12/program-of-the-month-sfslice/ sfslice]&lt;br /&gt;
| Extract a slice using picked surface.&lt;br /&gt;
|-&lt;br /&gt;
| May&lt;br /&gt;
| [https://ahay.org/blog/2019/05/06/program-of-the-month-sfzomig3/ sfzomig3]&lt;br /&gt;
| 3-D zero-offset modeling/migration with extended SSF.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==2017==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;border:1px&amp;quot;&lt;br /&gt;
| April&lt;br /&gt;
| [https://ahay.org/blog/2017/04/19/program-of-the-month-sfseislet/ sfseislet]&lt;br /&gt;
| Seislet transform.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==2016==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;border:1px&amp;quot;&lt;br /&gt;
| March&lt;br /&gt;
| [https://ahay.org/blog/2016/03/23/program-of-the-month-sflinear/ sflinear]&lt;br /&gt;
| 1-D linear interpolation.&lt;br /&gt;
|-&lt;br /&gt;
| February&lt;br /&gt;
| [https://ahay.org/blog/2016/02/18/program-of-the-month-sfmig2/ sfmig2]&lt;br /&gt;
| 2-D prestack Kirchhoff time migration with antialiasing. &lt;br /&gt;
|-&lt;br /&gt;
| January&lt;br /&gt;
| [https://ahay.org/blog/2016/01/16/program-of-the-month-sfsort/ sfsort]&lt;br /&gt;
| Sort a float/complex vector by absolute values.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==2015==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;border:1px&amp;quot;&lt;br /&gt;
| December&lt;br /&gt;
| [https://ahay.org/blog/2015/12/22/program-of-the-month-sfdivn/ sfdivn]&lt;br /&gt;
| Smooth division. &lt;br /&gt;
|-&lt;br /&gt;
| November&lt;br /&gt;
| [https://ahay.org/blog/2015/11/16/program-of-the-month-sfpldb-and-sfplas/ sfpldb and sfplas]&lt;br /&gt;
| Convert Vplot to ASCII; convert ASCII to Vplot&lt;br /&gt;
|-&lt;br /&gt;
| October&lt;br /&gt;
| [https://ahay.org/blog/2015/10/15/program-of-the-month-sfisolr2/ sfisolr2]&lt;br /&gt;
| Lowrank decomposition for 2-D isotropic wave propagation. &lt;br /&gt;
|-&lt;br /&gt;
| September&lt;br /&gt;
| [https://ahay.org/blog/2015/09/14/program-of-the-month-sfsimilarity/ sfsimilarity]&lt;br /&gt;
| Local similarity measure between two datasets. &lt;br /&gt;
|-&lt;br /&gt;
| July&lt;br /&gt;
| [https://ahay.org/blog/2015/07/10/program-of-the-month-sfmutter/ sfmutter]&lt;br /&gt;
| Muting.&lt;br /&gt;
|-&lt;br /&gt;
| June&lt;br /&gt;
| [https://ahay.org/blog/2015/06/10/program-of-the-month-sfintbin/ sfintbin]&lt;br /&gt;
| Data binning by trace sorting. &lt;br /&gt;
|-&lt;br /&gt;
| May&lt;br /&gt;
| [https://ahay.org/blog/2015/05/01/program-of-the-month-sfbox/ sfbox]&lt;br /&gt;
| Draw a balloon-style label.&lt;br /&gt;
|-&lt;br /&gt;
| April&lt;br /&gt;
| [https://ahay.org/blog/2015/04/21/program-of-the-month-sfslant/ sfslant] &lt;br /&gt;
| Time-space-domain Radon transform (slant stack).&lt;br /&gt;
|-&lt;br /&gt;
| March&lt;br /&gt;
| [https://ahay.org/blog/2015/03/04/program-of-the-month-sfgrey/ sfgrey]&lt;br /&gt;
| Generate raster plot.&lt;br /&gt;
|-&lt;br /&gt;
| February&lt;br /&gt;
| [https://ahay.org/blog/2015/03/01/program-of-the-month-sfhistogram/ sfhistogram]&lt;br /&gt;
| Compute a histogram of integer- or float-valued input data.&lt;br /&gt;
|-&lt;br /&gt;
| January&lt;br /&gt;
| [https://ahay.org/blog/2015/01/30/program-of-the-month-sfmf/ sfmf]&lt;br /&gt;
| 1D median filtering. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==2014==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;border:1px&amp;quot;&lt;br /&gt;
| December&lt;br /&gt;
| [https://ahay.org/blog/2014/12/01/program-of-the-month-sfbin/ sfbin]&lt;br /&gt;
| Data binning in 2-D slices. &lt;br /&gt;
|-&lt;br /&gt;
| November&lt;br /&gt;
| [https://ahay.org/blog/2014/11/12/program-of-the-month-sfthreshold/ sfthreshold]&lt;br /&gt;
| Soft thresholding. &lt;br /&gt;
|-&lt;br /&gt;
| October&lt;br /&gt;
| [https://ahay.org/blog/2014/10/08/program-of-the-month-sfsigmoid/ sfsigmoid]&lt;br /&gt;
| 2-D synthetic model from J.F.Claerbout. &lt;br /&gt;
|-&lt;br /&gt;
| September&lt;br /&gt;
| [https://ahay.org/blog/2014/09/24/program-of-the-month-sfmax1/ sfmax1]&lt;br /&gt;
| Picking local maxima on the first axis. &lt;br /&gt;
|-&lt;br /&gt;
| August&lt;br /&gt;
| [https://ahay.org/blog/2014/08/03/program-of-the-month-sfstolt/ sfstolt]&lt;br /&gt;
| Post-stack Stolt modeling/migration.&lt;br /&gt;
|-&lt;br /&gt;
| July&lt;br /&gt;
| [https://ahay.org/blog/2014/07/13/program-of-the-month-sfltft/ sfltft]&lt;br /&gt;
| Local time-frequency transform (LTFT). &lt;br /&gt;
|-&lt;br /&gt;
| June&lt;br /&gt;
| [https://ahay.org/blog/2014/06/11/program-of-the-month-sfeikonal/ sfeikonal]&lt;br /&gt;
| Fast marching eikonal solver (3-D).&lt;br /&gt;
|-&lt;br /&gt;
| May&lt;br /&gt;
| [https://ahay.org/blog/2014/05/13/program-of-the-month-sfhelicon/ sfhelicon]&lt;br /&gt;
| Multidimensional convolution and deconvolution by helix transform. &lt;br /&gt;
|-&lt;br /&gt;
| April&lt;br /&gt;
| [https://ahay.org/blog/2014/04/02/program-of-the-month-sfcostaper/ sfcostaper]&lt;br /&gt;
| Cosine taper around the borders (N-D). &lt;br /&gt;
|-&lt;br /&gt;
| March&lt;br /&gt;
| [https://ahay.org/blog/2014/03/11/program-of-the-month-sflpad/ sflpad]&lt;br /&gt;
| Pad and interleave traces.&lt;br /&gt;
|-&lt;br /&gt;
| February&lt;br /&gt;
| [https://ahay.org/blog/2014/02/06/program-of-the-month-sfdipfilter/ sfdipfilter]&lt;br /&gt;
| Filter data based on dip in 2-D or 3-D.&lt;br /&gt;
|-&lt;br /&gt;
| January&lt;br /&gt;
| [https://ahay.org/blog/2014/01/09/program-of-the-month-sfinttest1/ sfinttest1]&lt;br /&gt;
| Interpolation from a regular grid in 1-D. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==2013==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;border:1px&amp;quot;&lt;br /&gt;
| December&lt;br /&gt;
| [https://ahay.org/blog/2013/12/01/program-of-the-month-sfcausint/ sfcausint]&lt;br /&gt;
| Causal integration on the first axis. &lt;br /&gt;
|-&lt;br /&gt;
| November&lt;br /&gt;
| [https://ahay.org/blog/2013/11/03/program-of-the-month-sfremap1/ sfremap1]&lt;br /&gt;
| 1-D ENO interpolation. &lt;br /&gt;
|-&lt;br /&gt;
| October&lt;br /&gt;
| [https://ahay.org/blog/2013/10/03/program-of-the-month-sfunif2/ sfunif2]&lt;br /&gt;
| Generate 2-D layered velocity model from specified interfaces. &lt;br /&gt;
|-&lt;br /&gt;
| September&lt;br /&gt;
| [https://ahay.org/blog/2013/09/14/program-of-the-month-sfpatch/ sfpatch] &lt;br /&gt;
| Patching (N-dimensional).&lt;br /&gt;
|-&lt;br /&gt;
| August&lt;br /&gt;
| [https://www.ahay.org/blog/2013/08/02/program-of-the-month-sfai2refl/ sfai2refl]&lt;br /&gt;
| Convert acoustic impedance to reflectivity. &lt;br /&gt;
|-&lt;br /&gt;
| July&lt;br /&gt;
| [https://www.ahay.org/blog/2013/07/01/program-of-the-month-sftime2depth/ sftime2depth]&lt;br /&gt;
| Time-to-depth conversion in V(z). &lt;br /&gt;
|-&lt;br /&gt;
| June&lt;br /&gt;
| [https://www.ahay.org/blog/2013/06/12/program-of-the-month-sfwiggle/ sfwiggle]&lt;br /&gt;
| Plot data with wiggly traces. &lt;br /&gt;
|-&lt;br /&gt;
| May&lt;br /&gt;
| [https://www.ahay.org/blog/2013/05/04/program-of-the-month-sfvscan/ sfvscan]&lt;br /&gt;
| Velocity analysis.&lt;br /&gt;
|-&lt;br /&gt;
| April&lt;br /&gt;
| [https://ahay.org/blog/2013/04/08/program-of-the-month-sfnmo/ sfnmo]&lt;br /&gt;
| Normal moveout.&lt;br /&gt;
|-&lt;br /&gt;
| March&lt;br /&gt;
| [https://www.ahay.org/blog/2013/03/10/program-of-the-month-sfpow/ sfpow]&lt;br /&gt;
| Apply power gain. &lt;br /&gt;
|-&lt;br /&gt;
| February&lt;br /&gt;
| [https://ahay.org/blog/2013/02/09/program-of-the-month-sfpwd/ sfpwd] &lt;br /&gt;
| 3-D plane wave destruction.&lt;br /&gt;
|-&lt;br /&gt;
| January&lt;br /&gt;
| [https://ahay.org/blog/2013/01/08/program-of-the-month-sfricker1/ sfricker1]&lt;br /&gt;
| Convolution with a Ricker wavelet. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==2012==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;border:1px&amp;quot;&lt;br /&gt;
| December&lt;br /&gt;
| [https://ahay.org/blog/2012/12/23/program-of-the-month-sfhalfint/ sfhalfint]&lt;br /&gt;
| Half-order integration or differentiation. &lt;br /&gt;
|-&lt;br /&gt;
| November&lt;br /&gt;
| [https://ahay.org/blog/2012/11/03/program-of-the-month-sfbandpass/ sfbandpass]&lt;br /&gt;
| Bandpass filtering. &lt;br /&gt;
|-&lt;br /&gt;
| October &lt;br /&gt;
| [https://ahay.org/blog/2012/10/03/program-of-the-month-sfkirmod/ sfkirmod]&lt;br /&gt;
| Kirchhoff 2-D/2.5-D modeling with analytical Green&#039;s functions. &lt;br /&gt;
|-&lt;br /&gt;
| September&lt;br /&gt;
| [https://ahay.org/blog/2012/09/03/program-of-the-month-sfiwarp/ sfiwarp]&lt;br /&gt;
| Inverse 1-D warping.&lt;br /&gt;
|-&lt;br /&gt;
| August&lt;br /&gt;
| [https://ahay.org/blog/2012/08/01/program-of-the-month-sfpick/ sfpick]&lt;br /&gt;
| Automatic picking from semblance-like panels. &lt;br /&gt;
|-&lt;br /&gt;
| July&lt;br /&gt;
| [https://ahay.org/blog/2012/07/02/program-of-the-month-sffft3/ sffft3]&lt;br /&gt;
| FFT transform on extra axis.&lt;br /&gt;
|-&lt;br /&gt;
| June&lt;br /&gt;
| [https://ahay.org/blog/2012/06/02/program-of-the-month-sfdip/ sfdip]&lt;br /&gt;
| 3-D dip estimation by plane wave destruction. &lt;br /&gt;
|-&lt;br /&gt;
| May&lt;br /&gt;
| [https://ahay.org/blog/2012/05/01/program-of-the-month-sfderiv/ sfderiv]&lt;br /&gt;
| First derivative with a maximally linear FIR differentiator. &lt;br /&gt;
|-&lt;br /&gt;
| April&lt;br /&gt;
| [https://ahay.org/blog/2012/04/01/program-of-the-month-sfgrey3/ sfgrey3]&lt;br /&gt;
| Generate 3-D cube plot.&lt;br /&gt;
|-&lt;br /&gt;
| March&lt;br /&gt;
| [https://ahay.org/blog/2012/03/18/program-of-the-month-sfspectra/ sfspectra]&lt;br /&gt;
| Frequency spectra.&lt;br /&gt;
|-&lt;br /&gt;
| January&lt;br /&gt;
| [https://ahay.org/blog/2012/01/01/program-of-the-month-sfsmooth/ sfsmooth] &lt;br /&gt;
| Multi-dimensional triangle smoothing.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==2011==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;border:1px&amp;quot;&lt;br /&gt;
| December&lt;br /&gt;
| [https://ahay.org/blog/2011/12/03/programs-of-the-month-sfcontour/ sfcontour] &lt;br /&gt;
| Contour plot.&lt;br /&gt;
|-&lt;br /&gt;
| November&lt;br /&gt;
| [https://ahay.org/blog/2011/11/05/program-of-the-month-sfenvelope/ sfenvelope]&lt;br /&gt;
| Compute data envelope or phase rotation.&lt;br /&gt;
|-&lt;br /&gt;
| October&lt;br /&gt;
| [https://ahay.org/blog/2011/10/01/program-of-the-month-sfagc/ sfagc]&lt;br /&gt;
| Automatic gain control. &lt;br /&gt;
|-&lt;br /&gt;
| September&lt;br /&gt;
| [https://ahay.org/blog/2011/09/03/program-of-the-month-sfclip/ sfclip]&lt;br /&gt;
| Clip the data.&lt;br /&gt;
|-&lt;br /&gt;
| August&lt;br /&gt;
| [https://ahay.org/blog/2011/08/09/program-of-the-month-sfgraph/ sfgraph]&lt;br /&gt;
| Graph plot.&lt;br /&gt;
|-&lt;br /&gt;
| July&lt;br /&gt;
| [https://ahay.org/blog/2011/07/03/program-of-the-month-sfnoise/ sfnoise]&lt;br /&gt;
| Add random noise to the data.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Fomels</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Guide_to_madagascar_programs&amp;diff=5384</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=5384"/>
		<updated>2024-11-19T00:13:20Z</updated>

		<summary type="html">&lt;p&gt;Fomels: ahay.org&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 [https://github.com/ahay/src/blob/master/book/rsf/rsf/prog.tex 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 [https://github.com/ahay/src/blob/master/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 message is printed out if 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: [https://github.com/ahay/src/blob/master/system/main/add.c 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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;
        filename[0] = &amp;quot;in&amp;quot;;&lt;br /&gt;
	nin=1;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 is &amp;lt;tt&amp;gt;nin&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&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; /* not a file */&lt;br /&gt;
	filename[nin] = 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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we enter the main loop, where the 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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;/syntaxhighlight&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 lval=2 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 =      0.987576&amp;lt;br&amp;gt;2-norm =       9.92354&amp;lt;br&amp;gt;variance =    0.00955481&amp;lt;br&amp;gt;std dev =     0.0977487&amp;lt;br&amp;gt;max =       1.12735 at 97&amp;lt;br&amp;gt;min =      0.151392 at 100&amp;lt;br&amp;gt;nonzero samples = 100&amp;lt;br&amp;gt;total 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;, &amp;lt;br&amp;gt;       &#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; 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Implementation: [https://github.com/ahay/src/blob/master/system/main/attr.c 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;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
    dim = (size_t) sf_largefiledims (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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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_SHORT:&lt;br /&gt;
                sf_shortread((short*) 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The data attributes are accumulated in corresponding double-precision variables. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
	    fsum += f;&lt;br /&gt;
	    fsqr += (double) f*f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, the attributes are reduced and printed out.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&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 = fabs(fsqr-nsiz*fmean*fmean)/(nsiz-1);&lt;br /&gt;
    else          fvar = 0.0;&lt;br /&gt;
    fstd = sqrt(fvar);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
    if(NULL==want || 0==strcmp(want,&amp;quot;rms&amp;quot;))&lt;br /&gt;
	printf(&amp;quot;rms = %13.6g \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 = %13.6g \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 = %13.6g \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 = %13.6g \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 = %13.6g \n&amp;quot;,(float) fstd);&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 order= space= axis=3 nspace=(int) (ni/(20*nin) + 1) o= d= [&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;float  &#039;&#039; || &#039;&#039;&#039;d=&#039;&#039;&#039; ||   || 	axis sampling&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;float  &#039;&#039; || &#039;&#039;&#039;o=&#039;&#039;&#039; ||   || 	axis origin&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;ints   &#039;&#039; || &#039;&#039;&#039;order=&#039;&#039;&#039; ||   || 	concatenation order  [nin]&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;
&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: [https://github.com/ahay/src/blob/master/system/main/cat.c 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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;
	filename[0] = &amp;quot;in&amp;quot;;&lt;br /&gt;
	nin=1;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;
	filename[nin] = 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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the output, the selected axis will get extended.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;/syntaxhighlight&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 by taking advantage that the complex-to-complex FFT is a linear operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&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;lt; real.rsf &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: [https://github.com/ahay/src/blob/master/system/main/cmplx.c 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;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
    /* the first two non-parameters are real and imag 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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&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 mwt=mwt.rsf known=known.rsf x0=x0.rsf &amp;gt; to.rsf &amp;lt; from.rsf &amp;gt; out.rsf niter=1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;known=&#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;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;mwt=&#039;&#039;&#039; ||   || 	auxiliary input file name&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;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;x0=&#039;&#039;&#039; ||   || 	auxiliary input file name&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 [https://ahay.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 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 at all. The program [https://ahay.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; 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 addition to the input and output vectors. We create a helical  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 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 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 | 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;
The misfit decreased by an order of magnitude in 10 iterations. Running the program for more iterations can improve the result.&lt;br /&gt;
&lt;br /&gt;
An equivalent implementation for complex-valued inputs is [https://ahay.org/RSF/sfcconjgrad.html sfcconjgrad]. A lightweight Python implementation can be found in [https://github.com/ahay/src/blob/master/user/fomels/conjgrad.py $PYTHONPATH/rsf/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 &amp;lt; in.rsf &amp;gt; out.rsf 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: [https://github.com/ahay/src/blob/master/system/main/cp.c 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 input and the output files.  &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
    sf_cp(in,out);&lt;br /&gt;
    if (NULL != strstr (prog,&amp;quot;mv&amp;quot;)) &lt;br /&gt;
	sf_rm(infile,false,false,false);&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 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;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Reverse of window. &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;largeint&#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;verb=n&#039;&#039;&#039; ||  [y/n] || 	Verbosity flag&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 trunc=n line=8 ibm=n 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;bool   &#039;&#039; || &#039;&#039;&#039;ibm=n&#039;&#039;&#039; ||  [y/n] || 	Special case - assume integers actually represent IBM floats&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;bool   &#039;&#039; || &#039;&#039;&#039;trunc=n&#039;&#039;&#039; ||  [y/n] || 	Truncate or round to nearest when converting from float to int/short&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;type=&#039;&#039;&#039; ||   || 	int, float, complex, short, long&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 examine RSF files quickly. 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;
| &#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;
&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;
dimensions and size of these vectors! If the program does not respond&lt;br /&gt;
for a very long time, the dimension and size&lt;br /&gt;
of the vectors may be 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 has no restrictive&lt;br /&gt;
limitations on the size of the vectors.&lt;br /&gt;
Here is an example. We first create 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 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 parform=y all=n par1 par2 ...&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;all=n&#039;&#039;&#039; ||  [y/n] || 	If output all values.&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;
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: [https://github.com/ahay/src/blob/master/system/main/get.c 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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the parameter value (as a 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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;/syntaxhighlight&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;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;mask=&#039;&#039;&#039; ||   || 	auxiliary input file name&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;
==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 inv=n&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;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;inv=n&#039;&#039;&#039; ||  [y/n] || 	inversion flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;mask=&#039;&#039;&#039; ||   || 	auxiliary input file name&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 [&amp;lt;file0.rsf] 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sed -i &#039;s/n6=1//g&#039; file.rsf&lt;br /&gt;
&amp;lt;/syntaxhighlight&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= 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=&#039;&#039;&#039; ||   || 	maximum header value&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;min=&#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 nostdin=n n#= d#=(1,1,...) o#=(0,0,...) label#= unit#= type= label= unit= output=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Known functions: &amp;lt;br&amp;gt;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;erf,  erfc, sign (for float data),&amp;lt;br&amp;gt;arg,  conj, real, imag (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;Arguments which are not treated as variables in mathematical expressions:&amp;lt;br&amp;gt;datapath=, type=, out=&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;See also: sfheadermath.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d#=(1,1,...)&#039;&#039;&#039; ||   || 	sampling on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label=&#039;&#039;&#039; ||   || 	data label&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;largeint&#039;&#039; || &#039;&#039;&#039;n#=&#039;&#039;&#039; ||   || 	size of #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;nostdin=n&#039;&#039;&#039; ||  [y/n] || 	y - ignore stdin&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;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; ||   || 	data unit&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;
&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 files with the&lt;br /&gt;
same dimensions and data type. The data type can be real (floating&lt;br /&gt;
point) or complex. The following example 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;
Functions can be nested and combined, and variable names, as well as the &amp;lt;tt&amp;gt;input&amp;lt;/tt&amp;gt; keyword, may be combined with the axes keywords &amp;lt;tt&amp;gt;x1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;x2&amp;lt;/tt&amp;gt;, etc. Here is an example that shifts a wavelet -0.4s to t=0, computes the frequency-domain complex square root (equivalent to the convolutional square root in time), and shifts the result back to t=0.4s:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pi=3.14159265&lt;br /&gt;
tshift=0.4&lt;br /&gt;
&lt;br /&gt;
sfspike n1=256 k1=101 |\&lt;br /&gt;
sfbandpass flo=4 fhi=30 |\&lt;br /&gt;
sffft1 opt=n sym=y |\&lt;br /&gt;
sfmath output=&amp;quot;sqrt(input*exp(2*$pi*$tshift*x1*I))*exp(-2*$pi*$tshift*x1*I)&amp;quot; |\&lt;br /&gt;
sffft1 opt=n sym=y inv=y |\&lt;br /&gt;
sfgraph |\&lt;br /&gt;
sfpen&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&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 beg#=0 end#=0 n#=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;n#out is equivalent to n#, both of them overwrite end#.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Other parameters from the command line are passed to the output (similar to sfput).&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;beg#=0&#039;&#039;&#039; ||   || 	the number of zeros to add before the beginning of #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;end#=0&#039;&#039;&#039; ||   || 	the number of zeros to add after the end of #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n#=&#039;&#039;&#039; ||   || 	the output length of #-th axis - padding at the end&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfpad&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 [parameter=value list]&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 by editing the file 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 Madagascar 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;, and 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=n 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 pair=n&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;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;pair=n&#039;&#039;&#039; ||  [y/n] || 	y - use odd elements for the real part and even ones for the imaginary part&lt;br /&gt;
|}&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. pclip=100. 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.&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;pclip=100.&#039;&#039;&#039; ||   || 	data clip percentile&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;
&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 with &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;
==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;lt; in.rsf &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;
&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 axes:&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 scale= axis=2 rms=n norm=y min=n max=n prod=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. If axis=0, stack over all dimensions&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;prod=n&#039;&#039;&#039; ||  [y/n] || 	If y, find product instead of stack.  Ignores rms and norm.&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;
| &#039;&#039;floats &#039;&#039; || &#039;&#039;&#039;scale=&#039;&#039;&#039; ||   || 	optionally scale before stacking  [n2]&lt;br /&gt;
|}&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;tt&amp;gt;plane=&amp;lt;/tt&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;tt&amp;gt;memsize=&amp;lt;/tt&amp;gt; parameter or&lt;br /&gt;
the &amp;lt;tt&amp;gt;RSFMEMSIZE&amp;lt;/tt&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 a 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;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Other parameters from the command line are passed to the output (similar to sfput).&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;largeint&#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;largeint&#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 select a window from the minimum and maximum&lt;br /&gt;
parameters. 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://www.ahay.org/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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apply log-stretch FFT:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Compute the 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Prepare for 8-bit greyscale visualization:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt; spikeamo.rsf sfbyte pclip=100 gainpanel=a &amp;gt; spikebyte.rsf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Picture from the middle of the impulse response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Picture illustrating the artifacts (i.e. need for f-k filter):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apply the f-k filter and (in this case) visualize:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&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 identify meaningful keywords 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 helpful in&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;header&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;
An 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 their 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;tfile=&amp;lt;/tt&amp;gt; option. The user may remap these predefined keywords to 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 an 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 the name of the file in which the binary reel header (the 400-byte thing following the 3600-byte 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 an 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. The 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;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=d&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 mask samples is the same as the number of traces in the unmasked SEG-Y. There should be zeros in the mask in places corresponding to unwanted traces.&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 estimate automatically 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 &amp;lt;tt&amp;gt;tape=&amp;lt;/tt&amp;gt; tag specifies the output file.&lt;br /&gt;
=Generic programs=&lt;br /&gt;
Programs in this category are general signal and image processing programs. The source files for these programs can be found under [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/generic/ system/generic] in the Madagascar distribution.&lt;br /&gt;
==sfnoise==&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 random noise to the data.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfnoise &amp;lt; in.rsf &amp;gt; out.rsf seed=time(NULL) type=y var= range= mean=0 rep=n&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;mean=0&#039;&#039;&#039; ||   || 	noise mean&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;range=&#039;&#039;&#039; ||   || 	noise range (default=1)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;rep=n&#039;&#039;&#039; ||  [y/n] || 	if y, replace data with noise&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;seed=time(NULL)&#039;&#039;&#039; ||   || 	random seed&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;type=y&#039;&#039;&#039; ||  [y/n] || 	noise distribution, y: normal, n: uniform&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;var=&#039;&#039;&#039; ||   || 	noise variance&lt;br /&gt;
|}&lt;br /&gt;
See the [http://www.ahay.org/rsflog/index.php?/archives/262-Program-of-the-month-sfnoise.html Program of the Month] blog entry.&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 [https://ahay.org/blog/2005/03/28/color-schemes/ color schemes] are available&lt;br /&gt;
for sfgrey and sfgrey3. Examples are in the book at [https://ahay.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 [https://ahay.org/blog/2005/03/28/color-schemes/ color schemes] are available, and examples are in the book at [https://ahay.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 like &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 [https://ahay.org/wikilocal/movies/sfplsurf_membrane.mpg movie of the output] is available as well.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&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;/syntaxhighlight&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 aperture (gate= parameter in sfpick) limits the search radius.&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;
Many people have discovered and rediscovered the algorithm. 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 the 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 follows below. First, create an input file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&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 in length:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&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 transposed on disk:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Depending on your needs, you may want to run the output through &amp;lt;tt&amp;gt;sftransp&amp;lt;/tt&amp;gt;. 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that since this program does not need any arguments (just stdin and stdout), it will not display the man page when called with no arguments. 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 the &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 are different, files in Fig that are missing from Lock, and files in 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;
==sfawefd2d==&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;
Below, we will demonstrate an example of a model with nx=nz=200 and dx=dz=4m (size: 800x800m). There are two layers: the first 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. The 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;ol&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Velocity model:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Density model:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Source position (x,z):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Receiver position (x,z):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Source wavelet:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Creating data at specified receiver + saving full wavefield every 10th step:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;View the wavefield movie:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt; Fwfl.rsf sfgrey gainpanel=a pclip=99 color=j scalebar=y | sfpen&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;View a wavefield snapshot:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;View the data recorded at the receiver:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&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 it should be 5 or so for reasonable results. 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 [https://ahay.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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt; tdata.rsf sfdd type=float &amp;gt; trchdr.rsf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Shot positions:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
Extract offset positions from the trace header files, eliminate length-1 axis, scale, and create a header for binning (required by &amp;lt;tt&amp;gt;sfintbin&amp;lt;/tt&amp;gt;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
Binning and muting:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&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. The receiver and shot frequency slices are &amp;quot;placed&amp;quot; at the right location and padded with zeros up to the x-axis dimension specified below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt; swav.rsf sftransp plane=12 | sftransp plane=23 &amp;gt; stra.rsf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt; rwav.rsf sftransp plane=12 | sftransp plane=23 &amp;gt; rtra.rsf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This creates a surface receiver wavefield ready for input to migration. Axis 4 is the 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 that of the whole 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&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 an RSF file with the name of the tag and no rsf extension will be created:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
The migration of 20 shots takes approximately three 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;img.rsf sfwindow squeeze=y | sftransp | sfgrey &amp;gt; img.vpl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Fomels</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Guide_to_madagascar_programs&amp;diff=5301</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=5301"/>
		<updated>2024-11-13T23:35:42Z</updated>

		<summary type="html">&lt;p&gt;Fomels: typos&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 [https://github.com/ahay/src/blob/master/book/rsf/rsf/prog.tex 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 [https://github.com/ahay/src/blob/master/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 message is printed out if 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: [https://github.com/ahay/src/blob/master/system/main/add.c 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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;
        filename[0] = &amp;quot;in&amp;quot;;&lt;br /&gt;
	nin=1;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 is &amp;lt;tt&amp;gt;nin&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&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; /* not a file */&lt;br /&gt;
	filename[nin] = 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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we enter the main loop, where the 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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;/syntaxhighlight&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 lval=2 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 =      0.987576&amp;lt;br&amp;gt;2-norm =       9.92354&amp;lt;br&amp;gt;variance =    0.00955481&amp;lt;br&amp;gt;std dev =     0.0977487&amp;lt;br&amp;gt;max =       1.12735 at 97&amp;lt;br&amp;gt;min =      0.151392 at 100&amp;lt;br&amp;gt;nonzero samples = 100&amp;lt;br&amp;gt;total 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;, &amp;lt;br&amp;gt;       &#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; 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Implementation: [https://github.com/ahay/src/blob/master/system/main/attr.c 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;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
    dim = (size_t) sf_largefiledims (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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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_SHORT:&lt;br /&gt;
                sf_shortread((short*) 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The data attributes are accumulated in corresponding double-precision variables. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
	    fsum += f;&lt;br /&gt;
	    fsqr += (double) f*f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, the attributes are reduced and printed out.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&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 = fabs(fsqr-nsiz*fmean*fmean)/(nsiz-1);&lt;br /&gt;
    else          fvar = 0.0;&lt;br /&gt;
    fstd = sqrt(fvar);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
    if(NULL==want || 0==strcmp(want,&amp;quot;rms&amp;quot;))&lt;br /&gt;
	printf(&amp;quot;rms = %13.6g \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 = %13.6g \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 = %13.6g \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 = %13.6g \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 = %13.6g \n&amp;quot;,(float) fstd);&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 order= space= axis=3 nspace=(int) (ni/(20*nin) + 1) o= d= [&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;float  &#039;&#039; || &#039;&#039;&#039;d=&#039;&#039;&#039; ||   || 	axis sampling&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;float  &#039;&#039; || &#039;&#039;&#039;o=&#039;&#039;&#039; ||   || 	axis origin&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;ints   &#039;&#039; || &#039;&#039;&#039;order=&#039;&#039;&#039; ||   || 	concatenation order  [nin]&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;
&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: [https://github.com/ahay/src/blob/master/system/main/cat.c 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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;
	filename[0] = &amp;quot;in&amp;quot;;&lt;br /&gt;
	nin=1;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;
	filename[nin] = 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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the output, the selected axis will get extended.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;/syntaxhighlight&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 by taking advantage that the complex-to-complex FFT is a linear operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&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;lt; real.rsf &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: [https://github.com/ahay/src/blob/master/system/main/cmplx.c 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;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
    /* the first two non-parameters are real and imag 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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&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 mwt=mwt.rsf known=known.rsf x0=x0.rsf &amp;gt; to.rsf &amp;lt; from.rsf &amp;gt; out.rsf niter=1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;known=&#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;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;mwt=&#039;&#039;&#039; ||   || 	auxiliary input file name&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;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;x0=&#039;&#039;&#039; ||   || 	auxiliary input file name&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 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 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; 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 addition to the input and output vectors. We create a helical  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 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 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 | 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;
The misfit decreased by an order of magnitude in 10 iterations. Running the program for more iterations can improve the result.&lt;br /&gt;
&lt;br /&gt;
An equivalent implementation for complex-valued inputs is [http://www.reproducibility.org/RSF/sfcconjgrad.html sfcconjgrad]. A lightweight Python implementation can be found in [https://github.com/ahay/src/blob/master/user/fomels/conjgrad.py $PYTHONPATH/rsf/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 &amp;lt; in.rsf &amp;gt; out.rsf 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: [https://github.com/ahay/src/blob/master/system/main/cp.c 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 input and the output files.  &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
    sf_cp(in,out);&lt;br /&gt;
    if (NULL != strstr (prog,&amp;quot;mv&amp;quot;)) &lt;br /&gt;
	sf_rm(infile,false,false,false);&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 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;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Reverse of window. &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;largeint&#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;verb=n&#039;&#039;&#039; ||  [y/n] || 	Verbosity flag&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 trunc=n line=8 ibm=n 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;bool   &#039;&#039; || &#039;&#039;&#039;ibm=n&#039;&#039;&#039; ||  [y/n] || 	Special case - assume integers actually represent IBM floats&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;bool   &#039;&#039; || &#039;&#039;&#039;trunc=n&#039;&#039;&#039; ||  [y/n] || 	Truncate or round to nearest when converting from float to int/short&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;type=&#039;&#039;&#039; ||   || 	int, float, complex, short, long&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 examine RSF files quickly. 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;
| &#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;
&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;
dimensions and size of these vectors! If the program does not respond&lt;br /&gt;
for a very long time, the dimension and size&lt;br /&gt;
of the vectors may be 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 has no restrictive&lt;br /&gt;
limitations on the size of the vectors.&lt;br /&gt;
Here is an example. We first create 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 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 parform=y all=n par1 par2 ...&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;all=n&#039;&#039;&#039; ||  [y/n] || 	If output all values.&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;
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: [https://github.com/ahay/src/blob/master/system/main/get.c 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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the parameter value (as a 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;syntaxhighlight lang=&amp;quot;c&amp;quot;&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;/syntaxhighlight&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;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;mask=&#039;&#039;&#039; ||   || 	auxiliary input file name&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;
==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 inv=n&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;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;inv=n&#039;&#039;&#039; ||  [y/n] || 	inversion flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;mask=&#039;&#039;&#039; ||   || 	auxiliary input file name&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 [&amp;lt;file0.rsf] 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sed -i &#039;s/n6=1//g&#039; file.rsf&lt;br /&gt;
&amp;lt;/syntaxhighlight&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= 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=&#039;&#039;&#039; ||   || 	maximum header value&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;min=&#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 nostdin=n n#= d#=(1,1,...) o#=(0,0,...) label#= unit#= type= label= unit= output=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Known functions: &amp;lt;br&amp;gt;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;erf,  erfc, sign (for float data),&amp;lt;br&amp;gt;arg,  conj, real, imag (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;Arguments which are not treated as variables in mathematical expressions:&amp;lt;br&amp;gt;datapath=, type=, out=&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;See also: sfheadermath.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d#=(1,1,...)&#039;&#039;&#039; ||   || 	sampling on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label=&#039;&#039;&#039; ||   || 	data label&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;largeint&#039;&#039; || &#039;&#039;&#039;n#=&#039;&#039;&#039; ||   || 	size of #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;nostdin=n&#039;&#039;&#039; ||  [y/n] || 	y - ignore stdin&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;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; ||   || 	data unit&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;
&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 files with the&lt;br /&gt;
same dimensions and data type. The data type can be real (floating&lt;br /&gt;
point) or complex. The following example 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;
Functions can be nested and combined, and variable names, as well as the &amp;lt;tt&amp;gt;input&amp;lt;/tt&amp;gt; keyword, may be combined with the axes keywords &amp;lt;tt&amp;gt;x1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;x2&amp;lt;/tt&amp;gt;, etc. Here is an example that shifts a wavelet -0.4s to t=0, computes the frequency-domain complex square root (equivalent to the convolutional square root in time), and shifts the result back to t=0.4s:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pi=3.14159265&lt;br /&gt;
tshift=0.4&lt;br /&gt;
&lt;br /&gt;
sfspike n1=256 k1=101 |\&lt;br /&gt;
sfbandpass flo=4 fhi=30 |\&lt;br /&gt;
sffft1 opt=n sym=y |\&lt;br /&gt;
sfmath output=&amp;quot;sqrt(input*exp(2*$pi*$tshift*x1*I))*exp(-2*$pi*$tshift*x1*I)&amp;quot; |\&lt;br /&gt;
sffft1 opt=n sym=y inv=y |\&lt;br /&gt;
sfgraph |\&lt;br /&gt;
sfpen&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&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 beg#=0 end#=0 n#=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;n#out is equivalent to n#, both of them overwrite end#.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Other parameters from the command line are passed to the output (similar to sfput).&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;beg#=0&#039;&#039;&#039; ||   || 	the number of zeros to add before the beginning of #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;end#=0&#039;&#039;&#039; ||   || 	the number of zeros to add after the end of #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n#=&#039;&#039;&#039; ||   || 	the output length of #-th axis - padding at the end&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfpad&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 [parameter=value list]&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 by editing the file 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 Madagascar 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;, and 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=n 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 pair=n&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;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;pair=n&#039;&#039;&#039; ||  [y/n] || 	y - use odd elements for the real part and even ones for the imaginary part&lt;br /&gt;
|}&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. pclip=100. 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.&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;pclip=100.&#039;&#039;&#039; ||   || 	data clip percentile&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;
&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 with &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;
==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;lt; in.rsf &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;
&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 axes:&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 scale= axis=2 rms=n norm=y min=n max=n prod=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. If axis=0, stack over all dimensions&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;prod=n&#039;&#039;&#039; ||  [y/n] || 	If y, find product instead of stack.  Ignores rms and norm.&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;
| &#039;&#039;floats &#039;&#039; || &#039;&#039;&#039;scale=&#039;&#039;&#039; ||   || 	optionally scale before stacking  [n2]&lt;br /&gt;
|}&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;tt&amp;gt;plane=&amp;lt;/tt&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;tt&amp;gt;memsize=&amp;lt;/tt&amp;gt; parameter or&lt;br /&gt;
the &amp;lt;tt&amp;gt;RSFMEMSIZE&amp;lt;/tt&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 a 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;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Other parameters from the command line are passed to the output (similar to sfput).&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;largeint&#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;largeint&#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 select a window from the minimum and maximum&lt;br /&gt;
parameters. 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://www.ahay.org/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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apply log-stretch FFT:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Compute the 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Prepare for 8-bit greyscale visualization:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt; spikeamo.rsf sfbyte pclip=100 gainpanel=a &amp;gt; spikebyte.rsf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Picture from the middle of the impulse response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Picture illustrating the artifacts (i.e. need for f-k filter):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apply the f-k filter and (in this case) visualize:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&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 identify meaningful keywords 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 helpful in&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;header&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;
An 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 their 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;tfile=&amp;lt;/tt&amp;gt; option. The user may remap these predefined keywords to 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 an 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 the name of the file in which the binary reel header (the 400-byte thing following the 3600-byte 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 an 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. The 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;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=d&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 mask samples is the same as the number of traces in the unmasked SEG-Y. There should be zeros in the mask in places corresponding to unwanted traces.&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 estimate automatically 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 &amp;lt;tt&amp;gt;tape=&amp;lt;/tt&amp;gt; tag specifies the output file.&lt;br /&gt;
=Generic programs=&lt;br /&gt;
Programs in this category are general signal and image processing programs. The source files for these programs can be found under [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/generic/ system/generic] in the Madagascar distribution.&lt;br /&gt;
==sfnoise==&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 random noise to the data.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfnoise &amp;lt; in.rsf &amp;gt; out.rsf seed=time(NULL) type=y var= range= mean=0 rep=n&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;mean=0&#039;&#039;&#039; ||   || 	noise mean&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;range=&#039;&#039;&#039; ||   || 	noise range (default=1)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;rep=n&#039;&#039;&#039; ||  [y/n] || 	if y, replace data with noise&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;seed=time(NULL)&#039;&#039;&#039; ||   || 	random seed&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;type=y&#039;&#039;&#039; ||  [y/n] || 	noise distribution, y: normal, n: uniform&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;var=&#039;&#039;&#039; ||   || 	noise variance&lt;br /&gt;
|}&lt;br /&gt;
See the [http://www.ahay.org/rsflog/index.php?/archives/262-Program-of-the-month-sfnoise.html Program of the Month] blog entry.&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, 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 like &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;syntaxhighlight lang=&amp;quot;python&amp;quot;&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;/syntaxhighlight&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 aperture (gate= parameter in sfpick) limits the search radius.&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;
Many people have discovered and rediscovered the algorithm. 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 the 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 follows below. First, create an input file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&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 in length:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&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 transposed on disk:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Depending on your needs, you may want to run the output through &amp;lt;tt&amp;gt;sftransp&amp;lt;/tt&amp;gt;. 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that since this program does not need any arguments (just stdin and stdout), it will not display the man page when called with no arguments. 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 the &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 are different, files in Fig that are missing from Lock, and files in 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;
==sfawefd2d==&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;
Below, we will demonstrate an example of a model with nx=nz=200 and dx=dz=4m (size: 800x800m). There are two layers: the first 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. The 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;ol&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Velocity model:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Density model:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Source position (x,z):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Receiver position (x,z):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Source wavelet:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Creating data at specified receiver + saving full wavefield every 10th step:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;View the wavefield movie:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt; Fwfl.rsf sfgrey gainpanel=a pclip=99 color=j scalebar=y | sfpen&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;View a wavefield snapshot:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;View the data recorded at the receiver:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&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 it should be 5 or so for reasonable results. 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt; tdata.rsf sfdd type=float &amp;gt; trchdr.rsf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Shot positions:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
Extract offset positions from the trace header files, eliminate length-1 axis, scale, and create a header for binning (required by &amp;lt;tt&amp;gt;sfintbin&amp;lt;/tt&amp;gt;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
Binning and muting:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&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. The receiver and shot frequency slices are &amp;quot;placed&amp;quot; at the right location and padded with zeros up to the x-axis dimension specified below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt; swav.rsf sftransp plane=12 | sftransp plane=23 &amp;gt; stra.rsf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt; rwav.rsf sftransp plane=12 | sftransp plane=23 &amp;gt; rtra.rsf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This creates a surface receiver wavefield ready for input to migration. Axis 4 is the 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 that of the whole 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&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 an RSF file with the name of the tag and no rsf extension will be created:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&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;/syntaxhighlight&amp;gt;&lt;br /&gt;
The migration of 20 shots takes approximately three 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;img.rsf sfwindow squeeze=y | sftransp | sfgrey &amp;gt; img.vpl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Fomels</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Hall_of_Fame&amp;diff=4825</id>
		<title>Hall of Fame</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Hall_of_Fame&amp;diff=4825"/>
		<updated>2024-11-04T23:29:19Z</updated>

		<summary type="html">&lt;p&gt;Fomels: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Laurel.png|right|]]&lt;br /&gt;
This page honors individuals who made crucial contributions to Madagascar&#039;s development and to the Madagascar community. You can read their stories by following the links below.&lt;br /&gt;
&lt;br /&gt;
==Ioan &amp;quot;Nick&amp;quot; Vlad==&lt;br /&gt;
&lt;br /&gt;
[[Nick Vlad]] enhanced Madagascar installation by improving directory structures and configuration scripts. He maintained the Madagascar wiki pages and generated much of their content. He actively participated in community discussions and created the [https://www.linkedin.com/groups/1847746/ LinkedIn group] for Madagascar users.&lt;br /&gt;
&lt;br /&gt;
==Pengliang Yang==&lt;br /&gt;
&lt;br /&gt;
[[Pengliang Yang]] developed efficient CUDA codes for fast execution on GPU devices and provided examples of their usage in geophysical tasks, from forward wave modeling to full waveform inversion. He served as an instructor at Madagascar schools, including [[Harbin 2015|Harbin-2015]] and [[Zurich 2016|Zurich-2016]].&lt;br /&gt;
&lt;br /&gt;
==Vladimir Bashkardin==&lt;br /&gt;
&lt;br /&gt;
[[Vladimir Bashkardin]] wrote [https://reproducibility.org/RSF/sfoglpen.html oglpen], a Vplot visualization program based on [https://en.wikipedia.org/wiki/OpenGL OpenGL]. He also developed new tools for parallel computing and handling large-scale datasets. Vladimir actively participated in the Madagascar community and taught at Madagascar schools, including [[Houston 2010|Houston-2010]].&lt;br /&gt;
&lt;br /&gt;
==Yang Liu==&lt;br /&gt;
&lt;br /&gt;
[[Yang Liu]] contributed code, reproducible examples, and research papers. He taught at numerous Madagascar schools, including [[Houston 2010|Houston-2010]], [[Beijing 2011|Beijing-2011]], [[Melbourne 2013|Melbourne-2013]], and [[Shanghai 2017|Shanghai-2017]]. Yang played a critical role in promoting Madagascar in China and hosted [[Hefei 2020|Hefei-2020]] at the 1st Asia-Pacific Geophysics Student Conference. He currently maintains the Madagascar webserver.&lt;br /&gt;
&lt;br /&gt;
==Jeff Godwin==&lt;br /&gt;
&lt;br /&gt;
[[Jeff Godwin]] wrote a [[Tutorial|Madagascar Tutorial]] and useful Python scripts, including [[tkMadagascar|TkMadagascar]], an example of a complete interactive environment. He also helped many other users and taught at the Madagascar school in [[Houston 2010|Houston-2010]].&lt;br /&gt;
&lt;br /&gt;
==Jim Jennings==&lt;br /&gt;
&lt;br /&gt;
[[Jim Jennings]] was the first active Madagascar user outside the geophysics community. He contributed [https://github.com/ahay/src/tree/master/book/geostats Python packages for geostatistical modeling] and improved the Madagascar infrastructure by writing [[Automatic_Testing|scripts for reproducibility testing]]. Jim actively participated in the Madagascar community and served as an instructor at Madagascar schools, including [[RSF_Austin_School_2007|Austin-2007]] and [[Houston 2010|Houston-2010]].&lt;br /&gt;
&lt;br /&gt;
==Joe Dellinger==&lt;br /&gt;
&lt;br /&gt;
[[Joe Dellinger]] is the primary author of [[Graphics_development_with_vplot|Vplot]]. Originally developed at Stanford in the 1980s, Vplot serves as Madagascar&#039;s plotting library today. During the [[2008_Implementation_Workshop|Golden-2008]] workshop, Joe developed the *sfvplotdiff* program for comparing Vplot files, the cornerstone for reproducibility testing. Joe taught at multiple Madagascar schools and workshops, including [[RSF_School_and_Workshop,_Vancouver_2006|Vancouver-2006]], [[RSF_Austin_School_2007|Austin-2007]], and [[Houston 2010|Houston-2010]].&lt;br /&gt;
&lt;br /&gt;
==Zicheng Geng==&lt;br /&gt;
&lt;br /&gt;
[[Zicheng Geng]] played a leading role in maintaining and developing Madagascar in the 2010s. Among other contributions, he converted the Python code to version 3, introduced unit testing, and enhanced [https://reproducibility.org/blog/2016/02/20/continuous-reproducibility-using-circleci/ continuous integration] using CircleCI.&lt;/div&gt;</summary>
		<author><name>Fomels</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Tutorial&amp;diff=4640</id>
		<title>Tutorial</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Tutorial&amp;diff=4640"/>
		<updated>2024-10-31T23:12:42Z</updated>

		<summary type="html">&lt;p&gt;Fomels: &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 [https://github.com/ahay/src/tree/master/book/tutorial book/tutorial/] using [[latex2wiki]]&#039;&#039;&amp;lt;/font&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
Welcome to a brief introduction to Madagascar.  The purpose of this&lt;br /&gt;
document is to teach new users how to use the powerful tools in&lt;br /&gt;
Madagascar to: process data, produce documents and build your own&lt;br /&gt;
Madagascar programs.&lt;br /&gt;
To gradually introduce you to Madagascar, we have created a series of&lt;br /&gt;
tutorials that are targeted to distinct audiences and designed to make&lt;br /&gt;
you an experienced Madagascar user in a short-time period.  The&lt;br /&gt;
tutorials are divided by interest into three main categories:&lt;br /&gt;
* &#039;&#039;&#039;Users&#039;&#039;&#039; learn about Madagascar, how to use the processing programs, and build scripts.&lt;br /&gt;
* &#039;&#039;&#039;Authors&#039;&#039;&#039; learn how to build reproducible documents using Madagascar.&lt;br /&gt;
* &#039;&#039;&#039;Developers&#039;&#039;&#039; build new Madagascar programs that add additional functionality to Madagascar.&lt;br /&gt;
Each tutorial is designed to be completed in a short period of time.&lt;br /&gt;
Additionally, each tutorial has hands-on examples that you should be&lt;br /&gt;
able to reproduce on your computer as you go along with the tutorials.&lt;br /&gt;
Most tutorials will use scripts that you can edit, modify, or play&lt;br /&gt;
with to further gain experience and understanding.  By the end of the&lt;br /&gt;
tutorial series, you should be able to use all of the tools inside of&lt;br /&gt;
Madagascar.  Please note that this tutorial series does not explicitly&lt;br /&gt;
show you how to process certain types of data, or how to perform common data&lt;br /&gt;
processing operations (e.g. CMP semblance picking,&lt;br /&gt;
time migration,etc.).  Additional tutorials on those specific subjects&lt;br /&gt;
will be added over time.  The purpose of this document is simply to&lt;br /&gt;
familiarize you with the Madagascar framework in a general sense.&lt;br /&gt;
Before you go on, here are some notes on notation:&lt;br /&gt;
*important names, or program names are usually bold in the text.  For example: &#039;&#039;&#039;sfwindow&#039;&#039;&#039;  &lt;br /&gt;
*code snippets are always in the following formatting: &amp;lt;pre&amp;gt; sfwindow &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Users=&lt;br /&gt;
The Users tutorials demonstrate how to use the Madagascar framework to create, process, and visualize data and to create reproducible scripts for processing data.  The main goals of the Users tutorials are to learn about:&lt;br /&gt;
  &lt;br /&gt;
*the Madagascar framework, &lt;br /&gt;
*the RSF file format, &lt;br /&gt;
*the command line interface, &lt;br /&gt;
*how to interact with files on the command line, &lt;br /&gt;
*commonly used programs, &lt;br /&gt;
*how to make plots in Madagascar, &lt;br /&gt;
*how to make reproducible scripts, &lt;br /&gt;
*how to use SCons and Python, &lt;br /&gt;
*how to visualize your data. &lt;br /&gt;
By the end of this tutorial group, you should be able to fully use all of Madagascar&#039;s built-in tools for data processing and scripting. These tools will allow you to process data ranging from tens of megabytes to tens of terabytes in a reproducible fashion.  &lt;br /&gt;
==Introduction to Madagascar==&lt;br /&gt;
To begin, let&#039;s talk about the core principles of Madagascar and the RSF file format.  &lt;br /&gt;
[[Image:scheme.png|frame|center|The hierarchy of Madagascar.  Fundamentally, everything builds off of the RSF file format.  As you go up the chain the complexity level may increase, but the capabilities of the processing package increase as well.]]&lt;br /&gt;
===Madagascar&#039;s design===&lt;br /&gt;
There are a few layers to Madagascar.  At the bottom-most layer is the RSF file format, a common exchange format used by all Madagascar programs.  Non-Madagascar programs can also read/write to and from RSF because it is an open exchange format.  The next level of Madagascar contains the actual Madagascar programs that manipulate RSF files to process data.  Concurrent to this level is the VPLOT graphics library which allows users to plot and visualize RSF files.  The scripting utilities in Python and SCons are up another level from the core programs.  These scripting utilities enable users to make powerful scripts that can perform even the most advanced data processing tasks.  The last level includes support for LaTeX, which allows you to create documents combining the features of Madagascar with LaTeX&#039;s powerful typesetting.  Throughout the course of these tutorials, we will examine all of these components and demonstrate how they can be used individually and together.  When combined, the individual components of Madagascar allow us to: conduct experiments, process data, visualize our results, make reproducible scripts that can be shared with others, and write papers to document our experiments.  Thus, Madagascar provides a fully integrated research environment.&lt;br /&gt;
&lt;br /&gt;
===RSF file format===&lt;br /&gt;
As previously mentioned, the lowest level of Madagascar is the RSF file format, which is the format used to exchange information between Madagascar programs.  Conceptually, the RSF file format is one of the easiest to understand, as RSF files are simply regularly sampled hypercubes of information.   For reference, a hypercube is a hyperdimensional cube (or array) that can best be visualized as an &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt;-dimensional array, where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is between 1 and 9 in Madagascar. &lt;br /&gt;
&lt;br /&gt;
RSF hypercubes are defined by two files, the header file and the binary file.  The header file contains information about the dimensionality of the hypercube as well as the data contained within the hypercube.  Information contained in the header file may include the following: &lt;br /&gt;
      &lt;br /&gt;
*number of elements on all axes,     &lt;br /&gt;
*the origin of the axes,     &lt;br /&gt;
*the sampling interval of elements on the axes,     &lt;br /&gt;
*the type of elements in the axes (i.e., float, integer),     &lt;br /&gt;
*the size of the elements (e.g. single or double precision),     &lt;br /&gt;
*and the location of the actual binary file. &lt;br /&gt;
Since we often want to view this information about files without deciphering it, we store the header file as an ASCII text file in the local directory, usually with the suffix &#039;&#039;&#039;.rsf&#039;&#039;&#039; .  At any time, you can view or edit the contents of the header files using a text editor such as gedit, VIM, or Emacs.&lt;br /&gt;
&lt;br /&gt;
The binary file is stored remotely (i.e., in a separate directory) containing the actual hypercube data.  Because the hypercube data can be very large (&amp;lt;math&amp;gt;10s&amp;lt;/math&amp;gt; of GB or TB), we usually store the binary files in a remote directory with the suffix &#039;&#039;&#039;.rsf@&#039;&#039;&#039; .  The user can specify the remote directory using the &#039;&#039;&#039;DATAPATH&#039;&#039;&#039;  environmental variable.  The advantage of doing this is that we can store large binary data files on a fast remote filesystem if we want, and we can avoid working in local directories.  &lt;br /&gt;
[[Image:format.png|frame|center|Cartoon of the RSF file format.  The header file points to the binary file, which can be separate from each other.  The header file, which is text, is tiny compared to the binary file.]]&lt;br /&gt;
&lt;br /&gt;
Because the header and binary are separated from one another, it is possible that we can lose either the header or binary for a particular RSF file.  If the header is lost, then we can simply reconstruct the header using our previous knowledge of the data and a text editor.  However, if we lose the binary file, then we cannot reconstruct the data regardless of what we do.  Therefore, you should try and avoid losing either the header or binary data.  The best way to prevent data loss is to make your research reproducible so that your results can be replicated later.&lt;br /&gt;
Sometimes, we need to store RSF files for archiving or transfer to other machines.  Fortunately, we can avoid transferring the header and binary separately by using the combined header/binary format for RSF files.  Files can be constructed using the combined header/binary format by specifying additional parameters on the command line, in particular &#039;&#039;&#039;--out=stdout&#039;&#039;&#039; , for any Madagascar program.  The output file will then be header/binary combined, which allows you to transfer the file without fear of losing either the header or binary.  Be careful, though: header/binary combined files can be very large and might slow down your local filesystem.  A best practice is only to use combined header/binary files when absolutely necessary for file transfers.  Note: header/binary combined files are usually automatically converted to header/binary separate files when processed by a Madagascar program.&lt;br /&gt;
&lt;br /&gt;
===Additional documentation===&lt;br /&gt;
&lt;br /&gt;
For more complete documentation on the RSF file format see the following links:&lt;br /&gt;
&lt;br /&gt;
A [[Guide_to_RSF_file_format|gentle guide to the RSF file format]]&lt;br /&gt;
&lt;br /&gt;
A [[RSF_Comprehensive_Description|detailed guide to the RSF file format]]&lt;br /&gt;
&lt;br /&gt;
==Command line interface==&lt;br /&gt;
Madagascar was designed initially to be used from the command&lt;br /&gt;
line. Programmers create Madagascar programs (prefixed with the sf&lt;br /&gt;
designation) that read and write Madagascar files. These programs are&lt;br /&gt;
designed to be as general as possible so that each could operate&lt;br /&gt;
on any dataset in RSF format, provided you also supply the correct&lt;br /&gt;
parameters and have the right data type for the program.&lt;br /&gt;
&lt;br /&gt;
===Using programs===&lt;br /&gt;
Madagascar programs follow the standard UNIX conventions for reading and writing RSF files to and from &#039;&#039;&#039;stdin&#039;&#039;&#039;  and &#039;&#039;&#039;stdout&#039;&#039;&#039;. This is also the convention that Seismic Unix uses, so it should be familiar to SU users.&lt;br /&gt;
For example: the program &#039;&#039;&#039;sfattr&#039;&#039;&#039;  allows us to get attributes about an RSF file (mean, standard deviation, min, max, etc.) To get the attributes for a pre-computed file, we might use&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfattr &amp;lt; file.rsf&lt;br /&gt;
     rms =       1.41316 &lt;br /&gt;
   mean =      0.999667 &lt;br /&gt;
 2-norm =       357.503 &lt;br /&gt;
 variance =      0.997693 &lt;br /&gt;
std dev =      0.998846 &lt;br /&gt;
    max =       5.05567 at 36 8 27 &lt;br /&gt;
    min =      -3.59936 at 18 9 6 &lt;br /&gt;
 nonzero samples = 64000 &lt;br /&gt;
 total samples = 64000 &lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
We demonstrate how to read and write RSF files using &#039;&#039;&#039;sfwindow&#039;&#039;&#039;  which is a program that allows us to select portions of an RSF file. When &#039;&#039;&#039;sfwindow&#039;&#039;&#039;  is used without any additional parameters, we are able to make a copy of a file with a different filename. For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 sfwindow &amp;lt; file.rsf &amp;gt; file2.rsf&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
gives us two files, file.rsf and file2.rsf which are identical but not the same file. If your intention is simply to copy a file, you can also use &#039;&#039;&#039;sfcp&#039;&#039;&#039; .&lt;br /&gt;
In addition to specifying files to read in and out on the command line we can specify the parameters for each program that are necessary for it to run, or to produce the desired result. The general format for specifying parameters on the command line is &#039;&#039;&#039;key=val&#039;&#039;&#039; , where &#039;&#039;&#039;key&#039;&#039;&#039;  is the name of the parameter that you want to set, and &#039;&#039;&#039;val&#039;&#039;&#039;  is the value of the parameter. There are four (4) types of values that are acceptable: integers, floating point numbers, booleans, or strings. Going back to the window program, we can specify the number of traces or pieces of the file that we want to keep like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfwindow &amp;lt; file.rsf n1=10 &amp;gt; file-win.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Self-documentation===&lt;br /&gt;
Of course, we can specify as many parameters as we&#039;d like on the command line. To figure out which parameters are needed for a specific program, just type the name of the program with no input files our output files on the command line to bring up a program&#039;s self-documentation.  For example, &#039;&#039;&#039;sfwindow&#039;&#039;&#039; &#039;s self documentation is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NAME&lt;br /&gt;
sfwindow&lt;br /&gt;
DESCRIPTION&lt;br /&gt;
Window a portion of a dataset. &lt;br /&gt;
SYNOPSIS&lt;br /&gt;
sfwindow &amp;lt; in.rsf &amp;gt; out.rsf verb=n squeeze=y &lt;br /&gt;
j#=(1,...) d#=(d1,d2,...) f#=(0,...) min#=(o1,o2,,...) &lt;br /&gt;
n#=(0,...) max#=(o1+(n1-1)*d1,o2+(n1-1)*d2,,...)&lt;br /&gt;
PARAMETERS&lt;br /&gt;
float   d#=(d1,d2,...)  sampling in #-th dimension &lt;br /&gt;
largeint f#=(0,...)     window start in #-th dimension &lt;br /&gt;
int     j#=(1,...)      jump in #-th dimension &lt;br /&gt;
float   max#=(o1+(n1-1)*d1,o2+(n1-1)*d2,,...)   &lt;br /&gt;
maximum in #-th dimension &lt;br /&gt;
float   min#=(o1,o2,,...)       minimum in #-th dimension &lt;br /&gt;
largeint n#=(0,...)     window size in #-th dimension &lt;br /&gt;
bool    squeeze=y [y/n] &lt;br /&gt;
if y, squeeze dimensions equal to 1 to the end &lt;br /&gt;
bool    verb=n [y/n]    Verbosity flag&lt;br /&gt;
USED IN&lt;br /&gt;
bei/dpmv/krchdmo&lt;br /&gt;
bei/dpmv/matt&lt;br /&gt;
bei/dwnc/sigmoid&lt;br /&gt;
bei/fdm/kjartjac&lt;br /&gt;
bei/fld/cube&lt;br /&gt;
bei/fld/shotmovie&lt;br /&gt;
bei/fld/synmarine&lt;br /&gt;
bei/fld/yc&lt;br /&gt;
bei/ft1/autocor&lt;br /&gt;
bei/ft1/brad&lt;br /&gt;
bei/ft1/ft2d&lt;br /&gt;
bei/krch/sep73&lt;br /&gt;
bei/sg/denmark&lt;br /&gt;
bei/sg/toldi&lt;br /&gt;
bei/trimo/mod&lt;br /&gt;
bei/trimo/subsamp&lt;br /&gt;
bei/vela/stretch&lt;br /&gt;
bei/vela/vscan&lt;br /&gt;
bei/wvs/head&lt;br /&gt;
bei/wvs/vscan&lt;br /&gt;
cwp/geo2006TimeShiftImagingCondition/flat&lt;br /&gt;
cwp/geo2006TimeShiftImagingCondition/icomp&lt;br /&gt;
cwp/geo2006TimeShiftImagingCondition/zicig&lt;br /&gt;
cwp/geo2007StereographicImagingCondition/flat4&lt;br /&gt;
cwp/geo2007StereographicImagingCondition/gaus1&lt;br /&gt;
167 more examples listed in:&lt;br /&gt;
/usr/local/RSFROOT/share/doc/madagascar/html/sfwindow.html&lt;br /&gt;
SOURCE&lt;br /&gt;
system/main/window.c&lt;br /&gt;
DOCUMENTATION&lt;br /&gt;
http://ahay.org/wiki/Guide_to_madagascar_programs#sfwindow&lt;br /&gt;
VERSION&lt;br /&gt;
1.3-svn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The self-documentation tells us the function of the program, as well as the parameters that are available to be specified. The parameter format is type - name=default value [options] and then a short description of the parameter. File parameters request a name of a file. For example: &lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
file=file.rsf &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Note: strings with spaces must be enclosed in quotation marks&lt;br /&gt;
(e.g. &#039;my value&#039;) so that the Unix shell could interpret them correctly.&lt;br /&gt;
&lt;br /&gt;
===Piping===&lt;br /&gt;
Sometimes we want to chain multiple commands together without writing intermediate Madagascar RSF files in the process. We can avoid making intermediate files by using another standard UNIX construct, pipes. Pipes allow us to connect the standard output from one Madagascar program to the standard input to another program without first writing to a file. For example we could do the following without pipes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfwindow &amp;lt; file.rsf &amp;gt; file-win.rsf&lt;br /&gt;
sftransp &amp;lt; file-win.rsf &amp;gt; file2.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Or we could do the equivalent using pipes on one line:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfwindow &amp;lt; file.rsf | sftransp &amp;gt; file2.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Pipes simply make these statements more compact, and allow us to reduce the number of files that we need to save to disk.  Piping is very powerful, because there is no limit to the number of statements that you can pipe together.  For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfwindow &amp;lt; file.rsf | sftransp | sfnoise var=1 &amp;gt; file2.rsf &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you&#039;re using multiple programs, and do not want to save the intermediate files, then pipes will greatly reduce the number of files that you have to keep track of.&lt;br /&gt;
&lt;br /&gt;
===Interacting with files from the command line===&lt;br /&gt;
Ultimately though, 95% of your time using Madagascar on the command line will be to inspect and view files that are output by your scripts. Some of the key commands that are used to interact with files on the command line are:&lt;br /&gt;
*&#039;&#039;&#039;sfin&#039;&#039;&#039; , used to get header information, &lt;br /&gt;
*&#039;&#039;&#039;sfattr&#039;&#039;&#039; , used to get file attributes, &lt;br /&gt;
*&#039;&#039;&#039;sfwindow&#039;&#039;&#039; , used to select portions of RSF files, &lt;br /&gt;
*and &#039;&#039;&#039;sftransp&#039;&#039;&#039; , used to reorder files. &lt;br /&gt;
Here are detailed usage examples and explanations of what the above programs do:&lt;br /&gt;
&#039;&#039;&#039;sfin&#039;&#039;&#039;  is one of the most used program on the command line, because most often we simply need to check the dimensionality of our files to make sure that we have them in the correct order.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfin file.rsf&lt;br /&gt;
 &lt;br /&gt;
file.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/file.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=34          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
	3400 elements 13600 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;sfattr&#039;&#039;&#039;  is also commonly used from the command line to check files for correct values. Most often, we use sfattr to ensure that files are not filled with zeros, or with NaN&#039;s after a long computation, or to make sure that the values are reasonable. sfattr can be used to obtain basic statistics about the files as well.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfattr &amp;lt; file.rsf &lt;br /&gt;
 &lt;br /&gt;
******************************************* &lt;br /&gt;
     rms =             1 &lt;br /&gt;
    mean =             1 &lt;br /&gt;
  2-norm =       58.3095 &lt;br /&gt;
variance =             0 &lt;br /&gt;
 std dev =             0 &lt;br /&gt;
     max =             1 at 1 1 &lt;br /&gt;
     min =             1 at 1 1 &lt;br /&gt;
nonzero samples = 3400 &lt;br /&gt;
  total samples = 3400 &lt;br /&gt;
*******************************************&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;sfwindow&#039;&#039;&#039;  is used to select subsets of the data contained in an RSF file for computation elsewhere. Typically, you specify the data subset you want to keep using, the n, j, and f parameters which specify the number of indices in the arrays to keep, the jump in indices, and the first index to keep from the file in the respective dimension. For example if we want to keep the 15th-30th time samples from the first axis in &amp;lt;tt&amp;gt;file.rsf&amp;lt;/tt&amp;gt;, we might use the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfwindow &amp;lt; file.rsf f1=15 n1=15 j1=1 &amp;gt; file-win.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;sftransp&#039;&#039;&#039;  is used to reorder RSF files for other programs to be used. For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sftransp &amp;lt; file.rsf plane=12 &amp;gt; file-transposed.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
swaps the first and second axes, so that now the first axis is distance and the second axis is time.&lt;br /&gt;
For more information about commonly used Madagascar programs please see the [[Guide_to_madagascar_programs|guide to Madagascar programs]].&lt;br /&gt;
&lt;br /&gt;
==Plotting==&lt;br /&gt;
&lt;br /&gt;
VPLOT provides a method for making plots that are small in size, aesthetically pleasing, and easily compatible with Latex for rapid creation of productio-quality images in Madagascar.&lt;br /&gt;
===VPLOT===&lt;br /&gt;
The VPLOT file format (.vpl suffix) is a self-contained binary data&lt;br /&gt;
format that describes in vector format how to draw a plot on the&lt;br /&gt;
screen or a page using an interpreter. Since VPLOT is not a standard&lt;br /&gt;
imaging format, VPLOT files must be viewed with &lt;br /&gt;
interpreter programs which, for historical reasons, are called pens. Each pen interfaces VPLOT with a&lt;br /&gt;
third-party graphing library such as X11, plplot, opengl, and&lt;br /&gt;
others. This flexibility makes VPLOT files almost as portable as&lt;br /&gt;
standard image formats such as: EPS, GIF, JPEG, PDF, PNG, SVG, and TIFF. Unlike rasterized&lt;br /&gt;
formats, VPLOT files can be scaled to any size without losing image&lt;br /&gt;
quality.&lt;br /&gt;
===Creating plots===&lt;br /&gt;
To generate VPLOT files, we need to pass our computed RSF files through VPLOT filters, that convert RSF data files to VPLOT files. The VPLOT filters are named by the type of plot that they produce. The following table lists all of the available VPLOT filters.&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;2&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | List of available plotting programs in Madagascar.&lt;br /&gt;
|- &lt;br /&gt;
| &#039;&#039;&#039;sfbox&#039;&#039;&#039; || make box-line plots &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sfcontour&#039;&#039;&#039; || make contour plots &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sfcontour3&#039;&#039;&#039; || make contour plots of 3D surfaces &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sfdots&#039;&#039;&#039;  || plot signal with lollipops &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sfgraph&#039;&#039;&#039; || create line plots, or scatter plots &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sfgraph3&#039;&#039;&#039; || generate 3-D cube plots for surfaces. &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sfgrey&#039;&#039;&#039; || create raster plots or 2D image plots &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sfgrey3&#039;&#039;&#039; || create 3D image plots of panels (or slices) of a 3D cube &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sfgrey4&#039;&#039;&#039; || generate movies of 3-D cube plots &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sfplotrays&#039;&#039;&#039; || make plots of rays &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sfthplot&#039;&#039;&#039; || make hidden-line surface plots &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sfwiggle&#039;&#039;&#039; || plot data with wiggly traces &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To actually create a plot, we can use the plotting programs on the command line in the same fashion that we would use a Madagascar program:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfspike n1=100 | sfnoise &amp;gt; file.rsf&lt;br /&gt;
sfgraph &amp;lt; file.rsf title=&amp;quot;noise&amp;quot; &amp;gt; file.vpl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Visualizing plots===&lt;br /&gt;
In this example, we create a single trace full of noise and then send&lt;br /&gt;
it to sfgraph to produce a single VPLOT file, &amp;lt;tt&amp;gt;file.vpl&amp;lt;/tt&amp;gt;.  As&lt;br /&gt;
you may have noticed, this only creates the file which is useful for&lt;br /&gt;
saving the plot, does not allow us to visualize the data.  To visualize&lt;br /&gt;
the data we need to use a &#039;&#039;&#039;pen&#039;&#039;&#039; , which tells your machine how&lt;br /&gt;
to actually draw the plot.  A typical Madagascar installation will&lt;br /&gt;
have multiple pens available for you to use.  By default, you should&lt;br /&gt;
use &#039;&#039;&#039;sfpen&#039;&#039;&#039;  which will pick the best pen available for you.&lt;br /&gt;
You can use &#039;&#039;&#039;sfpen&#039;&#039;&#039;  to visualize your plots in the following&lt;br /&gt;
manner:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfpen &amp;lt; file.vpl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will pop up a screen on your window with the plot shown.  Depending on which pen you are using you may be able to interact with the pen interface to control various parameters of the plot as shown by the buttons at the top of the screen.  Depending on the pen that you are using, there may be keyboard shortcuts to many of the buttons.  NOTE: &#039;&#039;&#039;oglpen&#039;&#039;&#039;  uses a mouse interface that can be accessed by right-clicking on the plot.&lt;br /&gt;
&lt;br /&gt;
===Converting VPLOT to other formats===&lt;br /&gt;
If you want to build reports or documents using other programs, or want to send your images to someone who does not have Madagascar you will need to convert your VPLOT files to other image formats for transfer.    To convert a VPLOT plot to another format use the tool &#039;&#039;&#039;vpconvert&#039;&#039;&#039; .  &lt;br /&gt;
&#039;&#039;&#039;vpconvert&#039;&#039;&#039;  allows you to convert VPLOT files to any of the following formats, provided that you have the appropriate third-party libraries installed: &lt;br /&gt;
  &lt;br /&gt;
*avi,  &lt;br /&gt;
*eps, &lt;br /&gt;
*gif,  &lt;br /&gt;
*jpeg/jpg, &lt;br /&gt;
*mpeg/mpg (movie format), &lt;br /&gt;
*pdf, &lt;br /&gt;
*png, &lt;br /&gt;
*ppm, &lt;br /&gt;
*ps, &lt;br /&gt;
*svg, &lt;br /&gt;
*and tif. &lt;br /&gt;
Here&#039;s an example of how to use &#039;&#039;&#039;vpconvert&#039;&#039;&#039; :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vpconvert file.vpl format=jpeg&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
NOTE: details on how to install these third-party libraries are not&lt;br /&gt;
included with the Madagascar library, and we provide no support on&lt;br /&gt;
installing them.  Most users will be able to install them using either&lt;br /&gt;
package management software (on Linux, Windows, and Mac) or&lt;br /&gt;
pre-compiled binaries. The PS and EPS support is provided by default.&lt;br /&gt;
&lt;br /&gt;
==Scripting Madagascar==&lt;br /&gt;
Madagascar&#039;s command line interface allows us to create, manipulate and plot data.  Often though, we want to create scripts that will perform these operations automatically for us.  Scripting is especially important when processing large amounts of data, or performing a complex chain of file manipulations in order to ensure that operations are completed in the right order or with proper parameters.&lt;br /&gt;
In Madagascar, there are two main ways of creating scripts: shell scripts, and Python scripts using SCons.  &lt;br /&gt;
===Shell scripting===&lt;br /&gt;
Shell scripting is the first option for creating scripts.  In shell scripting we simply copy the command lines that we would use and paste them into a file that is recognized by either BASH, C-shell or another shell of your choosing.  Shell scripting may be familiar to users of other packages such as SU, because it is the primary method of scripting there.  An example of a Madagascar shell script is shown below:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
sfspike n1=100 &amp;gt; file.rsf&lt;br /&gt;
&amp;lt; file.rsf sfgraph &amp;gt; file.vpl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For simple processing flows, shell scripting is a quick and easy approach to saving your processing flow.  However, shell scripts quickly become unmanageable when more complicated processing flows are used.  Additionally, shell scripts have no way to avoid repeating commands that have already been successfully run, which causes shell scripts to spend a significant amount of time duplicating already completed work.  Because of these issues, Madagascar&#039;s main scripting option is to use a build manager called SCons for scripting instead of shell scripts.&lt;br /&gt;
&lt;br /&gt;
===SCons===&lt;br /&gt;
SCons is a build manager written in 100% Python.  As a build manager, SCons keeps track of three items for each file built in the script: the name of the output file(s), the name of the input file(s), and the rule (Madagascar program(s) with options) used to build the output file(s) from the input file(s).  The advantage to keeping track of these items is that SCons can then check to see if any of those items have changed and if so mark the output file to be rebuilt.  If no changes are detected, and the output file already exists, then SCons &#039;&#039;skips&#039;&#039; the output file and goes onto building other files.  This gives the user the ability to avoid re-running portions of their scripts that previously completed without issue, which is very important when working on processing flows with large datasets where individual commands may take hours to execute.  SCons also tracks dependencies between various processing commands.  For example, if command 2 depends on the ouptut of command 1, and the input to command 1 changes, then SCons will automatically know that the input to command 2 has changed and will re-run command 2 as well.  Furthermore, SCons allows us to run multiple processing commands at the same time on computers with sufficient capabilities, further reducing the amount of time that it takes for us to process data in Madagascar.  Now, we&#039;ll discuss how to create SCons scripts and use SCons on the command line.&lt;br /&gt;
===SConstructs and commands===&lt;br /&gt;
SCons scripts are called SConstructs.  In order to use SCons, you must create an SConstruct in the local directory where you want to work. Since SCons is written in Python, an SConstruct is simply a text file written using Python syntax.  If you don&#039;t know Python, you can still use SCons, because the syntax is simple.&lt;br /&gt;
First, a primer on Python syntax.  In SConstructs we are going to deal with Python functions and strings.  Python functions are simple, and should be familiar to anyone who has used a programming language.  For example, calling a Python function, foo, looks like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
One argument - foo(1).&lt;br /&gt;
Many arguments - foo(1,2,3,4,5,123)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Python functions can take many arguments, and arguments of different types, but the syntax is the same.  Python strings are also very similar to other programming languages.  In Python anything inside double quotes is automatically considered to be a string, and not a variable declaration.  However, Python also supports a few  notations to indicate strings (or long strings) as shown below:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
&amp;quot;this is a string&amp;quot;&lt;br /&gt;
&#039;this is a string&#039;&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;this is a string&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&amp;quot;&#039;this is a string&amp;quot;&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Somtimes in Python you will need to nest a string within a string.  To do use one of the string representations for the outer string, and use a different one for the inner string.  For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;sfgraph title=&amp;quot;my plot&amp;quot; &amp;quot;&amp;quot;&amp;quot;  OR&lt;br /&gt;
&#039;&#039;&#039; sfgraph title=&amp;quot;my plot&amp;quot; &#039;&#039;&#039; OR&lt;br /&gt;
&#039;   sfgraph title=&amp;quot;my plot&amp;quot; &#039; &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Fundamentally, Madagascar&#039;s data-processing SConstructs are composed of only four commands: &#039;&#039;&#039;Fetch&#039;&#039;&#039; , &#039;&#039;&#039;Flow&#039;&#039;&#039; , &#039;&#039;&#039;Plot&#039;&#039;&#039;  and &#039;&#039;&#039;Result&#039;&#039;&#039; .  The main command is &#039;&#039;&#039;Flow&#039;&#039;&#039; .  A &#039;&#039;&#039;Flow&#039;&#039;&#039;  creates a relationship between the input file, the output file, and the processing command used to create the output file from the input file.  The syntax for a &#039;&#039;&#039;Flow&#039;&#039;&#039;  is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Flow(output file,input file,command)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
where, target and source are file names (strings), and command is a string that contains the Madagascar program to be used, along with the command line parameters needed for that program to run.  For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
Flow(&amp;quot;spike1&amp;quot;,&amp;quot;spike&amp;quot;,&amp;quot;scale dscale=4.0&amp;quot;) &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
creates a dependency relationship between the output file &#039;spike1&#039; and the input file &#039;spike&#039;.  The dependency indicates that &#039;spike1&#039; cannot be created without &#039;spike&#039; and that if &#039;spike&#039; changes then &#039;spike1&#039; also changes.  The relationship in this case is that &#039;spike1&#039; should be &#039;spike&#039; scaled by four times.  The equivalent command on the command line would be: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt; spike.rsf sfscale dscale=4.0 &amp;gt; spike1.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note: the file names of the input and output files do not need to include &#039;.rsf&#039; on the end of the files as SCons automatically adds the suffix to all of our file names.&#039;&#039;&#039; &lt;br /&gt;
Now that we can create relationships between files using &#039;&#039;&#039;Flow&#039;&#039;&#039; s, we can create an SConstruct to do all of our data processing using SCons.   However, we often want to visualize the results of our processing in order to quality control the results. In order to create &#039;&#039;&#039;Plot&#039;&#039;&#039; s (or other visualizations) in Madagascar we have two additional SCons commands:  &#039;&#039;&#039;Plot&#039;&#039;&#039;  and &#039;&#039;&#039;Result&#039;&#039;&#039; .  &#039;&#039;&#039;Plot&#039;&#039;&#039;  and &#039;&#039;&#039;Result&#039;&#039;&#039;  tell SCons how to use Madagascar&#039;s plotting programs to create visualizations of files on the fly after they have been computed.  The syntax for both &#039;&#039;&#039;Plot&#039;&#039;&#039;  and &#039;&#039;&#039;Result&#039;&#039;&#039;  is as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Plot(input file, command)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OR&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Result(input file, command)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In both cases, the &#039;&#039;&#039;Plot&#039;&#039;&#039;  or &#039;&#039;&#039;Result&#039;&#039;&#039;  command tells SCons to build a VPLOT file with same file name as the input file (with the .vpl suffix instead) from the input file using the command provided.  For example, if we want to make a graph of a file we could use:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
Plot(&amp;quot;spike1&amp;quot;,&amp;quot;sfgraph pclip=100&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Behind the scenes, SCons establishes that we want to use &amp;quot;spike1.rsf&amp;quot; to create a &#039;&#039;&#039;Plot&#039;&#039;&#039;  called &amp;quot;spike1.vpl&amp;quot; using sfgraph.  The equivalent command line operation is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt; spike1.rsf sfgraph pclip=100 &amp;gt; spike1.vpl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Result&#039;&#039;&#039;  can be used in the same way as &#039;&#039;&#039;Plot&#039;&#039;&#039; , illustrated above.  &lt;br /&gt;
At this point, you might be asking yourself, what&#039;s the difference between &#039;&#039;&#039;Plot&#039;&#039;&#039;  and &#039;&#039;&#039;Result&#039;&#039;&#039; ?  The answer is that &#039;&#039;&#039;Plot&#039;&#039;&#039;  creates all VPLOT files in the local directory, whereas &#039;&#039;&#039;Result&#039;&#039;&#039;  creates its VPLOT files in a subdirectory called &amp;lt;tt&amp;gt;Fig&amp;lt;/tt&amp;gt;. &amp;lt;tt&amp;gt;Fig&amp;lt;/tt&amp;gt; is a location used to store &#039;&#039;&#039;Plot&#039;&#039;&#039; s that we want to later use when creating papers using L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX.  By default, you should use &#039;&#039;&#039;Plot&#039;&#039;&#039;  when creating visualizations.  Only use &#039;&#039;&#039;Result&#039;&#039;&#039;  when you want to save something to be used in a paper.  Note: since the VPLOTs from &#039;&#039;&#039;Plot&#039;&#039;&#039;  and &#039;&#039;&#039;Result&#039;&#039;&#039;  are placed in different locations you can use both &#039;&#039;&#039;Plot&#039;&#039;&#039;  and &#039;&#039;&#039;Result&#039;&#039;&#039;  for a single RSF file, but create two different plots for the same file.&lt;br /&gt;
&lt;br /&gt;
===Creating an SConstruct===&lt;br /&gt;
Now that we have the three SConstruct commands, we can write our first SConstruct.  To do so, open the SConstruct file in your favorite text editor.  Before we can create any &#039;&#039;&#039;Flow&#039;&#039;&#039; , &#039;&#039;&#039;Plot&#039;&#039;&#039;  or &#039;&#039;&#039;Result&#039;&#039;&#039;  statements we have to add a first statement to the SConstruct.  Enter the following statement (verbatim) into your new SConstruct:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This statement tells SCons where to find the &#039;&#039;&#039;Flow&#039;&#039;&#039; , &#039;&#039;&#039;Plot&#039;&#039;&#039;  and &#039;&#039;&#039;Result&#039;&#039;&#039;  commands, and must be included in &#039;&#039;&#039;every&#039;&#039;&#039;  SConstruct.&lt;br /&gt;
After that statement has been entered, you can enter as many &#039;&#039;&#039;Flow&#039;&#039;&#039; , &#039;&#039;&#039;Plot&#039;&#039;&#039;  and &#039;&#039;&#039;Result&#039;&#039;&#039;  commands as you wish making sure to use proper syntax.  It&#039;s helpful to use a text editor that has Python syntax highlighting, as that will help you find and remedy strings that are not closed.  You can also create Python comments using the &amp;lt;math&amp;gt;\#&amp;lt;/math&amp;gt; mark to indicate the beginning of a comment to help document your SConstructs.&lt;br /&gt;
&lt;br /&gt;
Lastly, you must include the following statement at the end of your SConstruct:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
End()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This statement tells SCons that the script is done and that it should not look for anything else in the script.  Make sure to include this statement as the very last item in every SConstruct. &lt;br /&gt;
Here&#039;s a sample SConstruct:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from rsf.proj import *  # Remember, this statement comes first... ALWAYS&lt;br /&gt;
Flow(&amp;quot;spike&amp;quot;,None,&amp;quot;sfspike n1=100 k1=50&amp;quot;) &lt;br /&gt;
# None is a trick, see Advanced SCons for more information&lt;br /&gt;
Flow(&amp;quot;spike1&amp;quot;,&amp;quot;spike&amp;quot;,&amp;quot;sfadd scale=4.0&amp;quot;)&lt;br /&gt;
Flow(&amp;quot;noise&amp;quot;,&amp;quot;spike1&amp;quot;,&amp;quot;sfnoise&amp;quot;)&lt;br /&gt;
Plot(&amp;quot;spike&amp;quot;,&#039;sfgraph title=&amp;quot;spike&amp;quot; &#039; ) # Note string nesting&lt;br /&gt;
Plot(&amp;quot;spike1&amp;quot;,&#039;sfgraph title=&amp;quot;spike1&amp;quot; &#039;) &lt;br /&gt;
Plot(&amp;quot;noise&amp;quot;,&#039;sfgraph title=&amp;quot;noisy&amp;quot; &#039;)&lt;br /&gt;
Result(&amp;quot;noise&amp;quot;,&#039;sfgraph title=&amp;quot;noisy&amp;quot; pclip=75 &#039;)&lt;br /&gt;
End() # Remember, this always ends the script.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: you do not have to order your &#039;&#039;&#039;Flow&#039;&#039;&#039; , &#039;&#039;&#039;Plot&#039;&#039;&#039;  and &#039;&#039;&#039;Result&#039;&#039;&#039;  commands as shown above.  You can mix &#039;&#039;&#039;Flow&#039;&#039;&#039; , &#039;&#039;&#039;Plot&#039;&#039;&#039;  and &#039;&#039;&#039;Result&#039;&#039;&#039;  in any order.  SCons automatically establishes the relationships between related files and commands.&lt;br /&gt;
&lt;br /&gt;
===Executing SCons===&lt;br /&gt;
Now that you have an SConstruct, you can start processing data the Madagascar way.  To do so open a terminal and navigate to the local directory where your SConstruct is located.  To execute your SConstruct simply run: &#039;&#039;&#039;scons&#039;&#039;&#039;  .  When you run SCons, it will check to make sure that all necessary dependencies are found and that all of your commands inside the SConstruct are valid.  If not, SCons will return an error message showing you where you made a mistake.  If everything is OK, then SCons will begin creating your files in the local directory and will output its progress as it executes the Madagascar programs on the command line.  For example, running the sample SConstruct from above should show something similar to the following output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scons: Reading SConscript files ...&lt;br /&gt;
scons: done reading SConscript files.&lt;br /&gt;
scons: Building targets ...&lt;br /&gt;
/opt/rsf/bin/sfspike n1=100 k1=50 &amp;gt; spike.rsf&lt;br /&gt;
&amp;lt; spike.rsf /opt/rsf/bin/sfadd scale=4.0 &amp;gt; spike1.rsf&lt;br /&gt;
&amp;lt; spike1.rsf /opt/rsf/bin/sfnoise &amp;gt; noise.rsf&lt;br /&gt;
&amp;lt; spike.rsf /opt/rsf/bin/sfgraph title=&amp;quot;spike&amp;quot; &amp;gt; spike.vpl&lt;br /&gt;
&amp;lt; spike1.rsf /opt/rsf/bin/sfgraph title=&amp;quot;spike1&amp;quot; &amp;gt; spike1.vpl&lt;br /&gt;
&amp;lt; noise.rsf /opt/rsf/bin/sfgraph title=&amp;quot;noisy&amp;quot; &amp;gt; noise.vpl&lt;br /&gt;
&amp;lt; noise.rsf /opt/rsf/bin/sfgraph title=&amp;quot;noisy&amp;quot; pclip=75 &amp;gt; Fig/noise.vpl&lt;br /&gt;
scons: done building targets.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the execution of scons ends with, &amp;quot;scons: done building targets&amp;quot; then the script completed successfully.  Check your local directory for your output files.&lt;br /&gt;
&lt;br /&gt;
===Common errors in SConstructs===&lt;br /&gt;
There are two common errors that most users will experience when executing SConstructs: missing dependency errors, and misconfiguration errors.  We&#039;ll demonstrate both of these errors to help new users troubleshoot them below. &lt;br /&gt;
The first error is caused by missing a dependency in the SConstruct.  To introduce this error into your SConstruct modify the sample SConstruct from above to the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from rsf.proj import *  # Remember, this statement comes first... ALWAYS&lt;br /&gt;
Flow(&amp;quot;spike1&amp;quot;,&amp;quot;spike&amp;quot;,&amp;quot;sfadd scale=4.0&amp;quot;)&lt;br /&gt;
Flow(&amp;quot;noise&amp;quot;,&amp;quot;spike1&amp;quot;,&amp;quot;sfnoise&amp;quot;)&lt;br /&gt;
Plot(&amp;quot;spike&amp;quot;,&#039;sfgraph title=&amp;quot;spike&amp;quot; &#039; ) # Note string nesting&lt;br /&gt;
Plot(&amp;quot;spike1&amp;quot;,&#039;sfgraph title=&amp;quot;spike1&amp;quot; &#039;) &lt;br /&gt;
Plot(&amp;quot;noise&amp;quot;,&#039;sfgraph title=&amp;quot;noisy&amp;quot; &#039;)&lt;br /&gt;
Result(&amp;quot;noise&amp;quot;,&#039;sfgraph title=&amp;quot;noisy&amp;quot; pclip=75 &#039;)&lt;br /&gt;
End() # Remember, this always ends the script.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now when you run &#039;&#039;&#039;scons&#039;&#039;&#039; , you should get an error message:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scons: Reading SConscript files ...&lt;br /&gt;
scons: done reading SConscript files.&lt;br /&gt;
scons: Building targets ...&lt;br /&gt;
scons: *** [spike1.rsf] Source `spike.rsf&#039; not found, needed by target `spike1.rsf&#039;.&lt;br /&gt;
scons: building terminated because of errors.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this case, SCons tells you exactly which file is missing and which output file is missing one of its dependencies.  To solve this problem, add the &#039;&#039;&#039;Flow&#039;&#039;&#039;  to create &#039;spike&#039; to the SConstruct.  If your SConstruct uses a file that is not created inside the SConstruct, and is complaining about a missing dependency, then make sure the file you are looking for is in a location that the SConstruct can access.&lt;br /&gt;
The second error, is caused by having a misconfigured command.  To demonstrate this type of error change your SConstruct to:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from rsf.proj import *  # Remember, this statement comes first... ALWAYS&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Flow&#039;&#039;&#039; (&amp;quot;spike&amp;quot;,None,&amp;quot;sfspike n1=100 k1=50&amp;quot;) &lt;br /&gt;
# None is a trick, see Users 4 for more information&lt;br /&gt;
&#039;&#039;&#039;Flow&#039;&#039;&#039; (&amp;quot;spike1&amp;quot;,&amp;quot;spike&amp;quot;,&amp;quot;sfasd scale=4.0&amp;quot;) &lt;br /&gt;
# HERE IS THE ERROR, NOTE sfasd instead of sfadd&lt;br /&gt;
&#039;&#039;&#039;Flow&#039;&#039;&#039; (&amp;quot;noise&amp;quot;,&amp;quot;spike1&amp;quot;,&amp;quot;sfnoise&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Plot&#039;&#039;&#039; (&amp;quot;spike&amp;quot;,&#039;sfgraph title=&amp;quot;spike&amp;quot; &#039; ) # Note string nesting&lt;br /&gt;
&#039;&#039;&#039;Plot&#039;&#039;&#039; (&amp;quot;spike1&amp;quot;,&#039;sfgraph title=&amp;quot;spike1&amp;quot; &#039;) &lt;br /&gt;
&#039;&#039;&#039;Plot&#039;&#039;&#039; (&amp;quot;noise&amp;quot;,&#039;sfgraph title=&amp;quot;noisy&amp;quot; &#039;)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Result&#039;&#039;&#039; (&amp;quot;noise&amp;quot;,&#039;sfgraph title=&amp;quot;noisy&amp;quot; pclip=75 &#039;)&lt;br /&gt;
&lt;br /&gt;
End() # Remember, this always ends the script.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
In this case, we&#039;ve introduced a typo into one of our commands.  When running scons, the result is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scons: Reading SConscript files ...&lt;br /&gt;
scons: done reading SConscript files.&lt;br /&gt;
scons: Building targets ...&lt;br /&gt;
/opt/rsf/bin/sfspike n1=100 k1=50 &amp;gt; spike.rsf&lt;br /&gt;
&amp;lt; spike.rsf sfasd scale=4.0 &amp;gt; spike1.rsf&lt;br /&gt;
sh: sfasd: command not found&lt;br /&gt;
scons: *** [spike1.rsf] Error 127&lt;br /&gt;
scons: building terminated because of errors.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Again, the error message is pretty descriptive and could help you track down the error relatively quickly.  It&#039;s important to note that in this case, the error was caught after SCons tried to execute the command and failed to do so, whereas the dependency error was caught before any commands were executed.  This means that this typo error would kill a script that&#039;s been running a long time without any issues up till that point.  Fortunately, SCons would restart the script at the point of failure thereby saving you all the additional time to recompute everything before this point in the script.&lt;br /&gt;
These are only two of the most common errors that novice users will see.  For additional information about debugging SConstructs, or for exceptionally strange errors please consult the [[SCons|online documentation]] or the RSF users mailing list.&lt;br /&gt;
&lt;br /&gt;
===Additional SCons commands===&lt;br /&gt;
Here are some additional SCons commands that are useful to know.&lt;br /&gt;
====Viewing Plots====&lt;br /&gt;
If you&#039;re running an SConstruct and want to view the plots that it generates as it creates them, then you can use: &#039;&#039;&#039;scons view&#039;&#039;&#039;  to force SCons to show the plots interactively.  Doing so allows you to view your output at runtime and to stop the SConstruct as it&#039;s running if you don&#039;t like what you see.&lt;br /&gt;
====Viewing only one plot====&lt;br /&gt;
If you want to view the plot associated with only a single file you can tell SCons to view that plot by using the command: &#039;&#039;&#039;scons file.view&#039;&#039;&#039;  where file is the filename of the item that you want to view.  For example: scons spike.view would show the plot of the spike.rsf file.  The advantage to using this command is that SCons will only build the dependencies needed to view that specific plot, which can save you a lot of time in longer processing scripts.&lt;br /&gt;
====Building specific targets====&lt;br /&gt;
If you want to build a specific RSF file, or a few specific RSF files you can simply specify them on the command line when you execute SCons as follows: &#039;&#039;&#039;scons file.rsf file2.rsf file3.rsf ...&#039;&#039;&#039; .  The advantage to doing this, is that SCons will only build those files and their dependencies instead of running through the entire script.&lt;br /&gt;
====Cleaning up====&lt;br /&gt;
After we&#039;ve executed our SConstruct and viewed the results of the processings flow, we might decide that we want to clean up our project and go work on something else.  Normally, one would have to delete all of the files and then move on, but SCons automates this process using the command: &#039;&#039;&#039;scons -c&#039;&#039;&#039; .  Simply execute it in the local directory and SCons will remove all of the built RSF files, and VPLOT files.  SCons will not remove files that it does not have rules for.&lt;br /&gt;
====Dry-runs====&lt;br /&gt;
Sometimes we want to test an SConstruct through the end of the script without waiting for it to run completely.  To do so, we can use &#039;&#039;&#039;scons -n&#039;&#039;&#039;  which tells SCons to simulate an actual execution. During a dry-run SCons will check all of the commands, and dependencies to ensure that they exist and are properly configured.  If not, then SCons will tell you which commands are misconfigured.  This command can save you hours of debugging!  Use it liberally.&lt;br /&gt;
====Parallel executions====&lt;br /&gt;
For long scripts we can use parallel execution to run multiple processing commands at the same time.  Parallel execution requires that the commands can function independently of one another (i.e. there are commands that do not depend on each other&#039;s output).  To use parallel execution use: &#039;&#039;&#039;pscons&#039;&#039;&#039;  which launches the maximum number of parallel jobs that your computer can handle at once.  Parallel execution can greatly speed up your processing flows if SCons can parallelize it.  In the worst case, SCons won&#039;t be able to parallelize your script and it will run at the same speed as if you just used &#039;&#039;&#039;scons&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
===Final thoughts===&lt;br /&gt;
At this point you should have a solid understanding of how to use SCons and create SConstructs to script your Madagascar processing flows.  Admittedly, SCons is somewhat complicated and difficult to understand at first, but don&#039;t give up.  By using SCons, you are able to create powerful Madagascar scripts that are completely reproducible and enjoy the benefits of using a powerful build management system.  However, we have not shown you the most useful aspects of SCons, which are demonstrated in the next tutorial, where we show how to integrate Python with SCons, thereby making processing flows that are even more powerful.&lt;br /&gt;
&lt;br /&gt;
==Advanced SCons==&lt;br /&gt;
Now that you have a grasp of how to use SCons to put together simple processing flows, we&#039;re going to show you how to abuse SCons to make more advanced processing flows that can handle multiple input and output files properly.  Additionally, we&#039;re going to demonstrate some SCons tricks that make your life easier, and allow you to work faster, and smarter.&lt;br /&gt;
===Multiple input files===&lt;br /&gt;
Many Madagascar programs require multiple input files and/or output multiple files.  In order for SCons to properly recognize that these additional files are dependencies for a specific output file we have to change the syntax that we use for &#039;&#039;&#039;Flow&#039;&#039;&#039; , &#039;&#039;&#039;Plot&#039;&#039;&#039;  and &#039;&#039;&#039;Result&#039;&#039;&#039;  statements.  To do so, we&#039;ll need to use Python lists to help us keep everything together when using our SCons commands.  We first discuss the case where we need multiple input files.  &lt;br /&gt;
An example of a Madagascar program that requires multiple input files is &#039;&#039;&#039;sfcat&#039;&#039;&#039; .  For reference, sfcat is used to concatenate multiple files together, essentially a file manipulation program.  For example, we might use sfcat on the command line in the following fashion:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt; file.rsf sfcat axis=2 &lt;br /&gt;
file1.rsf file2.rsf file3.rsf file4.rsf &amp;gt; catted.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To replicate this behavior using SCons we need to tell our &#039;&#039;&#039;Flow&#039;&#039;&#039;  statements about the presence of multiple input files.  &#039;&#039;&#039;Important: if we do not indicate to SCons that we have multiple input files then the dependency chain will not be correct and we cannot guarantee our results are correct&#039;&#039;&#039; .  We can easily tell SCons of the presence of multiple input files by using a Python list as our input file, instead of a string:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
Flow(&#039;catted&#039;,[&#039;file&#039;,&#039;file1&#039;,&#039;file2&#039;,&#039;file3&#039;,&#039;file4&#039;],&#039;sfcat axis=2 ${SOURCES[1:-1]}&#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
or, equivalently,&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
Flow(&#039;catted&#039;,&#039;file file1 file2 file3 file4&#039;,&#039;sfcat axis=2 ${SOURCES[1:-1]}&#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
As you may have noticed, there are two new items in this &#039;&#039;&#039;Flow&#039;&#039;&#039;  statement, but let&#039;s start by discussing only the list of file names: &#039;&#039;&#039;[&#039;file&#039;,&#039;file1&#039;,&#039;file2&#039;,&#039;file3&#039;,&#039;file4&#039;]&#039;&#039;&#039; .  The list of file names is simply a Python list of strings that contains each of the names of the files that we want to use in this Flow command.  As usual, we don&#039;t have to append the &#039;.rsf&#039; suffix to the end of these names because SCons adds it for us.  &lt;br /&gt;
The second new part to the &#039;&#039;&#039;Flow&#039;&#039;&#039;  command is:&lt;br /&gt;
&#039;&#039;&#039;&amp;amp;#36;{SOURCES[1:-1]&#039;&#039;&#039; }, referred to as the SCons source list,&lt;br /&gt;
which tells SCons about the presence of additional input files in the&lt;br /&gt;
command, and to substitute the names into the command automatically.&lt;br /&gt;
Without this command, SCons would not include the files in the final&lt;br /&gt;
command.  As an example of what the SCons source list does, compare&lt;br /&gt;
the two SConstructs below against one another.  The top is correct,&lt;br /&gt;
the bottom is incorrectly configured:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# Correct&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
Flow(&#039;file&#039;,None,&#039;spike n1=100&#039;)&lt;br /&gt;
Flow(&#039;file1&#039;,None,&#039;spike n1=100 mag=2&#039;)&lt;br /&gt;
Flow(&#039;file2&#039;,None,&#039;spike n1=100 mag=3&#039;)&lt;br /&gt;
Flow(&#039;file3&#039;,None,&#039;spike n1=100 mag=4&#039;)&lt;br /&gt;
Flow(&#039;file4&#039;,None,&#039;spike n1=100 mag=5&#039;)&lt;br /&gt;
Flow(&#039;catted&#039;,[&#039;file&#039;,&#039;file1&#039;,&#039;file2&#039;,&#039;file3&#039;,&#039;file4&#039;],&lt;br /&gt;
&#039;sfcat axis=2 ${SOURCES[1:-1]}&#039;)&lt;br /&gt;
End()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# Wrong&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
Flow(&#039;file&#039;,None,&#039;spike n1=100&#039;)&lt;br /&gt;
Flow(&#039;file1&#039;,None,&#039;spike n1=100&#039;)&lt;br /&gt;
Flow(&#039;file2&#039;,None,&#039;spike n1=100&#039;)&lt;br /&gt;
Flow(&#039;file3&#039;,None,&#039;spike n1=100&#039;)&lt;br /&gt;
Flow(&#039;file4&#039;,None,&#039;spike n1=100&#039;)&lt;br /&gt;
Flow(&#039;catted&#039;,[&#039;file&#039;,&#039;file1&#039;,&#039;file2&#039;,&#039;file3&#039;,&#039;file4&#039;],&#039;sfcat axis=2&#039;)&lt;br /&gt;
End()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you noticed the command line output from SCons, you would find that for the incorrect SConstruct, SCons ran the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt; file.rsf sfcat axis=2 &amp;gt; catted.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
which is not correct.  This is because SCons was not informed that the additional sources actually are used inside the command and did not substitute them in.  &lt;br /&gt;
The SCons source list contains a reference to all of the file names that we passed in our Python list earlier.  In order to access those names we have to use a specific notation, but it is essentially a Python list enclosed in curly brackets that begins with a &amp;amp;#36;. Since the source list is a Python list, we can get the file names in a few ways if we follow standard Python list conventions.   Standard Python list conventions are:&lt;br /&gt;
*List indexing starts with index 0, &lt;br /&gt;
*Lists may be negatively indexed, which returns the items from the end (e.g. LIST[-1]), &lt;br /&gt;
*Lists may be sliced using the LIST[start:end] notation, where start and end are indices, &lt;br /&gt;
*List slicing indices are inclusive for the starting index, and exclusive for the ending index (e.g. LIST[0:4] returns LIST[0],LIST[1],LIST[2],LIST[3] but NOT LIST[4], &lt;br /&gt;
*Open slicing indices may be used (e.g. LIST[2:] gets everything from index 2 to the end, and LIST[:4] returns everything from 0 to but not including 4).   &lt;br /&gt;
*Negative and positive indices may be used together (e.g. LIST[1:-1] returns all elements but the first and last). &lt;br /&gt;
These are the most useful conventions to remember, and the ones you will most frequently see.  Please see the Python documentation (freely available online) for more information about dealing with Lists.&lt;br /&gt;
Using the above conventions the following &#039;&#039;&#039;Flow&#039;&#039;&#039;  statements are all equivalent for lettings SCons know about the presence of multiple input files:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
Flow(&#039;catted&#039;,[&#039;file&#039;,&#039;file1&#039;,&#039;file2&#039;,&#039;file3&#039;,&#039;file4&#039;],&lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
sfcat axis=2 ${SOURCES[1]} ${SOURCES[2]} &lt;br /&gt;
    ${SOURCES[3]} ${SOURCES[4]}&lt;br /&gt;
&#039;&#039;&#039;)&lt;br /&gt;
Flow(&#039;catted&#039;,[&#039;file&#039;,&#039;file1&#039;,&#039;file2&#039;,&#039;file3&#039;,&#039;file4&#039;],&lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
sfcat axis=2 ${SOURCES[1:5]}&lt;br /&gt;
&#039;&#039;&#039;)&lt;br /&gt;
Flow(&#039;catted&#039;,[&#039;file&#039;,&#039;file1&#039;,&#039;file2&#039;,&#039;file3&#039;,&#039;file4&#039;],&lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
sfcat axis=2 ${SOURCES[1:-1]}&lt;br /&gt;
&#039;&#039;&#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note:  never use SOURCES[0] because SOURCES[0] corresponds to &#039;file&#039; which is already used by SCons for standard input.   Also, never use open slicing on the SOURCES list, because at the end of the SOURCES list are extra items added by SCons for safe keeping that will break the command if accidentally used.&lt;br /&gt;
&lt;br /&gt;
===Multiple outputs===&lt;br /&gt;
For multiple outputs, we can use the same conventions as before, except we specify a list of output files instead of input files, and we use the TARGETS SCons list, instead of SOURCES.  For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
Flow([&#039;pef&#039;,&#039;lag&#039;], &#039;dat&#039;, &#039;sflpef lag=${TARGETS[1]}&#039;).&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===None inputs===&lt;br /&gt;
Sometimes, &#039;&#039;&#039;Flow&#039;&#039;&#039; s are created that don&#039;t have an input file.  For example, files created using &#039;&#039;&#039;sfspike&#039;&#039;&#039;  do not require input files.  To get around the need for an input file, we can use the Python keyword &#039;&#039;&#039;None&#039;&#039;&#039; , equivalent to NULL in C or Java, to indicate to SCons that no input file is needed.  For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
Flow(&#039;spike&#039;,None,&#039;sfspike n1=100&#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Toggling standard input and standard output===&lt;br /&gt;
When None inputs are used, then standard input is no longer needed and can be disabled. To turn off standard input on a &#039;&#039;&#039;Flow&#039;&#039;&#039; , add another argument to the &#039;&#039;&#039;Flow&#039;&#039;&#039;  statement:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
Flow(&#039;spike&#039;,None,&#039;sfspike n1=100&#039;,stdin=0)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
When SCons runs this &#039;&#039;&#039;Flow&#039;&#039;&#039; , the output command line will be:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfspike n1=100 &amp;gt; spike.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Likewise, we can toggle output to standard output as well.  Standard output has two options, redirect to null or completely off.  For some programs we need to redirect standard output to null, and others will require standard output to be completely off.  To toggle standard output off use the following syntax:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
Flow(&#039;spike&#039;,None,&#039;sfspike n1=100&#039;,stdout=-1)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
OR to redirect to &amp;lt;tt&amp;gt;/dev/null&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
Flow(&#039;spike&#039;,None,&#039;sfspike n1=100&#039;,stdout=0)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Plots with a different output name===&lt;br /&gt;
Occasionally, you might want to create a plot with a different name than the input file.  For example, a file might have multiple axes, and you could window along one of the axes, to create multiple graphs from a single input file.  To distinguish between the different plots, you can rename the output files from Plot and Result commands using a syntax similar to Flow:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
Plot(&#039;output&#039;,&#039;input&#039;,&#039;sfgraph&#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This Plot command will produce output.vpl instead of input.vpl.  In this way, you can create multiple visualizations of the same file. This applies to Result commands as well.&lt;br /&gt;
&lt;br /&gt;
==Integrating Python with SCons==&lt;br /&gt;
Because SCons is written in Python, we can take advantage of all the features of the Python programming language.  By doing so, we are able to make our life a lot easier by: compartmentalizing build commands, creating functions for commonly used scripts, organizing our scripts to make them easier to understand.  Instead of giving an exhaustive tutorial of the combination of SCons and Python, we&#039;re going to demonstrate a few of the more commonly features of Python inside of SConstructs.  We leave it to the end user to develop additional techniques that further exploit the power of Python.&lt;br /&gt;
===A forewarning===&lt;br /&gt;
While Python and SCons are compatible with one another they are not completely interchangeable.  To understand why that is the case, you need to understand the underlying design of SCons. SCons is a &#039;&#039;declarative&#039;&#039;  language, which means that you tell SCons what to do through the: Flow, Plot, and Result commands, and then SCons decides how and when to execute those commands.  Python on the other hand is &#039;&#039;imperative&#039;&#039; , which means that as Python reads a Python script, it executes the commands immediately.  Python does not take time to decide how or when to execute your commands.  This point causes a bit of confusion to users who start to combine Python and SCons together because they expect SCons commands to execute in the order that they place them, which is not the case.  Because of this, you may not be able to use certain Python features in their native Python way.  For example, loops which require repeated computation, and whose results depend on the result of the last iteration are not possible using SCons.  It is also not usually possible to use Python variables that change during execution with SCons because the variable value that SCons will use is &#039;&#039;always&#039;&#039;  the last value of the variable.  Typically, you cannot use conditional statements in SCons, where the choice depends on a file that SCons will build.  &lt;br /&gt;
To be safe, you should always assume that whatever Python does happens &#039;&#039;before&#039;&#039;  SCons starts running commands.&lt;br /&gt;
===Variables===&lt;br /&gt;
The most effective way to combine SCons and Python is to use Python to manage important variables for your scripts.  For example, if you want to test a variety of values for a certain processing Flow, then you might save the value to a variable and then let Python format it correctly for you, instead of changing the string each time you want to run a new test.  You can also save all your variables in a convenient location and then easily change them to test different parameters as well.  For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
nx = 100&lt;br /&gt;
nz = 100&lt;br /&gt;
Flow(&#039;model&#039;,None,&#039;sfspike n1=&#039;+str(nx)+&#039;n2=&#039;+str(nz))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: variables must be converted to strings in order to be combined into the command statements.  Because these variables are converted using string concatenation, there is a possibility that a user could give a value of a wrong type.&lt;br /&gt;
&lt;br /&gt;
===String substitution===&lt;br /&gt;
While using variables is convenient, formatting them in the fashion shown above is not convenient.  An easier way to format variables for strings is to use string substitution.   String substitution works in the same way as the C - printf function works, i.e. we place markers that indicate where values should be substituted and what format they should be in.  The above example using string substitution is:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
nx = 100&lt;br /&gt;
nz = 100&lt;br /&gt;
Flow(&#039;model&#039;,None,&lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
sfspike n1=%d n2=%d &lt;br /&gt;
&#039;&#039;&#039; % (nx,nz) ) &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
In this statement, both nx, and nz are formatted as integers, and contained inside a tuple.  All variables to be used for string substitution must be contained within the tuple at the end of the string statement.  For reference, all C-printf like formatting choices are available in Python as well.  Note: treat booleans as integers in Python.&lt;br /&gt;
&lt;br /&gt;
===Dictionaries===&lt;br /&gt;
When scripts have a large number of variables, it is often easier to contain them within a Python dictionary instead of letting them float around the script.  Dictionaries are declared in key=value format in Python using the &#039;&#039;&#039;dict&#039;&#039;&#039;  keyword.  For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
parameters = dict(nx=100,nz=100,verb=True,final_file=&#039;output123&#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To access variables from within the dictionary, we use list-like indexing where the index given is the name of the variable that we want to access:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
nx = parameters[&#039;nx&#039;] # Returns 100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
We can also set variables within the dictionary, or modify their values after the initial declaration:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
parameters[&#039;nx&#039;] = 200 # Sets nx to 200&lt;br /&gt;
parameters[&#039;ny&#039;] = 150 # Adds ny, and sets it to 150&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To use the dictionary for string substitution, we only need to modify our formatters to include the key names of the variables that we wish to access from the dictionary.  For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
Flow(&#039;model&#039;,None,&lt;br /&gt;
	&#039;&#039;&#039;&lt;br /&gt;
	sfspike n1=%(nx)d n2=%(nz)d &lt;br /&gt;
	&#039;&#039;&#039; % parameters )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Notice that the formatters now have the name of the variable inside parentheses: %(nx)d before the formatting expression.  Then, the entire dictionary is passed to the string for substitution.  At runtime, Python places the values for the keys from the dictionary into the string.  If the values are the wrong type, or the key does not exist in the dictionary, then Python will throw an error at runtime, and prevent you from running with a bad value.&lt;br /&gt;
&lt;br /&gt;
By using dictionaries with string substitution, we can add flexibility to our scripts, and improve their readability, which ultimately improves the ability of others to reproduce our work.  Thus, you should strive to use dictionaries wherever possible in your SConstructs.&lt;br /&gt;
&lt;br /&gt;
===Loops===&lt;br /&gt;
Perhaps the most useful construct from Python that can be added to SConstructs are loops.  By using loops, we can automate many redundant processes.  To use a Python loop we just use the standard Python syntax in the following fashion:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
for i in range(10):&lt;br /&gt;
    count = str(i) # Convert integer to string&lt;br /&gt;
    Flow(&#039;spike-&#039;+count,None,&#039;sfspike n1=100 mag=&#039;+count)&lt;br /&gt;
    Plot(&#039;spike-&#039;+count,&#039;sfgraph&#039;)&lt;br /&gt;
End()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
In order for the loop to work, you need to make sure that all the files that are created have a unique file name.  The easiest way to do so is to use the loop index in the filename, the count variable in this case.  The count variable must be a string, because only strings can be concatenated together in Python.   If you want to make more complicated file names (from nested loops) then examine the printf like syntax for Python strings. &lt;br /&gt;
All the usual Python rules apply to these loops.  Typically, for loops are easier to understand than while loops in Python, and so we recommend using for loops for most purposes.&lt;br /&gt;
&lt;br /&gt;
===Functions===&lt;br /&gt;
Python functions are incredibly useful because you can compartmentalize repeated uses of commonly used &#039;&#039;&#039;Flow&#039;&#039;&#039; s, and then use them in multiple SConstructs.  For the best use of Python functions you should use the following conventions:&lt;br /&gt;
*always use keyword=value arguments to help document your code, &lt;br /&gt;
*list file names for input and output first, then other arguments, &lt;br /&gt;
*use default values for all arguments, even if they are None, &lt;br /&gt;
*use the locals() dictionary to get the values of the arguments, &lt;br /&gt;
*always perform an action inside the function (i.e. create a Flow, Plot or Result), &lt;br /&gt;
*do not return anything from the function, &lt;br /&gt;
*and always accept **kwargs as the last argument to allow for dictionary substitution. &lt;br /&gt;
Here&#039;s an example of a well-defined function to create a Ricker wavelet with a peak frequency specified by the user:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
def ricker(out=&#039;wave&#039;,freq=20.0,kt=100,nt=1001,dt=0.01,ot=0.0,**kwargs):&lt;br /&gt;
    Flow(out,None,&lt;br /&gt;
    	 &#039;&#039;&#039;&lt;br /&gt;
	 spike n1=%(nt)d o1=%(ot)f d1=%(d1)f &lt;br /&gt;
         nsp=1 mag=1.0 k1=%(kt)d l1=%(kt)d | &lt;br /&gt;
	 ricker1 frequency=%(freq)f &lt;br /&gt;
	 &#039;&#039;&#039; % locals())&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Notice that we use the python function &#039;&#039;&#039;locals()&#039;&#039;&#039;  for string substitution.  This function returns a dictionary that contains only the names and values of the named arguments for the function.  &lt;br /&gt;
To call this function, you can use it as a normal Python function.  Since there are default arguments, not all arguments need to be passed as long as you are OK with the default value.  &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
ricker(&#039;wave&#039;,freq=30,kt=50)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you are using a dictionary that has all of your variables in it, then you can call the function using explicit parameter fetching:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
ricker(&#039;wave&#039;,parameters[&#039;freq&#039;],parameters[&#039;kt&#039;],...)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
where you have to explicitly grab certain variables from the parameter dictionary.  Conversely, you can use automatic parameter fetching: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
ricker(&#039;wave&#039;,**parameters)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
which will look for all the named arguments to the ricker function in the parameter dictionary, and send their values to the function.  When there are many parameters, and you have already set them in the dictionary, then automatic parameter fetching is the best way to go.&lt;br /&gt;
&lt;br /&gt;
===Modules===&lt;br /&gt;
Of course, functions can be compiled into groups and then placed into Python modules for widespread re-use throughout your SConstructs.  Commonly used Python modules are currently located in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/book/Recipes&amp;lt;/tt&amp;gt;, which is where you should place your modules as well.  As usual, you must use correct Python syntax to access functions contained within modules.  For example, if you create a module called myutil.py, then you can access your functions in the following manner:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import myutil&lt;br /&gt;
myutil.ricker(...)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Classes===&lt;br /&gt;
The least used, but most powerful part of Python that you can bring into your SConstructs are Python classes.   For example, if you are writing a script to process multiple models in the exact same way, but that have different parameters you would have to write separate Flow statements to process each of them, OR you could write a Python class that takes the model parameters and uses those parameters to generate Flow statements automatically, similar to functions.  However, a class can allow you to group functions together into a single coherent body and allow you to drastically reduce the amount of code that must be reused.  &lt;br /&gt;
We refer the reader to the Python documentation for more information on creating and using classes.&lt;br /&gt;
&lt;br /&gt;
===Final thoughts===&lt;br /&gt;
Congratulations on completing the Madagascar User tutorial series.  Now, you should have all the tools to: use Madagascar programs, write SConstructs to script your processing flows, and combine Python with SCons to make powerful scripts that can process data in ways not previously possible.  From here, you can continue learning about how to write your own Madagascar programs, or learn about how to make reproducible documents using the Madagascar framework.&lt;br /&gt;
&lt;br /&gt;
=Authors=&lt;br /&gt;
The Authors tutorials demonstrate how one can create reproducible documents using the Madagascar processing package and L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX together.  By the end of the Authors tutorials, you should be able to:&lt;br /&gt;
  &lt;br /&gt;
*build papers, including: SEG and EAGE abstracts, manuscripts for Geophysics, and handouts, &lt;br /&gt;
*build a CSM thesis, &lt;br /&gt;
*build a CWP report, &lt;br /&gt;
*build slides, &lt;br /&gt;
*and add/modify Latex class files to add your custom document formats to Madagascar. &lt;br /&gt;
After completing this tutorial series, you will be able to maximize your research productivity using Madagascar.&lt;br /&gt;
&lt;br /&gt;
==Getting started==&lt;br /&gt;
Before you can get started writing reproducible documents, you need to ensure that your system is properly setup.  This section of the tutorial will walk you through the setup process, which can be somewhat difficult and laborious depending on which operating system you are on, as you will need a full installation of L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX and additional L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX class files that Madagascar makes available to you. The good news is that this configuration only happens once.&lt;br /&gt;
===Downloading L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX===&lt;br /&gt;
To begin, you need to download a full installation of L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX for your operating system.  To do so, you may need to contact your system administrator.  If you have administrative rights, then you can download a full install for your platform from the following locations:&lt;br /&gt;
  &lt;br /&gt;
*Linux - use your package management software to install a full texlive (you may need additional packages depending on your distribution). &lt;br /&gt;
*Mac - install MacTex http://www.tug.org/mactex/2011/. &lt;br /&gt;
*Windows - install MikTex http://miktex.org/. &lt;br /&gt;
The respective downloads typically are quite large and take a substantial amount of time to complete, so start the download and come back later.  Once your download is done, test your installation by executing &#039;&#039;&#039;pdflatex&#039;&#039;&#039;  at the command line.  If everything works fine then continue onwards. For Mac users, you may need &amp;quot;sudo port install texlive-latex-extra&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Downloading SEGTeX===&lt;br /&gt;
The next step is to download the SEG\TeX class files, which tells L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX how to build certain documents that we commonly use.  To download SEG\TeX first &#039;&#039;&#039;cd&#039;&#039;&#039;  to a directory where L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX can find additional class files.  This directory is typically operating system dependent, and may be distribution dependent for Linux.  Typically, you can place these files in &#039;&#039;&#039;&amp;amp;#36;HOME/texmf&#039;&#039;&#039; .  Otherwise, you will need to place them in the root installation for Latex which can be found by searching for the basic class files, such as article.cls.  On a Mac the typical place to put these files is &#039;&#039;&#039;&amp;amp;#36;HOME/Library/texmf&#039;&#039;&#039; .  In any case, once you are in the proper location, then use the following command to download the class files (using subversion):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn co https://segtex.svn.sourceforge.net/svnroot/segtex/trunk texmf &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or download a stable release from http://sourceforge.net/projects/segtex/files/ and unpack it into the &amp;lt;tt&amp;gt;texmf&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
===Updating your L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX install===&lt;br /&gt;
Once the class files are successfully downloaded, you will need to run &#039;&#039;&#039;texhash&#039;&#039;&#039;  or &#039;&#039;&#039;texconfig rehash&#039;&#039;&#039;  to update L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX about the new class files.  For reference, a successful run of &#039;&#039;&#039;texhash&#039;&#039;&#039;  produces the following output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
jgodwin&amp;amp;#36; texhash&lt;br /&gt;
texhash: Updating /usr/local/texlive/2010/../texmf-local/ls-R... &lt;br /&gt;
texhash: Updating /usr/local/texlive/2010/texmf/ls-R... &lt;br /&gt;
texhash: Updating /usr/local/texlive/2010/texmf-config/ls-R... &lt;br /&gt;
texhash: Updating /usr/local/texlive/2010/texmf-dist/ls-R... &lt;br /&gt;
texhash: Updating /usr/local/texlive/2010/texmf-var/ls-R... &lt;br /&gt;
texhash: Done.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To determine if these files are found successfully, go into &amp;amp;#36;RSFROOT/book/rsf/manual and run &#039;&#039;&#039;scons manual.read&#039;&#039;&#039; .  If L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX complains about being unable to find the class files then you should re-run texhash, or make sure that your class files are in the proper location.  If you are still having difficulties, then contact the [[SEGTeX|SEGTeX webpage]] or the user mailing list for further information.&lt;br /&gt;
&lt;br /&gt;
==Papers==&lt;br /&gt;
With L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX installed, we can now create reproducible documents using Madagascar.  First, we will demonstrate how to build shorter, less complicated documents using Madagascar, such as SEG/EAGE abstracts, Geophysics articles, and handouts.  All of these papers have similar build styles, so the rules for building each respective paper have only slight differences from one another.  Instead of talking in detail about each of these documents, we illustrate the basic idea for each of the documents, and provide examples that demonstrate the particulars for each type of document.  &lt;br /&gt;
===Paper organization===&lt;br /&gt;
All Madagascar papers expect a specific organization to your directories.  In particular, you are expected to have a paper-level directory where your &#039;&#039;&#039;tex&#039;&#039;&#039;  files and main SConstruct will exist.  These files will tell Madagascar how to build your documents for a particular project.  You can have multiple documents built from the same location, using the same SConstruct as we will demonstrate later.  &lt;br /&gt;
Below the paper directory, are the individual &amp;quot;chapters&amp;quot; that contain the processing flows used to generate the plots or process the data that you wish to use in your reproducible documents.  Ideally, each &amp;quot;chapter&amp;quot; directory correlates to the processing flows or examples in each chapter or section for your paper.  Additionally, each &amp;quot;chapter&amp;quot; contains its own SConstruct that operates independently of the paper SConstruct one level above it.  Furthermore, inside the &amp;quot;chapter&amp;quot; folder, Madagascar needs to have a &#039;&#039;&#039;Fig&#039;&#039;&#039;  folder that contains all of the VPLOT files that were created using Result commands during processing.    This folder is automatically created during processing using SCons, so you don&#039;t need to manually create it.  It is important to note that Madagascar can only locate VPLOT files that are in this file hierarchy for use in your papers.  The figure below illustrates the folder hierarchy as well.&lt;br /&gt;
Note: &amp;quot;chapter&amp;quot; folders may be symbolic links that point to folders elsewhere on the file system.  This trick can be useful to reuse figures without copying files and folders around to various folders.  If you use symlinks, make sure to avoid editing files that are symbolically linked, as your changes may propagate in unintended ways to other projects and papers.&lt;br /&gt;
[[Image:dir.png|frame|center|The organizational hierarchy for Madagascar paper directories.]]&lt;br /&gt;
&lt;br /&gt;
===Locking figures===&lt;br /&gt;
Once you have created the necessary folder hierarchy with your &amp;quot;chapters&amp;quot; and processing flows, then go ahead and run your processing SConstructs.  After those are finished, you need to lock your figures using &#039;&#039;&#039;scons lock&#039;&#039;&#039; .  &#039;&#039;&#039;scons lock&#039;&#039;&#039;  tells Madagascar that the figures you have generated are ready to go into a publication, and will store them in a subfolder of the &#039;&#039;&#039;&amp;amp;#36;RSFFIGS&#039;&#039;&#039;  directory for safe keeping.  Locked figures are used for document figures instead of the figures in your local directory, because they are locked and not still changing.  If you change your plots but do not lock your figures, you will not see your figures change.  Always make sure to lock your figures before building a document.&lt;br /&gt;
===TeX files===&lt;br /&gt;
Now that your figures are locked, you can create your first reproducible document in Madagascar.  To do so, you will need to:&lt;br /&gt;
*make your TeX files, and  &lt;br /&gt;
*make a paper SConstruct,  &lt;br /&gt;
Before making a document, you need to create your TeX files in the paper level directory.   For example, to create an EAGE abstract, you would create a main TeX file called: &#039;&#039;&#039;eageabs.tex&#039;&#039;&#039;  which contains the content and TeX commands to build your abstract.  Your TeX file can use all of the standard and expanded L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX commands provided by any available packages on your system. It&#039;s important to remember that you should try and break apart your TeX files into manageable chunks, so that you can modify them independently, or reuse the content in other documents.  For example, instead of having a single TeX file for your EAGE abstract, you could have a separate TeX file that contains: &#039;&#039;&#039;\input{...}&#039;&#039;&#039;  statements that include additional TeX files for each section, such as the abstract, theory, discussion, conclusions, etc.&lt;br /&gt;
Additionally, Madagascar provides some convenience commands for often used L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX functions.  Here is a short description of some of those convenience commands that you may run across.  Here&#039;s a brief list of these convenience functions:&lt;br /&gt;
*&amp;lt;font color=&amp;quot;#cd4b19&amp;quot;&amp;gt;\plot&amp;lt;/font&amp;gt;, &lt;br /&gt;
*&amp;lt;font color=&amp;quot;#cd4b19&amp;quot;&amp;gt;\multiplot&amp;lt;/font&amp;gt;, &lt;br /&gt;
*&amp;lt;font color=&amp;quot;#cd4b19&amp;quot;&amp;gt;\sideplot&amp;lt;/font&amp;gt;, &lt;br /&gt;
*and more. &lt;br /&gt;
These convenience functions are not available for every type of document, but are demonstrated in documents where they are available.  The definition for the convenience functions may be found in the L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX class definitions listed at the end of this tutorial.&lt;br /&gt;
&lt;br /&gt;
===Paper SConstructs===&lt;br /&gt;
One of Madagascar&#039;s aims is to make TeX files as layout-agnostic as possible.  To do so, Madagascar automatically adds the TeX document preamble (including the L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX document class information), the L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX package inclusions, and end of document information at runtime.  This allows you to generate multiple documents from a single TeX file by simply changing the SConstruct, instead of the TeX file.  &lt;br /&gt;
Note: the paper SConstruct is only used to build papers.  It contains no other information, and cannot be used to process data in the same SConstruct.  This is why the paper SConstruct must exist in a separate directory from any processing SConstructs.&lt;br /&gt;
The paper SConstruct is very simple compared to most processing SConstructs, in that it contains only a few lines as shown below (in an example for an EAGE abstract):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from rsf.tex import *&lt;br /&gt;
Paper(&#039;eageabs&#039;,&lt;br /&gt;
      lclass=&#039;eageabs&#039;,&lt;br /&gt;
      options=&#039;11pt&#039;,&lt;br /&gt;
      use=&#039;times,natbib,color,amssymb,amsmath,amsbsy,graphicx,fancyhdr&#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The first section, &#039;&#039;&#039;from rsf.tex import *&#039;&#039;&#039;  tells Madagascar to import Python packages for processing TeX files instead of the usual processing packages.  Next, we call a &#039;&#039;&#039;Paper&#039;&#039;&#039;  object, which takes the following parameters:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Paper(name,lclass,options,use)&lt;br /&gt;
name - name of the root tex file to build.&lt;br /&gt;
lclass - name of the LaTeX class file to use.&lt;br /&gt;
options - document options for LaTeX class file.&lt;br /&gt;
use - names of LaTeX packages to import during compilation.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
All of the parameters are passed as strings to the Paper object.  Parameters with more that one possible value (e.g. options and use) accept comma delimited strings as shown above.  &lt;br /&gt;
To generate different types of documents, you simply change the &#039;&#039;&#039;lclass&#039;&#039;&#039;  and options sent to the Paper object in the SConstruct for the respective document type.  Since the documents that we are creating use custom L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX document classes that require additional TeX commands to function properly, it is easier for us to provide you with a template instead of discussing the details of each document class.  The templates for the documents can be found in the following directory: &#039;&#039;&#039;$RSFSRC/book/tutorial/authors&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
===Templates===&lt;br /&gt;
To run the templates, you first need to generate the data used for them in the &#039;&#039;&#039;data&#039;&#039;&#039;  directory inside of the &#039;&#039;&#039;$RSFSRC/book/tutorial/authors&#039;&#039;&#039; .  To do so, run &#039;&#039;&#039;scons lock&#039;&#039;&#039;  which will produce and lock the figures necessary.  Then go into the template directory that you are interested in, and make a symbolic link to the data directory: &#039;&#039;&#039;ln -s ../data&#039;&#039;&#039;  and a symbolic link to the BibTeX file: &#039;&#039;&#039;ln -s ../demobib.bib&#039;&#039;&#039;  in the template directory.  After those steps are made you can build and view the paper using &#039;&#039;&#039;scons&#039;&#039;&#039;  or &#039;&#039;&#039;scons paper.read&#039;&#039;&#039;  where paper is the name of the root tex file.  Of course, if you want to remove all the generated files, then you can use &#039;&#039;&#039;scons -c&#039;&#039;&#039;  to clean the directory.&lt;br /&gt;
&lt;br /&gt;
===Handouts===&lt;br /&gt;
Handouts are informal documents that are loosely formatted, and very flexible.  The handout example is located in: &#039;&#039;&#039;$RSFSRC/book/tutorial/authors/handout&#039;&#039;&#039; .  Handouts do not require many additional arguments and are the most flexible of the documents discussed here.&lt;br /&gt;
&lt;br /&gt;
===EAGE abstracts===&lt;br /&gt;
EAGE abstracts are short documents, with a few particular formatting tricks. In particular, EAGE requires the logo of the current year&#039;s convention to appear in the abstract.  A template is available in: &#039;&#039;&#039;$RSFSRC/book/tutorial/authors/eage&#039;&#039;&#039; .&lt;br /&gt;
&lt;br /&gt;
===SEG abstracts===&lt;br /&gt;
SEG abstracts are different from EAGE abstracts in that they require two-column formatting and are strictly limited to four pages not including references.  To build an SEG abstract, we first build the abstract, and then build another document using the segcut.tex file that removes the references from the final pdf.  An example is found in: &#039;&#039;&#039;$RSFSRC/book/tutorial/authors/seg&#039;&#039;&#039; .&lt;br /&gt;
&lt;br /&gt;
===Geophysics manuscripts===&lt;br /&gt;
Geophysics manuscripts come in two flavors: the first is the manuscript prepared for peer review, and the second is the final document that would appear in a print version of Geophysics.  The example shows how to build both from the same TeX files, which makes it painless to transition the formatting between the two documents.  An example is located in: &#039;&#039;&#039;$RSFSRC/book/tutorial/authors/geophys&#039;&#039;&#039; .  Make sure to use the template as there are quite a few additional TeX commands that have to be used to get the correct formatting.&lt;br /&gt;
&lt;br /&gt;
===CWP reports===&lt;br /&gt;
CWP reports are slightly more complicated then most documents in that they require substantial modification to get the proper formatting.  The CWP template is available in &#039;&#039;&#039;$RSFSRC/book/tutorial/authors/cwp&#039;&#039;&#039; .&lt;br /&gt;
&lt;br /&gt;
==Slides==&lt;br /&gt;
Additionally, one can create presentation slides using L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX  and Madagascar together.  To create slides, we use the Beamer class files that have been customized for the CWP.  Slides have distinctly different commands then regular documents, so be sure to examine the template before diving in.  The template is in: &#039;&#039;&#039;$RSFSRC/book/tutorial/authors/slides&#039;&#039;&#039; .&lt;br /&gt;
&lt;br /&gt;
==Theses==&lt;br /&gt;
One can also create very complex documents using Madagascar in a reproducible way.  To iillustrate this point we provide a template for building a thesis for the Colorado School of Mines.  This template is quite heavily modified, and requires substantial modification due to all the formatting requirements.  If you want to include a thesis template for another institution then you can do so by examining this template along with the CSM class files.  The template is located in: &#039;&#039;&#039;$RSFSRC/book/tutorial/authors/thesis&#039;&#039;&#039; .&lt;br /&gt;
&lt;br /&gt;
==Books==&lt;br /&gt;
You can make whole books using Madagascar.  The advantage to doing so, is that you can make individual chapters with examples of processing or workflows that can be run independently of one another.  Then Madagascar will stitch the chapters together into a cohesive package seamlessly.  The example for a book is this document itself, which is located in: &#039;&#039;&#039;$RSFSRC/book/tutorial/&#039;&#039;&#039; .  Note: creating a book is significantly different from creating a paper.&lt;br /&gt;
&lt;br /&gt;
==Adding/modifying L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX class files==&lt;br /&gt;
The L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX class files made available from SEGtex are found in &#039;&#039;&#039;texmf/tex/latex&#039;&#039;&#039; .  You can modify these files locally by changing the files inside this location.  &lt;br /&gt;
To add your own L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX class files, place them in this same directory, and then request SEG\TeX access to commit them to the main repository.&lt;br /&gt;
==Using the default L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX class files==&lt;br /&gt;
Lastly, you can use any of the default L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX class files just by changing the options to the Paper object to the appropriate lclass and options. For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
Paper(&#039;article&#039;,&lt;br /&gt;
lclass=&#039;article&#039;,&lt;br /&gt;
options=&#039;11pt&#039;,&lt;br /&gt;
use=&#039;times,natbib,color,amssymb,amsmath,amsbsy,graphicx,fancyhdr&#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Developers=&lt;br /&gt;
The goal of this brief tutorial is to demonstrate the key concepts&lt;br /&gt;
behind writing programs for Madagascar.  Since the Madagascar API is&lt;br /&gt;
well documented, we focus on a high level view of the development&lt;br /&gt;
process and the core design functionality.  For technical details of&lt;br /&gt;
how to interface with the Madagascar API for a specific programming&lt;br /&gt;
language, we refer the reader to the current online documentation&lt;br /&gt;
mentioned at the end of this tutorial.&lt;br /&gt;
By the end of this tutorial, you should understand the basic design of&lt;br /&gt;
Madagascar programs, and where to find more information about how to&lt;br /&gt;
develop programs using your programming language of choice.&lt;br /&gt;
==Core design==&lt;br /&gt;
As previously mentioned, the main way for programs to communicate in&lt;br /&gt;
Madagascar is through RSF files.  Thus, Madagascar programs are&lt;br /&gt;
expected to read RSF files, process them, and then write RSF files as&lt;br /&gt;
outputs that can be then used in other RSF programs.  At the highest&lt;br /&gt;
level of abstraction, we can consider RSF programs as black boxes that&lt;br /&gt;
simply input and output RSF files and do something to them in between.&lt;br /&gt;
From a practical standpoint, your programs will first read RSF files&lt;br /&gt;
from disk into memory (or progressively do so) as hypercubes.  Once&lt;br /&gt;
the file is read,the program processes the hypercubes using routines&lt;br /&gt;
that you design or external libraries.  After processing, you then&lt;br /&gt;
write the hypercubes to RSF files on disk.&lt;br /&gt;
In pseudocode this process looks something like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
data = make_array()&lt;br /&gt;
&lt;br /&gt;
input = rsf_input()&lt;br /&gt;
&lt;br /&gt;
rsf_read(input,data) &lt;br /&gt;
&lt;br /&gt;
. . . process data . . .&lt;br /&gt;
&lt;br /&gt;
output = rsf_output()&lt;br /&gt;
&lt;br /&gt;
rsf_write(output,data)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==Core API==&lt;br /&gt;
Madagascar provides core APIs for each language to ease the process of&lt;br /&gt;
reading/writing files.  Additionally, the core API provides functions&lt;br /&gt;
to parse command line variables that can be used to control the&lt;br /&gt;
execution of your programs.&lt;br /&gt;
In some languages, the API is extended to allow you to access commonly&lt;br /&gt;
used functions from the RSF main library.  For example, you can&lt;br /&gt;
use the FFT library that is contained in Madagascar.  &lt;br /&gt;
==Program design philosophy==&lt;br /&gt;
While Madagascar does not strictly have a design requirement for&lt;br /&gt;
programs to enter the main distribution, there are some general&lt;br /&gt;
guidelines to programs that we would like developers to follow.  In&lt;br /&gt;
particular, we would like developers to: design programs that have&lt;br /&gt;
error handling and parameter checking, that accept command line&lt;br /&gt;
arguments to control important parameters in the program, and write&lt;br /&gt;
programs that are limited in scope.  For example, a program that is&lt;br /&gt;
limited in scope is a program that computes the Fourier transform of a&lt;br /&gt;
real-valued signal and outputs a complex-valued RSF file.  Conversely,&lt;br /&gt;
a program that overreaches in its scope, would be a program that&lt;br /&gt;
conducts a long series of processing completely in another language&lt;br /&gt;
(say C or Fortran).  You should avoid designing programs with too much&lt;br /&gt;
scope, because you cannot fully leverage the advantages of SCons and&lt;br /&gt;
Python, if everything is happening inside a C or Fortran program.&lt;br /&gt;
[[Image:pipe.png|frame|center|A Madagascar program reads RSF files, processes them, and then outputs them at the most fundamental level.]]&lt;br /&gt;
&lt;br /&gt;
==Final thoughts==&lt;br /&gt;
With this background, and some additional information provided below,&lt;br /&gt;
you should be able to start writing your own Madagascar programs to&lt;br /&gt;
process data and implement algorithms that are not provided with&lt;br /&gt;
Madagascar by default.  We welcome you to the developer community, and&lt;br /&gt;
would greatly appreciate it if you would consider releasing your&lt;br /&gt;
programs to the community as a whole.&lt;br /&gt;
If you have further questions, please feel free to ask the RSF mailing lists.&lt;br /&gt;
==Further information==&lt;br /&gt;
* For more information about using the API for a particular language, please see [[Guide to madagascar API]]&lt;br /&gt;
* For more information about developing Madagascar programs in general see [[Adding new programs to Madagascar]]&lt;br /&gt;
* For more information about contributing your programs see [[Contributing new programs to Madagascar]]&lt;br /&gt;
* For a full reference of the C API see [http://www.ahay.org/RSF/book/rsf/manual/manual_html/ Manual]&lt;br /&gt;
&lt;br /&gt;
=Quick reference=&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;2&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Environmental variables that are used in Madagascar programs&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;RSFROOT&#039;&#039;&#039; || location of the main Madagascar installation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;RSFSRC&#039;&#039;&#039; || location of the source for Madagascar &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DATAPATH&#039;&#039;&#039; || location where to put the binary RSF files &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;RSF_MEMSIZE&#039;&#039;&#039; || maximum memory size for some programs to use &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PYTHONPATH&#039;&#039;&#039; || set to point to Python libraries &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;LD_LIBRARY_PATH || set to point to RSF dynamic libraries &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&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;
! style=&amp;quot;background:#ffdead;&amp;quot; | Using programs on the command line&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;sfprogram &amp;lt; input.rsf arg1=val1 arg2=val2 ... &amp;gt; output.rsf&amp;lt;/tt&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;sftransp &amp;lt; file.rsf plane=12 &amp;gt; file2.rsf&amp;lt;/tt&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;sftransp &amp;lt; file.rsf plane=12 &amp;lt;math&amp;gt;|&amp;lt;/math&amp;gt; sftransp plane=23 &amp;lt;math&amp;gt;|&amp;lt;/math&amp;gt; sftransp plane=34 &amp;gt; file2.rsf&amp;lt;/tt&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&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;2&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Some useful programs&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sfdoc -k . &amp;lt;math&amp;gt;|&amp;lt;/math&amp;gt; less&#039;&#039;&#039; || show program descriptions&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sfbrowser&#039;&#039;&#039; || show program browser &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sfgui&#039;&#039;&#039; || show tkMadagascar GUI &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sfspike&#039;&#039;&#039;  || create RSF files &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sfmath&#039;&#039;&#039; || create and manipulate RSF files &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sftransp&#039;&#039;&#039; || change the order of axes in RSF files &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sfwindow&#039;&#039;&#039; || window out portions of RSF files  &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sfricker1&#039;&#039;&#039; || create a Ricker wavelet  &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sfft1&#039;&#039;&#039; || FFT on the first axis (real to complex)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sffft3&#039;&#039;&#039; || FFT on other axes (complex)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sfnoise&#039;&#039;&#039; || add noise &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sfdd&#039;&#039;&#039; || convert datasets&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sfgrey&#039;&#039;&#039; || make raster plots  &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sfcat&#039;&#039; || concatenate datasets together &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sfput&#039;&#039;&#039; || modify header values &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sfsegyread&#039;&#039;&#039; || read SEGY/SU files &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;sfsegywrite&#039;&#039;&#039; || write SEGY/SU files&lt;br /&gt;
|}&lt;br /&gt;
&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;2&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | SCons commands&lt;br /&gt;
|- &lt;br /&gt;
| &#039;&#039;&#039;scons&#039;&#039;&#039; || run an SConstruct&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;scons view&#039;&#039;&#039; || view the results from an SConstruct, run if necessary &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;scons lock&#039;&#039;&#039; || lock the results from an SConstruct &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;scons -c&#039;&#039;&#039;  || clean the local directory, delete all target files  &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;scons -n&#039;&#039;&#039; || dry-run of an SConstruct &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;scons --debug=explain&#039;&#039;&#039; || explain why SCons is doing what it does &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;pscons&#039;&#039;&#039; || parallel execution of an SConstruct    &lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Fomels</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Package_overview&amp;diff=4633</id>
		<title>Package overview</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Package_overview&amp;diff=4633"/>
		<updated>2024-10-29T22:11:51Z</updated>

		<summary type="html">&lt;p&gt;Fomels: typos&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_5127720_XS.jpg|right|]]&lt;br /&gt;
&lt;br /&gt;
The mission of the Madagascar project is to provide a &#039;&#039;&#039;shared research environment&#039;&#039;&#039; for computational data analysis in geophysics and related fields.&lt;br /&gt;
&lt;br /&gt;
The Madagascar environment consists of:&lt;br /&gt;
# Standalone programs for out-of-core data analysis;&lt;br /&gt;
# Standalone programs for geophysical data processing and imaging;&lt;br /&gt;
# A development kit for C, C++, Java, Fortran-77, Fortran-90, Python, Matlab, and Octave;&lt;br /&gt;
# A framework for reproducible numerical experiments, based on [http://www.scons.org/ SCons];&lt;br /&gt;
# A framework for scientific publications, based on [http://www.scons.org/ SCons] and [http://en.wikipedia.org/wiki/LaTeX LaTeX];&lt;br /&gt;
# A collection of reproducible scientific articles also used as usage examples and regression tests for the standalone programs;&lt;br /&gt;
# A collection of datasets used as input to reproducible numerical experiments.&lt;br /&gt;
&lt;br /&gt;
This guide serves as a brief introduction to different components and shows how they all fit together.&lt;br /&gt;
&lt;br /&gt;
==How to obtain Madagascar==&lt;br /&gt;
&lt;br /&gt;
See [[Download|download]] and [[Installation | installation instructions]]. Madagascar runs on Unix/Linux platforms, including MacOS X and Unix emulations under Microsoft Windows. Its installation requires a working C compiler and Python. &lt;br /&gt;
&lt;br /&gt;
==How to find your way around Madagascar==&lt;br /&gt;
&lt;br /&gt;
Start by checking the [[Reproducible_Documents|list of reproducible papers]]. If any of these papers look close to your interests, follow the links until you find a figure with a &amp;quot;wrench&amp;quot; button under it [[Image:configure.png]]. Click on the wrench, and it will open a computational recipe used for generating the figure (the &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file). &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
Flow(&#039;rose&#039;,None,&lt;br /&gt;
     &#039;&#039;&#039;&lt;br /&gt;
     math 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; |&lt;br /&gt;
     rtoc |&lt;br /&gt;
     math output=&amp;quot;input*exp(I*x1)&amp;quot;&lt;br /&gt;
     &#039;&#039;&#039;)&lt;br /&gt;
Result(&#039;rose&#039;,&lt;br /&gt;
       &#039;graph title=Rose screenratio=1 wantaxis=n&#039;)&lt;br /&gt;
End()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
You can copy this recipe to your computer or find it already in the &amp;quot;book&amp;quot; subtree under the Madagascar source directory. For example, the recipe at https://ahay.org/RSF/book/rsf/rsf/sfmath.html also exists in the file &amp;lt;tt&amp;gt;RSFSRC/book/rsf/rsf/sfmath/SConstruct&amp;lt;/tt&amp;gt;. After copying or locating the appropriate &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file,&lt;br /&gt;
run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scons view&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
on the command line to generate all the figures in the selected project and to display them on your screen. For example, try&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ cd RSFSRC/book/rsf/rsf/sfmath&lt;br /&gt;
bash$ scons view&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
where &amp;lt;tt&amp;gt;bash$&amp;lt;/tt&amp;gt; stands for the Unix prompt and &amp;lt;tt&amp;gt;RSFSRC&amp;lt;/tt&amp;gt; stands for the Madagascar source directory. The output should look like&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scons: Reading SConscript files ...&lt;br /&gt;
scons: done reading SConscript files.&lt;br /&gt;
scons: Building targets ...&lt;br /&gt;
/RSFROOT/bin/sfmath n1=629 d1=0.01 o1=0 n2=40 d2=1 o2=5 output=&amp;quot;x2*(8+sin(6*x1+x2/10))&amp;quot; | /RSFROOT/bin/sfrtoc | &lt;br /&gt;
/RSFROOT/bin/sfmath output=&amp;quot;input*exp(I*x1)&amp;quot; &amp;gt; rose.rsf&lt;br /&gt;
&amp;lt; rose.rsf /RSFROOT/bin/sfgraph title=Rose screenratio=1 wantaxis=n &amp;gt; Fig/rose.vpl&lt;br /&gt;
/RSFROOT/bin/sfpen Fig/rose.vpl&lt;br /&gt;
scons: done building targets.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
with a picture appearing on your screen.&lt;br /&gt;
[[Image:rose.png|frame|center]]&lt;br /&gt;
If there are several figures in the recipe, you can run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scons figurename.view&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
(e.g. &amp;lt;tt&amp;gt;scons rose.view&amp;lt;/tt&amp;gt;) to display individual figures. To remove all files that &amp;lt;tt&amp;gt;scons view&amp;lt;/tt&amp;gt; generated, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scons -c view&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you want to know in advance what commands will be executed to generate the figures, try&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scons -n view&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can output this command to a file&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scons -n -Q view &amp;gt; script.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and use &amp;lt;tt&amp;gt;script.sh&amp;lt;/tt&amp;gt; as a shell script. If you are to modify the data processing recipe (changing parameters or trying new data), working with SCons is more powerful and convenient than running shell scripts.&lt;br /&gt;
&lt;br /&gt;
A computational recipe puts together individual commands through Unix pipes and SCons rules. These commands act like Lego blocks for creating complex data analysis constructions. In the example above, three &amp;quot;blocks&amp;quot; are used: &amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sfrtoc&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;sfgraph&amp;lt;/tt&amp;gt;. To find out what a particular command is doing, follow the links from the bottom of the web page: https://ahay.org/RSF/book/rsf/rsf/sfmath.html .&lt;br /&gt;
Alternatively, run the command without arguments on the command line. Running&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfrtoc&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
produces something like&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NAME&lt;br /&gt;
        sfrtoc&lt;br /&gt;
DESCRIPTION&lt;br /&gt;
        Convert real data to complex (by adding zero imaginary part).&lt;br /&gt;
SYNOPSIS&lt;br /&gt;
        sfrtoc &amp;lt; real.rsf &amp;gt; cmplx.rsf&lt;br /&gt;
COMMENTS   &lt;br /&gt;
        See also: sfcmplx&lt;br /&gt;
USED IN&lt;br /&gt;
        bei/ft1/plane4&lt;br /&gt;
        bei/ft1/autocor&lt;br /&gt;
        bei/ft1/brad&lt;br /&gt;
        [...]&lt;br /&gt;
SOURCE&lt;br /&gt;
        user/main/rtoc.c&lt;br /&gt;
DOCUMENTATION&lt;br /&gt;
        https://ahay.org/wiki/Guide_to_madagascar_programs#sfrtoc&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;b&amp;gt;DOCUMENTATION&amp;lt;/b&amp;gt; section links to more detailed documentation on the web. The most helpful part is the &amp;lt;b&amp;gt;USED IN&amp;lt;/b&amp;gt; section, which points to more examples of using the program. As an exercise, change the directory to &amp;lt;tt&amp;gt;RSFSRC/book/bei/ft1/plane4&amp;lt;/tt&amp;gt; or any other example directory, examine the &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file and run &amp;lt;tt&amp;gt;scons view&amp;lt;/tt&amp;gt;. Alternatively, look at https://ahay.org/RSF/book/bei/ft1/plane4.html .&lt;br /&gt;
&lt;br /&gt;
Want to find a program by keywords? Try &amp;lt;tt&amp;gt;sfdoc -k&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfdoc -k complex&lt;br /&gt;
sfsort: Sort a float/complex vector by absolute values.&lt;br /&gt;
sfrtoc: Convert real data to complex (by adding zero imaginary part).&lt;br /&gt;
sfjacobi2: Find eigenvalues of a general complex matrix by Jacobi-like iteration. &lt;br /&gt;
sfboolcmp: Element-wise boolean comparison of values. For int/float/complex datasets.&lt;br /&gt;
sfcmatmult: Simple matrix multiplication for complex matrices &lt;br /&gt;
sfimag: Extract real (sfreal) or imaginary (sfimag) part of a complex dataset. &lt;br /&gt;
sfthr: Threshold float/complex inputs given a constant/varying threshold level.&lt;br /&gt;
sfcpef: 1-D prediction-error filter estimation from complex data &lt;br /&gt;
sfroots: Find roots of a complex polynomial. &lt;br /&gt;
sfreal: Extract real (sfreal) or imaginary (sfimag) part of a complex dataset. &lt;br /&gt;
sfcmplx: Create a complex dataset from its real and imaginary parts.&lt;br /&gt;
sfsin: Simple operations with complex sinusoids &lt;br /&gt;
sfcdottest: Generic dot-product test for complex linear operators with adjoints &lt;br /&gt;
sfcconjgrad: Generic conjugate-gradient solver for linear inversion with complex data&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Individual components of the Madagascar environment are described in more detail below.&lt;br /&gt;
&lt;br /&gt;
==Madagascar components==&lt;br /&gt;
&lt;br /&gt;
===Standalone programs===&lt;br /&gt;
The list of all standalone programs is available [https://ahay.org/RSF/ online]. Most programs act as filters on input data and can be chained through Unix pipes, i.e.:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; data.rsf sfwindow n1=100 | sfbandpass fhi=60 &amp;gt; data2.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
This approach follows the Unix philosophy, as formulated by Doug McIlroy, the inventor of Unix pipes (Salus, 1994&amp;lt;ref&amp;gt;Salus, P. H.,  1994, A quarter-century of Unix: Addison-Wesley.&amp;lt;/ref&amp;gt;):   &lt;br /&gt;
#Write programs that do one thing and do it well.  &lt;br /&gt;
#Write programs to work together.  &lt;br /&gt;
#Write programs to handle text streams because that is a universal interface. &lt;br /&gt;
&lt;br /&gt;
Following the Unix convention, programs have brief &amp;lt;tt&amp;gt;man&amp;lt;/tt&amp;gt; pages explaining the program&#039;s purpose and parameters. You can access this documentation by running a program without parameters. To search for a program by a keyword, use &amp;lt;tt&amp;gt;sfdoc -k &amp;lt;keyword&amp;gt;&amp;lt;/tt&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
The [[guide to Madagascar programs]] provides more detailed documentation for selected programs, while the [[task-centric program list]] attempts to categorize them. The programs in actual use can be found in [[Reproducible Documents]].&lt;br /&gt;
&lt;br /&gt;
===Data format===&lt;br /&gt;
&lt;br /&gt;
For data, Madagascar uses the [[Guide to RSF file format| Regularly Sampled Format]] (RSF), which is based on the concept of hypercubes (n-D arrays, or regularly sampled functions of several variables), much like the SEPlib (its closest relative), DDS, or the regularly-sampled version of the Javaseis format (SVF). Up to 9 dimensions are supported. For 1D, it is conceptually analogous to a time series, 2D to a raster image, and 3D to a [http://en.wikipedia.org/wiki/Voxel voxel volume]. The format (actually a [http://en.wikipedia.org/wiki/Meta meta]format) makes use of an ASCII file with metadata (information about the data), including a pointer (&amp;lt;tt&amp;gt;in=&amp;lt;/tt&amp;gt; parameter) to the location of the file with the actual data values. Irregularly sampled data are currently handled as a pair of datasets, one containing data and the second containing the corresponding irregular geometry information. Programs for conversion to and from other formats, such as SEG-Y and SU, are provided. &lt;br /&gt;
&lt;br /&gt;
Madagascar currently uses the Vplot vector graphics format for graphics. Converters to other graphics formats (Postscript, PNG, GIF, JPEG) are also provided.&lt;br /&gt;
&lt;br /&gt;
===Reproducible documents===&lt;br /&gt;
&lt;br /&gt;
A reproducible document consists of LaTeX source combined with SCons rules required to fully build the document. These rules are expressed in terms of SCons extensions provided as part of Madagascar. &lt;br /&gt;
&lt;br /&gt;
This is the key to Madagascar&#039;s reproducibility. An introduction to reproducible Madagascar documents is at [[Reproducible_computational_experiments_using_SCons]].&lt;br /&gt;
&lt;br /&gt;
===Vplot graphics===&lt;br /&gt;
&lt;br /&gt;
In contrast to most other Madagascar Components, graphics components produce Vplot data as output.&lt;br /&gt;
&lt;br /&gt;
Vplot is a device-independent graphics format that allows both vector and raster elements (as such, &lt;br /&gt;
it is comparable to Postscript). Several output devices can interpret Vplot files. The typical usage is for a visual display in X-windows. A list of them is [[Guide to Madagascar programs#Plotting programs | provided on the wiki]].&lt;br /&gt;
&lt;br /&gt;
Here is an example of a Madagascar pipe. In this case, it takes a subsection of a file, low-pass &lt;br /&gt;
filters it, and saves the result&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt; data.rsf sfwindow n1=100 | sfbandpass fhi=60 &amp;gt; data2.rsf &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this more elaborate case, the final output is passed to a graphics program and plotted.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt; data.rsf sfwindow n1=100 | sfbandpass fhi=60 | sfcontour | xtpen&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More extensive examples are in [[Guide to Madagascar programs]]. The novice reader should read the material below before proceeding to that page.&lt;br /&gt;
&lt;br /&gt;
===Reproducibility and Project Management===&lt;br /&gt;
&lt;br /&gt;
Madagascar uses and extends [http://www.scons.org/ SCons], an open-source &lt;br /&gt;
software construction package to document and maintain data processing flows. Documented projects become &lt;br /&gt;
computational recipes that can be easily exchanged among Madagascar users. &lt;br /&gt;
&lt;br /&gt;
SCons is a rule-based package in Python typically used as a build system analogous to &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt;. Familiarity with any build system will&lt;br /&gt;
help understand SCons. SCons statements, as Python statements, are invoked in the sequence in which they are &lt;br /&gt;
written, but as such, they only define rules. The rules are invoked by a dependency graph, which&lt;br /&gt;
SCons builds based on those rules. Components regarded as &amp;quot;up-to-date&amp;quot; are not rebuilt. &lt;br /&gt;
&lt;br /&gt;
SCons allows for user-contributed Builders (meta-rule categories), and Madagascar uses this capability extensively. &lt;br /&gt;
The idea is that building an output file based on a workflow chain is analogous to building a &lt;br /&gt;
software package based on a software toolchain. The calculation is seen simply as a build with dependencies. &lt;br /&gt;
This setup greatly benefits developing alternative workflows using a given dataset. The system &lt;br /&gt;
maintains an awareness of already completed calculations. Without user intervention, redundant calculations &lt;br /&gt;
are avoided.&lt;br /&gt;
&lt;br /&gt;
Madagascar calculations are thus expressed as SCons scripts (&amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; files). SCons extensions follow SCons conventions, beginning &lt;br /&gt;
with an uppercase letter. The most common Madagascar extensions are &amp;lt;tt&amp;gt;Flow()&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Result()&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;End()&amp;lt;/tt&amp;gt;. A &amp;lt;tt&amp;gt;Flow()&amp;lt;/tt&amp;gt; invocation wraps Madagascar computational components. &amp;lt;tt&amp;gt;Result()&amp;lt;/tt&amp;gt; is a version of &amp;lt;tt&amp;gt;Flow()&amp;lt;/tt&amp;gt; with a graphical output. Finally an&lt;br /&gt;
End() invokes the default rules for multiple results. &lt;br /&gt;
&lt;br /&gt;
Finally, Madagascar enables a collection of reproducible documents to be organized into living books. Each &lt;br /&gt;
reproducible book contains a collection of Madagascar recipes (&amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; files) used to generate book figures. The recipes &lt;br /&gt;
cover a variety of data processing and imaging tasks described in the books. Figures and recipes serve &lt;br /&gt;
a dual purpose concerning Madagascar maintenance. They provide demos to introduce new users to the &lt;br /&gt;
functionality of the package and, at the same time, [[Automatic Testing|regression tests]] to assure the system&#039;s stability &lt;br /&gt;
under change.&lt;br /&gt;
&lt;br /&gt;
==Madagascar Trivia==&lt;br /&gt;
&lt;br /&gt;
===Why the Name &amp;quot;Madagascar&amp;quot;?===&lt;br /&gt;
&lt;br /&gt;
[http://ahay.org/blog/2006/04/19/madagascar/ Whimsy, really]. It seems easier to remember than the previous name &amp;quot;RSF&amp;quot;, and it provides us interesting [http://ahay.org/blog/2008/10/21/ahay/ mascots].&lt;br /&gt;
&lt;br /&gt;
===License===&lt;br /&gt;
&lt;br /&gt;
The Madagascar package is released open-source under the standard [http://www.gnu.org/copyleft/gpl.html GNU GPL] license. In simple &lt;br /&gt;
words, there are no restrictions on the use of the software (including copying, modifying, selling, etc.) &lt;br /&gt;
However, there are restrictions on the software redistribution intended to prevent the package from losing &lt;br /&gt;
its open-source status. Users are encouraged to [[Contributing new programs to Madagascar|submit their modifications]] back to the original distribution for the benefit of the whole [[Package_overview#Community|community]].&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Madagascar seeks to be an open and active community. Mailing lists are maintained, and annual meetings take place. See &lt;br /&gt;
* [[Conferences]]&lt;br /&gt;
* [http://ahay.org/blog/ Development blog]&lt;br /&gt;
* [https://lists.sourceforge.net/lists/listinfo/rsf-user RSF-user mailing list] &lt;br /&gt;
* [https://lists.sourceforge.net/lists/listinfo/rsf-devel RSF-devel mailing list] &lt;br /&gt;
* [http://www.linkedin.com/e/vgh/1847746 LinkedIn group]&lt;br /&gt;
Your participation is welcome.&lt;br /&gt;
&lt;br /&gt;
===History=== &lt;br /&gt;
&lt;br /&gt;
Madagascar was first publicly presented at the [[Conferences#Vienna_2006_.28EAGE.29|EAGE Workshop]] in Vienna in June 2006. The work on the package (previously named RSF) was started by Sergey Fomel in 2003. Since then, many people have contributed to it. See [https://github.com/ahay/src/blob/master/AUTHORS.txt AUTHORS.txt] for an incomplete list.&lt;br /&gt;
&lt;br /&gt;
While being written primarily from scratch, Madagascar borrows ideas from the design of [http://sepwww.stanford.ed/doku.php?id=sep:software:seplib SEPlib], a package maintained by Bob Clapp at the Stanford Exploration Project (SEP). Generations of SEP students and researchers contributed to SEPlib. The most significant contributions came from Rob Clayton, Jon Claerbout, Dave Hale, Stew Levin, Rick Ottolini, Joe Dellinger, Steve Cole, Dave Nichols, Martin Karrenbach, Biondo Biondi, and Bob Clapp.&lt;br /&gt;
&lt;br /&gt;
Madagascar also borrows ideas from [http://timna.mines.edu/cwpcodes/ Seismic Unix] (SU), an open-source package maintained by John Stockwell at the Center for Wave Phenomena (CWP) at the Colorado School of Mines (Stockwell, 1997&amp;lt;ref&amp;gt;Stockwell, J. W.,  1997, Free software in education: A case study of CWP/SU: Seismic Unix: The Leading Edge, &#039;&#039;&#039;16&#039;&#039;&#039;, 1045--1049.&amp;lt;/ref&amp;gt;;Stockwell, 1999&amp;lt;ref&amp;gt;--------, 1999, The CWP/SU: Seismic Un*x package: Computers and  Geosciences, &#039;&#039;&#039;25&#039;&#039;&#039;, 415--419.&amp;lt;/ref&amp;gt;). Main contributors to SU included Einar Kjartansson, Shuki Ronen, Jack Cohen, Chris Liner, Dave Hale, and John Stockwell. SU adopted an open-source BSD-style license starting with release 40 (April 10, 2007).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Estimated Cost=== &lt;br /&gt;
&lt;br /&gt;
The Project Cost Calculator on Madagascar&#039;s [https://www.openhub.net/p/m8r Open Hub (formerly Ohloh) metrics page] shows the estimated cost of the project, using the Basic COCOMO Model, to be about $22 million by October 29, 2024.&lt;/div&gt;</summary>
		<author><name>Fomels</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Package_overview&amp;diff=4632</id>
		<title>Package overview</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Package_overview&amp;diff=4632"/>
		<updated>2024-10-29T22:10:53Z</updated>

		<summary type="html">&lt;p&gt;Fomels: typos&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_5127720_XS.jpg|right|]]&lt;br /&gt;
&lt;br /&gt;
The mission of the Madagascar project is to provide a &#039;&#039;&#039;shared research environment&#039;&#039;&#039; for computational data analysis in geophysics and related fields.&lt;br /&gt;
&lt;br /&gt;
The Madagascar environment consists of:&lt;br /&gt;
# Standalone programs for out-of-core data analysis;&lt;br /&gt;
# Standalone programs for geophysical data processing and imaging;&lt;br /&gt;
# A development kit for C, C++, Java, Fortran-77, Fortran-90, Python, Matlab, and Octave;&lt;br /&gt;
# A framework for reproducible numerical experiments, based on [http://www.scons.org/ SCons];&lt;br /&gt;
# A framework for scientific publications, based on [http://www.scons.org/ SCons] and [http://en.wikipedia.org/wiki/LaTeX LaTeX];&lt;br /&gt;
# A collection of reproducible scientific articles also used as usage examples and regression tests for the standalone programs;&lt;br /&gt;
# A collection of datasets used as input to reproducible numerical experiments.&lt;br /&gt;
&lt;br /&gt;
This guide serves as a brief introduction to different components and shows how they all fit together.&lt;br /&gt;
&lt;br /&gt;
==How to obtain Madagascar==&lt;br /&gt;
&lt;br /&gt;
See [[Download|download]] and [[Installation | installation instructions]]. Madagascar runs on Unix/Linux platforms, including MacOS X and Unix emulations under Microsoft Windows. Its installation requires a working C compiler and Python. &lt;br /&gt;
&lt;br /&gt;
==How to find your way around Madagascar==&lt;br /&gt;
&lt;br /&gt;
Start by checking the [[Reproducible_Documents|list of reproducible papers]]. If any of these papers look close to your interests, follow the links until you find a figure with a &amp;quot;wrench&amp;quot; button under it [[Image:configure.png]]. Click on the wrench, and it will open a computational recipe used for generating the figure (the &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file). &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
Flow(&#039;rose&#039;,None,&lt;br /&gt;
     &#039;&#039;&#039;&lt;br /&gt;
     math 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; |&lt;br /&gt;
     rtoc |&lt;br /&gt;
     math output=&amp;quot;input*exp(I*x1)&amp;quot;&lt;br /&gt;
     &#039;&#039;&#039;)&lt;br /&gt;
Result(&#039;rose&#039;,&lt;br /&gt;
       &#039;graph title=Rose screenratio=1 wantaxis=n&#039;)&lt;br /&gt;
End()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
You can copy this recipe to your computer or find it already in the &amp;quot;book&amp;quot; subtree under the Madagascar source directory. For example, the recipe at http://www.reproducibility.org/RSF/book/rsf/rsf/sfmath.html also exists in the file &amp;lt;tt&amp;gt;RSFSRC/book/rsf/rsf/sfmath/SConstruct&amp;lt;/tt&amp;gt;. After copying or locating the appropriate &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file,&lt;br /&gt;
run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scons view&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
on the command line to generate all the figures in the selected project and to display them on your screen. For example, try&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ cd RSFSRC/book/rsf/rsf/sfmath&lt;br /&gt;
bash$ scons view&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
where &amp;lt;tt&amp;gt;bash$&amp;lt;/tt&amp;gt; stands for the Unix prompt and &amp;lt;tt&amp;gt;RSFSRC&amp;lt;/tt&amp;gt; stands for the Madagascar source directory. The output should look like&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scons: Reading SConscript files ...&lt;br /&gt;
scons: done reading SConscript files.&lt;br /&gt;
scons: Building targets ...&lt;br /&gt;
/RSFROOT/bin/sfmath n1=629 d1=0.01 o1=0 n2=40 d2=1 o2=5 output=&amp;quot;x2*(8+sin(6*x1+x2/10))&amp;quot; | /RSFROOT/bin/sfrtoc | &lt;br /&gt;
/RSFROOT/bin/sfmath output=&amp;quot;input*exp(I*x1)&amp;quot; &amp;gt; rose.rsf&lt;br /&gt;
&amp;lt; rose.rsf /RSFROOT/bin/sfgraph title=Rose screenratio=1 wantaxis=n &amp;gt; Fig/rose.vpl&lt;br /&gt;
/RSFROOT/bin/sfpen Fig/rose.vpl&lt;br /&gt;
scons: done building targets.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
with a picture appearing on your screen.&lt;br /&gt;
[[Image:rose.png|frame|center]]&lt;br /&gt;
If there are several figures in the recipe, you can run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scons figurename.view&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
(e.g. &amp;lt;tt&amp;gt;scons rose.view&amp;lt;/tt&amp;gt;) to display individual figures. To remove all files that &amp;lt;tt&amp;gt;scons view&amp;lt;/tt&amp;gt; generated, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scons -c view&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you want to know in advance what commands will be executed to generate the figures, try&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scons -n view&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can output this command to a file&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scons -n -Q view &amp;gt; script.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and use &amp;lt;tt&amp;gt;script.sh&amp;lt;/tt&amp;gt; as a shell script. If you are to modify the data processing recipe (changing parameters or trying new data), working with SCons is more powerful and convenient than running shell scripts.&lt;br /&gt;
&lt;br /&gt;
A computational recipe puts together individual commands through Unix pipes and SCons rules. These commands act like Lego blocks for creating complex data analysis constructions. In the example above, three &amp;quot;blocks&amp;quot; are used: &amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sfrtoc&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;sfgraph&amp;lt;/tt&amp;gt;. To find out what a particular command is doing, follow the links from the bottom of the web page: https://ahay.org/RSF/book/rsf/rsf/sfmath.html .&lt;br /&gt;
Alternatively, run the command without arguments on the command line. Running&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfrtoc&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
produces something like&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NAME&lt;br /&gt;
        sfrtoc&lt;br /&gt;
DESCRIPTION&lt;br /&gt;
        Convert real data to complex (by adding zero imaginary part).&lt;br /&gt;
SYNOPSIS&lt;br /&gt;
        sfrtoc &amp;lt; real.rsf &amp;gt; cmplx.rsf&lt;br /&gt;
COMMENTS   &lt;br /&gt;
        See also: sfcmplx&lt;br /&gt;
USED IN&lt;br /&gt;
        bei/ft1/plane4&lt;br /&gt;
        bei/ft1/autocor&lt;br /&gt;
        bei/ft1/brad&lt;br /&gt;
        [...]&lt;br /&gt;
SOURCE&lt;br /&gt;
        user/main/rtoc.c&lt;br /&gt;
DOCUMENTATION&lt;br /&gt;
        http://reproducibility.org/wiki/Guide_to_madagascar_programs#sfrtoc&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;b&amp;gt;DOCUMENTATION&amp;lt;/b&amp;gt; section links to more detailed documentation on the web. The most helpful part is the &amp;lt;b&amp;gt;USED IN&amp;lt;/b&amp;gt; section, which points to more examples of using the program. As an exercise, change the directory to &amp;lt;tt&amp;gt;RSFSRC/book/bei/ft1/plane4&amp;lt;/tt&amp;gt; or any other example directory, examine the &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file and run &amp;lt;tt&amp;gt;scons view&amp;lt;/tt&amp;gt;. Alternatively, look at https://ahay.org/RSF/book/bei/ft1/plane4.html .&lt;br /&gt;
&lt;br /&gt;
Want to find a program by keywords? Try &amp;lt;tt&amp;gt;sfdoc -k&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfdoc -k complex&lt;br /&gt;
sfsort: Sort a float/complex vector by absolute values.&lt;br /&gt;
sfrtoc: Convert real data to complex (by adding zero imaginary part).&lt;br /&gt;
sfjacobi2: Find eigenvalues of a general complex matrix by Jacobi-like iteration. &lt;br /&gt;
sfboolcmp: Element-wise boolean comparison of values. For int/float/complex datasets.&lt;br /&gt;
sfcmatmult: Simple matrix multiplication for complex matrices &lt;br /&gt;
sfimag: Extract real (sfreal) or imaginary (sfimag) part of a complex dataset. &lt;br /&gt;
sfthr: Threshold float/complex inputs given a constant/varying threshold level.&lt;br /&gt;
sfcpef: 1-D prediction-error filter estimation from complex data &lt;br /&gt;
sfroots: Find roots of a complex polynomial. &lt;br /&gt;
sfreal: Extract real (sfreal) or imaginary (sfimag) part of a complex dataset. &lt;br /&gt;
sfcmplx: Create a complex dataset from its real and imaginary parts.&lt;br /&gt;
sfsin: Simple operations with complex sinusoids &lt;br /&gt;
sfcdottest: Generic dot-product test for complex linear operators with adjoints &lt;br /&gt;
sfcconjgrad: Generic conjugate-gradient solver for linear inversion with complex data&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Individual components of the Madagascar environment are described in more detail below.&lt;br /&gt;
&lt;br /&gt;
==Madagascar components==&lt;br /&gt;
&lt;br /&gt;
===Standalone programs===&lt;br /&gt;
The list of all standalone programs is available [https://ahay.org/RSF/ online]. Most programs act as filters on input data and can be chained through Unix pipes, i.e.:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; data.rsf sfwindow n1=100 | sfbandpass fhi=60 &amp;gt; data2.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
This approach follows the Unix philosophy, as formulated by Doug McIlroy, the inventor of Unix pipes (Salus, 1994&amp;lt;ref&amp;gt;Salus, P. H.,  1994, A quarter-century of Unix: Addison-Wesley.&amp;lt;/ref&amp;gt;):   &lt;br /&gt;
#Write programs that do one thing and do it well.  &lt;br /&gt;
#Write programs to work together.  &lt;br /&gt;
#Write programs to handle text streams because that is a universal interface. &lt;br /&gt;
&lt;br /&gt;
Following the Unix convention, programs have brief &amp;lt;tt&amp;gt;man&amp;lt;/tt&amp;gt; pages explaining the program&#039;s purpose and parameters. You can access this documentation by running a program without parameters. To search for a program by a keyword, use &amp;lt;tt&amp;gt;sfdoc -k &amp;lt;keyword&amp;gt;&amp;lt;/tt&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
The [[guide to Madagascar programs]] provides more detailed documentation for selected programs, while the [[task-centric program list]] attempts to categorize them. The programs in actual use can be found in [[Reproducible Documents]].&lt;br /&gt;
&lt;br /&gt;
===Data format===&lt;br /&gt;
&lt;br /&gt;
For data, Madagascar uses the [[Guide to RSF file format| Regularly Sampled Format]] (RSF), which is based on the concept of hypercubes (n-D arrays, or regularly sampled functions of several variables), much like the SEPlib (its closest relative), DDS, or the regularly-sampled version of the Javaseis format (SVF). Up to 9 dimensions are supported. For 1D, it is conceptually analogous to a time series, 2D to a raster image, and 3D to a [http://en.wikipedia.org/wiki/Voxel voxel volume]. The format (actually a [http://en.wikipedia.org/wiki/Meta meta]format) makes use of an ASCII file with metadata (information about the data), including a pointer (&amp;lt;tt&amp;gt;in=&amp;lt;/tt&amp;gt; parameter) to the location of the file with the actual data values. Irregularly sampled data are currently handled as a pair of datasets, one containing data and the second containing the corresponding irregular geometry information. Programs for conversion to and from other formats, such as SEG-Y and SU, are provided. &lt;br /&gt;
&lt;br /&gt;
Madagascar currently uses the Vplot vector graphics format for graphics. Converters to other graphics formats (Postscript, PNG, GIF, JPEG) are also provided.&lt;br /&gt;
&lt;br /&gt;
===Reproducible documents===&lt;br /&gt;
&lt;br /&gt;
A reproducible document consists of LaTeX source combined with SCons rules required to fully build the document. These rules are expressed in terms of SCons extensions provided as part of Madagascar. &lt;br /&gt;
&lt;br /&gt;
This is the key to Madagascar&#039;s reproducibility. An introduction to reproducible Madagascar documents is at [[Reproducible_computational_experiments_using_SCons]].&lt;br /&gt;
&lt;br /&gt;
===Vplot graphics===&lt;br /&gt;
&lt;br /&gt;
In contrast to most other Madagascar Components, graphics components produce Vplot data as output.&lt;br /&gt;
&lt;br /&gt;
Vplot is a device-independent graphics format that allows both vector and raster elements (as such, &lt;br /&gt;
it is comparable to Postscript). Several output devices can interpret Vplot files. The typical usage is for a visual display in X-windows. A list of them is [[Guide to Madagascar programs#Plotting programs | provided on the wiki]].&lt;br /&gt;
&lt;br /&gt;
Here is an example of a Madagascar pipe. In this case, it takes a subsection of a file, low-pass &lt;br /&gt;
filters it, and saves the result&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt; data.rsf sfwindow n1=100 | sfbandpass fhi=60 &amp;gt; data2.rsf &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this more elaborate case, the final output is passed to a graphics program and plotted.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt; data.rsf sfwindow n1=100 | sfbandpass fhi=60 | sfcontour | xtpen&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More extensive examples are in [[Guide to Madagascar programs]]. The novice reader should read the material below before proceeding to that page.&lt;br /&gt;
&lt;br /&gt;
===Reproducibility and Project Management===&lt;br /&gt;
&lt;br /&gt;
Madagascar uses and extends [http://www.scons.org/ SCons], an open-source &lt;br /&gt;
software construction package to document and maintain data processing flows. Documented projects become &lt;br /&gt;
computational recipes that can be easily exchanged among Madagascar users. &lt;br /&gt;
&lt;br /&gt;
SCons is a rule-based package in Python typically used as a build system analogous to &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt;. Familiarity with any build system will&lt;br /&gt;
help understand SCons. SCons statements, as Python statements, are invoked in the sequence in which they are &lt;br /&gt;
written, but as such, they only define rules. The rules are invoked by a dependency graph, which&lt;br /&gt;
SCons builds based on those rules. Components regarded as &amp;quot;up-to-date&amp;quot; are not rebuilt. &lt;br /&gt;
&lt;br /&gt;
SCons allows for user-contributed Builders (meta-rule categories), and Madagascar uses this capability extensively. &lt;br /&gt;
The idea is that building an output file based on a workflow chain is analogous to building a &lt;br /&gt;
software package based on a software toolchain. The calculation is seen simply as a build with dependencies. &lt;br /&gt;
This setup greatly benefits developing alternative workflows using a given dataset. The system &lt;br /&gt;
maintains an awareness of already completed calculations. Without user intervention, redundant calculations &lt;br /&gt;
are avoided.&lt;br /&gt;
&lt;br /&gt;
Madagascar calculations are thus expressed as SCons scripts (&amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; files). SCons extensions follow SCons conventions, beginning &lt;br /&gt;
with an uppercase letter. The most common Madagascar extensions are &amp;lt;tt&amp;gt;Flow()&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Result()&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;End()&amp;lt;/tt&amp;gt;. A &amp;lt;tt&amp;gt;Flow()&amp;lt;/tt&amp;gt; invocation wraps Madagascar computational components. &amp;lt;tt&amp;gt;Result()&amp;lt;/tt&amp;gt; is a version of &amp;lt;tt&amp;gt;Flow()&amp;lt;/tt&amp;gt; with a graphical output. Finally an&lt;br /&gt;
End() invokes the default rules for multiple results. &lt;br /&gt;
&lt;br /&gt;
Finally, Madagascar enables a collection of reproducible documents to be organized into living books. Each &lt;br /&gt;
reproducible book contains a collection of Madagascar recipes (&amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; files) used to generate book figures. The recipes &lt;br /&gt;
cover a variety of data processing and imaging tasks described in the books. Figures and recipes serve &lt;br /&gt;
a dual purpose concerning Madagascar maintenance. They provide demos to introduce new users to the &lt;br /&gt;
functionality of the package and, at the same time, [[Automatic Testing|regression tests]] to assure the system&#039;s stability &lt;br /&gt;
under change.&lt;br /&gt;
&lt;br /&gt;
==Madagascar Trivia==&lt;br /&gt;
&lt;br /&gt;
===Why the Name &amp;quot;Madagascar&amp;quot;?===&lt;br /&gt;
&lt;br /&gt;
[http://ahay.org/blog/2006/04/19/madagascar/ Whimsy, really]. It seems easier to remember than the previous name &amp;quot;RSF&amp;quot;, and it provides us interesting [http://ahay.org/blog/2008/10/21/ahay/ mascots].&lt;br /&gt;
&lt;br /&gt;
===License===&lt;br /&gt;
&lt;br /&gt;
The Madagascar package is released open-source under the standard [http://www.gnu.org/copyleft/gpl.html GNU GPL] license. In simple &lt;br /&gt;
words, there are no restrictions on the use of the software (including copying, modifying, selling, etc.) &lt;br /&gt;
However, there are restrictions on the software redistribution intended to prevent the package from losing &lt;br /&gt;
its open-source status. Users are encouraged to [[Contributing new programs to Madagascar|submit their modifications]] back to the original distribution for the benefit of the whole [[Package_overview#Community|community]].&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Madagascar seeks to be an open and active community. Mailing lists are maintained, and annual meetings take place. See &lt;br /&gt;
* [[Conferences]]&lt;br /&gt;
* [http://ahay.org/blog/ Development blog]&lt;br /&gt;
* [https://lists.sourceforge.net/lists/listinfo/rsf-user RSF-user mailing list] &lt;br /&gt;
* [https://lists.sourceforge.net/lists/listinfo/rsf-devel RSF-devel mailing list] &lt;br /&gt;
* [http://www.linkedin.com/e/vgh/1847746 LinkedIn group]&lt;br /&gt;
Your participation is welcome.&lt;br /&gt;
&lt;br /&gt;
===History=== &lt;br /&gt;
&lt;br /&gt;
Madagascar was first publicly presented at the [[Conferences#Vienna_2006_.28EAGE.29|EAGE Workshop]] in Vienna in June 2006. The work on the package (previously named RSF) was started by Sergey Fomel in 2003. Since then, many people have contributed to it. See [https://github.com/ahay/src/blob/master/AUTHORS.txt AUTHORS.txt] for an incomplete list.&lt;br /&gt;
&lt;br /&gt;
While being written primarily from scratch, Madagascar borrows ideas from the design of [http://sepwww.stanford.ed/doku.php?id=sep:software:seplib SEPlib], a package maintained by Bob Clapp at the Stanford Exploration Project (SEP). Generations of SEP students and researchers contributed to SEPlib. The most significant contributions came from Rob Clayton, Jon Claerbout, Dave Hale, Stew Levin, Rick Ottolini, Joe Dellinger, Steve Cole, Dave Nichols, Martin Karrenbach, Biondo Biondi, and Bob Clapp.&lt;br /&gt;
&lt;br /&gt;
Madagascar also borrows ideas from [http://timna.mines.edu/cwpcodes/ Seismic Unix] (SU), an open-source package maintained by John Stockwell at the Center for Wave Phenomena (CWP) at the Colorado School of Mines (Stockwell, 1997&amp;lt;ref&amp;gt;Stockwell, J. W.,  1997, Free software in education: A case study of CWP/SU: Seismic Unix: The Leading Edge, &#039;&#039;&#039;16&#039;&#039;&#039;, 1045--1049.&amp;lt;/ref&amp;gt;;Stockwell, 1999&amp;lt;ref&amp;gt;--------, 1999, The CWP/SU: Seismic Un*x package: Computers and  Geosciences, &#039;&#039;&#039;25&#039;&#039;&#039;, 415--419.&amp;lt;/ref&amp;gt;). Main contributors to SU included Einar Kjartansson, Shuki Ronen, Jack Cohen, Chris Liner, Dave Hale, and John Stockwell. SU adopted an open-source BSD-style license starting with release 40 (April 10, 2007).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Estimated Cost=== &lt;br /&gt;
&lt;br /&gt;
The Project Cost Calculator on Madagascar&#039;s [https://www.openhub.net/p/m8r Open Hub (formerly Ohloh) metrics page] shows the estimated cost of the project, using the Basic COCOMO Model, to be about $22 million by October 29, 2024.&lt;/div&gt;</summary>
		<author><name>Fomels</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Main_Page&amp;diff=4631</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Main_Page&amp;diff=4631"/>
		<updated>2024-10-29T21:55:15Z</updated>

		<summary type="html">&lt;p&gt;Fomels: /* Latest News */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;big&amp;gt;&#039;&#039;&#039;Madagascar&#039;&#039;&#039;&amp;lt;/big&amp;gt; is an open-source software package for multidimensional data analysis and [[Reproducibility|reproducible]] computational experiments. Its mission is to provide&lt;br /&gt;
* a convenient and powerful environment&lt;br /&gt;
* a convenient technology transfer tool&lt;br /&gt;
for researchers working with digital image and data processing in geophysics and related fields. Technology developed using the Madagascar project management system is transferred in the form of recorded processing histories, which become &amp;quot;computational recipes&amp;quot; to be verified, exchanged, and modified by the users.&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Crystal_Clear_app_katomic.png|left|30px|Modern]]&lt;br /&gt;
Madagascar is a &amp;lt;u&amp;gt;modern&amp;lt;/u&amp;gt;  package. It started in 2003 and was publicly released in 2006. It was developed almost entirely from scratch. It is a relatively new package that follows modern software engineering practices such as module encapsulation and test-driven development. The rapid growth of a project of this scope (more than 1,000 main programs and more than 5,000 tests) would not be possible without standing on the shoulders of giants and learning from the 30 years of previous experience in open packages such as SEPlib and Seismic Unix. We have borrowed and reimplemented functionality and ideas from these other packages. &lt;br /&gt;
&lt;br /&gt;
[[Image:Crystal_Clear_app_vcalendar.png|left|30px|Test-driven]]&lt;br /&gt;
Madagascar is a &amp;lt;u&amp;gt;test-driven&amp;lt;/u&amp;gt;  package. Test-driven development is not only an agile software programming practice but also a way of bringing a scientific foundation to geophysical research that involves numerical experiments. Bringing reproducibility and peer review, the backbone of any real science, to computational geophysics is the primary motivation for Madagascar&#039;s development. The package consists of two levels: low-level main programs (typically developed in the C programming language and working as data filters) and high-level processing flows (described using the Python programming language) that combine main programs and unambiguously document data processing histories for testing and reproducibility. Experience shows that high-level programming is easily mastered even by beginning students without any previous programming experience. &lt;br /&gt;
&lt;br /&gt;
[[Image:Crystal_Clear_app_gadu.png|left|30px|Open]]&lt;br /&gt;
Madagascar is an &amp;lt;u&amp;gt;open-source&amp;lt;/u&amp;gt;  package. It is distributed under the standard GPL open-source license, which does not restrict the usage and modification of the code. Moreover, access to modifying the source repository is not controlled by one organization but shared equally among developers. Sharing the responsibility enables an open collaboration among different groups spread worldwide, in the true spirit of the open-source movement. &lt;br /&gt;
&lt;br /&gt;
[[Image:Crystal_Clear_filesystem_blockdevice.png|left|30px|Simple,flexible]]&lt;br /&gt;
Madagascar uses a &amp;lt;u&amp;gt;simple, flexible, and universal&amp;lt;/u&amp;gt;  data format that can handle very large datasets but is not tied specifically to seismic data or any other particular kind. This &amp;quot;regularly sampled&amp;quot; format is borrowed from the traditional SEPlib. A universal data format allows us to share general-purpose data processing tools with scientists and engineers from other disciplines.&lt;br /&gt;
&lt;br /&gt;
== Latest News ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;rss max=7&amp;gt;https://ahay.org/blog/feed/&amp;lt;/rss&amp;gt;&lt;/div&gt;</summary>
		<author><name>Fomels</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=SEGTeX&amp;diff=4454</id>
		<title>SEGTeX</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=SEGTeX&amp;diff=4454"/>
		<updated>2024-10-24T23:34:19Z</updated>

		<summary type="html">&lt;p&gt;Fomels: get rid of svn&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:SEG-Logo Final SM.png|thumb|[https://seg.org Society of Exploration Geophysicists]]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;SEGTeX&#039;&#039;&#039; is a LaTeX package for geophysical publications. It consists of&lt;br /&gt;
* LaTeX2e class files for [https://library.seg.org/journal/gpysa7/ Geophysics] papers, SEG expanded abstracts, etc&lt;br /&gt;
* BibTeX style files [https://github.com/SEGTeX/texmf/blob/master/bibtex/bst/seg/seg.bst seg.bst]&lt;br /&gt;
* BibTeX cumulative bibliography of geophysical publications [https://github.com/SEGTeX/texmf/blob/master/bibtex/bib/seg/SEG.bib SEG.bib]&lt;br /&gt;
* [http://www.latex2html.org/ latex2html] customizations&lt;br /&gt;
&lt;br /&gt;
== Downloading ==&lt;br /&gt;
&lt;br /&gt;
Access SEGTeX through its [http://sourceforge.net/projects/segtex/ SourceForge project] by downloading [http://sourceforge.net/projects/segtex/files/ the latest stable release].&lt;br /&gt;
&lt;br /&gt;
Alternatively, access the current working version by using [https://git-scm.com/ Git] and running&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone &amp;lt;nowiki&amp;gt;https://github.com/SEGTeX/texmf&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also [https://github.com/SEGTeX/texmf browse the GitHub repository].&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
If your LaTeX installation is missing/incomplete, try installing [http://www.tug.org/texlive/ TeX Live] first.&lt;br /&gt;
&lt;br /&gt;
To install, put the contents of the &amp;lt;tt&amp;gt;texmf&amp;lt;/tt&amp;gt; folder where LaTeX can find it. Most systems recognize &amp;lt;tt&amp;gt;$HOME/texmf&amp;lt;/tt&amp;gt; as one of the default places. On MacOS X, it can be &amp;lt;tt&amp;gt;$HOME/Library/texmf&amp;lt;/tt&amp;gt;. You may need to run &amp;lt;tt&amp;gt;texhash&amp;lt;/tt&amp;gt; to tell LaTeX about the new files. For more help on &amp;lt;tt&amp;gt;texmf&amp;lt;/tt&amp;gt;, see [http://www.tex.ac.uk/cgi-bin/texfaq2html?label=privinst “Private” installations of files].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prerequisites ===&lt;br /&gt;
&lt;br /&gt;
Some of the required additional LaTeX packages are:&lt;br /&gt;
&lt;br /&gt;
* [http://www.ctan.org/pkg/natbib natbib] support for (author,year) bibliography style of natural sciences&lt;br /&gt;
&lt;br /&gt;
== Download and Install SEGTEX on Mac ==&lt;br /&gt;
 cd $HOME/Library&lt;br /&gt;
 git clone https://github.com/SEGTEX/texmf &lt;br /&gt;
 sudo port install texlive-latex-extra&lt;br /&gt;
&lt;br /&gt;
== SEG expanded abstracts ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;SEGTeX&#039;&#039;&#039; includes &#039;&#039;&#039;segabs.cls&#039;&#039;&#039; -- a LaTeX class for generating SEG expanded abstracts. Alternatively,  you can &lt;br /&gt;
[https://sourceforge.net/projects/segtex/files/segabs/segabs-2015.1/ download &#039;&#039;&#039;segabs-2015&#039;&#039;&#039;] -- a packaged expanded abstract template.&lt;br /&gt;
&lt;br /&gt;
To generate an expanded abstract without references, as SEG requires, use two LaTeX files: one for the abstract itself and the other for separating pages without references. Examples are [http://sourceforge.net/p/segtex/code/HEAD/tree/trunk/tex/latex/seg/segabs_example.ltx segabs_example.ltx] and [http://sourceforge.net/p/segtex/code/HEAD/tree/trunk/tex/latex/seg/segabs_final.ltx segabs_final.ltx]&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;latex&amp;quot;&amp;gt;&lt;br /&gt;
\documentclass{article}&lt;br /&gt;
\usepackage{pdfpages}&lt;br /&gt;
\begin{document}&lt;br /&gt;
\includepdf[pages={1-4}]{segabs_example}&lt;br /&gt;
\end{document}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This solution only works with &#039;&#039;&#039;pdflatex&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
Alternatively, you can separate pages using an external program. &lt;br /&gt;
* In [http://www.adobe.com/products/acrobatpro/ Acrobat Pro], open the PDF file with references, select &amp;lt;tt&amp;gt;Document -&amp;amp;gt; Pages -&amp;amp;gt; Extract&amp;lt;/tt&amp;gt;, and extract the reference page with the delete option (&#039;&#039;thanks to Norm Bleistein for the tip&#039;&#039;.)&lt;br /&gt;
* Another helpful program is [http://www.accesspdf.com/pdftk/ pdftk] (PDF toolkit.)&lt;br /&gt;
&lt;br /&gt;
== Documentation ==&lt;br /&gt;
&lt;br /&gt;
The [https://github.com/SEGTeX/texmf/tree/master/tex/latex/seg tex/latex/seg] directory contains several example files.&lt;br /&gt;
&lt;br /&gt;
Use the manuscript style to submit papers to &#039;&#039;&#039;Geophysics&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* Manuscript style &#039;&#039;&#039;Geophysics&#039;&#039;&#039; paper [http://reproducibility.org/wikilocal/docs/geophysics_example.pdf geophysics_example] [http://reproducibility.org/wikilocal/docs/geophysics_titlepage.pdf geophysics_titlepage] [http://reproducibility.org/wikilocal/docs/geophysics_notitlepage.pdf geophysics_notitlepage]&lt;br /&gt;
* Manuscript style &#039;&#039;&#039;Geophysics&#039;&#039;&#039; paper using &amp;lt;tt&amp;gt;endfloat&amp;lt;/tt&amp;gt; [http://reproducibility.org/wikilocal/docs/geophysics_endfloat.pdf geophysics_endfloat]&lt;br /&gt;
* Manuscript style &#039;&#039;&#039;Geophysics&#039;&#039;&#039; with author information (no double-blind review) [http://reproducibility.org/wikilocal/docs/geophysics_noblind.pdf geophysics_noblind]&lt;br /&gt;
* Publication style two-column &#039;&#039;&#039;Geophysics&#039;&#039;&#039; paper [http://reproducibility.org/wikilocal/docs/geophysics_twocolumn.pdf geophysics_twolumn]&lt;br /&gt;
* &#039;&#039;&#039;SEG&#039;&#039;&#039; expanded abstract (with references) [http://reproducibility.org/wikilocal/docs/segabs_example.pdf segabs_example]&lt;br /&gt;
* &#039;&#039;&#039;SEG&#039;&#039;&#039; expanded abstract (without references) [http://reproducibility.org/wikilocal/docs/segabs_final.pdf segabs_final]&lt;br /&gt;
* Report style paper [http://reproducibility.org/wikilocal/docs/geophysics_paper.pdf geophysics_paper]&lt;br /&gt;
&lt;br /&gt;
== Tips and tricks ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Equations, citation commands, etc. don&#039;t work inside \old.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Enclose citations in &amp;lt;tt&amp;gt;\mbox&amp;lt;/tt&amp;gt;: Instead of &amp;lt;tt&amp;gt;\old{wrong citation \cite{wrong}}&amp;lt;/tt&amp;gt;, use  &amp;lt;tt&amp;gt;\old{wrong citation \mbox{\cite{wrong}}}&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enclose equations in &amp;lt;tt&amp;gt;\parbox&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;minipage&amp;lt;/tt&amp;gt;:  Instead of&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;latex&amp;quot;&amp;gt;&lt;br /&gt;
\old{wrong equation&lt;br /&gt;
\begin{equation}&lt;br /&gt;
2*2 = 5&lt;br /&gt;
\end{equation}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
use&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;latex&amp;quot;&amp;gt;&lt;br /&gt;
\old{wrong equation \\&lt;br /&gt;
\begin{minipage}{\textwidth}&lt;br /&gt;
\begin{equation}&lt;br /&gt;
2*2 = 5&lt;br /&gt;
\end{equation}&lt;br /&gt;
\end{minipage}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
or&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;latex&amp;quot;&amp;gt;&lt;br /&gt;
\old{wrong equation \\&lt;br /&gt;
\parbox{\textwidth}{&lt;br /&gt;
\begin{equation}&lt;br /&gt;
2*2 = 5&lt;br /&gt;
\end{equation}&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;\parbox&amp;lt;/tt&amp;gt; seems to work better with &amp;lt;tt&amp;gt;\eqnarray&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Thanks to Brad Artman and James Gunning for reporting this problem.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Communication ==&lt;br /&gt;
&lt;br /&gt;
The SEGTeX development is discussed at the [http://listserver.seg.org/cgi-bin/mailman/listinfo/segtex SEGTeX mailing list] maintained by Joe Dellinger.&lt;br /&gt;
&lt;br /&gt;
== Reproducible papers ==&lt;br /&gt;
&lt;br /&gt;
SEGTeX is used in the [[Main Page|Madagascar]] package to produce [[Reproducible Documents|reproducible research papers]].&lt;br /&gt;
&lt;br /&gt;
See a [http://reproducibility.org/wikilocal/docs/vancouver06/fomel_latex.pdf presentation on LaTeX and Web tools] from the [[RSF School and Workshop%2C Vancouver 2006]].&lt;br /&gt;
&lt;br /&gt;
== LaTeX references ==&lt;br /&gt;
&lt;br /&gt;
* LaTeX [http://www.latex-project.org/ open project]&lt;br /&gt;
&lt;br /&gt;
* LaTeX [http://en.wikipedia.org/wiki/LaTeX Wikipedia page]&lt;br /&gt;
&lt;br /&gt;
* LaTeX [http://www.latex-project.org/guides/books.html books]&lt;br /&gt;
&lt;br /&gt;
== News ==&lt;br /&gt;
[[Image:image21.png|frame|right|[https://imageevent.org/2021 SEG/AAPG Image Conference]]]&lt;br /&gt;
&lt;br /&gt;
* 07/04/2006 SEGTeX moved to [http://sourceforge.net/projects/segtex SourceForge]&lt;br /&gt;
* 07/07/2006 version 0.8   released&lt;br /&gt;
* 10/26/2006 version 0.8.1 released&lt;br /&gt;
* 10/27/2006 version 0.8.2 released&lt;br /&gt;
* 12/11/2006 version 0.8.3 and segabs-2007.1 released&lt;br /&gt;
* 03/15/2007 version 0.8.4 and segabs-2007.2 released&lt;br /&gt;
* 04/03/2007 version 0.8.5 and segabs-2007.3 released&lt;br /&gt;
* 04/20/2008 version 0.8.6 and segabs-2008.1 released&lt;br /&gt;
* 04/27/2008 version 0.8.7 and segabs-2008.2 released&lt;br /&gt;
* 05/16/2008 version 0.8.8 released&lt;br /&gt;
* 06/07/2009 version 0.8.9 and segabs-2009.1 released&lt;br /&gt;
* 03/09/2011 version 0.9   and segabs-2011.1 released&lt;br /&gt;
* 03/23/2013 version 0.9.1 and segabs-2013.1 released&lt;br /&gt;
* 03/11/2014 version 0.9.2 and segabs-2014.1 released&lt;br /&gt;
* 03/06/2015 version 0.9.3 and segabs-2015.1 released&lt;br /&gt;
* 07/28/2015 SEGTeX repository moved to [https://github.com/SEGTeX/texmf GitHub]&lt;br /&gt;
* 03/07/2016 version 0.9.5 and segabs-2016.1 released&lt;br /&gt;
* 09/05/2018 version 0.9.6 released&lt;br /&gt;
* 08/31/2021 version 0.9.7 and segabs-2021.1 released&lt;br /&gt;
* 10/12/2021 version 0.9.8 released&lt;/div&gt;</summary>
		<author><name>Fomels</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=SEGTeX&amp;diff=4453</id>
		<title>SEGTeX</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=SEGTeX&amp;diff=4453"/>
		<updated>2024-10-24T23:33:08Z</updated>

		<summary type="html">&lt;p&gt;Fomels: typos&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:SEG-Logo Final SM.png|thumb|[https://seg.org Society of Exploration Geophysicists]]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;SEGTeX&#039;&#039;&#039; is a LaTeX package for geophysical publications. It consists of&lt;br /&gt;
* LaTeX2e class files for [https://library.seg.org/journal/gpysa7/ Geophysics] papers, SEG expanded abstracts, etc&lt;br /&gt;
* BibTeX style files [https://github.com/SEGTeX/texmf/blob/master/bibtex/bst/seg/seg.bst seg.bst]&lt;br /&gt;
* BibTeX cumulative bibliography of geophysical publications [https://github.com/SEGTeX/texmf/blob/master/bibtex/bib/seg/SEG.bib SEG.bib]&lt;br /&gt;
* [http://www.latex2html.org/ latex2html] customizations&lt;br /&gt;
&lt;br /&gt;
== Downloading ==&lt;br /&gt;
&lt;br /&gt;
Access SEGTeX through its [http://sourceforge.net/projects/segtex/ SourceForge project] by downloading [http://sourceforge.net/projects/segtex/files/ the latest stable release].&lt;br /&gt;
&lt;br /&gt;
Alternatively, access the current working version by either using [https://git-scm.com/ Git] and running&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone &amp;lt;nowiki&amp;gt;https://github.com/SEGTeX/texmf&amp;lt;/nowiki&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or using [http://subversion.tigris.org/ Subversion] and running&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn co &amp;lt;nowiki&amp;gt;https://github.com/SEGTeX/texmf/trunk&amp;lt;/nowiki&amp;gt; texmf &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can also [https://github.com/SEGTeX/texmf browse the GitHub repository].&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
If your LaTeX installation is missing/incomplete, try installing [http://www.tug.org/texlive/ TeX Live] first.&lt;br /&gt;
&lt;br /&gt;
To install, put the contents of the &amp;lt;tt&amp;gt;texmf&amp;lt;/tt&amp;gt; folder where LaTeX can find it. Most systems recognize &amp;lt;tt&amp;gt;$HOME/texmf&amp;lt;/tt&amp;gt; as one of the default places. On MacOS X, it can be &amp;lt;tt&amp;gt;$HOME/Library/texmf&amp;lt;/tt&amp;gt;. You may need to run &amp;lt;tt&amp;gt;texhash&amp;lt;/tt&amp;gt; to tell LaTeX about the new files. For more help on &amp;lt;tt&amp;gt;texmf&amp;lt;/tt&amp;gt;, see [http://www.tex.ac.uk/cgi-bin/texfaq2html?label=privinst “Private” installations of files].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prerequisites ===&lt;br /&gt;
&lt;br /&gt;
Some of the required additional LaTeX packages are:&lt;br /&gt;
&lt;br /&gt;
* [http://www.ctan.org/pkg/natbib natbib] support for (author,year) bibliography style of natural sciences&lt;br /&gt;
&lt;br /&gt;
== Download and Install SEGTEX on Mac ==&lt;br /&gt;
 cd $HOME/Library&lt;br /&gt;
 git clone https://github.com/SEGTEX/texmf &lt;br /&gt;
 sudo port install texlive-latex-extra&lt;br /&gt;
&lt;br /&gt;
== SEG expanded abstracts ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;SEGTeX&#039;&#039;&#039; includes &#039;&#039;&#039;segabs.cls&#039;&#039;&#039; -- a LaTeX class for generating SEG expanded abstracts. Alternatively,  you can &lt;br /&gt;
[https://sourceforge.net/projects/segtex/files/segabs/segabs-2015.1/ download &#039;&#039;&#039;segabs-2015&#039;&#039;&#039;] -- a packaged expanded abstract template.&lt;br /&gt;
&lt;br /&gt;
To generate an expanded abstract without references, as SEG requires, use two LaTeX files: one for the abstract itself and the other for separating pages without references. Examples are [http://sourceforge.net/p/segtex/code/HEAD/tree/trunk/tex/latex/seg/segabs_example.ltx segabs_example.ltx] and [http://sourceforge.net/p/segtex/code/HEAD/tree/trunk/tex/latex/seg/segabs_final.ltx segabs_final.ltx]&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;latex&amp;quot;&amp;gt;&lt;br /&gt;
\documentclass{article}&lt;br /&gt;
\usepackage{pdfpages}&lt;br /&gt;
\begin{document}&lt;br /&gt;
\includepdf[pages={1-4}]{segabs_example}&lt;br /&gt;
\end{document}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This solution only works with &#039;&#039;&#039;pdflatex&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
Alternatively, you can separate pages using an external program. &lt;br /&gt;
* In [http://www.adobe.com/products/acrobatpro/ Acrobat Pro], open the PDF file with references, select &amp;lt;tt&amp;gt;Document -&amp;amp;gt; Pages -&amp;amp;gt; Extract&amp;lt;/tt&amp;gt;, and extract the reference page with the delete option (&#039;&#039;thanks to Norm Bleistein for the tip&#039;&#039;.)&lt;br /&gt;
* Another helpful program is [http://www.accesspdf.com/pdftk/ pdftk] (PDF toolkit.)&lt;br /&gt;
&lt;br /&gt;
== Documentation ==&lt;br /&gt;
&lt;br /&gt;
The [https://github.com/SEGTeX/texmf/tree/master/tex/latex/seg tex/latex/seg] directory contains several example files.&lt;br /&gt;
&lt;br /&gt;
Use the manuscript style to submit papers to &#039;&#039;&#039;Geophysics&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* Manuscript style &#039;&#039;&#039;Geophysics&#039;&#039;&#039; paper [http://reproducibility.org/wikilocal/docs/geophysics_example.pdf geophysics_example] [http://reproducibility.org/wikilocal/docs/geophysics_titlepage.pdf geophysics_titlepage] [http://reproducibility.org/wikilocal/docs/geophysics_notitlepage.pdf geophysics_notitlepage]&lt;br /&gt;
* Manuscript style &#039;&#039;&#039;Geophysics&#039;&#039;&#039; paper using &amp;lt;tt&amp;gt;endfloat&amp;lt;/tt&amp;gt; [http://reproducibility.org/wikilocal/docs/geophysics_endfloat.pdf geophysics_endfloat]&lt;br /&gt;
* Manuscript style &#039;&#039;&#039;Geophysics&#039;&#039;&#039; with author information (no double-blind review) [http://reproducibility.org/wikilocal/docs/geophysics_noblind.pdf geophysics_noblind]&lt;br /&gt;
* Publication style two-column &#039;&#039;&#039;Geophysics&#039;&#039;&#039; paper [http://reproducibility.org/wikilocal/docs/geophysics_twocolumn.pdf geophysics_twolumn]&lt;br /&gt;
* &#039;&#039;&#039;SEG&#039;&#039;&#039; expanded abstract (with references) [http://reproducibility.org/wikilocal/docs/segabs_example.pdf segabs_example]&lt;br /&gt;
* &#039;&#039;&#039;SEG&#039;&#039;&#039; expanded abstract (without references) [http://reproducibility.org/wikilocal/docs/segabs_final.pdf segabs_final]&lt;br /&gt;
* Report style paper [http://reproducibility.org/wikilocal/docs/geophysics_paper.pdf geophysics_paper]&lt;br /&gt;
&lt;br /&gt;
== Tips and tricks ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Equations, citation commands, etc. don&#039;t work inside \old.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Enclose citations in &amp;lt;tt&amp;gt;\mbox&amp;lt;/tt&amp;gt;: Instead of &amp;lt;tt&amp;gt;\old{wrong citation \cite{wrong}}&amp;lt;/tt&amp;gt;, use  &amp;lt;tt&amp;gt;\old{wrong citation \mbox{\cite{wrong}}}&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enclose equations in &amp;lt;tt&amp;gt;\parbox&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;minipage&amp;lt;/tt&amp;gt;:  Instead of&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;latex&amp;quot;&amp;gt;&lt;br /&gt;
\old{wrong equation&lt;br /&gt;
\begin{equation}&lt;br /&gt;
2*2 = 5&lt;br /&gt;
\end{equation}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
use&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;latex&amp;quot;&amp;gt;&lt;br /&gt;
\old{wrong equation \\&lt;br /&gt;
\begin{minipage}{\textwidth}&lt;br /&gt;
\begin{equation}&lt;br /&gt;
2*2 = 5&lt;br /&gt;
\end{equation}&lt;br /&gt;
\end{minipage}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
or&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;latex&amp;quot;&amp;gt;&lt;br /&gt;
\old{wrong equation \\&lt;br /&gt;
\parbox{\textwidth}{&lt;br /&gt;
\begin{equation}&lt;br /&gt;
2*2 = 5&lt;br /&gt;
\end{equation}&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;\parbox&amp;lt;/tt&amp;gt; seems to work better with &amp;lt;tt&amp;gt;\eqnarray&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Thanks to Brad Artman and James Gunning for reporting this problem.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Communication ==&lt;br /&gt;
&lt;br /&gt;
The SEGTeX development is discussed at the [http://listserver.seg.org/cgi-bin/mailman/listinfo/segtex SEGTeX mailing list] maintained by Joe Dellinger.&lt;br /&gt;
&lt;br /&gt;
== Reproducible papers ==&lt;br /&gt;
&lt;br /&gt;
SEGTeX is used in the [[Main Page|Madagascar]] package to produce [[Reproducible Documents|reproducible research papers]].&lt;br /&gt;
&lt;br /&gt;
See a [http://reproducibility.org/wikilocal/docs/vancouver06/fomel_latex.pdf presentation on LaTeX and Web tools] from the [[RSF School and Workshop%2C Vancouver 2006]].&lt;br /&gt;
&lt;br /&gt;
== LaTeX references ==&lt;br /&gt;
&lt;br /&gt;
* LaTeX [http://www.latex-project.org/ open project]&lt;br /&gt;
&lt;br /&gt;
* LaTeX [http://en.wikipedia.org/wiki/LaTeX Wikipedia page]&lt;br /&gt;
&lt;br /&gt;
* LaTeX [http://www.latex-project.org/guides/books.html books]&lt;br /&gt;
&lt;br /&gt;
== News ==&lt;br /&gt;
[[Image:image21.png|frame|right|[https://imageevent.org/2021 SEG/AAPG Image Conference]]]&lt;br /&gt;
&lt;br /&gt;
* 07/04/2006 SEGTeX moved to [http://sourceforge.net/projects/segtex SourceForge]&lt;br /&gt;
* 07/07/2006 version 0.8   released&lt;br /&gt;
* 10/26/2006 version 0.8.1 released&lt;br /&gt;
* 10/27/2006 version 0.8.2 released&lt;br /&gt;
* 12/11/2006 version 0.8.3 and segabs-2007.1 released&lt;br /&gt;
* 03/15/2007 version 0.8.4 and segabs-2007.2 released&lt;br /&gt;
* 04/03/2007 version 0.8.5 and segabs-2007.3 released&lt;br /&gt;
* 04/20/2008 version 0.8.6 and segabs-2008.1 released&lt;br /&gt;
* 04/27/2008 version 0.8.7 and segabs-2008.2 released&lt;br /&gt;
* 05/16/2008 version 0.8.8 released&lt;br /&gt;
* 06/07/2009 version 0.8.9 and segabs-2009.1 released&lt;br /&gt;
* 03/09/2011 version 0.9   and segabs-2011.1 released&lt;br /&gt;
* 03/23/2013 version 0.9.1 and segabs-2013.1 released&lt;br /&gt;
* 03/11/2014 version 0.9.2 and segabs-2014.1 released&lt;br /&gt;
* 03/06/2015 version 0.9.3 and segabs-2015.1 released&lt;br /&gt;
* 07/28/2015 SEGTeX repository moved to [https://github.com/SEGTeX/texmf GitHub]&lt;br /&gt;
* 03/07/2016 version 0.9.5 and segabs-2016.1 released&lt;br /&gt;
* 09/05/2018 version 0.9.6 released&lt;br /&gt;
* 08/31/2021 version 0.9.7 and segabs-2021.1 released&lt;br /&gt;
* 10/12/2021 version 0.9.8 released&lt;/div&gt;</summary>
		<author><name>Fomels</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Reproducible_Documents&amp;diff=4394</id>
		<title>Reproducible Documents</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Reproducible_Documents&amp;diff=4394"/>
		<updated>2024-10-17T23:01:17Z</updated>

		<summary type="html">&lt;p&gt;Fomels: reproducibility.org -&amp;gt; ahay.org&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_6815478_XS.jpg|right|]]&lt;br /&gt;
&lt;br /&gt;
== [https://ahay.org/RSF/book/bei/ Basic Earth Imaging] ==&lt;br /&gt;
* [https://ahay.org/RSF/book/bei/sg/paper_html/ Imaging in shot-geophone space] by &#039;&#039;Jon F. Claerbout&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/bei/dwnc/paper_html/ Downward continuation] by &#039;&#039;Jon F. Claerbout&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/bei/ft1/paper_html/ Waves and Fourier sums] by &#039;&#039;Jon F. Claerbout&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/bei/krch/paper_html/ Zero-offset migration] by &#039;&#039;Jon F. Claerbout&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/bei/vela/paper_html/ Moveout, velocity, and stacking] by &#039;&#039;Jon F. Claerbout&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/bei/wvs/paper_html/ Waves in strata] by &#039;&#039;Jon F. Claerbout&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/bei/conj/paper_html/ Adjoint operators] by &#039;&#039;Jon F. Claerbout&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/bei/fld/paper_html/ Field recording geometry] by &#039;&#039;Jon F. Claerbout&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== [https://ahay.org/RSF/book/cwp/ Center for Wave Phenomena] ==&lt;br /&gt;
* [https://ahay.org/RSF/book/cwp/geo2011WideAzimuthAngleDecomposition/paper_html/ Wide-azimuth angle gathers for wave-equation migration] by &#039;&#039;Paul Sava and Ioan Vlad&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 76, no. 3, S131-S141, (2011) &lt;br /&gt;
* [https://ahay.org/RSF/book/cwp/pept2011MicroearthquakeMonitoring/paper_html/ Micro-earthquake monitoring with sparsely-sampled data] by &#039;&#039;Paul Sava&#039;&#039;: &#039;&#039;&#039;Journal of Petroleum Exploration and Production Technology&#039;&#039;&#039;, 1, no. 1, 43-49, (2011)&lt;br /&gt;
* [https://ahay.org/RSF/book/cwp/geo2008IsotropicAngleDomainElasticRTM/paper_html/ Isotropic angle-domain elastic reverse-time migration] by &#039;&#039;Jia Yan and Paul Sava&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 73 , no. 6, S229-S239, (2008)&lt;br /&gt;
* [https://ahay.org/RSF/book/cwp/geo2009VTIModeSeparation/paper_html/ Elastic wave-mode separation for VTI media] by &#039;&#039;Jia Yan and Paul Sava&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 74 , no. 5, WB19-WB32, (2009)&lt;br /&gt;
* [https://ahay.org/RSF/book/cwp/geo2009TTIModeSeparation/paper_html/ Elastic wave-mode separation for TTI media] by &#039;&#039;Jia Yan and Paul Sava&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 76, no. 4, T65-T78, (2011)&lt;br /&gt;
* [https://ahay.org/RSF/book/cwp/geo2008InterferometricImagingCondition/paper_html/ Interferometric imaging condition for wave-equation migration] by &#039;&#039;Paul Sava and Oleg Poliannikov&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 73 , no. 2, S47-S61, (2008)&lt;br /&gt;
* [https://ahay.org/RSF/book/cwp/geo2008NumericWEMVAoperators/paper_html/ Numeric implementation of wave-equation migration velocity analysis operators] by &#039;&#039;Paul Sava and Ioan Vlad&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 73 , no. 5, VE145-VE159, (2008)&lt;br /&gt;
* [https://ahay.org/RSF/book/cwp/geo2007StereographicImagingCondition/paper_html/ Stereographic imaging condition for wave-equation migration] by &#039;&#039;Paul Sava&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 72 , no. 6, A87-A91, (2007)&lt;br /&gt;
* [https://ahay.org/RSF/book/cwp/jse2006RWEImagingOverturningReflections/paper_html/ Imaging overturning reflections by Riemannian Wavefield Extrapolation] by &#039;&#039;Paul Sava&#039;&#039;: &#039;&#039;&#039;Journal of Seismic Exploration&#039;&#039;&#039;, 15, no 3, 209-223 (2006)&lt;br /&gt;
* [https://ahay.org/RSF/book/cwp/geo2006TimeShiftImagingCondition/paper_html/ Time-shift imaging condition in seismic migration] by &#039;&#039;Paul Sava and Sergey Fomel&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 71 , no. 6, S209-S217, (2006)&lt;br /&gt;
* [https://ahay.org/RSF/book/cwp/aniso/paper_html/ Nonhyperbolic reflection moveout of &amp;lt;i&amp;gt;P&amp;lt;/i&amp;gt;-waves: An overview and comparison of reasons] by &#039;&#039;Sergey Fomel and Vladimir Grechka&#039;&#039;: &#039;&#039;&#039;Center for Wave Phenomena&#039;&#039;&#039;, CWP-372 (2001)&lt;br /&gt;
&lt;br /&gt;
== [https://ahay.org/RSF/book/cup/ China University of Petroleum] ==&lt;br /&gt;
* [https://ahay.org/RSF/book/cup/rna2d/paper_html/ Random noise attenuation using f-x regularized nonstationary autoregression] by &#039;&#039;Guochang Liu, Xiaohong Chen, Jing Du, and Kailong Wu&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 77 , no. 2, V61-V69, (2012)&lt;br /&gt;
* [https://ahay.org/RSF/book/cup/rna3d/paper_html/ Noncausal f-x-y regularized nonstationary prediction filtering for random noise attenuation on 3D seismic data] by &#039;&#039;Guochang Liu and Xiaohong Chen &#039;&#039;: &#039;&#039;&#039;Journal of Applied Geophysics&#039;&#039;&#039;, 93, 60-66, (2013)&lt;br /&gt;
&lt;br /&gt;
== [https://ahay.org/RSF/book/hansung/ Hansung University] ==&lt;br /&gt;
* [https://ahay.org/RSF/book/hansung/cgg/paper_html/ Conjugate guided gradient (CGG) method for robust inversion and its application to velocity-stack inversion] by &#039;&#039;Jun Ji&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 71 , no. 4, R59-R67, (2006)&lt;br /&gt;
&lt;br /&gt;
== [https://ahay.org/RSF/book/gee/ Image Estimation by Example] ==&lt;br /&gt;
* [https://ahay.org/RSF/book/gee/lmn/paper_html/ Plane waves in three dimensions] by &#039;&#039;Jon F. Claerbout&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/gee/pch/paper_html/ Nonstationarity: patching] by &#039;&#039;Jon F. Claerbout&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/gee/lal/paper_html/ Spatial aliasing and scale invariance] by &#039;&#039;Jon F. Claerbout&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/gee/mda/paper_html/ Multidimensional autoregression] by &#039;&#039;Jon F. Claerbout&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/gee/prc/paper_html/ Preconditioning] by &#039;&#039;Jon F. Claerbout&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/gee/hlx/paper_html/ The helical coordinate] by &#039;&#039;Jon F. Claerbout&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/gee/iin/paper_html/ Empty bins and inverse interpolation] by &#039;&#039;Jon F. Claerbout&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/gee/lsq/paper_html/ Model fitting by least squares] by &#039;&#039;Jon F. Claerbout&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/gee/ajt/paper_html/ Basic operators and adjoints] by &#039;&#039;Jon F. Claerbout&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== [https://ahay.org/RSF/book/data/ Madagascar Datasets] ==&lt;br /&gt;
* [https://ahay.org/RSF/book/data/marmousi2mp/paper_html/ 2D modeling and basic processing with Madagascar] by &#039;&#039;Pongthep Thongsang, Lian Jiang, Hao Li, and Karl Schleicher&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/data/marmousi2/paper_html/ Marmousi2 model] by &#039;&#039;Trevor Irons&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/data/alaska/paper_html/ Open Data/Open Source: Seismic Unix scripts to process a 2D land line] by &#039;&#039;Karl Schleicher&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/data/teapotdome/paper_html/ Processing the Teapot Dome Land 3D Survey with Madagascar] by &#039;&#039;Karl Schleicher&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/data/sigsbee/paper_html/ Sigsbee2 models] by &#039;&#039;Trevor Irons&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/data/pluto/paper_html/ Pluto model] by &#039;&#039;Trevor Irons&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/data/marmousi/paper_html/ Marmousi model] by &#039;&#039;Trevor Irons&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/data/amoco/paper_html/ Amoco model] by &#039;&#039;Trevor Irons&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== [https://ahay.org/RSF/book/icp/ ICP-Ecopetrol] ==&lt;br /&gt;
* [https://ahay.org/RSF/book/icp/sam2013gpushortestpath/segabs_graphrayt_html/ Shortest path ray tracing on parallel GPU devices] by &#039;&#039;Jorge Monsegny and William Agudelo&#039;&#039;: &#039;&#039;&#039;SEG Expanded Abstracts&#039;&#039;&#039;, 3470-3474, (2013)&lt;br /&gt;
&lt;br /&gt;
== [https://ahay.org/RSF/book/jlu/ Jilin University] ==&lt;br /&gt;
&lt;br /&gt;
* [https://ahay.org/RSF/book/jlu/fxyspfdenoi/paper_html/ Noniterative f-x-y streaming prediction filtering for random noise attenuation on seismic data] by &#039;&#039;Yang Liu and Zhisheng Zhen&#039;&#039;: &#039;&#039;&#039;IEEE Transactions on Geoscience and Remote Sensing&#039;&#039;&#039;, 60, 1-9, Early Access, (2022)&lt;br /&gt;
* [https://ahay.org/RSF/book/jlu/fspfint/paper_html/ Seismic data interpolation using streaming prediction filter in the frequency domain] by &#039;&#039;Zhisheng Zheng, Yang Liu, and Geng Wu&#039;&#039;: &#039;&#039;&#039;Geophysical Journal International&#039;&#039;&#039;, 229, 370-389, (2022)&lt;br /&gt;
* [https://ahay.org/RSF/book/jlu/txyspfint/paper_html/ Seismic data interpolation without iteration using a t-x-y streaming prediction filter with varying smoothness] by &#039;&#039;Yang Liu, Geng Wu, and Zhisheng Zheng&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 87, V29-V38, (2022)&lt;br /&gt;
* [https://ahay.org/RSF/book/jlu/apefsnsep/paper_html/ Nonstationary pattern-based signal-noise separation using adaptive prediction-error filter] by &#039;&#039;Zhisheng Zheng, Yang Liu, and Cai Liu&#039;&#039;: &#039;&#039;&#039;Journal of Geophysics and Engineering&#039;&#039;&#039;, 19, 14-27, (2022)&lt;br /&gt;
* [https://ahay.org/RSF/book/jlu/spefdecon/paper_html/ Multichannel adaptive deconvolution based on streaming prediction-error filter] by &#039;&#039;Qinghan Wang, Yang Liu, Cai Liu, and Zhisheng Zheng&#039;&#039;: &#039;&#039;&#039;Journal of Geophysics and Engineering&#039;&#039;&#039;, 18, 825-833, (2021)&lt;br /&gt;
* [https://ahay.org/RSF/book/jlu/lcfs/paper_html/ Continuous time-varying Q-factor estimation method in the time-frequency domain] by &#039;&#039;Qinghan Wang, Yang Liu, Cai Liu, and Zhisheng Zheng&#039;&#039;: &#039;&#039;&#039;Applied Geophysics&#039;&#039;&#039;, 17, 844-856, (2020)&lt;br /&gt;
* [https://ahay.org/RSF/book/jlu/txsopf/paper_html/ Streaming orthogonal prediction filter in t-x domain for random noise attenuation] by &#039;&#039;Yang Liu and Bingxiu Li&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 83, F41-F48, (2018)&lt;br /&gt;
* [https://ahay.org/RSF/book/jlu/gvdseisint/paper_html/ Seismic data interpolation using generalised velocity-dependent seislet transform] by &#039;&#039;Yang Liu, Peng Zhang, and Cai Liu&#039;&#039;: &#039;&#039;&#039;Geophysical Prospecting&#039;&#039;&#039;, 65, 82-93, (2017)&lt;br /&gt;
* [https://ahay.org/RSF/book/jlu/vdseislet/paper_html/ Signal and noise separation in prestack seismic data using velocity-dependent seislet transform] by &#039;&#039;Yang Liu, Sergey Fomel, and Cai Liu&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 80, WD117-WD128, (2015)&lt;br /&gt;
* [https://ahay.org/RSF/book/jlu/riesz/paper_html/ Seismic dip estimation based on the two-dimensional Hilbert transform and its application in random noise attenuation] by &#039;&#039;Cai Liu, Changle Chen, Dian Wang, Yang Liu, Shiyu Wang, and Liang Zhang&#039;&#039;: &#039;&#039;&#039;Applied Geophysics&#039;&#039;&#039;, 12, 55-63, (March 2015)&lt;br /&gt;
* [https://ahay.org/RSF/book/jlu/txyapf/paper_html/ Adaptive prediction filtering in t -x-y domain for random noise attenuation using regularized nonstationary autoregression] by &#039;&#039;Yang Liu, Ning Liu, and Cai Liu&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 80, V13-V21, (2015)&lt;br /&gt;
&lt;br /&gt;
== [https://ahay.org/RSF/book/rsf/ Madagascar Documentation] ==&lt;br /&gt;
* [https://ahay.org/RSF/book/rsf/school2012/tutorial_html/ Madagascar tutorial: Field data processing] by &#039;&#039;Maurice the Aye-Aye&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/rsf/school/articleWSI_html/ Seismic Imaging Tutorial: &amp;quot;exploding reflector&amp;quot; modeling/migration] by &#039;&#039;Paul Sava&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/tutorial A brief introduction to Madagascar] by &#039;&#039;Jeff Godwin&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/rsf/manual/manual_html/ Madagascar Programming Reference Manual] by &#039;&#039;Mohammad Akbar Zuberi, Tariq Alkhalifah, and Christos Saragoitis&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/rsf/school2009/paper_html/ Madagascar tutorial] by &#039;&#039;Maurice the Aye-Aye&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/rsf/rsf/prog_html/ Guide to Madagascar programs] by &#039;&#039;Sergey Fomel&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/rsf/rsf/tour_html/ Revisiting SEP tour with RSF and SCons] by &#039;&#039;Sergey Fomel&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/rsf/rsf/api_html/ Guide to RSF API] by &#039;&#039;Sergey Fomel&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/rsf/rsf/demo_html/ Guide to programming using RSF] by &#039;&#039;Paul Sava&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/rsf/scons/paper_html/ Reproducible computational experiments using SCons] by &#039;&#039;Sergey Fomel and Gilles Hennenfent&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== [https://ahay.org/RSF/book/milano/ Politecnico di Milano] ==&lt;br /&gt;
* [https://ahay.org/RSF/book/milano/taupvel/paper_html/ Velocity-independent tau-p moveout in a horizontally-layered VTI medium ] by &#039;&#039;Lorenzo Casasanta and Sergey Fomel&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 76, no. 4, U45-U57, (2011)&lt;br /&gt;
&lt;br /&gt;
== [https://ahay.org/RSF/book/slim/ Seismic Laboratory for Imaging and Modeling] ==&lt;br /&gt;
* [https://ahay.org/RSF/book/slim/geo2008NewInsightsPareto/paper_html/ New insights into one-norm solvers from the Pareto curve] by &#039;&#039;Gilles Hennenfent, Ewout van den Berg, Michael P. Friedlander, and Felix J. Herrmann&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 73, no. 4, A23-A26, (2008)&lt;br /&gt;
* [https://ahay.org/RSF/book/slim/slimUserManual/paper_html/ User&#039;s manual for SLIM programs in Madagascar] by &#039;&#039;Gilles Hennenfent&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== [https://ahay.org/RSF/book/sep/ Stanford Exploration Project] ==&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/geostat/paper_html/ Multiple realizations using standard inversion techniques] by &#039;&#039;Robert Clapp&#039;&#039;: &#039;&#039;&#039;SEP Report&#039;&#039;&#039;, 105, 67-78 (2000)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/sparse2/paper_html/ Test case for PEF estimation with sparse data II] by &#039;&#039;Morgan Brown, Jon Claerbout, and Sergey Fomel&#039;&#039;: &#039;&#039;&#039;SEP Report&#039;&#039;&#039;, 105, 117-122 (2000)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/elliptic2/paper_html/ The double-elliptic approximation in the group and phase domains] by &#039;&#039;Joe Dellinger and Francis Muir&#039;&#039;: &#039;&#039;&#039;SEP Report&#039;&#039;&#039;, 70, 361-366 (1991)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/balance/paper_html/ Iterative least-square inversion for amplitude balancing] by &#039;&#039;Arnaud Berlioux and William Harlan&#039;&#039;: &#039;&#039;&#039;SEP Report&#039;&#039;&#039;, 89, 167-178 (1995)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/pefmult/paper_html/ Multiple suppression using prediction-error filter] by &#039;&#039;Yalei Sun&#039;&#039;: &#039;&#039;&#039;SEP Report&#039;&#039;&#039;, 94, 205-212 (1997)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/aal/paper_html/ When is anti-aliasing needed in Kirchhoff migration?] by &#039;&#039;Dimitri Bevc and David Lumley&#039;&#039;: &#039;&#039;&#039;SEP Report&#039;&#039;&#039;, 80, 467-476 (1994)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/passive/paper_html/ Passive seismic imaging applied to synthetic data] by &#039;&#039;James Rickett and Jon Claerbout&#039;&#039;: &#039;&#039;&#039;SEP Report&#039;&#039;&#039;, 92, 83-90 (1996)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/avo/paper_html/ Seismic AVO analysis of methane hydrate structures] by &#039;&#039;Christine Ecker and David Lumley&#039;&#039;: &#039;&#039;&#039;SEP Report&#039;&#039;&#039;, 80, 277-292 (1994)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/super/paper_html/ A prospect for super resolution] by &#039;&#039;Jon Claerbout&#039;&#039;: &#039;&#039;&#039;SEP Report&#039;&#039;&#039;, 93, 133-136 (1996)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/shearer/paper_html/ Earthquake stacks at constant offset] by &#039;&#039;Jon Claerbout&#039;&#039;: &#039;&#039;&#039;SEP Report&#039;&#039;&#039;, 77, 361-366 (1993) &lt;br /&gt;
* [https://ahay.org/RSF/book/sep/txamo/paper_html/ The time and space formulation of azimuth moveout] by &#039;&#039;Sergey Fomel and Biondo Biondi&#039;&#039;: &#039;&#039;&#039;SEP Report&#039;&#039;&#039;, 84, 25-37 (1995)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/waverays/paper_html/ Wavefront construction using waverays] by &#039;&#039;Hector Urdaneta&#039;&#039;: &#039;&#039;&#039;SEP Report&#039;&#039;&#039;, 80, 85-100 (1994)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/helft/paper_html/ Multi-dimensional Fourier transforms in the helical coordinate system] by &#039;&#039;James Rickett and Antoine Guitton&#039;&#039;: &#039;&#039;&#039;SEP Report&#039;&#039;&#039;, 105, 167-176 (2000)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/fat/paper_html/ Imaging complex structures with first-arrival traveltimes] by &#039;&#039;Dimitri Bevc&#039;&#039;: &#039;&#039;&#039;SEP Report&#039;&#039;&#039;, 84, 1-10 (1995)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/texture/paper_html/ Texture synthesis and prediction error filtering] by &#039;&#039;Morgan Brown&#039;&#039;: &#039;&#039;&#039;SEP report&#039;&#039;&#039;, 100, 211-222 (1999)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/lines/paper_html/ Random lines in a plane] by &#039;&#039;Jon Claerbout&#039;&#039;: &#039;&#039;&#039;SEP report&#039;&#039;&#039;, 103, 325-328 (2000)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/fractal/paper_html/ Modeling 3-D anisotropic fractal media] by &#039;&#039;Nizar Chemingui&#039;&#039;: &#039;&#039;&#039;SEP report&#039;&#039;&#039;, 80, 603-616 (1994)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/banana/paper_html/ Traveltime sensitivity kernels: Banana-doughnuts or just plain bananas?] by &#039;&#039;James Rickett&#039;&#039;: &#039;&#039;&#039;SEP report&#039;&#039;&#039;, 103, 61-68 (2000)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/steer/paper_html/ Solution steering with space-variant filters] by &#039;&#039;Robert G. Clapp, Sergey Fomel, and Jon Claerbout&#039;&#039;: &#039;&#039;&#039;SEP report&#039;&#039;&#039;, 95, 27-42 (1997)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/lineiko/paper_html/ Traveltime computation with the linearized eikonal equation] by &#039;&#039;Sergey Fomel&#039;&#039;: &#039;&#039;&#039;SEP report&#039;&#039;&#039;, 94, 123-131 (1997)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/bspl/paper_html/ Inverse B-spline interpolation] by &#039;&#039;Sergey Fomel&#039;&#039;: &#039;&#039;&#039;SEP report&#039;&#039;&#039;, 105, 79-108 (2000)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/plane/paper_html/ Plane wave prediction in 3-D] by &#039;&#039;Sergey Fomel&#039;&#039;: &#039;&#039;&#039;SEP report&#039;&#039;&#039;, 102, 101-110 (1999)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/stoltst/paper_html/ Evaluating the Stolt-stretch parameter] by &#039;&#039;Sergey Fomel and Louis Vaillant&#039;&#039;: &#039;&#039;&#039;Journal of Seismic Exploration&#039;&#039;&#039;, v. 9, 319-335, (2001)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/huygens/paper_html/ Huygens wavefront tracing: A robust alternative to conventional ray tracing] by &#039;&#039;Paul Sava and Sergey Fomel&#039;&#039;: &#039;&#039;&#039;SEP Report&#039;&#039;&#039;, 95, 101-113 (1997)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/fkamo/paper_html/ Effective AMO implementation in the log-stretch, frequency-wavenumber domain] by &#039;&#039;Ioan Vlad and Biondo Biondi&#039;&#039;: &#039;&#039;&#039;SEP Report&#039;&#039;&#039;, 110, 63-70 (2001)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/antial/paper_html/ Antialiasing of Kirchhoff operators by reciprocal parameterization] by &#039;&#039;Sergey Fomel&#039;&#039;: &#039;&#039;&#039;Journal of Seismic Exploration&#039;&#039;&#039;, v. 10, 293-310 (2002)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/norm/paper_html/ Amplitude preservation for offset continuation: Confirmation for Kirchhoff data] by &#039;&#039;Sergey Fomel and Norman Bleistein&#039;&#039;: &#039;&#039;&#039;Journal of Seismic Exploration&#039;&#039;&#039;, v. 9, 121-130 (2001)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/angle/paper_html/ Angle-gather time migration] by &#039;&#039;Sergey Fomel and Marie Prucha&#039;&#039;: &#039;&#039;&#039;SEP report&#039;&#039;&#039;, 100, 141-150 (1999)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/spitz/paper_html/ Spitz makes a better assumption for the signal PEF] by &#039;&#039;Jon F. Claerbout and Sergey Fomel&#039;&#039;: &#039;&#039;&#039;SEP report&#039;&#039;&#039;, 103, 211-219 (2000)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/findif/paper_html/ Exploring three-dimensional implicit wavefield extrapolation with the helix transform] by &#039;&#039;Sergey Fomel and Jon F. Claerbout&#039;&#039;: &#039;&#039;&#039;SEP report&#039;&#039;&#039;, 95, 43-60 (1997)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/vc2/paper_html/ Time-migration velocity analysis by velocity continuation] by &#039;&#039;Sergey Fomel&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 68, 1662-1672 (2003)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/burg/paper_html/ The Wilson-Burg method of spectral factorization with application to helical filtering] by &#039;&#039;Sergey Fomel, Paul Sava, James Rickett, and Jon F. Claerbout&#039;&#039;: &#039;&#039;&#039;Geophysical Prospecting&#039;&#039;&#039;, 51, 409-420 (2003)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/velspec/paper_html/ Velocity continuation by spectral methods] by &#039;&#039;Sergey Fomel&#039;&#039;: &#039;&#039;&#039;SEP Report&#039;&#039;&#039;, 97, 157-172 (1998)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/specfac/paper_html/ Spectral factorization revisited] by &#039;&#039;Paul Sava and Sergey Fomel&#039;&#039;: &#039;&#039;&#039;SEP Report&#039;&#039;&#039;, 100, 227-234 (1999)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/oc2/paper_html/ Seismic reflection data interpolation with differential offset and shot continuation] by &#039;&#039;Sergey Fomel&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 68, 733-744 (2003)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/oc1/paper_html/ Theory of differential offset continuation] by &#039;&#039;Sergey Fomel&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 68, 718-732 (2003)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/vc1/paper_html/ Velocity continuation and the anatomy of residual prestack time migration] by &#039;&#039;Sergey Fomel&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 68, 1650-1661 (2003)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/fmsec/paper_html/ A second-order fast marching eikonal solver] by &#039;&#039;James Rickett and Sergey Fomel&#039;&#039;: &#039;&#039;&#039;SEP Report&#039;&#039;&#039;, 100, 287-292 (1999)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/stack/paper_html/ Asymptotic pseudounitary stacking operators] by &#039;&#039;Sergey Fomel&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 68, 1032-1042(2003)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/cdstep/paper_html/ Least-square inversion with inexact adjoints. Method of conjugate directions: A tutorial] by &#039;&#039;Sergey Fomel&#039;&#039;: &#039;&#039;&#039;SEP Report&#039;&#039;&#039;, 92, 253-365 (1996)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/fmeiko/paper_html/ A variational formulation of the fast marching eikonal solver] by &#039;&#039;Sergey Fomel&#039;&#039;: &#039;&#039;&#039;SEP Report&#039;&#039;&#039;, 95, 127-147 (1997)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/forwd/paper_html/ Forward interpolation] by &#039;&#039;Sergey Fomel&#039;&#039;: &#039;&#039;&#039;SEP Report&#039;&#039;&#039; (Ph.D. Thesis Chapter), 107 (2001) &lt;br /&gt;
* [https://ahay.org/RSF/book/sep/precon/paper_html/ Multidimensional recursive filter preconditioning in geophysical estimation problems] by &#039;&#039;Sergey Fomel and Jon Claerbout&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 68, 577-588 (2003)&lt;br /&gt;
* [https://ahay.org/RSF/book/sep/pwd/paper_html/ Applications of plane-wave destruction filters] by &#039;&#039;Sergey Fomel&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 67, 1946-1960 (2002)&lt;br /&gt;
&lt;br /&gt;
== [https://ahay.org/RSF/book/swag/ Seismic Wave Analysis Group] ==&lt;br /&gt;
* [https://ahay.org/RSF/book/swag/itime/paper_html/ Automatic traveltime picking using the instantaneous traveltime] by &#039;&#039;Christos Saragiotis, Tariq Alkhalifah, and Sergey Fomel&#039;&#039;:  &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 78, T53-T58, (2013)&lt;br /&gt;
* [https://ahay.org/RSF/book/swag/tau/paper_html/ Wavefield extrapolation in pseudodepth domain] by &#039;&#039;Xuxin Ma and Tariq Alkhalifah&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 78, S81-S91, (2013)&lt;br /&gt;
* [https://ahay.org/RSF/book/swag/thetaScan/article_html/ Traveltime approximations for transversely isotropic media with an inhomogeneous background] by &#039;&#039;Tariq Alkhalifah&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 76, WA31-WA42, (2011)&lt;br /&gt;
* [https://ahay.org/RSF/book/swag/anisogath/article_html/ Angle gathers in wave-equation imaging for transversely isotropic media] by &#039;&#039;Tariq Alkhalifah and Sergey Fomel&#039;&#039;: &#039;&#039;&#039;Geophysical Prospecting&#039;&#039;&#039;, 59, 422-431 (2011)&lt;br /&gt;
* [https://ahay.org/RSF/book/swag/eikds/paper_html/ An eikonal based formulation for traveltime perturbation with respect to the source location] by &#039;&#039;Tariq Alkhalifah and Sergey Fomel&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 75, T175-T183 (2010)&lt;br /&gt;
* [https://ahay.org/RSF/book/swag/waveds/paper_html/ Acoustic wavefield evolution as function of source location perturbation] by &#039;&#039;Tariq Alkhalifah&#039;&#039;: &#039;&#039;&#039;Geophysical Journal International&#039;&#039;&#039;, 183, 1324-1331 (2010)&lt;br /&gt;
* [https://ahay.org/RSF/book/swag/introDTI/article_html/ A transversely isotropic medium with a tilted symmetry axis normal to the reflector] by &#039;&#039;Tariq Alkhalifah and Paul Sava&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039; (Letters), 75, A19-A24 (2010)&lt;br /&gt;
&lt;br /&gt;
== [https://ahay.org/RSF/book/tccs/ Texas Consortium for Computational Seismology] ==&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/timewarp/paper_html/ Probabilistic moveout analysis by time warping] by &#039;&#039;Yanadet Sripanich, Sergey Fomel, Jeannot Trampert, William Burnett, and Thomas Hess&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, v. 85, U1–U20, (2020)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/rtseis/paper_html/ Relative time seislet transform] by &#039;&#039;Zhicheng Geng, Xinming Wu, Sergey Fomel, and Yangkang Chen&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, v. 85, V223–V232, (2020)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/pwstack/paper_html/ High-resolution recursive stacking using plane-wave construction] by &#039;&#039;Kelly Regimbal and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;SEG Expanded Abstracts&#039;&#039;&#039;, 4069-4074, (2016)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/pimicro/paper_html/ Microseismic source localization using time-domain path-integral migration] by &#039;&#039;Yunzhi Shi, Dmitrii Merzlikin, and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;SEG Expanded Abstracts&#039;&#039;&#039;, 2601-2606, (2016)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/pfwi/paper_html/ Full waveform inversion of passive seismic data for sources and velocities] by &#039;&#039;Junzhe Sun, Zhiguang Xue, Sergey Fomel, Tieyuan Zhu, and Nori Nakata&#039;&#039;, &#039;&#039;&#039;SEG Expanded Abstracts&#039;&#039;&#039;, 1405-1410, (2016)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/mistie/paper_html/ Using well-seismic mistie to update the velocity model] by &#039;&#039;Sean Bader, Sergey Fomel, and Zhiguang Xue&#039;&#039;, &#039;&#039;&#039;SEG Expanded Abstracts&#039;&#039;&#039;, 5218-5222, (2018)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/micro/paper_html/ Investigating the possibility of locating microseismic sources using distributed sensor networks] by &#039;&#039;Junzhe Sun, Tieyuan Zhu, Sergey Fomel, and Wen-Zhan Song&#039;&#039;, &#039;&#039;&#039;SEG Expanded Abstracts&#039;&#039;&#039;, 2485-2490, (2015)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/match/paper_html/ Least-squares non-stationary triangle smoothing] by &#039;&#039;Reem Alomar and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;IMAGE Expanded Abstracts&#039;&#039;&#039;, 2847-2851, (2022)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/ltftapwd/paper_html/ Estimation of timeshifts in time-lapse seismic images using spectral decomposition] by &#039;&#039;Mason Phillips and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;SEG Expanded Abstracts&#039;&#039;&#039;, 5839-5844, (2017)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/interpfault/paper_html/ Well log interpolation guided by geologic distance] by &#039;&#039;Yunzhi Shi, Xinming Wu, and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;SEG Expanded Abstracts&#039;&#039;&#039;, 1939-1944, (2017)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/beyond1d/paper_html/ Effects of lateral heterogeneity on time-domain processing parameters] by &#039;&#039;Yanadet Sripanich, Sergey Fomel, and Alexey Stovas&#039;&#039;, &#039;&#039;&#039;Geophysical Journal International&#039;&#039;&#039;, v. 219, 1181–1201, (2019)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/apwd/paper_html/ Seismic time-lapse image registration using amplitude-adjusted plane-wave destruction] by &#039;&#039;Mason Phillips and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;SEG Expanded Abstracts&#039;&#039;&#039;, 5473-5478, (2016)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/pwshape/paper_html/ Seismic data interpolation using plane-wave shaping regularization] by &#039;&#039;Ryan Swindeman and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;SEG Expanded Abstracts&#039;&#039;&#039;, 3853-3858, (2015)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/varipick/paper_html/ A variational approach for picking optimal surfaces from semblance-like panels] by &#039;&#039;Luke Decker and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, v. 87, U93-U108, (2022)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/wetm/paper_html/ Wave-equation time migration] by &#039;&#039;Sergey Fomel and Harpreet Kaur&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, v. 86, S103-S111, (2021)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/probdif/paper_html/ A probabilistic approach to seismic diffraction imaging] by &#039;&#039;Luke Decker and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;Lithosphere&#039;&#039;&#039;, v. 2021, 6650633, (2021)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/dlchan/paper_html/ Automatic channel detection using deep learning] by &#039;&#039;Nam Pham, Sergey Fomel, and Dallas Dunlap&#039;&#039;, &#039;&#039;&#039;Interpretation&#039;&#039;&#039;, v. 7, SE43-SE50, (2019)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/dtwaniso/paper_html/ Quantifying and correcting residual azimuthal anisotropic moveout in image gathers using dynamic time warping] by &#039;&#039;Luke Decker and Qunshan Zhang&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, v. 85, O71-O82, (2020)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/anisodiff/paper_html/ Least-squares diffraction imaging using shaping regularization by anisotropic smoothing] by &#039;&#039;Dmitrii Merzlikin, Sergey Fomel, and Xinming Wu&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, v. 85, S313-S325, (2020)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/drr5d/paper_html/ Simultaneous denoising and reconstruction of 5D seismic data via damped rank-reduction method] by &#039;&#039;Yangkang Chen, Dong Zhang, Zhaoyu Jin, Xiaohong Chen, Shaohuan Zu, Weilin Huang, and Shuwei Gan&#039;&#039;, &#039;&#039;&#039;Geophysical Journal International&#039;&#039;&#039;, 206, 1695-1717, (2016)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/npm/paper_html/ Data-driven time-frequency analysis of seismic data using non-stationary Prony method] by &#039;&#039;Guoning Wu, Sergey Fomel, and Yangkang Chen&#039;&#039;, &#039;&#039;&#039;Geophysical Prospecting&#039;&#039;&#039;, 66, 85-97, (2018)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/enhemd/paper_html/ Enhancing seismic reflections using empirical mode decomposition in the flattened domain] by &#039;&#039;Yangkang Chen, Guoyin Zhang, Shuwei Gan, and Chenglin Zhang&#039;&#039;, &#039;&#039;&#039;Journal of Applied Geophysics&#039;&#039;&#039;, 119, 99-105, (2015)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/pcastack/paper_html/ Application of principal component analysis in weighted stacking of seismic data] by &#039;&#039;Jianyong Xie, Wei Chen, Dong Zhang, Shaohuan Zu, and Yangkang Chen&#039;&#039;, &#039;&#039;&#039;IEEE Geoscience and Remote Sensing Letters&#039;&#039;&#039;, 14, 1213-1217, (2017)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/svscan/paper_html/ Velocity analysis of simultaneous-source data using high-resolution semblance - coping with the strong noise] by &#039;&#039;Shuwei Gan, Shoudong Wang, Yangkang Chen, Shan Qu, and Shaohuan Zu&#039;&#039;, &#039;&#039;&#039;Geophysical Journal International&#039;&#039;&#039;, 204, 768-779, (2016)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/cs/paper_html/ Compressive sensing for seismic data reconstruction via fast projection onto convex sets based on seislet transform] by &#039;&#039;Shuwei Gan, Shoudong Wang, Yangkang Chen, Xiaohong Chen, Weiling Huang, and Hanming Chen&#039;&#039;, &#039;&#039;&#039;Journal of Applied Geophysics&#039;&#039;&#039;, 130, 194-208, (2016)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/sgk/paper_html/ Fast dictionary learning for noise attenuation of multidimensional seismic data] by &#039;&#039;Yangkang Chen&#039;&#039;, &#039;&#039;&#039;Geophysical Journal International&#039;&#039;&#039;, 209, 21-31, (2017)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/sswtapp/paper_html/ Probing the subsurface karst features using time-frequency decomposition] by &#039;&#039;Yangkang Chen&#039;&#039;, &#039;&#039;&#039;Interpretation&#039;&#039;&#039;, 4, T541-T550, (2016)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/asa/paper_html/ Application of spectral decomposition using regularized non-stationary autoregression to random noise attenuation] by &#039;&#039;Wencheng Yang, Runqiu Wang, Yangkang Chen, Jian Wu, Jiang Yuan, and Shuwei Gan&#039;&#039;, &#039;&#039;&#039;Journal of Geophysics and Engineering&#039;&#039;&#039;, 12, 175-187, (2015)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/drr3d/paper_html/ An open-source Matlab code package for improved rank-reduction 3D seismic data denoising and reconstruction] by &#039;&#039;Yangkang Chen, Weilin Huang, Dong Zhang, and Wei Chen&#039;&#039;, &#039;&#039;&#039;Computers &amp;amp; Geosciences&#039;&#039;&#039;, 95, 59-66, (2016)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/strsvd/paper_html/ Structure-oriented singular value decomposition for random noise attenuation of seismic data] by &#039;&#039;Shuwei Gan, Yangkang Chen, Shaohuan Zu, Shan Qu, and Wei Zhong&#039;&#039;, &#039;&#039;&#039;Journal of Geophysics and Engineering&#039;&#039;&#039;, 12, 262-272, (2015)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/dealiase2/paper_html/ One-step slope estimation for dealiased seismic data reconstruction via iterative seislet thresholding] by &#039;&#039;Wei Liu, Siyuan Cao, Shuwei Gan, Yangkang Chen, Shaohuan Zu, and Zhaoyu Jin&#039;&#039;, &#039;&#039;&#039;IEEE Geoscience and Remote Sensing Letters&#039;&#039;&#039;, 13, 1462-1466, (2016)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/dipseis/paper_html/ Dip-separated structural filtering using seislet transform and adaptive empirical mode decomposition based dip filter] by &#039;&#039;Yangkang Chen&#039;&#039;, &#039;&#039;&#039;Geophysical Journal International&#039;&#039;&#039;, 206, 457-469, (2016)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/halfthr/paper_html/ Irregular seismic data reconstruction using a percentile-half-thresholding algorithm] by &#039;&#039;Yangkang Chen, Keling Chen, Peidong Shi, and Yanyan Wang&#039;&#039;, &#039;&#039;&#039;Journal of Geophysics and Engineering&#039;&#039;&#039;, 11, 065001, (2014)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/demulemd/paper_html/ Multiple reflections noise attenuation using adaptive randomized-order empirical mode decomposition] by &#039;&#039;Wei Chen, Jianyong Xie, Shaohuan Zu, Shuwei Gan, and Yangkang Chen&#039;&#039;, &#039;&#039;&#039;IEEE Geoscience and Remote Sensing Letters&#039;&#039;&#039;, 14, 18-22, (2017)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/dmssa/paper_html/ Damped multichannel singular spectrum analysis for 3D random noise attenuation] by &#039;&#039;Weilin Huang, Runqiu Wang, Yangkang Chen, Huijian Li, and Shuwei Gan&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 81, V261-V270, (2016)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/dealiase/paper_html/ De-aliased seismic data interpolation using seislet transform with low-frequency constraint] by &#039;&#039;Shuwei Gan, Shoudong Wang, Yangkang Chen, Yizhuo Zhang, and Zhaoyu Jin&#039;&#039;, &#039;&#039;&#039;IEEE Geoscience and Remote Sensing Letters&#039;&#039;&#039;, 12, 2150-2154, (2015)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/fraclapl/paper_html/ Viscoacoustic modeling and imaging using low-rank approximation] by &#039;&#039;Junzhe Sun, Tieyuan Zhu, and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 80, A103-A108, (2015)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/welllogs/paper_html/ Missing log data interpolation and semiautomatic seismic well ties using data matching techniques] by &#039;&#039;Sean Bader, Xinming Wu, and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;Interpretation&#039;&#039;&#039;, 7, T374-T361, (2019)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/acrossfault/paper_html/ Predictive painting across faults] by &#039;&#039;Zhiguang Xue, Xinming Wu, and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;Interpretation&#039;&#039;&#039;, 6, T449-T455, (2018)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/sparse/paper_html/ Least-squares path-summation diffraction imaging using sparsity constraints] by &#039;&#039;Dmitrii Merzlikin, Sergey Fomel, and Mrinal K. Sen&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 84, S187–S200, (2019)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/gmresq/paper_html/ Q-compensated least-squares reverse time migration using lowrank one-step wave extrapolation] by &#039;&#039;Junzhe Sun, Sergey Fomel, Tieyuan Zhu, and Jingwei Hu&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 81, S271-S279, (2016)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/eseis/paper_html/ EMD-seislet transform] by &#039;&#039;Yangkang Chen and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 83, A27-A32, (2018)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/elas/paper_html/ Recursive integral time extrapolation of elastic waves using low-rank symbol approximation] by &#039;&#039;Junzhe Sun, Sergey Fomel, Yanadet Sripanich, and Paul Fowler&#039;&#039;, &#039;&#039;&#039;Geophysical Journal International&#039;&#039;&#039;, 211, 1478-1493, (2017)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/merge/paper_html/ Matching and merging high-resolution and legacy seismic images] by &#039;&#039;Sarah Greer and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 83, V115-V122, (2018)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/t2dweak/paper_html/ Fast time-to-depth conversion and interval velocity estimation in the case of weak lateral variations] by &#039;&#039;Yanadet Sripanich and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 83, S227-S235, (2018)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/sobel/paper_html/ Plane-wave Sobel attribute for discontinuity enhancement in seismic images] by &#039;&#039;Mason Phillips and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 82, WB63-WB69, (2017)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/fwiseislet/paper_html/ Full-waveform inversion using seislet regularization] by &#039;&#039;Zhiguang Xue, Hejun Zhu, and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 82, A43-A49, (2017)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/ovc/paper_html/ Diffraction imaging and time-migration velocity analysis using oriented velocity continuation] by &#039;&#039;Luke Decker, Dmitrii Merzlikin, and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 82, U25-U35, (2017)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/pi/paper_html/ Analytical path-summation imaging of seismic diffractions] by &#039;&#039;Dmitrii Merzlikin and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 82, S51-S59, (2017)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/hyper3/paper_html/ 3D generalized nonhyperboloidal moveout approximation] by &#039;&#039;Yanadet Sripanich, Sergey Fomel, Alexey Stovas, and Qi Hao&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 82, C49-C59, (2017)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/decomp/paper_html/ Elastic wave-vector decomposition in heterogeneous anisotropic media] by &#039;&#039;Yanadet Sripanich, Sergey Fomel, Junzhe Sun, and Jiubing Cheng&#039;&#039;, &#039;&#039;&#039;Geophysical Prospecting&#039;&#039;&#039;, doi 10.1111/1365-2478.12482, (2016)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/interval/paper_html/ Theory of interval traveltime parameter estimation in layered anisotropic media] by &#039;&#039;Yanadet Sripanich and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 81, C253-C263, (2016)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/onestep/paper_html/ Lowrank one-step wave extrapolation for reverse-time migration] by &#039;&#039;Junzhe Sun, Sergey Fomel, and Lexing Ying&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 81, S39-S54, (2016)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/dsd/paper_html/  Double sparsity dictionary for seismic noise attenuation] by &#039;&#039;Yangkang Chen, Jianwei Ma, and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 81, V17-V30, (2016)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/intshape/paper_html/  Seismic data interpolation using nonlinear shaping regularization] by &#039;&#039;Yangkang Chen, Lele Zhang, and Le-wei Mo&#039;&#039;, &#039;&#039;&#039;Journal of Seismic Exploration&#039;&#039;&#039;, 24, 327-342, (2015)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/orthogroll/paper_html/  Ground-roll noise attenuation using a simple and effective approach based on local band limited orthogonalization] by &#039;&#039;Yangkang Chen, Shebao Jiao, Jianwei Ma, Hanming Chen, Yatong Zhou, and Shuwei Gan&#039;&#039;, &#039;&#039;&#039;IEEE Geoscience and Remote Sensing Letters&#039;&#039;&#039;, 12, 2316-2320, (2015)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/shemd/paper_html/ Random noise attenuation by a selective hybrid approach using f-x empirical mode decomposition] by &#039;&#039;Yangkang Chen, Shuwei Gan, Tingting Liu, Jiang Yuan, Yizhuo Zhang, and Zhaoyu Jin&#039;&#039;, &#039;&#039;&#039;Journal of Geophysics and Engineering&#039;&#039;&#039;, 12, 12-25, (2015)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/svmf/paper_html/ Deblending using a space-varying median filter] by &#039;&#039;Yangkang Chen&#039;&#039;, &#039;&#039;&#039;Exploration Geophysics&#039;&#039;&#039;, doi 10.1071/EG14051&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/group3/paper_html/ On anelliptic approximations for qP velocities in TI and orthorhombic media] by &#039;&#039;Yanadet Sripanich and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 80, C89-C105, (2015)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/dbortho/paper_html/ Iterative deblending with multiple constraints based on shaping regularization] by &#039;&#039;Yangkang Chen&#039;&#039;, &#039;&#039;&#039;IEEE Geoscience and Remote Sensing Letters&#039;&#039;&#039;, doi 10.1109/LGRS.2015.2463815&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/vscan/paper_html/ Velocity analysis using similarity-weighted semblance] by &#039;&#039;Yangkang Chen, Tingting Liu, and Xiaohong Chen&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 80, A75-A82, (2015)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/aii/paper_html/ Structure-constrained relative acoustic impedance using stratigraphic coordinates] by &#039;&#039;Parvaneh Karimi&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 80, A63-A67, (2015)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/scan3/paper_html/ A fast algorithm for 3D azimuthally anisotropic velocity scan] by &#039;&#039;Jingwei Hu, Sergey Fomel, and Lexing Ying&#039;&#039;,  &#039;&#039;&#039;Geophysical Prospecting&#039;&#039;&#039;, 63, 368-377, (2015)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/strat/paper_html/ Stratigraphic coordinates, a coordinate system tailored to seismic interpretation] by &#039;&#039;Parvaneh Karimi and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;Geophysical Prospecting&#039;&#039;&#039;, v. 63, 1246-1255, (2015) &lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/synth/paper_html/ Carbonate reservoir characterization using seismic diffraction imaging] by &#039;&#039;Luke Decker, Xavier Janson, and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;Interpretation&#039;&#039;&#039;, 3, SF21-SF30, (2015)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/ortho/paper_html/ Random noise attenuation using local signal-and-noise orthogonalization] by &#039;&#039;Yangkang Chen and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 80, WD1-WD9, (2015)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/synwav/paper_html/ Time-frequency analysis of seismic data using synchrosqueezing wavelet transform] by &#039;&#039;Yangkang Chen, Tingting Liu, Xiaohong Chen, Jingye Li, and Erying Wang&#039;&#039;, &#039;&#039;&#039;Journal of Seismic Exploration&#039;&#039;&#039;, 23, 303-312, (2014)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/nmodeblend/paper_html/ Deblending using normal moveout and median filtering in common-midpoint gathers] by &#039;&#039;Yangkang Chen, Jiang Yuan, Zhaoyu Jin, Keling Chen, and Lele Zhang&#039;&#039;, &#039;&#039;&#039;Journal of Geophysics and Engineering&#039;&#039;&#039;, 11, 045012, (2014)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/time2depth2/paper_html/ A robust approach to time-to-depth conversion and interval velocity estimation from time migration in the presence of lateral velocity variations] by &#039;&#039;Siwei Li and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;Geophysical Prospecting&#039;&#039;&#039;, 63, 315-337, (2015)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/deblend/paper_html/ Iterative deblending of simultaneous-source seismic data using seislet-domain shaping regularization] by &#039;&#039;Yangkang Chen, Sergey Fomel, and Jingwei Hu&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 79, V179-V189, (2014)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/sglowrank/paper_html/ Lowrank seismic wave extrapolation on a staggered grid] by &#039;&#039;Gang Fang, Sergey Fomel, Qizhen Du, and Jingwei Hu&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 79, T157-T168, (2014)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/emdpf/paper_html/ Random noise attenuation by f-x empirical mode decomposition predictive filtering] by &#039;&#039;Yangkang Chen and Jitao Ma&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 79, V81-V91, (2014)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/optapert/paper_html/ Selecting an optimal aperture in Kirchhoff migration using dip-angle images] by &#039;&#039;Alexander Klokov and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 78, S243-S254, (2013)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/phase/paper_html/ Local skewness attribute as a seismic phase detector] by &#039;&#039;Sergey Fomel and Mirko van der Baan&#039;&#039;, &#039;&#039;&#039;Interpretation&#039;&#039;&#039;, 2, SA49-SA56, (2014)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/uncert/paper_html/ Structural uncertainty of time-migrated seismic images] by &#039;&#039;Sergey Fomel and Evgeny Landa&#039;&#039;, &#039;&#039;&#039;Journal of Applied Geophysics&#039;&#039;&#039;, 101, 27–30, (2014)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/psp/paper_html/ A parallel sweeping preconditioner for heterogeneous 3D Helmholtz equations] by &#039;&#039;Jack Poulson, Björn Engquist, Siwei Li, and Lexing Ying&#039;&#039;, &#039;&#039;&#039;SIAM Journal on Scientific Computing&#039;&#039;&#039;, 35, C194-C212, (2013)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/dsrtomo/paper_html/ First-break traveltime tomography with the double-square-root eikonal equation] by &#039;&#039;Siwei Li, Alexander Vladimirsky, and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 78, U89-U101, (2013)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/nar/paper_html/ Seismic data decomposition into spectral components using regularized nonstationary autoregression] by &#039;&#039;Sergey Fomel&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 78, O69-O76, (2013)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/specrecom/paper_html/ Automated spectral recomposition with application in stratigraphic interpretation] by &#039;&#039;Yihua Cai, Sergey Fomel, and Hongliu Zeng&#039;&#039;, &#039;&#039;&#039;Interpretation&#039;&#039;&#039;, 1, SA109-SA116, (2013)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/opwd/paper_html/ Omnidirectional plane-wave destruction] by &#039;&#039;Zhonghuan Chen, Sergey Fomel, and Wenkai Lu&#039;&#039;,  &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 78, V171-V179, (2013)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/butterfly/paper_html/ A fast butterfly algorithm for generalized Radon transforms] by &#039;&#039;Jingwei Hu, Sergey Fomel, Laurent Demane, and Lexing Ying&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 78, U41-U51, (2013)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/orthorhombic/paper_html/ Modeling of pseudo-acoustic P-waves in orthorhombic media with a lowrank approximation] by &#039;&#039;Xiaolei Song and Tariq Alkhalifah&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 78, C33-C40, (2013)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/eikods/paper_html/ Kirchhoff migration using eikonal-based computation of traveltime source-derivatives] by &#039;&#039;Siwei Li and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 78, S211-S219, (2013)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/lfd/paper_html/ Lowrank finite-differences and lowrank Fourier finite-differences for seismic wave extrapolation in the acoustic approximation] by &#039;&#039;Xiaolei Song, Sergey Fomel, and Lexing Ying&#039;&#039;, &#039;&#039;&#039;Geophysical Journal International&#039;&#039;&#039;, 193, 960-969, (2013)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/fpwd/paper_html/ Accelerated plane-wave destruction] by &#039;&#039;Zhonghuan Chen, Sergey Fomel, and Wenkai Lu&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 78, V1-V9, (2013)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/crs/paper_html/ Non-hyperbolic common reflection surface] by &#039;&#039;Sergey Fomel and Roman Kazinnik&#039;&#039;, &#039;&#039;&#039;Geophysical Prospecting&#039;&#039;&#039;, 61, 21-27, (2013) &lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/lowrank/paper_html/ Seismic wave extrapolation using lowrank symbol approximation] by &#039;&#039;Sergey Fomel, Lexing Ying, and Xiaolei Song&#039;&#039;, &#039;&#039;&#039;Geophysical Prospecting&#039;&#039;&#039;, 61, 526–536, (2013)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/ltft/paper_html/ Seismic data analysis using local time-frequency decomposition] by &#039;&#039;Yang Liu and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;Geophysical Prospecting&#039;&#039;&#039;, 61, 516–525, (2013)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/timefreq/paper_html/ Time-frequency analysis of seismic data using local attributes] by &#039;&#039;Guochang Liu, Sergey Fomel, and Xiaohong Chen&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 76, P23-P34, (2011)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/apefint/paper_html/ Seismic data interpolation beyond aliasing using regularized nonstationary autoregression] by &#039;&#039;Yang Liu and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 76, V69-V77, (2011)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/ffd/paper_html/ Fourier finite-difference wave propagation] by &#039;&#039;Xiaolei Song and Sergey Fomel&#039;&#039;, &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 76, T123-T129, (2011)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/reversible/paper_html/ A reversible transform for seismic data processing] by &#039;&#039;William Burnett and Robert Ferguson&#039;&#039;, &#039;&#039;&#039;Journal of Geophysics and Engineering&#039;&#039;&#039;, 8, 477-486, (2011)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/vc3/paper_html/ Azimuthally anisotropic 3D velocity continuation] by &#039;&#039;William Burnett and Sergey Fomel&#039;&#039;: &#039;&#039;&#039;International Journal of Geophysics&#039;&#039;&#039;, Article ID 484653, (2011)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/agath/paper_html/ Theory of 3-D angle gathers in wave-equation seismic imaging] by &#039;&#039;Sergey Fomel&#039;&#039;: &#039;&#039;&#039;Journal of Petroleum Exploration and Production Technology&#039;&#039;&#039;, 1, 11-16, (2011)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/oc3/paper_html/ OC-seislet: seislet transform construction with differential offset continuation] by &#039;&#039;Yang Liu and Sergey Fomel&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 75, WB235-WB245, (2010)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/stackadcig/paper_html/ Stacking angle-domain common-image gathers for normalization of illumination] by &#039;&#039;Guochang Liu, Sergey Fomel, and Xiaohong Chen&#039;&#039;: &#039;&#039;&#039;Geophysical Prospecting&#039;&#039;&#039;, 59, 244-255, (2011)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/flat/paper_html/ Predictive painting of 3-D seismic volumes] by &#039;&#039;Sergey Fomel&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 75, no. 4, A25-A30, (2010)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/seislet/paper_html/ Seislet transform and seislet frame] by &#039;&#039;Sergey Fomel and Yang Liu&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 75, no. 3, V25-V38, (2010)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/hyper/paper_html/ Generalized nonhyperbolic moveout approximation] by &#039;&#039;Sergey Fomel and Alexey Stovas&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 75, no. 2, U9-U18, (2010)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/strfilter/paper_html/ Nonlinear structure-enhancing filtering using plane-wave prediction] by &#039;&#039;Yang Liu, Sergey Fomel, and Guochang Liu&#039;&#039;: &#039;&#039;&#039;Geophysical Prospecting&#039;&#039;&#039;, 58, 415-427, (2010)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/nmo3/paper_html/ 3D velocity-independent elliptically-anisotropic moveout correction] by &#039;&#039;William Burnett and Sergey Fomel&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 74, no. 5, WB129-WB136, (2009)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/simistack/paper_html/ Stacking seismic data using local correlation] by &#039;&#039;Guochang Liu, Sergey Fomel, Long Jin, and Xiaohong Chen&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 74, no. 3, V43-V48, (2009)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/atten/paper_html/ Fractal heterogeneities in sonic logs and low-frequency scattering attenuation] by &#039;&#039;Thomas J. Browaeys and Sergey Fomel&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 74, no. 2, WA77-WA92, (2009)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/timelapse/paper_html/ Time-lapse image registration using the local similarity attribute] by &#039;&#039;Sergey Fomel and Long Jin&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 74, no. 2, A7-A11, (2009)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/medianfilter/paper_html/ A 1-D time-varying median filter for seismic random, spike-like noise elimination] by &#039;&#039;Yang Liu, Cai Liu, and Dian Wang&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 74, V17-V24, (2009)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/lpf/paper_html/ Adaptive multiple subtraction using regularized nonstationary regression] by &#039;&#039;Sergey Fomel&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 74, no. 1, V25-V33, (2009)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/time2depth/paper_html/ Time-to-depth conversion and seismic velocity estimation using time-migration velocity] by &#039;&#039;Maria Cameron, Sergey Fomel, and James Sethian&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 73, no. 5, VE205-VE210, (2008)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/avo/paper_html/ Velocity analysis using &amp;lt;i&amp;gt;AB&amp;lt;/i&amp;gt; semblance] by &#039;&#039;Sergey Fomel&#039;&#039;: &#039;&#039;&#039;Geophysical Prospecting&#039;&#039;&#039;, v. 57, 311-321 (2009)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/diffr/paper_html/ Post-stack velocity analysis by separation and imaging of seismic diffractions] by &#039;&#039;Sergey Fomel, Evgeny Landa, and M. Turhan Taner&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 72,  U89-U94, (2007)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/pmig/paper_html/ Velocity-independent time-domain seismic imaging using local event slopes] by &#039;&#039;Sergey Fomel&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 72, no. 3, S139-S147, (2007)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/attr/paper_html/ Local seismic attributes] by &#039;&#039;Sergey Fomel&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 72, no. 3, A29-A33, (2007)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/shape/paper_html/ Shaping regularization in geophysical estimation problems] by &#039;&#039;Sergey Fomel&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 72 , no. 2, R29-R36, (2007)&lt;br /&gt;
* [https://ahay.org/RSF/book/tccs/group/paper_html/ On anelliptic approximations for &amp;lt;i&amp;gt;qP&amp;lt;/i&amp;gt; velocities in transversally isotropic media] by &#039;&#039;Sergey Fomel&#039;&#039;: &#039;&#039;&#039;Geophysical Prospecting&#039;&#039;&#039;, v. 52, 247-259 (2004)&lt;br /&gt;
&lt;br /&gt;
== [https://ahay.org/RSF/book/tongji/ Tongji University] ==&lt;br /&gt;
* [https://ahay.org/RSF/book/tongji/decoupledpropagation/paper_html/ Simulating propagation of decoupled elastic waves using low-rank approximate mixed-domain integral operators for anisotropic media] by &#039;&#039;Jiubing Cheng, Tariq Alkhalifah, Zedong Wu, Peng Zou, and Chenlong Wang&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 81, T63-T77, (2016)&lt;br /&gt;
* [https://ahay.org/RSF/book/tongji/qswave/paper_html/ Simulating propagation of separated wave modes in general anisotropic media, Part II: qS-wave propagators] by &#039;&#039;Jiubing Cheng and Wei Kang&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 81, C39-C52, (2016)&lt;br /&gt;
* [https://ahay.org/RSF/book/tongji/qpwave/paper_html/ Simulating propagation of separated wave modes in general anisotropic media, Part I: qP-wave propagators] by &#039;&#039;Jiubing Cheng and Wei Kang&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 79, C1-C18, (2014)&lt;br /&gt;
* [https://ahay.org/RSF/book/tongji/lrmode/paper_html/ Fast algorithms for elastic-wave-mode separation and vector decomposition using low-rank approximation for anisotropic media] by &#039;&#039;Jiubing Cheng and Sergey Fomel&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 79, C97-C110, (2014)&lt;br /&gt;
&lt;br /&gt;
== [https://ahay.org/RSF/book/trip/ The Rice Inversion Project] ==&lt;br /&gt;
* [https://ahay.org/RSF/book/trip/asg/paper_html/ Acoustic staggered grid modeling in IWAVE] by &#039;&#039;William W. Symes&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/trip/struct/paper_html/ IWAVE structure and basic use cases] by &#039;&#039;William W. Symes&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== [https://ahay.org/RSF/book/uh/ University of Houston] ==&lt;br /&gt;
* [https://ahay.org/RSF/book/uh/avostack/paper_html/ Weighted stacking of seismic AVO data using hybrid AB semblance and local similarity] by &#039;&#039;Pan Deng, Yangkang Chen, Yu Zhang, and Hua-Wei Zhou&#039;&#039;: &#039;&#039;&#039;Journal of Geophysics and Engineering&#039;&#039;&#039;, 13, 152-163, (2016)&lt;br /&gt;
&lt;br /&gt;
== [https://ahay.org/RSF/book/uwa/ University of Western Australia] ==&lt;br /&gt;
* [https://ahay.org/RSF/book/uwa/geo2013ElasticModellingGPU/paper_html/ Solving 3D anisotropic elastic wave equations on parallel GPU devices] by &#039;&#039;Robin M. Weiss and Jeffrey Shragge&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 78, F7-F15, (2013)&lt;br /&gt;
&lt;br /&gt;
== [https://ahay.org/RSF/book/xjtu/ Xi&#039;an Jiaotong University] ==&lt;br /&gt;
* [https://ahay.org/RSF/book/xjtu/mcaseislet/paper_html/paper.html Seislet-based morphological component analysis using scale-dependent exponential shrinkage] by &#039;&#039;Pengliang Yang and Sergey Fomel&#039;&#039;: &#039;&#039;&#039;Journal of Applied Geophysics&#039;&#039;&#039;, doi : 10.1016/j.jappgeo.2015.04.003, (2015)&lt;br /&gt;
* [https://ahay.org/RSF/book/xjtu/gpufwi/paper_html/ A graphics processing unit implementation of time-domain full-waveform inversion] by &#039;&#039;Pengliang Yang, Jinghuai Gao, and Baoli Wang&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 80, F31-F39, (2015)&lt;br /&gt;
* [https://ahay.org/RSF/book/xjtu/primer/paper_html/ A numerical tour of wave propagation] by &#039;&#039;Pengliang Yang&#039;&#039;&lt;br /&gt;
* [https://ahay.org/RSF/book/xjtu/gpurtm/paper_html/ RTM using effective boundary saving: A staggered grid GPU implementation] by &#039;&#039;Pengliang Yang, Jinghuai Gao, and Baoli Wang&#039;&#039;: &#039;&#039;&#039;Computers &amp;amp; Geosciences&#039;&#039;&#039;, 68, 64-72, (2014)&lt;br /&gt;
&lt;br /&gt;
== [https://ahay.org/RSF/book/zju/ Zhejiang University] ==&lt;br /&gt;
* [https://ahay.org/RSF/book/zju/dtv/paper_html/ Full waveform inversion and joint migration inversion with an automatic directional total variation constraint] by &#039;&#039;Shan Qu, Eric Verschuur, and Yangkang Chen&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 84, no.2, R175-R183, (2019)&lt;br /&gt;
* [https://ahay.org/RSF/book/zju/odrr5d/paper_html/ Five-dimensional seismic data reconstruction using the optimally damped rank-reduction method] by &#039;&#039;Yangkang Chen, Min Bai, Zhe Guan, Qingchen Zhang, Mi Zhang, and Hang Wang&#039;&#039;: &#039;&#039;&#039;Geophysical Journal International&#039;&#039;&#039;, 222, 1824-1845, (2020)&lt;br /&gt;
* [https://ahay.org/RSF/book/zju/odrr3d/paper_html/ Seismic signal enhancement based on the lowrank methods] by &#039;&#039;Min Bai, Guangtan Huang, Hang Wang, and Yangkang Chen&#039;&#039;: &#039;&#039;&#039;Geophysical Prospecting&#039;&#039;&#039;, 68, 2783-2807, (2020)&lt;br /&gt;
* [https://ahay.org/RSF/book/zju/diffrlrra/paper_html/ Separation and imaging of seismic diffractions using a localized rank-reduction method with adaptively selected ranks] by &#039;&#039;Hang Wang, Xingye Liu, and Yangkang Chen&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 85, V497-V506, (2020)&lt;br /&gt;
* [https://ahay.org/RSF/book/zju/qrtm/paper_html/ CuQ-RTM: A CUDA-based code package for stable and efficient Q-compensated reverse time migration] by &#039;&#039;Yufeng Wang, Hui Zhou, Xuebin Zhao, Qingchen Zhang, Poru Zhao, Xiance Yu, and Yangkang Chen&#039;&#039;: &#039;&#039;&#039;Geophysics&#039;&#039;&#039;, 84, F1-F15, (2019)&lt;br /&gt;
* [https://ahay.org/RSF/book/zju/optnoise/paper_html/ Plane-wave orthogonal polynomial transform for amplitude-preserving noise attenuation] by &#039;&#039;Yangkang Chen, Weilin Huang, Yatong Zhou, Wei Liu, and Dong Zhang&#039;&#039;: &#039;&#039;&#039;Geophysical Journal International&#039;&#039;&#039;, 214, 1214-1232, (2018)&lt;br /&gt;
* [https://ahay.org/RSF/book/zju/sosvmf/paper_html/ Deblending of simultaneous-source data using a structure-oriented space-varying median filter] by &#039;&#039;Yangkang Chen, Shaohuan Zu, Yufeng Wang, and Xiaohong Chen&#039;&#039;: &#039;&#039;&#039;Geophysical Journal International&#039;&#039;&#039;, 216, 1214-1232, (2019)&lt;br /&gt;
* [https://ahay.org/RSF/book/zju/q/paper_html/ Multi-channel quality factor Q estimation] by &#039;&#039;Yangkang Chen&#039;&#039;: &#039;&#039;&#039;Geophysical Journal International&#039;&#039;&#039;, 218, 655-665, (2019)&lt;/div&gt;</summary>
		<author><name>Fomels</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Installation&amp;diff=4274</id>
		<title>Installation</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Installation&amp;diff=4274"/>
		<updated>2024-10-15T21:58:47Z</updated>

		<summary type="html">&lt;p&gt;Fomels: /* Prerequisites */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_4727725_XS.jpg|right|]]&lt;br /&gt;
Madagascar has been installed and is periodically tested on different platforms&lt;br /&gt;
*Linux distributions (Fedora, RedHat, Ubuntu, etc.) &lt;br /&gt;
*MacOS X &lt;br /&gt;
*Windows under the [http://www.cygwin.com/ Cygwin] environment.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Precompiled binary packages==&lt;br /&gt;
&lt;br /&gt;
See the [[Download|Madagascar download page]] for the availability of binary packages.&lt;br /&gt;
&lt;br /&gt;
==Installation from source==&lt;br /&gt;
&lt;br /&gt;
===Platform-specific instructions===&lt;br /&gt;
&lt;br /&gt;
[[Windows|Specific instructions are provided]] for &#039;&#039;&#039;Windows&#039;&#039;&#039; users.&lt;br /&gt;
&lt;br /&gt;
Please consult the [[Advanced Installation#Platform-specific_installation_advice|Advanced Installation]] guide for other platform-specific instructions.&lt;br /&gt;
&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
  &lt;br /&gt;
#C compiler. Any ANSI-compliant compiler such as [http://gcc.gnu.org/ GCC] should work. GCC usually comes pre-installed on Linux machines. &lt;br /&gt;
#Python interpreter. [http://www.python.org/ Python] is an interpretable programming language. It is used in Madagascar installation scripts and project management scripts. Python comes pre-installed on some platforms. Madagascar supports Python 3.&lt;br /&gt;
&lt;br /&gt;
Each API option has [[Advanced Installation#Dependencies|its own prerequisites]].&lt;br /&gt;
&lt;br /&gt;
Prerequisites for optional add-on functionality are [[Advanced Installation#Platform specific installation advice|platform-specific]]. &lt;br /&gt;
&lt;br /&gt;
[[Windows|Building under cygwin on Windows]] requires several preparatory steps.&lt;br /&gt;
&lt;br /&gt;
===General instructions===&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Configuration:&#039;&#039;&#039; Open a terminal window, change to the top Madagascar source directory, and run &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;./configure --prefix=/directory/where/you/want/madagascar/installed&amp;lt;/syntaxhighlight&amp;gt; You can examine the &amp;lt;tt&amp;gt;config.py&amp;lt;/tt&amp;gt; file that this command generates. Additional options are available. You can obtain a full list of customizable variables by running &amp;lt;tt&amp;gt;scons -h&amp;lt;/tt&amp;gt;. For example, to install Fortran-90 API bindings in addition to the basic package, run &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;./configure API=f90 --prefix=/directory/where/you/want/madagascar/installed&amp;lt;/syntaxhighlight&amp;gt; After running &amp;lt;tt&amp;gt;./configure&amp;lt;/tt&amp;gt; you may see a list of dependencies that your system does not have installed (the items that have &amp;quot;no&amp;quot; next to them). Most of them are optional. If you decide to install additional packages for your platform, rerun the &amp;lt;tt&amp;gt;./configure&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
# &#039;&#039;&#039;Building and installing the package:&#039;&#039;&#039; Run &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;make install&amp;lt;/syntaxhighlight&amp;gt; If you need &amp;quot;root&amp;quot; privileges for installing under &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT&amp;lt;/tt&amp;gt;, you may need to run &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;make; su; make install&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;make; sudo make install&amp;lt;/syntaxhighlight&amp;gt; If &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt; does not exist on your system, an alternative procedure can be found in the [[#Troubleshooting|Troubleshooting]] section. &lt;br /&gt;
# &#039;&#039;&#039;User setup:&#039;&#039;&#039; If your shell is &amp;lt;tt&amp;gt;sh&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, add to your &amp;lt;tt&amp;gt;$HOME/.bashrc&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;$HOME/.profile&amp;lt;/tt&amp;gt; files the line &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;source ~/RSFSRC/share/madagascar/etc/env.sh&amp;lt;/syntaxhighlight&amp;gt; (if used something different in the &amp;lt;tt&amp;gt;--prefix&amp;lt;/tt&amp;gt; option to &amp;lt;tt&amp;gt;./configure&amp;lt;/tt&amp;gt;, use that instead of ~/RSFSRC). If your shell is &amp;lt;tt&amp;gt;(t)csh&amp;lt;/tt&amp;gt;, add to your &amp;lt;tt&amp;gt;$HOME/.cshrc&amp;lt;/tt&amp;gt; file the line &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;source ~/RSFSRC/share/madagascar/etc/env.csh&amp;lt;/syntaxhighlight&amp;gt; (if used something different in the &amp;lt;tt&amp;gt;--prefix&amp;lt;/tt&amp;gt; option to &amp;lt;tt&amp;gt;./configure&amp;lt;/tt&amp;gt;, use that instead of ~/RSFSRC.) Please be aware that, on some systems, the default value for DATAPATH set in the script above may get automatically cleaned at some intervals, so if you want to keep your data binaries for a long time, set &amp;lt;tt&amp;gt;DATAPATH&amp;lt;/tt&amp;gt; in your resource file to another location where you have write access and that allows large files. Remember that the value of DATAPATH should have a slash at the end. e.g. add &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;export DATAPATH=~/RSFDATA/ &amp;lt;/syntaxhighlight&amp;gt; to ~/.bashrc and ~/.profile .&lt;br /&gt;
&lt;br /&gt;
==Uninstall==&lt;br /&gt;
To clean all intermediate files and all installed files, run &amp;lt;pre&amp;gt;scons -c install&amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;make distclean&amp;lt;/pre&amp;gt; in the source code directory.&lt;br /&gt;
&lt;br /&gt;
==Troubleshooting==&lt;br /&gt;
===Alternative build/install procedure===&lt;br /&gt;
# &#039;&#039;&#039;Set the environment variables:&#039;&#039;&#039; If your shell is &amp;lt;tt&amp;gt;sh&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, type &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;source env.sh&amp;lt;/syntaxhighlight&amp;gt; Else, if your shell is &amp;lt;tt&amp;gt;csh&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;tcsh&amp;lt;/tt&amp;gt;, type &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;source env.csh&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# &#039;&#039;&#039;Build:&#039;&#039;&#039; Type &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;&lt;br /&gt;
# &#039;&#039;&#039;Install:&#039;&#039;&#039;  Run &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; . If you need &amp;quot;root&amp;quot; privileges for installing under &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT&amp;lt;/tt&amp;gt;, you may need to run &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;su; scons install &amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;sudo scons install&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Other issues===&lt;br /&gt;
Note that &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt; does not inherit your environmental variables including &amp;lt;tt&amp;gt;PATH&amp;lt;/tt&amp;gt;. &lt;br /&gt;
If the configuration part ends with the message like&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
checking if cc works ... failed&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
the problem may be that your compiler is in an unusual place. Try&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./configure CC=/full/path/to/cc&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./configure CC=`which cc`&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On Windows under SFU, use the &amp;lt;tt&amp;gt;gcc&amp;lt;/tt&amp;gt; compiler&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./configure CC=/opt/gcc.3.3/bin/gcc&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please consult the [[Advanced Installation]] guide for more information.&lt;br /&gt;
&lt;br /&gt;
==Testing and quick start==&lt;br /&gt;
&lt;br /&gt;
Here are a few simple tests and a brief introduction to Madagascar:&lt;br /&gt;
&lt;br /&gt;
Typing any Madagascar command in a terminal window without parameters should generate brief documentation. Try one of the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfin&lt;br /&gt;
sfattr&lt;br /&gt;
sfspike&lt;br /&gt;
sfbandpass&lt;br /&gt;
sfwiggle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you get an error like &amp;quot;Command not found,&amp;quot; you may not have your &amp;lt;tt&amp;gt;&amp;amp;#36;PATH&amp;lt;/tt&amp;gt; environment variable set correctly, or you may need to issue the &amp;lt;tt&amp;gt;rehash&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
Now try making a simple Madagascar data file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfspike n1=1000 k1=300 &amp;gt; spike.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command generates a one-dimensional list of 1000 numbers, all zero except for a spike equal to one at position 300. If this generates an error like&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Cannot write to data file /path/spike.rsf@: Bad file descriptor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you may need to create the directory pointed to by your &amp;lt;tt&amp;gt;&amp;amp;#36;DATAPATH&amp;lt;/tt&amp;gt; environment variable.&lt;br /&gt;
&lt;br /&gt;
The file &amp;lt;tt&amp;gt;spike.rsf&amp;lt;/tt&amp;gt; is a text header. The actual data are stored in the binary file pointed to by the &amp;lt;tt&amp;gt;in=&amp;lt;/tt&amp;gt; parameter in the header.  You can look at the header file directly with &amp;lt;tt&amp;gt;more&amp;lt;/tt&amp;gt;, or better, examine the file properties with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfin spike.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can learn more about the contents of &amp;lt;tt&amp;gt;spike.rsf&amp;lt;/tt&amp;gt; with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfattr &amp;lt; spike.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following command applies a bandpass filter to &amp;lt;tt&amp;gt;spike.rsf&amp;lt;/tt&amp;gt; and puts the result in &amp;lt;tt&amp;gt;filter.rsf&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfbandpass fhi=2 phase=y &amp;lt; spike.rsf &amp;gt; filter.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following command makes a graphics file from &amp;lt;tt&amp;gt;filter.rsf&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfwiggle clip=0.02 title=&amp;quot;Welcome to Madagascar&amp;quot; &amp;lt; filter.rsf &amp;gt; filter.vpl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have an X11 display program running, and your &amp;lt;tt&amp;gt;&amp;amp;#36;DISPLAY&amp;lt;/tt&amp;gt; environment variable is set correctly, you can display the graphics file with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfpen &amp;lt; filter.vpl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can pipe Madagascar commands together and do the whole thing at once like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfspike n1=1000 k1=300 | sfbandpass fhi=2 phase=y | \&lt;br /&gt;
sfwiggle clip=0.02 title=&amp;quot;Welcome to Madagascar&amp;quot; | sfpen&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have SCons installed, you can use it to automate Madagascar processing. Here is a simple &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file to make &amp;lt;tt&amp;gt;filter.rsf&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;filter.vpl&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Setting up&lt;br /&gt;
#&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# Make filter.rsf&lt;br /&gt;
#&lt;br /&gt;
Flow(&#039;filter&#039;,None,&#039;spike n1=1000 k1=300 | bandpass fhi=2 phase=y&#039;)&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# Make filter.vpl&lt;br /&gt;
#&lt;br /&gt;
Result(&#039;filter&#039;,&#039;wiggle clip=0.02 title=&amp;quot;Welcome to Madagascar&amp;quot;&#039;)&lt;br /&gt;
&lt;br /&gt;
End()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put the file in an empty directory, give it the name &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;cd&amp;lt;/tt&amp;gt; to that directory, and issue the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scons&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The graphics file is now stored in the &amp;lt;tt&amp;gt;Fig&amp;lt;/tt&amp;gt; subdirectory. You can view it manually with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfpen Fig/filter.vpl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
... or you can use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scons view&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When a SConstruct file makes more than one graphics file, the  &amp;lt;tt&amp;gt;scons view&amp;lt;/tt&amp;gt; command will display all of them in sequence. &lt;br /&gt;
[[Image:filter.png|frame|center|Welcome to Madagascar.]]&lt;br /&gt;
Now edit the &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file: change the title string on the &amp;lt;tt&amp;gt;Result&amp;lt;/tt&amp;gt; line to &amp;quot;Hello World!&amp;quot;, save the file, and rerun the scons command. You will see that scons has figured out that the file &amp;lt;tt&amp;gt;filter.rsf&amp;lt;/tt&amp;gt; does not need to be rebuilt because nothing that affects it has changed. Only the file &amp;lt;tt&amp;gt;filter.vpl&amp;lt;/tt&amp;gt; is rebuilt.&lt;/div&gt;</summary>
		<author><name>Fomels</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Installation&amp;diff=4273</id>
		<title>Installation</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Installation&amp;diff=4273"/>
		<updated>2024-10-15T21:58:07Z</updated>

		<summary type="html">&lt;p&gt;Fomels: typos&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_4727725_XS.jpg|right|]]&lt;br /&gt;
Madagascar has been installed and is periodically tested on different platforms&lt;br /&gt;
*Linux distributions (Fedora, RedHat, Ubuntu, etc.) &lt;br /&gt;
*MacOS X &lt;br /&gt;
*Windows under the [http://www.cygwin.com/ Cygwin] environment.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Precompiled binary packages==&lt;br /&gt;
&lt;br /&gt;
See the [[Download|Madagascar download page]] for the availability of binary packages.&lt;br /&gt;
&lt;br /&gt;
==Installation from source==&lt;br /&gt;
&lt;br /&gt;
===Platform-specific instructions===&lt;br /&gt;
&lt;br /&gt;
[[Windows|Specific instructions are provided]] for &#039;&#039;&#039;Windows&#039;&#039;&#039; users.&lt;br /&gt;
&lt;br /&gt;
Please consult the [[Advanced Installation#Platform-specific_installation_advice|Advanced Installation]] guide for other platform-specific instructions.&lt;br /&gt;
&lt;br /&gt;
===Prerequisites===&lt;br /&gt;
  &lt;br /&gt;
#C compiler. Any ANSI-compliant compiler such as [http://gcc.gnu.org/ GCC] should work. GCC usually comes pre-installed on Linux machines. &lt;br /&gt;
#Python interpreter. [http://www.python.org/ Python] is an interpretable programming language. It is used in Madagascar installation scripts and project management scripts. Python comes pre-installed on some platforms. Madagascar supports both Python 2.7 and Python 3.&lt;br /&gt;
&lt;br /&gt;
Each API option has [[Advanced Installation#Dependencies|its own prerequisites]].&lt;br /&gt;
&lt;br /&gt;
Prerequisites for optional add-on functionality are [[Advanced Installation#Platform specific installation advice|platform-specific]]. &lt;br /&gt;
&lt;br /&gt;
[[Windows|Building under cygwin on Windows]] requires several preparatory steps.&lt;br /&gt;
&lt;br /&gt;
===General instructions===&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Configuration:&#039;&#039;&#039; Open a terminal window, change to the top Madagascar source directory, and run &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;./configure --prefix=/directory/where/you/want/madagascar/installed&amp;lt;/syntaxhighlight&amp;gt; You can examine the &amp;lt;tt&amp;gt;config.py&amp;lt;/tt&amp;gt; file that this command generates. Additional options are available. You can obtain a full list of customizable variables by running &amp;lt;tt&amp;gt;scons -h&amp;lt;/tt&amp;gt;. For example, to install Fortran-90 API bindings in addition to the basic package, run &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;./configure API=f90 --prefix=/directory/where/you/want/madagascar/installed&amp;lt;/syntaxhighlight&amp;gt; After running &amp;lt;tt&amp;gt;./configure&amp;lt;/tt&amp;gt; you may see a list of dependencies that your system does not have installed (the items that have &amp;quot;no&amp;quot; next to them). Most of them are optional. If you decide to install additional packages for your platform, rerun the &amp;lt;tt&amp;gt;./configure&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
# &#039;&#039;&#039;Building and installing the package:&#039;&#039;&#039; Run &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;make install&amp;lt;/syntaxhighlight&amp;gt; If you need &amp;quot;root&amp;quot; privileges for installing under &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT&amp;lt;/tt&amp;gt;, you may need to run &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;make; su; make install&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;make; sudo make install&amp;lt;/syntaxhighlight&amp;gt; If &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt; does not exist on your system, an alternative procedure can be found in the [[#Troubleshooting|Troubleshooting]] section. &lt;br /&gt;
# &#039;&#039;&#039;User setup:&#039;&#039;&#039; If your shell is &amp;lt;tt&amp;gt;sh&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, add to your &amp;lt;tt&amp;gt;$HOME/.bashrc&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;$HOME/.profile&amp;lt;/tt&amp;gt; files the line &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;source ~/RSFSRC/share/madagascar/etc/env.sh&amp;lt;/syntaxhighlight&amp;gt; (if used something different in the &amp;lt;tt&amp;gt;--prefix&amp;lt;/tt&amp;gt; option to &amp;lt;tt&amp;gt;./configure&amp;lt;/tt&amp;gt;, use that instead of ~/RSFSRC). If your shell is &amp;lt;tt&amp;gt;(t)csh&amp;lt;/tt&amp;gt;, add to your &amp;lt;tt&amp;gt;$HOME/.cshrc&amp;lt;/tt&amp;gt; file the line &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;source ~/RSFSRC/share/madagascar/etc/env.csh&amp;lt;/syntaxhighlight&amp;gt; (if used something different in the &amp;lt;tt&amp;gt;--prefix&amp;lt;/tt&amp;gt; option to &amp;lt;tt&amp;gt;./configure&amp;lt;/tt&amp;gt;, use that instead of ~/RSFSRC.) Please be aware that, on some systems, the default value for DATAPATH set in the script above may get automatically cleaned at some intervals, so if you want to keep your data binaries for a long time, set &amp;lt;tt&amp;gt;DATAPATH&amp;lt;/tt&amp;gt; in your resource file to another location where you have write access and that allows large files. Remember that the value of DATAPATH should have a slash at the end. e.g. add &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;export DATAPATH=~/RSFDATA/ &amp;lt;/syntaxhighlight&amp;gt; to ~/.bashrc and ~/.profile .&lt;br /&gt;
&lt;br /&gt;
==Uninstall==&lt;br /&gt;
To clean all intermediate files and all installed files, run &amp;lt;pre&amp;gt;scons -c install&amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;make distclean&amp;lt;/pre&amp;gt; in the source code directory.&lt;br /&gt;
&lt;br /&gt;
==Troubleshooting==&lt;br /&gt;
===Alternative build/install procedure===&lt;br /&gt;
# &#039;&#039;&#039;Set the environment variables:&#039;&#039;&#039; If your shell is &amp;lt;tt&amp;gt;sh&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, type &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;source env.sh&amp;lt;/syntaxhighlight&amp;gt; Else, if your shell is &amp;lt;tt&amp;gt;csh&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;tcsh&amp;lt;/tt&amp;gt;, type &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;source env.csh&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# &#039;&#039;&#039;Build:&#039;&#039;&#039; Type &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;&lt;br /&gt;
# &#039;&#039;&#039;Install:&#039;&#039;&#039;  Run &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; . If you need &amp;quot;root&amp;quot; privileges for installing under &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT&amp;lt;/tt&amp;gt;, you may need to run &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;su; scons install &amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;sudo scons install&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Other issues===&lt;br /&gt;
Note that &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt; does not inherit your environmental variables including &amp;lt;tt&amp;gt;PATH&amp;lt;/tt&amp;gt;. &lt;br /&gt;
If the configuration part ends with the message like&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
checking if cc works ... failed&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
the problem may be that your compiler is in an unusual place. Try&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./configure CC=/full/path/to/cc&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./configure CC=`which cc`&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On Windows under SFU, use the &amp;lt;tt&amp;gt;gcc&amp;lt;/tt&amp;gt; compiler&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./configure CC=/opt/gcc.3.3/bin/gcc&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please consult the [[Advanced Installation]] guide for more information.&lt;br /&gt;
&lt;br /&gt;
==Testing and quick start==&lt;br /&gt;
&lt;br /&gt;
Here are a few simple tests and a brief introduction to Madagascar:&lt;br /&gt;
&lt;br /&gt;
Typing any Madagascar command in a terminal window without parameters should generate brief documentation. Try one of the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfin&lt;br /&gt;
sfattr&lt;br /&gt;
sfspike&lt;br /&gt;
sfbandpass&lt;br /&gt;
sfwiggle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you get an error like &amp;quot;Command not found,&amp;quot; you may not have your &amp;lt;tt&amp;gt;&amp;amp;#36;PATH&amp;lt;/tt&amp;gt; environment variable set correctly, or you may need to issue the &amp;lt;tt&amp;gt;rehash&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
Now try making a simple Madagascar data file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfspike n1=1000 k1=300 &amp;gt; spike.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command generates a one-dimensional list of 1000 numbers, all zero except for a spike equal to one at position 300. If this generates an error like&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Cannot write to data file /path/spike.rsf@: Bad file descriptor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you may need to create the directory pointed to by your &amp;lt;tt&amp;gt;&amp;amp;#36;DATAPATH&amp;lt;/tt&amp;gt; environment variable.&lt;br /&gt;
&lt;br /&gt;
The file &amp;lt;tt&amp;gt;spike.rsf&amp;lt;/tt&amp;gt; is a text header. The actual data are stored in the binary file pointed to by the &amp;lt;tt&amp;gt;in=&amp;lt;/tt&amp;gt; parameter in the header.  You can look at the header file directly with &amp;lt;tt&amp;gt;more&amp;lt;/tt&amp;gt;, or better, examine the file properties with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfin spike.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can learn more about the contents of &amp;lt;tt&amp;gt;spike.rsf&amp;lt;/tt&amp;gt; with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfattr &amp;lt; spike.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following command applies a bandpass filter to &amp;lt;tt&amp;gt;spike.rsf&amp;lt;/tt&amp;gt; and puts the result in &amp;lt;tt&amp;gt;filter.rsf&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfbandpass fhi=2 phase=y &amp;lt; spike.rsf &amp;gt; filter.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following command makes a graphics file from &amp;lt;tt&amp;gt;filter.rsf&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfwiggle clip=0.02 title=&amp;quot;Welcome to Madagascar&amp;quot; &amp;lt; filter.rsf &amp;gt; filter.vpl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have an X11 display program running, and your &amp;lt;tt&amp;gt;&amp;amp;#36;DISPLAY&amp;lt;/tt&amp;gt; environment variable is set correctly, you can display the graphics file with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfpen &amp;lt; filter.vpl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can pipe Madagascar commands together and do the whole thing at once like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfspike n1=1000 k1=300 | sfbandpass fhi=2 phase=y | \&lt;br /&gt;
sfwiggle clip=0.02 title=&amp;quot;Welcome to Madagascar&amp;quot; | sfpen&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have SCons installed, you can use it to automate Madagascar processing. Here is a simple &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file to make &amp;lt;tt&amp;gt;filter.rsf&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;filter.vpl&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Setting up&lt;br /&gt;
#&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# Make filter.rsf&lt;br /&gt;
#&lt;br /&gt;
Flow(&#039;filter&#039;,None,&#039;spike n1=1000 k1=300 | bandpass fhi=2 phase=y&#039;)&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# Make filter.vpl&lt;br /&gt;
#&lt;br /&gt;
Result(&#039;filter&#039;,&#039;wiggle clip=0.02 title=&amp;quot;Welcome to Madagascar&amp;quot;&#039;)&lt;br /&gt;
&lt;br /&gt;
End()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put the file in an empty directory, give it the name &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;cd&amp;lt;/tt&amp;gt; to that directory, and issue the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scons&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The graphics file is now stored in the &amp;lt;tt&amp;gt;Fig&amp;lt;/tt&amp;gt; subdirectory. You can view it manually with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfpen Fig/filter.vpl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
... or you can use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scons view&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When a SConstruct file makes more than one graphics file, the  &amp;lt;tt&amp;gt;scons view&amp;lt;/tt&amp;gt; command will display all of them in sequence. &lt;br /&gt;
[[Image:filter.png|frame|center|Welcome to Madagascar.]]&lt;br /&gt;
Now edit the &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file: change the title string on the &amp;lt;tt&amp;gt;Result&amp;lt;/tt&amp;gt; line to &amp;quot;Hello World!&amp;quot;, save the file, and rerun the scons command. You will see that scons has figured out that the file &amp;lt;tt&amp;gt;filter.rsf&amp;lt;/tt&amp;gt; does not need to be rebuilt because nothing that affects it has changed. Only the file &amp;lt;tt&amp;gt;filter.vpl&amp;lt;/tt&amp;gt; is rebuilt.&lt;/div&gt;</summary>
		<author><name>Fomels</name></author>
	</entry>
</feed>