A Beginner's Guide to SM


SM (SuperMongo) is a very easy to use package that will allow you to generate fairly sophisticated plots. It is installed centrally on the astro machines, but each of you should have a special file called .sm which contains all the necessary information for the program to run. To check if you have this file type ls .sm in your home directory. If the file does not show up (you will get a response something on the lines of ls: .sm: No such file or directory), please email me and I will fix the problem.

To run SM, simply type sm at the prompt:

student@hipparchus: sm

This command should pop open a window on your screen (this is the window where your plots will appear) and give you an SM prompt in your original window, like this:

SM>

At this point you can start typing the commands directly at the prompt. However, a much better way of doing things is to run batch files that contain of all the commands you need to make one (or more) plots. In this case you will need at least two files; one file containing your plotting commands and another file containing your data. (It is easiest to keep both files in the same directory from which you start SM.) Below are examples of each type of file. These should be enough to start you off -- everything else you can pick up from reading the SM Tutorial, SM Manual and experimenting on your own. So here goes the data file. It looks pretty much like any other data file with data arranged in columns. I am going to call it square.dat

x y dx dy
1 1 0.1 0.2
2 4 0.1 0.4
3 9 0.1 0.6
4 16 0.1 0.8
5 25 0.1 1.0

The first column contains my x values, the second column contains y=x^2 values, and the other two columns are the errors in x and y respectively. You can create your own data file by copying my numbers into emacs. Make sure you do not leave empty lines in the beginning or at the end of the files. (The way to get rid of empty lines, or lines of text in emacs, is to place the cursor at the beginning of the line and type CTRL-k.)

Now here is the file that will plot those values for you. Note that everything following '! ' is a comment which is not read by SM.

data square.dat ! Specifies the data files to use
lines 2 6 ! Tells the program to read only lines 2-6. Skip this
! if you do not have header lines in your data files.
read x 1 ! Reads in the first column and calls this data vector x
read y 2 ! Reads in the second column and calls this data vector y
read xerr 3 ! Reads in the third column and calls this data vector xerr
read yerr 4 ! Reads in the forth column and calls this data vector yerr
limits 0 6 0 27 ! Specifies the limits of the plot. You can leave it out
! and the program will figure out which limits make sense.
ptype 3 3 ! Sets the type of the points to be used.
points x y ! Plots the data.
connect x y ! Connects the data points with straight lines.
errorbar x y xerr 1 ! Draws an errorbar in the +x direction.
errorbar x y xerr 3 ! Draws an errorbar in the -x direction.
errorbar x y yerr 2 ! Draws an errorbar in the +y direction.
errorbar x y yerr 4 ! Draws an errorbar in the -y direction.
xlabel X ! Labels the x-axis.
ylabel X^2 ! Labels the y-axis.
box ! Draws the axes.

If you now save this file (I use names like square.sm), you can generate your plot by typing the following at the SM prompt:

SM> inp square.sm

Your figure should appear in the display window. Now the final thing you have to do is save the figure in order to print it. To do this you need to type in the following:

SM> dev postfile square.ps
SM> inp square.sm
SM> hardcopy
SM> dev x11

The last line will allow you to display your figures in the window again. Without it, everything you type in will end up in the postscript file square.ps. The printer in the lab is called sirius and you can print files on it using the command lpr -Psirius file.ps.

Unless you are writing your lab reports using LaTeX, you will probably want you plots in a format other than postscript. The easiest way to convert image files is by using unix convert 'command'. For example, typing

convert square.ps square.jpg

at the prompt will create a .jpg version of the existing square.ps file.

This is just the most basic set of commands to get you started. SM can do a lot more, for instance you can modify the data values after you read them in using the command set, make log plots, write text and draw inside your figure using commands relocate, label, putlabel, dot, draw, etc. You can find the descriptions of individial commands in the online SM Manual, or by typing help commandname at the SM prompt.