Skip to end of metadata
Go to start of metadata

== PyMca Tutorial ==

This is not the home page of PyMca, it is only a tutorial. PyMca is written by V. Armando Sole at the European Synchrotron Radiation Facility. PyMca can be used to identify individual elemental contributions to complicated spectra, and can yield trace element concentrations with surprisingly good accuracy. Thank you Armando for such a great effort!

We use 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 of the concentrations of the elements. Some matrix effects are not accounted for, but you would need to use monte carlo simulations to handle them properly and they tend to be computation intensive.

Once you get PyMca to recognize your experimental configuration, it can be used for batch processing of hundreds or thousands of spectra, generating reports that can in turn be converted into, for example, XRF microscopy images. The initial setup takes a little time and effort, but after that, things tend to move quickly. This page describes the initial setup.

== Getting Started ==

A nice introduction to PyMca is available at The PyMca sourcecode and application binaries have been published at 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. Please abide by the terms of the PyMca license, which is included in the download.

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.

== Opening Your Files ==

Our data are stored in files created by spec. The standard spec file format can be opened by PyMca, and an example file is available here. Run PyMca (or pymca) and open your data file using either of the two folder buttons. You may need to change the file type to ''All files (star)'' to make your files visible. Select your file and click ''Open''. In the !SpecFile tab, you should see a list of all the scans present in the file. Click on a scan to inspect it. Next, click on the mca tab and double click on an MCA spectra to plot it in the plot window.

== Determining The Detector Calibration ==

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

Note for XRF users (UTEP students):

if your data was obtained with XRF with the MET 3000 portable analyzer, it is convenient to use the x ray tube own source for calibration, i.e. the Ag KL3 (0.54112) peak that appears around channel 1106 and corresponds to about 22.2 eV. Click on figure to the right to see the Ag peak.

== Fitting The Data ==

To start, click the log button above the plot window. In the plot window, 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 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).

Note for XRF users (UTEP students):

Use the cfg file for ceramics.

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.

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. Set the zero and gain settings according to your earlier calibration results.

Finally, go to the ''CONCENTRATIONS'' tab. Select the ''From fundamental Parameters'' checkbox, and enter the photon flux on sample, measurement time, active area of your detector, and the distance between the sample and the detector.

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 ''Peaks 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 go 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 or later, a concentrations summary file is created, which you can import into a spreadsheet program like Excel. A webpage will appear on your screen. To speed things up, copy the detector parameters from the HTML report into the ''DETECTOR'' tab of your configuration settings, and check the ''Fixed'' boxes. This can greatly speed up the fitting process.

== Batch Processing ==

If you have a number of samples that can all be modeled with that same cfg file, 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.

  • No labels