Astro 293 - Lab 2

The Nature of Light: Identifying Elements from their Spectra



Instructions for the lab

IDL has not been setup on the Osmond machines in time to do Lab2 on Jan 28th. (IDL = interactive data language, which is the analysis software that we plan to use for most of this course.) However we have other software which we can use in the interim. We will start using IDL for Lab 3.

You will need to copy the following files into your working directory on the IBM/AIX machines for the lab.

Either copy them from here using netscape or use the unix commands and paths specified in the lab write-up . Note that the web verion of lab2.pro is different than the one you can copy in unix. If you download the web verion, you will also need to copy the following data files into your working directory:

We will be using two peices of software to handle interactive plotting of data, and determining the wavelength (dispersion) solution of the spectra. Here are the instructions for: You must also copy the following files from the web:

as well as the following binary executable:

Instructions for plotting:
To interactively plot data, start up the program Xmgr within unix by typing:

% xmgr &

The '&' puts the prgram in background, so you can still use your window for other good stuff, and generated a new plotting window which is really slick. This is a very nice, simple plotting program which will allow you to display the data, and read of coordinates. There is an excellent on-line help file (html) as well, however the package is almost self-explanatory. Play around with it until you figure out what is what. This beats the IDL plotting package for simplicity and ease of use by a long shot!

Instructions for fitting:
You can use the program polyfit to determine a polynomial fit up to 50 coefficients (49th order) for up to 1000 data points. You will never approach exceeding this capacity in this lab.

The program has now been tested and runs successfully on the IBM/AIX machines.

Use the program as follows: Once you have downloaded the file, you will need to make it an executable file. To do this, type:

% chmod u+x polyfit

Then, to run the program (within unix) simply type:

% polyfit

where again '%' is the command line prompt. The program will ask you for

  • a data file, which is assumed to be formatted in two columns of data (x and y);
  • the of lines (data points) in the data file;
  • the number of coefficients to fit.

Note that the 'order' of the fit is 1 less than the number of coefficients. The program will report the coefficients as well as the goodness of fit (chi-squared).

Instructions for editing:
Ok, you're ready to fit, but how do you get the data into a file for polyfit ?

There are several standard editors in unix. One is called vi and the other is emacs. The latter is far more powerful, and in the long-run preferable to learn. The above htpertext links take you to help files and manuals on these editors. In addition, there may be other text editors available within the AIX environment. These will have the advantge of being easy to use, but not portable (in other words, you won't be able to use them on other types of machines). Choose whichever editor you like. I prefer emacs.

Another simple way to get data into a file is with the unix command cat , as follows:

% cat > [filename]

where [filename] is the name of the file into which you would like to type data (do not type the '[]'). Hit 'RETURN' after the above, and then type data as if it were in a text file, with a 'RETURN' after every line of data. When you are done, type 'CTRL-D,' i.e. the Control key and the D key at the same time. Note you can back up and correct on a given line, but you won't be able to back up to previous lines. If you make a mistake, delete the file and start again. This can get tedious, so eventually you should learn an editor!


Last updated: Feb 4, 1997 Matthew A. Bershady