xrf Package¶
ClassMcaTheory
Module¶
-
class
PyMca5.PyMcaPhysics.xrf.ClassMcaTheory.
ClassMcaTheory
(initdict=None, filelist=None, **kw)[source]¶
-
class
PyMca5.PyMcaPhysics.xrf.ClassMcaTheory.
McaTheory
(initdict=None, filelist=None, **kw)[source]¶ Bases:
object
-
analyticalDerivative
(self, parameters, index, x)[source]¶ Internal function to calculate the derivative of the fitting function f(parameters, x) respect to the parameter given by the index at the array of points x.
-
getPeakMatrixContribution
(param0, t0=None, hypermet=None, continuum=None, summing=None)[source]¶ For the time being a huge copy paste from mcatheory
-
setConfiguration
(ddict)[source]¶ The current fit configuration dictionary is updated, but not replaced, by the input dictionary. It returns a copy of the final fit configuration.
-
setData
(*var, **kw)[source]¶ Method to update the data to be fitted. It accepts several combinations of input arguments, the simplest to take into account is:
setData(x, y sigmay=None, xmin=None, xmax=None)
x corresponds to the spectrum channels y corresponds to the spectrum counts sigmay is the uncertainty associated to the counts. If not given,
Poisson statistics will be assumed. If the fit configuration is set to no weight, it will not be used.- xmin and xmax define the limits to be considered for performing the fit.
- If the fit configuration flag self.config[‘fit’][‘use_limit’] is set, they will be ignored. If xmin and xmax are not given, the whole given spectrum will be considered for fitting.
- time (seconds) is the factor associated to the flux, only used when using
- a strategy based on concentrations
-
CoherentScattering
Module¶
-
PyMca5.PyMcaPhysics.xrf.CoherentScattering.
getElementCoherentDifferentialCrossSection
(ele, theta, energy, p1=None)[source]¶
-
PyMca5.PyMcaPhysics.xrf.CoherentScattering.
getElementFormFactor
(ele, theta, energy)[source]¶ - Usage:
- getFormFactor(ele,theta, energy):
ele - Element theta - Scattering angle or array of scattering angles in degrees energy- Photon Energy in keV
This routine calculates the atomic form factor in electron units using a four gaussians approximation
ConcentrationsTool
Module¶
ElementHtml
Module¶
Elements
Module¶
-
class
PyMca5.PyMcaPhysics.xrf.Elements.
BoundMethodWeakref
(bound_method, onDelete=None)[source]¶ Helper class to get a weakref to a bound method
-
PyMca5.PyMcaPhysics.xrf.Elements.
getElementCoherentDifferentialCrossSection
(ele, theta, energy, p1=None)[source]¶
-
PyMca5.PyMcaPhysics.xrf.Elements.
getElementComptonDifferentialCrossSection
(ele, theta, energy, p1=None)[source]¶
-
PyMca5.PyMcaPhysics.xrf.Elements.
getElementIncoherentScatteringFunction
(ele, theta, energy)[source]¶
-
PyMca5.PyMcaPhysics.xrf.Elements.
getElementLShellRates
(symbol, energy=None, photoweights = None)[source]¶ gives LShell branching ratios at a given energy weights due to photoeffect, fluorescence and Coster-Kronig transitions are calculated and used unless photoweights is False, in that case weights = [1.0, 1.0, 1.0, 1.0, 1.0]
-
PyMca5.PyMcaPhysics.xrf.Elements.
getElementMShellRates
(symbol, energy=None, photoweights = None)[source]¶ gives MShell branching ratios at a given energy weights due to photoeffect, fluorescence and Coster-Kronig transitions are calculated and used unless photoweights is False, in that case weights = [1.0, 1.0, 1.0, 1.0, 1.0]
-
PyMca5.PyMcaPhysics.xrf.Elements.
getEscape
(matrix, energy, ethreshold=None, ithreshold=None, nthreshold=None, alphain=None, cascade=None, fluorescencemode=None)[source]¶ - getEscape(matrixlist, energy,
- ethreshold=None, ithreshold=None, nthreshold = None, alphain = None)
matrixlist is a list of the form [material, density, thickness] energy is the incident beam energy ethreshold is the difference in keV between two peaks to be considered the same ithreshold is the minimum absolute peak intensity to consider nthreshold is maximum number of escape peaks to consider alphain is the incoming beam angle with detector surface It gives back a list of the form [[energy0, intensity0, label0],
[energyn, intensityn, labeln]]with the escape energies, intensities and labels
-
PyMca5.PyMcaPhysics.xrf.Elements.
getFluorescence
(matrix, energy, attenuators=None, alphain=None, alphaout=None, elementsList=None, cascade=None, detector=None, funnyfilters=None, userElementDict=None, matrixmutotalfluorescence=None, matrixmutotalexcitation=None)[source]¶ - getFluorescence(matrixlist, energy, attenuators = None, alphain = None, alphaout = None,
- elementsList = None, cascade=None, detector=None)
matrixlist is a list of the form [material, density, thickness] energy is the incident beam energy attenuators is a list of the form [[material1, density1, thickness1],....] alphain is the incoming beam angle with sample surface alphaout is the outgoing beam angle with sample surface if a given elements list is given, the fluorescence rate will be calculated for ONLY for those elements without taking into account if they are present in the matrix and considering a mass fraction of 1 to all of them. This should allow a program to fit directly concentrations. cascade is a flag to consider vacancy propagation (it is a crude approximation) detector is just one attenuator more but treated as (1 - Transmission)
[material, density, thickness]These formulae are strictly valid only for parallel beams. Needs to be corrected for detector efficiency (at least solid angle) and incoming intensity. Secondary transitions are neglected.
-
PyMca5.PyMcaPhysics.xrf.Elements.
getLJumpWeight
(ele, excitedshells=[1.0, 1.0, 1.0])[source]¶ wjump represents the probability for a vacancy to be created on the respective L-Shell by direct photoeffect on that shell
-
PyMca5.PyMcaPhysics.xrf.Elements.
getLWeights
(ele, energy=None, normalize=None, shellist=None)[source]¶
-
PyMca5.PyMcaPhysics.xrf.Elements.
getMJumpWeight
(ele, excitedshells=[1.0, 1.0, 1.0, 1.0, 1.0])[source]¶ wjump represents the probability for a vacancy to be created on the respective M-Shell by direct photoeffect on that shell
-
PyMca5.PyMcaPhysics.xrf.Elements.
getMWeights
(ele, energy=None, normalize=None, shellist=None)[source]¶
-
PyMca5.PyMcaPhysics.xrf.Elements.
getMaterialMassAttenuationCoefficients
(compoundList0, fractionList0, energy0=None, massfractions=False)[source]¶ - Usage:
- getMaterialMassAttenuationCoefficients(compoundList, fractionList,
- energy = None,massfractions=False)
compoundList - List of compounds into the material fractionList - List of masses of each compound energy - Energy at which the values are desired massfractions- Flag to supply mass fractions on output
-
PyMca5.PyMcaPhysics.xrf.Elements.
getMaterialTransmission
(compoundList0, fractionList0, energy0=None, density=None, thickness=None, listoutput=True)[source]¶ Usage: getMaterialTransmission(compoundList, fractionList, energy = None,
density=None, thickness=None):Input
compoundlist - List of elements, compounds or materials fractionlist - List of floats indicating the amount of respective material energy - Photon energy (it can be a list) density - Density in g/cm3 (default is 1.0) thickness - Thickness in cm (default is 1.0)
The product density * thickness has to be in g/cm2
Output
Detailed dictionary.
-
PyMca5.PyMcaPhysics.xrf.Elements.
getMultilayerFluorescence
(multilayer0, energyList, layerList=None, weightList=None, flagList=None, fulloutput=None, beamfilters=None, elementsList=None, attenuators=None, alphain=None, alphaout=None, cascade=None, detector=None, funnyfilters=None, forcepresent=None, secondary=None)[source]¶
-
PyMca5.PyMcaPhysics.xrf.Elements.
getPhotoWeight
(ele, shelllist, energy, normalize=None, totals=None)[source]¶
-
PyMca5.PyMcaPhysics.xrf.Elements.
getScattering
(matrix, energy, attenuators=None, alphain=None, alphaout=None, elementsList=None, cascade=None, detector=None)[source]¶
-
PyMca5.PyMcaPhysics.xrf.Elements.
getelementmassattcoef
(ele, energy=None)[source]¶ - Usage: getelementmassattcoef(element symbol, energy in kev)
It gets the info from files generated by XCOM If energy is not given, it gives back a dictionary with the form:
dict[‘energy’] = [energies] dict[‘coherent’] = [coherent scattering cross section(energies)] dict[‘compton’] = [incoherent scattering cross section(energies)] dict[‘photo’] = [photoelectic effect cross section(energies)] dict[‘pair’] = [pair production cross section(energies)] dict[‘total’] = [total cross section]
-
PyMca5.PyMcaPhysics.xrf.Elements.
getmassattcoef
(compound, energy=None)[source]¶ - Usage: getmassattcoef(element symbol/composite, energy in kev)
- Computes mass attenuation coefficients for a single element or a compound.
It gets the info from files generated by XCOM If energy is not given, it gives back a dictionary with the form:
dict[‘energy’] = [energies] dict[‘coherent’] = [coherent scattering cross section(energies)] dict[‘compton’] = [incoherent scattering cross section(energies)] dict[‘photo’] = [photoelectic effect cross section(energies)] dict[‘pair’] = [pair production cross section(energies)] dict[‘total’] = [total cross section]
- A compound is defined with a string as follow:
‘C22H10N2O5’ means 22 * C, 10 * H, 2 * N, 5 * O
xsection = SUM(xsection(zi)*ni*ai) / SUM(ai*ni)
zi = Z of each element ni = number of element zi ai = atomic weight of element zi
Result in cm2/g
FastXRFLinearFit
Module¶
FisxHelper
Module¶
-
PyMca5.PyMcaPhysics.xrf.FisxHelper.
getElementsInstance
(dataDir=None, bindingEnergies=None, xcomFile=None)[source]¶
-
PyMca5.PyMcaPhysics.xrf.FisxHelper.
getFisxCorrectionFactorsFromFitConfiguration
(fitConfiguration, elementsFromMatrix=False, secondaryCalculationLimit=0.0)[source]¶
-
PyMca5.PyMcaPhysics.xrf.FisxHelper.
getFisxCorrectionFactorsFromFitConfigurationFile
(fileName, elementsFromMatrix=False, secondaryCalculationLimit=0.0)[source]¶
-
PyMca5.PyMcaPhysics.xrf.FisxHelper.
getMultilayerFluorescence
(multilayerSample, energyList, layerList=None, weightList=None, flagList=None, fulloutput=None, beamFilters=None, elementsList=None, attenuatorList=None, alphaIn=None, alphaOut=None, cascade=None, detector=None, elementsFromMatrix=False, secondary=None, materials=None, secondaryCalculationLimit=0.0)[source]¶
GenerateXCOMCrossSections
Module¶
Generate specfile from XCOM generated files
IncoherentScattering
Module¶
-
PyMca5.PyMcaPhysics.xrf.IncoherentScattering.
getElementComptonDifferentialCrossSection
(ele, theta, energy, p1=None)[source]¶
-
PyMca5.PyMcaPhysics.xrf.IncoherentScattering.
getElementComptonFormFactor
(ele, theta, energy)[source]¶
-
PyMca5.PyMcaPhysics.xrf.IncoherentScattering.
getElementIncoherentDifferentialCrossSection
(ele, theta, energy, p1=None)¶
-
PyMca5.PyMcaPhysics.xrf.IncoherentScattering.
getElementIncoherentScatteringFunction
(ele, theta, energy)[source]¶ - Usage:
- getIncoherentScatteringFunction(ele,theta, energy):
ele - Element theta - Scattering angle in degrees energy- Photon Energy in keV
This routine calculates the incoherent scattering function in electron units an interpolation to EGS4 tabulation of S(x,Z)/Z
KShell
Module¶
LShell
Module¶
MShell
Module¶
McaAdvancedFitBatch
Module¶
-
class
PyMca5.PyMcaPhysics.xrf.McaAdvancedFitBatch.
McaAdvancedFitBatch
(initdict, filelist=None, outputdir=None, roifit=None, roiwidth=None, overwrite=1, filestep=1, mcastep=1, concentrations=0, fitfiles=1, fitimages=1, filebeginoffset=0, fileendoffset=0, mcaoffset=0, chunk=None, selection=None, lock=None)[source]¶ Bases:
object
PyMcaEPDL97
Module¶
Interface to the PyMca EPDL97 description
-
PyMca5.PyMcaPhysics.xrf.PyMcaEPDL97.
getElementCrossSections
(element, energy, forced_shells=None)[source]¶ Returns total and partial cross sections of element at the specified energies. If forced_shells are not specified, it uses the internal binding energies of EPDL97 for all shells. If forced_shells is specified, it enforces excitation of the relevant shells via log-log extrapolation if needed.
-
PyMca5.PyMcaPhysics.xrf.PyMcaEPDL97.
getPhotoelectricWeights
(element, shelllist, energy, normalize=None, totals=None)[source]¶ Given a certain list of shells and one excitation energy, gives back the ratio mu(shell, energy)/mu(energy) where mu refers to the photoelectric mass attenuation coefficient. The special shell “all others” refers to all the shells not in the K, L or M groups. Therefore, valid values for the items in the shellist are:
‘K’, ‘L1’, ‘L2’, ‘L3’, ‘M1’, ‘M2’, ‘M3’, ‘M4’, ‘M5’, ‘all other’For instance, for the K shell, it is the equivalent of (Jk-1)/Jk where Jk is the k jump. If normalize is None or True, normalizes the output to the shells given in shelllist. If totals is True, gives back the a dictionnary with all the mass attenuation coefficients used in the calculations.
-
PyMca5.PyMcaPhysics.xrf.PyMcaEPDL97.
setElementBindingEnergies
(element, ddict)[source]¶ Allows replacement of the element internal binding energies by a different set of energies. This is made to force this implementaticon of EPDL97 to respect other programs absorption edges. Data will be extrapolated when needed. WARNING: Coherent resonances are not replaced.
Scofield1973
Module¶
SingleLayerStrategy
Module¶
-
class
PyMca5.PyMcaPhysics.xrf.SingleLayerStrategy.
SingleLayerStrategy
[source]¶ Bases:
object
-
applyStrategy
(fitResult, fluorescenceRates, currentIteration=None)[source]¶ Provided a fit result, it returns an new fit configuration and a positive integer to indicate the strategy procedure has not finished.
Returning an empty fit configuration, or a number of iterations equal 0 will indicate the process is over.
-
Strategies
Module¶
XRayTubeEbel
Module¶
-
PyMca5.PyMcaPhysics.xrf.XRayTubeEbel.
characteristicEbel
(target, e0, window=None, alphae=None, alphax=None, transmission=None, targetthickness=None, filterlist=None)[source]¶ Calculation of target characteritic lines and intensities
- target : list [Symbol, density (g/cm2), thickness(cm)] or atomic ymbol
- If set to atomic symbol, the program sets density and thickness of 0.1 cm
- e0 : float
- Tube Voltage in kV
- e : float
- Energy of interest
- window : list
- Tube window [Formula, density, thickness]
- alphae : float
- Angle, in degrees, between electron beam and tube target. Normal incidence is 90.
- alphax : float
- Angle, in degrees, of X-ray exit beam. Normal exit is 90.
- transmission : Boolean, default is False
- If True the X-ray come out of the tube target by the side opposite to the one receiving the exciting electron beam.
- targetthickness : Target thickness in cm
- Only considered in transmission case. If not given, the program uses as target thickness the maximal penetration depth of the incident electron beam.
- filterlist : [list]
- Additional filters [[Formula, density, thickness], ...]
- Result: list
- Characteristic lines and intensities in the form [[energy0, intensity0, name0], [energy1, intensity1, name1], ...] Energies in keV Intensities in photons/sr/mA/keV/s
-
PyMca5.PyMcaPhysics.xrf.XRayTubeEbel.
continuumEbel
(target, e0, e=None, window=None, alphae=None, alphax=None, transmission=None, targetthickness=None, filterlist=None)[source]¶ Calculation of X-ray Tube continuum emission spectrum
- target : list [Symbol, density (g/cm2), thickness(cm)] or atomic ymbol
- If set to atomic symbol, the program sets density and thickness of 0.1 cm
- e0 : float
- Tube Voltage in kV
- e : float or array of floats
- Energy of interest. If not given, the program will generate an array of energies from 1 to the given tube voltage minus 1 kV in keV.
- window : list
- Tube window [Formula, density, thickness]
- alphae : float
- Angle, in degrees, between electron beam and tube target. Normal incidence is 90.
- alphax : float
- Angle, in degrees, of X-ray exit beam. Normal exit is 90.
- transmission : Boolean, default is False
- If True the X-ray come out of the tube target by the side opposite to the one receiving the exciting electron beam.
- targetthickness : Target thickness in cm
- Only considered in transmission case. If not given, the program uses as target thickness the maximal penetration depth of the incident electron beam.
- filterlist : [list]
- Additional filters [[Formula, density, thickness], ...]
- result : Array
- Spectral flux density. Flux of photons at the given energies in photons/sr/mA/keV/s
- Reference:
- H. Ebel, X-Ray Spectrometry 28 (1999) 255-266 Tube voltage from 5 to 50 kV Electron incident angle from 50 to 90 deg. X-Ray take off angle from 90 to 5 deg.
-
PyMca5.PyMcaPhysics.xrf.XRayTubeEbel.
generateLists
(target, e0, window=None, alphae=None, alphax=None, transmission=None, targetthickness=None, filterlist=None)[source]¶ Generate a theoretical X-Ray Tube emission profile
- target : list [Symbol, density (g/cm2), thickness(cm)] or atomic ymbol
- If set to atomic symbol, the program sets density and thickness of 0.1 cm
- e0 : float
- Tube Voltage in kV
- window : list
- Tube window [Formula, density, thickness]
- alphae : float
- Angle, in degrees, between electron beam and tube target. Normal incidence is 90.
- alphax : float
- Angle, in degrees, of X-ray exit beam. Normal exit is 90.
- transmission : Boolean, default is False
- If True the X-ray come out of the tube target by the side opposite to the one receiving the exciting electron beam.
- targetthickness : Target thickness in cm
- Only considered in transmission case. If not given, the program uses as target thickness the maximal penetration depth of the incident electron beam.
- filterlist : [list]
- Additional filters [[Formula, density, thickness], ...]
- result : Tuple
- [Array of Energies, Array of relative intensities, Array of flags] Flag set to 1 means it is a target characteristic energy Flag set to 0 means it corresponds to a continuum energy