next up previous [pdf]

Next: Header and Data files Up: Principles Previous: Principles

Example

Let us first create some synthetic RSF data.

bash$ sfmath n1=1000 output='sin(0.5*x1)' > sin.rsf

Open and read the file sin.rsf.

bash$ cat sin.rsf
sfmath  rsf/rsf/rsftour:        fomels@egl      Sun Jul 31 07:18:48 2005

        o1=0
        data_format="native_float"
        esize=4
        in="/tmp/sin.rsf@"
        x1=0
        d1=1
        n1=1000
The file contains nine lines with simple readable text. The first line shows the name of the program, the working directory, the user and computer that created the file and the time it was created (that information is recorded for accounting purposes). Other lines contain parameter-value pairs separated by the ``='' sign. The ``in'' parameter points to the location of the binary data. Before we discuss the meaning of parameters in more detail, let us plot the data.
bash$ < sin.rsf  sfwiggle title='One Trace' | sfpen
On your screen, you should see a plot similar to Figure 1.

sin1
sin1
Figure 1.
An example sinusoid plot.
[pdf] [png] [scons]

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 running

bash$ < sin.rsf sed 's/n1=1000/n1=100 n2=10/' > sin10.rsf 
bash$ < sin10.rsf sfwiggle title=Traces | sfpen
or (using pipes)
bash$ < sin.rsf sed 's/n1=1000/n1=50 n2=20/' | sfwiggle title=Traces | sfpen
On your screen, you should see a plot similar to Figure 2.

sin2
sin2
Figure 2.
An example sinusoid plot, with data reformatted to twenty traces.
[pdf] [png] [scons]

What happened? We used sed, a standard Unix line editing utility to change the parameters describing the data dimensions. Because of the simplicity of this operation, there is no need to create specialized data formatting tools or to make the sfwiggle program accept additional formatting parameters. Other general-purpose Unix tools that can be applied on RSF files include cat, echo, grep, etc.

An alternative way to obtain the previous result is to run

bash$ ( cat sin.rsf; echo n1=50 n2=20 ) > sin10.rsf 
bash$ < sin10.rsf sfwiggle title=Traces | sfpen
In this case, the cat utility simply copies the contents of the previous file, and the echo utility appends new line ``n1=50 n2=20''. A new value of the n1 parameter overwrites the old value of n1=1000, and we achieve the same result as before.

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 usually preferable to be able to process files with non-interactive tools.


next up previous [pdf]

Next: Header and Data files Up: Principles Previous: Principles

2012-07-19