Physics 405 Data Analysis Tools

Since the data acquisition systems were upgraded in Physics 405, there is no longer a "standard" set of data analysis tools that smoothly interface to the output files of ACQUIRE. There are several tools available, but each will require a little bit of data manipulation on your part in order to use them. Below are some guidelines, helpful hints, and words of caution. It is your responsibility to be sure that you are using the tools correctly -- that is: CHECK YOUR RESULTS by a hand calculation, a simple estimate, whatever you can do to convince yourself that the output looks reasonable.

DOS-based programs

EXCEL

MATHEMATICA

other tools that are available:

MATLAB

ORIGIN

The two DOS programs, LINREG and ANALYSIS, will perform all of the functions you need

for Physics 405.

LINREG performs a linear regression analysis on a two-column set of data. You can perform a least squares fit to a polynomial (including 1st order), or to a set of orthogonal functions such as Legendre polynomials, or to a few nonlinear functions such as an exponential. LINREG will read a file that has either two columns of (x,y) data or three columns of (x,y,dy) data.

* CAUTION ABOUT LINREG *

We recently discovered that LINREG does not work on a total of about 5-6 computers that

were all purchased from DELL during the summer of 1998. Four of these computers are in the
Physics 405 labs, the other two are in the OWL labe. The symptom is that the first-order
parameter of a polynomial fit is always 0, regardless of the data. It seems to be a
problem with the computers and not the program. If you see this, go to another computer
and try again!

ANALYSIS will allows the possibility of reading in files with data and background, subtracting background from data, and performing a nonlinear fit to peaks in a spectrum. ANALYSIS expects to see a file with only 2 columns of data. When using the program ANALYSIS, you should first fit the background, being careful to choose regions that are ONLY background (you can choose multiple regions), then select the portion of the graph you would like to fit (like all of it, only the upper half, etc.), then choose the peaks.

At present, these programs are only accessible from the Phys 405 Lab computers. Double-click on the icon labelled PC Dos applications. Save your data as a text file with two (or three) columns of data ((x,y) or (x,y,dy)), and get rid of any text information at the top of the file. Note that ACQUIRE saves 3 columns of data (time, A/D channel 0 and A/D channel 1), so you'll have edit the file (e.g., in EXCEL) before using these programs.

In general you are advised not to use the built-in linear fitting function in EXCEL. However, for fitting to a straight line or polynomial, there are some EXCEL macros which properly account for errors in either the independent or dependent variable. These were written by Prof. Boyd for Physics 275. You can use them in this course. Slightly modified versions have been made available for Phys 405. On the lab computers, go to

p:\p405\Analysis Tools\Excel Tools\

and double-click on the appropriate .XLS file.

LinFit.xls performs a linear fit to the data. There is an example called TestLinFit.XLS in which there is also a graph. Copy the file to your own personal area before using it, since the copy on the P: drive is READONLY. The fitted function is a straight line:

y = a0 + a1*x

In the file, there are columns labeled x, sig-x, y, sig-y. Be sure to enter your data in the correct columns. Also enter the number of points you would like to fit. To run the macro, go to the Tools drop-down menu, click on Macros, then highlight the one called LINFIT, and click on RUN. The resultant fit will show up in the boxes to the right of the data. You will have to construct your own graphs.

The other two files are other possible fitting procedures: ParaFit.XLS is a quadratic
fit, LnLnFit.XLS is a linear fit of y=a0x^a1, for example. ParaFit.XLS will be useful for
experiment 9, where you need to fit the expression A = 1 + cos^2(theta) + cos^4(theta).

An example of using ParaFit to do this is in the file called ParaFit-mc.xls.

Dr. Chang, the author of ANALYSIS and LINREG, has begun to develop Mathematica notebooks that will perform the same function as the DOS based programs. There are two notebooks that can be used instead of LINREG and ANALYSIS, but they should be used with caution since they are not set up to accomodate all types of situations. Either file should be copied to your own area and modified to suit your individual needs. Some (but not much) familiarity with Mathematica will be needed to use these programs. The two files are:

LR-err-example.nb: This notebook will perform a least-squares fit to a straight line. It uses the statistics package from Mathematica called "LinearRegression". You will have to modify the file to choose the directory location and file name of your own file. You may also change the fitting function it you wish to fit a higher order polynomial. As written, this notebook assumes the data are in 3 columns of the form (x,y,dy).

fhertz-example.nb: This notebook will perform the function that analysis performs: i.e., fit several peaks over a polynomial background. The example shown uses data from Experiment 3 (Franck-Hertz). You will of course have to supply your own data file. First the region over which one wants to fit is selected, then the background is fitted, then the peaks are fitted to Gaussian shapes. The assumed background shape is quadratic.

There are no developed tools using MATLAB for this course, but MATLAB is available and you are welcome to use it.

ORIGIN is a powerful graphics and analysis package that is frequently used in research laboratories. We will try to make it available on at least one computer in the lab. Ask. If you are familiar with ORIGIN, or have a strong desire to learn to use it, you are welcome to do so. There is a learning curve to using it but it makes beautiful graphs, handles large data files quickly, makes reduced sized plots for you notebook, and does least squares fitting. It goes well beyond the immediate needs of this lab and so may not be the tool that you first want to try.

*last update: Feb 8, 2000*