This is a pretty boring white paper at the moment. I'll try to make it more interesting once the CHESS wiki site is up and running.

We are using PyMca to interpret X-ray fluorescence spectra from a diverse array of samples. You can give PyMca information about your experiment, and it makes a good estimate the concentrations of the elements. Some matrix effects are not accounted for, you would need to use monte carlo simulations to handle them properly, which tend to be computation intensive.

Please go to the ESRF's Beamline Instrumentation Software Support page to download PyMca. The Suse82 file has been tested on the Suse Linux, Gentoo Linux and Red Hat Enterprise Linux 4 operating systems. For MSWindows, run the .exe file. For MacOS, use the darwin file.

Next, you can download sample cfg files which PyMca will use to perform the analysis. Please note, these cfg files are samples only, it is up to you to use them carefully in order to perform an appropriate analysis. I will do my best to provide a reasonable starting point, but you should consult with me in person if you are unsure of how to use them properly. For now, just drop these sample cfg files into the directory containing your data.

PyMca tutorial

Our data are stored in files created by spec. The standard spec file format can be opened by PyMca.

Run PyMca and open your data file (you may need to change the filter to see all of the files). Click on the mca tab and double click on a MCA spectra to plot it in the plot window. Click the logscale button above the plot window. If the detector calibration has been recorded in the file, you can select the original (source) calibration, otherwise press the calibrate button and select compute. Select the two "auto" check boxes, and then hit "search". You can the click on a low energy peak, identify it (for example, the Ca KL3 (Ka) line at 3.69 KeV or the Ti KL3 line at 4.52 KeV), click on a high energy peak, and identify it (for example, the Sr KL3 line at 14.165 KeV). Click ok, and select "Internal" from the "Calibration" selection box. You have a calibrated energy scale.

Next, use the mouse to drag out a range of interest in the plot window. This range should not include any low energy artifacts due to detector cutoff, and it is best to include the the shoulder of the compton peak, but not the peak itself. Now press the "FIT" button above the plot window, and select Advanced to open the McaAdvanced Fit window.

You will imediately get a warning about peaks not being identified. Click the "Configure" button. Click "Load" at the bottom left of the dialogue and select a configuration file for your material (if you are just getting started with PyMca, you can use one of my sample cfg files). Next, go to the "BEAM" tab, and define the incident energy (in KeV) by double clicking the top cell in the Energy column. Make sure the check box next to Energy 0 is selected, and the Weight should be 1.0.

Next, go to the peaks tab. For each element you want to include in your model, select the element (it will trun gray in the periodic table) and then the appropriate group of transitions. For example, the "K" button will include the K_alpha and K_beta lines with the appropriate relative intensities. The elements and fluorescence lines that will be included in your model will be highlighted in yellow.

Go to the attenuators tab and define everything that can attenuate the beam between the sample and the detector. This is a crucial step if you are doing any kind of quantitative analysis. The distance the fluorescent X-rays must pass through each medium before being detected is important, especially for lower-energy X-rays that are strongly attenuated. For the Vortex detector used at F3, we have a 7.5 micron kapton window, a 1 nm thick Si deadlayer, and the detector itself is Silicon, 400 microns thick. The length of air at F3 is equal to the position of "detx" in Spec (the software we use to control the experiment). In the "DETECTOR" tab, change the "Sum Factor" (both value and error) to 1e-8.

Next go to the "FIT" tab. Set the Continuum type to "NO Continuum" (it does a great job). I have been using a "Strip Background Width" of 20. You can play with the "Strip Background Iterations" and "Number of iterations" to get good results without taking too much time. You may need to limit the fitting region to ignore the compton peak and any low energy anomalies. Select "Short tail", Stripping", "Escape peaks", "Sum peaks", and "Scattering peaks". In the concentrations tab, enter the the incident flux and select the "from fundamental parameters" checkbox.

Save your configuration in a new .cfg file. Click ok to exit configuration.

Click the "Fit Again!" button. After the fit is complete, click the "peak spectrum" button. If a peak in your spectrum has not been fit, you may need to include another element in your model. Place your cursor over the peak and read the X-position in the box above the plot window (make sure you have selected the "E" button above the graph to get an energy scaled X-axis). Select "Tools", "Identify Peaks" and enter the energy in the top box. You probably need to increase the energy threshold to 50 or more. The window lists possible candidates. Note the Rate value, which is equal to that line's intensity divided by the total intensity for that family of lines. Most likely, you should be focussing on lines with relatively high rates.

You may notice that the more intense peaks have low energy tails that have not been modeled very well. Go back to the "MCA Fit Parameters" dialogue by pressing the "Configure" button. Go to the "PEAK SHAPE" tab and you can play with the "Short Tail Area" and "Short Tail Slope" values. I got good results with An area value = 0.1, error = 0.01, and slope value = 0.15, error = 0.1. Select "OK", fit again, and you may need to iterate to get a good fit. Dont forget to save the cfg file once you have settled on your parameters.

Now got to the concentrations tab, and the concentrations report will be generated. Finally, click "HTML Report" in the McaAdvanced Fit window, and a number of files will be generated in the directory you choose. If you are using PyMca-3.7 (which is currently being developed), you will also get a concentrations summary file, which you can import into a spreadsheet program like Excel.

If you have a number of samples that can be modeled with that same cfg file (same detector distance?), then you can perform those fits with a batch process. Click Tools in the menu bar, then Batch Fitting. Press the Browse button next to the Input File List window, and select the files you want to fit. Select the configuration file you just generated with the next browse button, and then select an output directory. Check the "Generate Report", "Generate .fit Files", "Table in Report" and "Concentrations" check boxes. Remember, if the detector distance changed from sample to sample, you need to use a different .cfg file to account for the change. Otherwise, the concentrations report will be incorrect.