next up previous [pdf]

Next: Plotting Up: Command line interface Previous: Piping

Interacting with files from the command line

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:

Here are detailed usage examples and explanations of what the above programs do:

sfin 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.

sfin file.rsf
 
file.rsf:
    in="/var/tmp/file.rsf@"
    esize=4 type=float form=native 
    n1=100         d1=0.004       o1=0          label1="Time" unit1="s" 
    n2=34          d2=0.1         o2=0          label2="Distance" unit2="km" 
	3400 elements 13600 bytes

sfattr 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'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.

sfattr < file.rsf 
 
******************************************* 
     rms =             1 
    mean =             1 
  2-norm =       58.3095 
variance =             0 
 std dev =             0 
     max =             1 at 1 1 
     min =             1 at 1 1 
nonzero samples = 3400 
  total samples = 3400 
*******************************************

sfwindow 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 file.rsf, we might use the following command:

sfwindow < file.rsf f1=15 n1=15 j1=1 > file-win.rsf

sftransp is used to reorder RSF files for other programs to be used. For example:

sftransp < file.rsf plane=12 > file-transposed.rsf
swaps the first and second axes, so that now the first axis is distance and the second axis is time.

For more information about commonly used Madagascar programs please see the guide to Madagascar programs: http://reproducibility.org/wiki/Guide_to_madagascar_programs.


next up previous [pdf]

Next: Plotting Up: Command line interface Previous: Piping

2011-11-03