FAQ

Is there a Graphical User Interface to Madagascar?

July 19, 2010 FAQ No comments

A hardcore Madagascar user does not need anything more than a friendly editor (to edit SConstruct files) and the good old command line (to run scons commands). However, sometimes it is necessary to provide simplified GUIs (Graphical User Interfaces) for inexperienced users. Creating GUIs in Python is quite simple. An example is provided in rsf/rsf/gui. In this example, we obtain a compressed approximation of a piecewise-regular signal with by a wavelet transform. The figure using default parameters is shown below:

There are two main parameters in this experiment: the type of the wavelet transform (type= parameter in sfdwt) and the thresholding percentile (pclip= parameter in sfthreshold). The first step is to expose these parameters to CLI (Command Line Interface) by using ARGUMENTS.get construct in SConstruct:

# Wavelet transform type 
type = ARGUMENTS.get('type','b') 
# Thresholding percentile 
pclip = int(ARGUMENTS.get('pclip',50))

Now one can select parameters on the command line by launching something like

scons type=b pclip=50 view

Next, we build the GUI by using one of the Python interfaces. The gui.py script provides an interface using Tkinter, the most standard Python GUI package. It allows the user to select the parameter values graphically. Clicking the Run button would then launch scons with the selected parameters in the background.

An alternative, both simple and powerful GUI package is Traits from Enthought Inc. An example Traits-based interface interface is provided by gui-traits.py.

For full-featured GUIs exposing all program parameters, one can use the Madagascar interface to TKSU or OpendTect.

How do I convert an image file to an RSF file?

March 15, 2009 FAQ No comments

One option is sfjpg2byte. It requires the JPEG library to be present at the compilation time.

< lena.jpg sfjpg2byte | sfdd type=float > lena.rsf

Another option (suggested by Vladimir Bashkardin) is to use the convert utility from ImageMagick.

< lena.jpg convert - lena.gray
echo in=lena.gray data_format=native_uchar n1=512 n2=512 | sfdd type=float > lena.rsf

or

< lena.jpg convert - lena.rgb
echo in=lena.rgb data_format=native_uchar n1=3 n2=512 n3=512 | sfdd type=float > lena.rsf

What are the most popular programs in Madagascar?

February 8, 2009 FAQ No comments

In reverse order, the 10 most popular programs in Madagascar are:
10. sftransp Transpose two axes in a dataset (used in 83 projects)
9. sfadd Add, multiply, or divide RSF datasets (used in 92 projects)
8. sfgraph Graph plot (used in 99 projects)
7. sfspike Generate simple data: spikes, boxes, planes, constants (used in 109 projects)
6. sfcat Concatenate datasets (used in 110 projects)
5. sfput Input parameters into a header (used in 118 projects)
4. sfmath Mathematical operations on data files (used in 143 projects)
3. sfdd Convert between different formats (used in 163 projects)
2. sfwindow Window a portion of a dataset (used in 216 projects)
1. sfgrey Generate raster plot (used in 260 projects)
More documentation on these and other programs – in Guide to Madagascar programs.
The three most popular programs in the “generic” category (signal processing programs applicable to any kind of data) are sffft1 (Fast Fourier Transform along the first axis), sfnoise (Add random noise to the data), and sfsmooth (Multi-dimensional triangle smoothing).
The three most popular programs in the “seismic” category (signal processing programs applicable to seismic data) are sfmutter (Muting), sfricker1 (Convolution with a Ricker wavelet), and sfsegyread (Convert a SEG-Y or SU dataset to RSF).
Here is a simple Python script that extracts the popularity information:

#!/usr/bin/env python
from rsfdoc import progs
import rsfprog
def nuses(p):
‘how many times a program is used’
n=0
uses = progs[p].uses
for book in uses.keys():
for chapter in uses[book].keys():
n = n + len(uses[book][chapter])
return n
programs = progs.keys()
programs.sort(lambda x,y: nuses(y)-nuses(x))
for prog in programs:
print ‘%s is used in %d projects’ % (prog,nuses(prog))

A journal requires a particular font (e.g. Arial or Helvetica) in figure labels. How do I achieve that?

October 15, 2008 FAQ No comments

Update: If you generate Geophysics manuscripts using rsf.tex, the font change should happen automatically. Otherwise, use font= parameter.

See also:

When converting from SEG-Y to RSF, how do I deal with non-standard trace headers?

May 24, 2008 FAQ No comments

sfsegyread currently limits the number of trace header keys to 71. However, you can remap a non-standard header. For example,

sfsegyread < file.segy tfile=tfile.rsf swdep=188 > file.rsf

will map the header value at 189-193 bytes to the “swdep” standard header.
Note that numeration starts at 0 at and that the number of bytes in the
headers (2 or 4) should match. You can test the output by running

sfheaderattr < tfile.rsf

GPL vs. research confidentiality agreements

May 23, 2008 FAQ No comments

