Editing
Guide to madagascar programs
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==sfreverse== {| class="wikitable" align="center" cellspacing="0" border="1" ! colspan="4" style="background:#ffdead;" | Reverse one or more axes in the data hypercube. |- ! colspan="4" | sfreverse < in.rsf > out.rsf which=-1 verb=n memsize=sf_memsize() opt= |- | ''int '' || '''memsize=sf_memsize()''' || || Max amount of RAM (in Mb) to be used |- | ''string '' || '''opt=''' || || If y, change o and d parameters on the reversed axis; :if i, don't change o and d |- | ''bool '' || '''verb=n''' || [y/n] || Verbosity flag |- | ''int '' || '''which=-1''' || || Which axis to reverse. :To reverse a given axis, start with 0, :add 1 to number to reverse n1 dimension, :add 2 to number to reverse n2 dimension, :add 4 to number to reverse n3 dimension, etc. :Thus, which=7 would reverse the first three dimensions, :which=5 just n1 and n3, etc. :which=0 will just pass the input on through unchanged. |} Here is an example of using <tt>sfreverse</tt>. First, let us create a 2-D dataset. <pre> bash$ sfmath n1=5 d1=1 n2=3 d2=1 output=x1+x2 > test.rsf bash$ < test.rsf sfdisfil 0: 0 1 2 3 4 5: 1 2 3 4 5 10: 2 3 4 5 6 </pre> Reversing the first axis: <pre> bash$ < test.rsf sfreverse which=1 | sfdisfil 0: 4 3 2 1 0 5: 5 4 3 2 1 10: 6 5 4 3 2 </pre> Reversing the second axis: <pre> bash$ < test.rsf sfreverse which=2 | sfdisfil 0: 2 3 4 5 6 5: 1 2 3 4 5 10: 0 1 2 3 4 </pre> Reversing both the first and the second axis: <pre> bash$ < test.rsf sfreverse which=3 | sfdisfil 0: 2 3 4 5 6 5: 1 2 3 4 5 10: 0 1 2 3 4 </pre> As you can see, the <tt>which=</tt> parameter controls the axes that are being reversed by encoding them into one number. When an axis is reversed, what happens with its axis origin and sampling parameters? This behavior is controlled by <tt>opt=</tt>. In our example, <pre> bash$ < test.rsf sfget n1 o1 d1 n1=5 o1=0 d1=1 bash$ < test.rsf sfreverse which=1 | sfget o1 d1 o1=4 d1=-1 </pre> The default behavior (equivalent to <tt>opt=y</tt>) puts the origin <tt>o1</tt> at the end of the axis and reverses the sampling parameter <tt>d1</tt>. Using <tt>opt=n</tt> preserves the sampling but reverses the origin. <pre> bash$ < test.rsf sfreverse which=1 opt=n | sfget o1 d1 o1=-4 d1=1 </pre> Using <tt>opt=i</tt> preserves both the sampling and the origin while reversing the axis. <pre> bash$ < test.rsf sfreverse which=1 opt=i | sfget o1 d1 o1=0 d1=1 </pre> One of the three possible behaviors may be desirable depending on the application.
Summary:
Please note that all contributions to Madagascar are considered to be released under the GNU Free Documentation License 1.3 or later (see
My wiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
English
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Getting Madagascar
download
Installation
GitHub repository
SEGTeX
Introduction
Package overview
Tutorial
Hands-on tour
Reproducible documents
Hall of Fame
User Documentation
List of programs
Common programs
Popular programs
The RSF file format
Reproducibility with SCons
Developer documentation
Adding programs
Contributing programs
API demo: clipping data
API demo: explicit finite differences
Community
Conferences
User mailing list
Developer mailing list
GitHub organization
LinkedIn group
Development blog
Twitter
Slack
Tools
What links here
Related changes
Special pages
Page information