Fitting and Quantification with PyMCA

tobascothwackUrban and Civil

Nov 15, 2013 (3 years and 6 months ago)

1,145 views



1


Fitting and
Quantification with PyMCA


This guide is for quantification of elements, however as peak fitting is a prerequisite the
steps for fitting are also described here.
This is not a full and complete guide so it’s worth
having a look at

the following

pages
:

http://wiki.utep.edu/display/MASE6402MME4501/PyMCA+support

http://pymca.sourceforge.net/documentation.html


To
start with you load the edf files of a 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 quantificatio
n)

:

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
xmapMca

(or
Xspress)
…2ble click on
allElementSum
…that moves it to the lower field and you tic
k
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 a
xis

o

Press

Configure

. Here you define the fit parameters, the experimental set
-
up
and the sample characteristics.

1.



Fit


tab
:

You want to
tick

Strip
ping


the background, you may want to include detector artefacts
like

Escape


peaks and you may or not w
ant 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 th
e top and it will slow down

batch fitting.

2.


Detector


tab :



2


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 the
y

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 o
nly 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 et
c…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.

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.


For
b
atch

fitting

go to the

Main Pymca


window and from

Tools


select
“Batch Fitting”
.
You then find the edf folder, 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.


Quantification

For
quantification
you
will use the
remaining

tabs
in “
Configuration

but

to test that you
are getting

reasonable results before quantifying the whole map

you
need to load a single
pixel mca
rather than the sum mca you have been working with up to now.

For Old Files (edf):

From the main Pymca window you need to find the “open

file
” symbol, there are two,
one
at the very top and a second one further down
-
left, that’s the one you want. Find the edf
folder and o
pen

an edf file. As this is a stack of all mcas in a row you then need to select
one spectrum from those and you do that from the drop
-
down menu at “I
mage”. You then
click on “Row 0” and Row field and then you “add”. In the spectrum display you now have


3


a single mca (although as it will be much lower counts than the total mca to be able to see
it you make have to click “log” a couple of times or delete
the sum spectrum ).

For New Files (.nxs) :

I have not found a neat way to select a pixel in a very accurate manner but you can use the
GUI icons on top right of the window displaying the map (above ICR):

-
Click on Rectangular selection

-
then on Brush Selec
tion

-
then on Select brush : 1 image pixel width and then click on a pixel. That will add the mca
to the main window mca view. As it will be much lower counts than the total mca to be
able to see it you make have to click “log” a couple of times or delete
the sum spectrum.

To click on another pixel you have to make sure you erase the previous selection otherwise
the mcas will be added up. So:

-
Click on Reset

-
then on Erase selection

-
then go through the previous sequence to select another pixel.

To do quant
ification with Pymca you first deal with a spectrum from the reference material
(provided it is uniform you can take any spectrum, if it’s not uniform then it possibly isn’t a
good reference material). You describe this material in terms of main compositio
n
, density
and thickness. You also need to describe parts of

the experimental setup

and then

you can
calculate the flux on the sample for good agreement between nominal and measured
concentrations. You then use a spectrum from the unknown sample, describe

it if different
from the reference material, describe any changes to the setup and then use the photon
flux you calcu
la
ted earlier to get an estimate of the levels of the elements of interest.


The

peak fitting

parameters you determined in the previous st
eps 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, i
ncluding these.



4


“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
the s
ample


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 symbol
s and will automatically input their density. For
composite materials you need to define them in the Mater
ial 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
-
d
own menu you need to cre
ate 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 Goethit
e 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

Loa
d


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.



5




“Filter4 “ : Window

of t
he detector
-

: Be
for both detectors
but it’s 0.00125 cm
thick for the Vortex and 0.0125cm for the Xspress.



“Detector” : Ge : 0.75cm thick for Xspress and Si: 0.035 cm thick for the Vortex.


7.


Matrix


:

De
f
i
ne incom
i
ng

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


: 170 mm
2
for the Vortex and 400 mm
2

for the Xspress.

NB: If you do change SDD between measurements
entering

the right numbers
changes

results as expected (signal ~1/R
2
) but you could have errors introduced from the fact that
different detector elements could be
receive relatively

more or less by signal due t
o their
relative geometry to the sample.


-

Adjust the
Photon

F
lux


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 trans
late the results for materials

that are not thin
(see
section on AXO
-
Reference Material)
.

You haven’t got the same flexibility with

MF in the

Material Editor
” as

these
can only be mass fractions (totalling 1)

and not ppm or %.


I have not tested the

Mola
r


option.



6


-

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 nu
mber of files that contain
concentration, peak fitting parameters and configuration.

-

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.