Some of the academic researchers that use Madagascar are sponsored by companies who require a period of confidentiality before deliverables can be made public. During discussions at the workshop, the issue of the interaction between the confidentiality agreement and the GPL was raised.
I am not a lawyer and what follows is not legal advice, but just describes my understanding of the issue.
Let us assume a researcher (called R) who wrote a program P linking with GPL-ed library G (in our case, G=rsflib). If Researcher R distributes the program P to anyone, then he will have to license P under the GPL because it is linking with a GPL-ed library. R is free to use G in any way he wants for his own purposes, and he is not required at all by the GPL to distribute program P. If, however, he chooses to distribute program P, he simply has no choice than to release it under the GPL, regardless of what contracts he may have with others. If he restricts the rights of the users by breaking the GPL, then he loses the right to use library G, it’s that simple. Notice again the starting assumption that researcher R received library G under the GPL. If he negotiated a private agreement with the author of G, and received G under another license (paying or not for it, it does not matter), then that is a different case, not treated by this analysis.
Researcher R, as the copyright holder, has the right to release the code to anyone he pleases, when he pleases, under whatever license he pleases. R is therefore free to release program P only to his sponsor companies Ci , (where i is a number between 1 and the number of sponsors) for the first Y years as agreed with the sponsors, then to release it to the general public. In all releases P will be licensed under the GPL.
Now comes the tricky part: Researcher R cannot break the GPL and restrict the freedom of whomever releases the code to, including companies Ci. This means that any of the companies Ci are free to redistribute the code under the GPL to whomever they see fit, whenver they see fit. Should there be any stipulations in the sponsorship contract stating that Ci cannot make public the code of program P during the first Y years, then such stipulations are illegal, and thus null and void. As expected, GPL is all about maximizing the freedom of the users!
Bottom line, there are no contradictions between GPL and sponsorship contract stipulations stating that researcher R has to release program P only to his sponsors for the first Y years. The contradictions can appear only if the contract stipulates that the sponsor Ci is restricted from redistributing the program. In reality, once sponsor Ci has received program P with a GPL license, he is free to redistribute it to anybody, as long as it is doing so under the GPL too.
This situation may get sponsors worried that one of them will “betray” the confidentiality pact. However, such cases are practically impossible to occur, since sponsor Ci, by entering the sponsorship contract, practically stated that it is in his best interest that the number of companies that get access to P is restricted for the first Y years. If Ci releases program P to a non-sponsor before the lapse of the Y year term, then he is in effect acting against its own interest. It is conceivable that Ci would release P to a non-competitor N (such as a contractor for optimizing codes or doing associated research). Then N would have the legal right to redistribute program P under the GPL, and would apparently not be constrained by self-interest since he is not competing with the competitors of Ci. However, he will in practice not do so, since Ci has the power to publicize that N acted against the interests of his patron (even if in a manner that is not punishable by law). Ci can thus ensure that N will lose other clients if he further released P. It is hard to conceive what benefit N would have from releasing P that would counterbalance the loss of clients. The chain of plausible transmissions before the end of the first Y years stops here. The only margin case remaining is the one in which N has a one-off relationship with Ci or is closing the business and does not want any more clients, and has a reason to bother to release P. However, this is totally improbable.
Therefore, in practice researcher R can release program P under the GPL to his sponsors Ci only for the first Y years, and to the general public after that, and both R and Ci can rest assured that the program will not be made public before the lapse of the Y-year term. The only assumptions made were that everybody obeys the law and acts in his own self-interest. The only case that allows P to be released before the term is entirely improbable. For all practical purposes, researchers sponsored by industry through typical agreements can use GPL-ed libraries without any problems.

A journal requires tick labels on my plots to be oriented vertically and aligned on the left. How do I achieve that?

March 26, 2008 FAQ No comments

  • To place tick labels perpendicular to an axis (rather than parallel to it), use parallel#=n, where # is 1, 2, or 3.
  • .

  • To control the tick selection manually, use n#tic=, o#=num, and d#num=.
  • To control the label format, use format#= (the argument is a printf-style string)

The following example is provided in rsf/rsf/sfgraph:

Can I use Pylab figures in reproducible documents?

March 21, 2008 FAQ No comments

Now you can. See an example, where a figure originally generated with Matlab is replicated with Pylab.

To prepare your figures, follow the rules similar to those for Matlab and Mathematica figures:

  1. Create a directory called Pylab.
  2. Put figure-generating python scripts in this directory.
  3. Each script should have a .py suffix
  4. Each script should end with a command like
savefig('junk_py.eps');

(the name junk_py.eps is important.)

Are there any hidden parameters that apply to all Madagascar programs?

July 11, 2007 FAQ No comments

Two of the hidden parameters (datapath= and out=) are described in the Guide to RSF file format. Other parameters like that include

  • readwrite= (yes or no, the default is no) for designating all auxiliary files to be available for both reading and writing.
  • tmpdatapath= (the default is the same as datapath, similar rules apply) for setting a separate directory for temporary data files.

How to make RSF files easy to fetch from FTP servers?

February 15, 2007 FAQ 1 comment

An RSF “file” typically consists of 2 parts: the binary file, where data values are stored, and the header file (text), where data attributes are put (see RSF file format page for more details). To prepare such file for distribution, it is recommended to 1) make the binary part architecture independent so that data can be downloaded on heterogeneous computer systems, and 2) pack the binary and header parts. Such result is achieved by using the sfdd program to convert the binary part to XDR format and, at the same time, to pack the two parts. See the example below.

(more…)