Fitting and Quantification with PyMCA DISCLAIMER: This is not “an official” guide (ie nothing to do with Armando). It is an inhouse user guide for Diamond’s I18 beamline. It would be an extra bonus if it helped others that need some tips to get started however you have to keep in mind that this guide is not intensively maintained therefore there might be (small) errors, references to old pymca versions and various oversights. This guide is for quantification of elements, however as peak fitting is a prerequisite the steps for fitting are also described here. For more details –useful screenshots and tutorialsgo to the following pages : http://wiki.utep.edu/display/MASE6402MME4501/PyMCA+support http://pymca.sourceforge.net/documentation.html To start with you load the map and that allows you to display the total mca (XRF spectrum) : Use the “ROI Imaging” tool to load a sum spectrum (this is a total spectrum from all pixels so you can use it to test fitting but not for quantification). It is always a good idea to also test your configuration file on single pixel mcas, see page 2 how to select those. So : Tools : ROI Imaging: Go to Experiment_1/nexus folder…..File types: HDF5…Select the .nxs map file. You then expand the file (click on +)…Expand entry1…expand Xspress 2system (or Xmap or Xspress3)…2ble click on allElementSum…that moves it to the lower field and you tick Signals …and Finish Calibrate channel number to Energy (for this you need the tutorial) Go to “Fit” …” Advanced” : This is where you define the configuration for peak fitting, experimental setup, sample description etc. o Click “E” to go back to energy axis o Press “Configure”. Here you define the fit parameters, the experimental set-up and the sample characteristics. 1. “Fit” tab: 1 You want to tick “Stripping” the background, you may want to include detector artefacts like “Escape” peaks and you may or not want to fit the “Scatter” peak (more difficult to fit than the XRF peaks so really you only need to include it if a) you have an XRF peak close to it therefore the background is distorted) or b) if you are using the scatter peak for normalisation purposes). Try different peak tail approximations. Try different “Continua” only if the default doesn’t work for you. Change the “Strip Background” iteration to something like 5000 as 20K is over the top and it will slow down batch fitting. 2. “Detector” tab : If you do want to fit Escape peaks you have to change the detector material. The calibration gain and offset have been already picked up from previous steps but when you do a fit they move slightly to match the expected XRF peaks. This is usually helpful but if you don’t want it tick “Fixed”. You may also want to adjust the Detector Noise to something bigger than the default eg 0.2 3. “Beam” : Tick “Energy 0” and enter the value of exciting beam energy in keV. You only need this if you are going to fit the scatter peak and/or if you are going to do quantification. 4. “Peaks” : Select the elements you want to fit and others that may affect the background even if you are not interested in it (eg big Ar peak next to small S peak). You need to click on the element and on the line (K, L etc…there are small differences between selecting K or Kα and Kβ, best practice is to be consistent). 5. “Peak Shape” : You may want to try different peak shapes and see what fits best. You can explore the fitting configuration by working on the Sum mca but it is always good to test it on a few individual pixel mcas before doing a batch fit. To select one pixel use the following buttons on the top right of window where the map is displayed: With a brush of one pixel width click on a pixel on a map and then ADD MCA. This will appear in the main window below the Stack Sum spectrum and it will usually be called Stack ICR selection. You may not see it unless you Log the display. Select the single pixel mca by clicking on Stack ICR selection to make it active (black) and then Fit. If you are going 2 to be comparing mcas from different pixels you need to be Resetting and Erasing selections in between. For batch fitting go to the “Main Pymca” window and from “Tools” select “Batch Fitting”. You then need to enter the input file, the fit folder which you have created and the configuration you saved. In most cases you don’t need to tick any of the non-default choices. If all you want is peak fitting that’s as far you need to go. You then “Ok” and “Fit Again”. Inspect and go back and change if necessary. The configuration file can be Saved and then Loaded for another map. Quantification For quantification you will use the remaining tabs in “Configuration”. You will need to describe both the reference material and your sample in terms of main composition, density and thickness. You also need to describe parts of the experimental setup and then you can calculate the flux on the ref mat for good agreement between nominal and measured concentrations. You then use a spectrum from the unknown sample, define it, describe any changes to the setup and then use the photon flux you calculated earlier to get an estimate of the levels of the elements of interest. Start by loading the reference material map (tools: ROI Imaging) and then select one pixel mca (as shown in page 2). Provided it is uniform you can take any spectrum, if it’s not uniform then it possibly isn’t a good reference material. The peak fitting parameters you determined in the previous steps of the configuration file should still produce a good fit on the single spectrum. Now continue with the quantification related tabs. 6. “Attenuators” : For quantification it is important to declare all materials between the sample and the detector, including these. “Filters” are in reality anything between the sample and the detector eg sample holder windows etc. You need to select them and give the thickness and the density if not already in the database (single elements and some materials commonly used for x-ray windows exist in the database but you need to check). “Beamfilters” refer to attenuation (usually Al) you put in the beam before the sample. These should only go in the beamfilters positions while all the other filters you define after 3 the sample –apart from the sample itself and the detector- can go in any position and do not have to be specifically related to the default name given as the manner in which they are used in the calculations is identical. The software recognises chemical symbols and will automatically input their density. For composite materials you need to define them in the Material Editor and then select them. “Matrix” is where you define the sample (or reference material ). If the material doesn’t already exist in the drop-down menu you need to create it first in the “Material Editor”: - In the “Material” field give it a name - Enter number of compounds and each chemical symbol with its mass fraction. You can also enter chemical formulas (if you load the already existing Goethite you will see how formulas need to be entered) - Enter default density and thickness although you can also edit these from the Attenuators fields. - To be able to select your new material in the “Attenuators “: “Matrix” you need to first “Save” and then “Load” the configuration file and then you should be able to see it in the drop-down menus in the “Attenuators”. NB: The elements you need to make sure you define in the matrix are the main constituents as they determine how the XRF signal from the elements of interest gets attenuated by the sample matrix. Often these main elements are invisible in terms of XRF signal eg C, O, H, N but sometimes they are also present in the X-ray spectrum eg Fe in Fe2O3. Generally speaking if the elements of interest are not present in large quantities they don’t need to be given in the sample description however if they exist in non-trace levels they may influence the calculated levels of the others. It may be best to check this eg by comparing the calculated levels when the matrix includes the element of interest that is in substantial amounts and when it doesn’t (eg for levels > 0.5 %). “Filters” you will always have : “Atmosphere “: Air is already defined and selectable but you can also type He. “Filter4 “ : Window –of the detector- : Be for all detectors but : 0.00125 cm thick for the Vortex, 0.003 cm for SGX and 0.0125cm for the Xspress. “Detector” : Si: 0.035 cm thick for the Vortex , Si: 0.045 cm thick for SGX and Ge : 0.75cm thick for Xspress 4 7. “Matrix” : Define incoming and outgoing angles –the defaults 45° are what is also used on the beamline by default. As shown, the matrix definition is only necessary for specific applications of multilayered materials. 8. “Concentrations” : - Use the default “Fundamental Parameters”. The “Matrix composition” is useful when you have an “internal standard” ie an element other than the unknown for which you have reliable concentration data…. - Input Measuring “time”, Sample Detector “Distance” (SDD) and detector “Active area” : 1.7 cm2 for the Vortex, 5.3 cm2 for the SGX and 4.0 cm2 for the Xspress. NB: If you do change SDD between measurements entering the right numbers changes results as expected (signal ~1/R2) but you could have errors introduced from the fact that different detector elements could be receive relatively more or less by signal due to their relative geometry to the sample. - Adjust the Photon “Flux” to get the correct quantities of the known material. You can then use this flux to predict the quantities in the unknown samples provided you are careful to update the other parameters such as SDD, time, and anything in the “Attenuator” fields that may be different between sample and reference material. PyMCA is using two different types of concentration, “Mass Fractions” (MF) by default and “Molar” if you select it. The MF approach is much more flexible it basically means any w/w unit you want (ppm, % etc) but it can also be used for other mass expressions eg area density which is how thin film standards are usually characterised. However with such use you have to be careful on how you translate the results for materials that are not thin (see section on AXO-Reference Material). Do a “Fit again” and see what concentrations PyMCA has calculated. Adjust the “Flux” to get the right numbers. You can then use this flux for the unknown samples - Remember to “Save” the configuration file. - Click on “HTML Report” to produce a number of files that contain concentration, peak fitting parameters and configuration. 5 - If you want to get the concentrations of each pixel of a map you need to do a “Batch fit” but include the “Concentrations” in the selected choices. Use of the thin-film AXO Reference Material This thin film reference material is composed of seven layers of different metals (Ca to Mo) and the given quantities for those are in ng/mm2 (see table). As for most real samples this unit is not very useful we have translated the AXO quantities into ppm. That means that you can then convert the unknown concentrations calculated by Pymca to w/w using the density of your material (to express ppm as MF divide by density of the compound). You don’t need to have the same elements in your samples as in the AXO as long as at least one of the AXO elements has an XRF peak in the same mca/energy region where the sample peaks are. As defining the AXO reference material is a bit more elaborate than most samples there are two configuration files Ge_AXO and Si_ AXO (first for Xspress second for Vortex) in I18/AXO_Config that already have the AXO parameters in (in “Attenuators” the Matrix is Multilayer, which is defined in the “Matrix” tab). NB : Loading these configuration files will set many other parameters throughout the configuration that don’t necessarily apply to your data so you really should go through every tab and change everything according to your experiment. The various Attenuators definitely need checking as does the energy calibration since the one within the detector configuration files you have loaded may have been based on a very different energy range to yours. The expected concentrations for the AXO are in the following table but bear in mind that only the ng/mm2 are “certified” by the manufacturers; the ppm values have been calculated in-house based on individual layer thicknesses provided by the company but not necessarily as accurately measured as the nominal concentrations: Energy keV ng/mm2 ppm Pd Lα: 2.84 Kα: 21.0 Ca Kα: 3.69 La Lα :4.65 Fe Kα: 6.40 Cu Kα:8.05 Pb Lα :10.55 Mo Kα : 17.45 1.8 19.31 11.01 5.04 2.84 7.61 1.32 4.41E+05 2.71E+05 3.42E+05 2.23E+05 2.25E+05 3.22E+05 3.00E+05 Depending on the excitation energy you use you will have some of these metals and only those should be included in the “Peaks” to be fitted. 6 As described in the previous section you adjust the flux until you get approximately correct AXO concentrations and then use this Flux for your samples. You can then Batch fit to get the concentrations in every pixel of a map. As this is a material to be used when there are no matrix-matching reference materials it will not be very accurate for absolute levels of all elements, all matrices and all ranges of concentrations (generic XRF quantification without appropriate standards or without matching matrices rarely is very accurate). However you can get an acceptable ball-park figure and then it will be reasonably good at predicting relative levels between elements and changes of concentrations for different measurement conditions. 7