示例#1
0
def radrate(element,line):
    """
    
    Get the Fractional Radiative rate for a line using the xraylib backend
    
    Parameters:
        Element : Name, Symbol or Atomic Number (Z) as input
        Line    : Accepts Siegbahn and line notations
                : line can be one of the following
                
                For line averages:
                'ka','lb','l1','l2','l3','la','lb','lg',
                
                or for the exact lines
                
                'ka1', 'ka2', 'ka3','kb1', 'kb2', 'kb3','kb4','kb5',
                'la1', 'la2', 'lb1', 'lb2', 'lb3', 'lb4', 'lb5',
                'lg1', 'lg2', 'lg3', 'lg4', 'll', 'ln',
                'ma1','ma2','mb','mg'
                    
    Returns:
        radrate  :  the Fractional Radiative rate 
    
    """
    z = elementDB[element]["Z"]
    if not isinstance(line,LinePair):
        line = _lookupxlsubline(line)
    return xraylib.RadRate(z,line.subline)
示例#2
0
xraylib.XRayInit()
xraylib.SetErrorMessages(0)
print("Example of python program using xraylib")
print("xraylib version: {}".format(xraylib.__version__))
print("Density of pure Al : {} g/cm3".format(xraylib.ElementDensity(13)))
print("Ca K-alpha Fluorescence Line Energy: {}".format(
    xraylib.LineEnergy(20, xraylib.KA_LINE)))
print("Fe partial photoionization cs of L3 at 6.0 keV: {}".format(
    xraylib.CS_Photo_Partial(26, xraylib.L3_SHELL, 6.0)))
print("Zr L1 edge energy: {}".format(xraylib.EdgeEnergy(40, xraylib.L1_SHELL)))
print("Pb Lalpha XRF production cs at 20.0 keV (jump approx): {}".format(
    xraylib.CS_FluorLine(82, xraylib.LA_LINE, 20.0)))
print("Pb Lalpha XRF production cs at 20.0 keV (Kissel): {}".format(
    xraylib.CS_FluorLine_Kissel(82, xraylib.LA_LINE, 20.0)))
print("Bi M1N2 radiative rate: {}".format(
    xraylib.RadRate(83, xraylib.M1N2_LINE)))
print("U M3O3 Fluorescence Line Energy: {}".format(
    xraylib.LineEnergy(92, xraylib.M3O3_LINE)))
print("Ca(HCO3)2 Rayleigh cs at 10.0 keV: {}".format(
    xraylib.CS_Rayl_CP("Ca(HCO3)2", 10.0)))

cdtest = xraylib.CompoundParser("Ca(HCO3)2")
print(
    "Ca(HCO3)2 contains {} atoms, {} elements and has a molar mass of {} g/mol"
    .format(cdtest['nAtomsAll'], cdtest['nElements'], cdtest['molarMass']))
for i in range(cdtest['nElements']):
    print("Element {}: %lf %% and {} atoms".format(
        cdtest['Elements'][i], cdtest['massFractions'][i] * 100.0,
        cdtest['nAtoms'][i]))

cdtest = xraylib.CompoundParser("SiO2")
示例#3
0
import sys, string
import xraylib
import math


if __name__ == '__main__' :
	xraylib.XRayInit()
	xraylib.SetErrorMessages(0)
	print ("Example of python program using xraylib")
	print ("Density of pure Al : %f g/cm3" % xraylib.ElementDensity(13))
	print ("Ca K-alpha Fluorescence Line Energy: %f" % xraylib.LineEnergy(20,xraylib.KA_LINE))
	print ("Fe partial photoionization cs of L3 at 6.0 keV: %f" % xraylib.CS_Photo_Partial(26,xraylib.L3_SHELL,6.0))
	print ("Zr L1 edge energy: %f" % xraylib.EdgeEnergy(40,xraylib.L1_SHELL))
	print ("Pb Lalpha XRF production cs at 20.0 keV (jump approx): %f" % xraylib.CS_FluorLine(82,xraylib.LA_LINE,20.0))
	print ("Pb Lalpha XRF production cs at 20.0 keV (Kissel): %f" % xraylib.CS_FluorLine_Kissel(82,xraylib.LA_LINE,20.0))
	print ("Bi M1N2 radiative rate: %f" % xraylib.RadRate(83,xraylib.M1N2_LINE))
	print ("U M3O3 Fluorescence Line Energy: %f" % xraylib.LineEnergy(92,xraylib.M3O3_LINE))
	print ("Ca(HCO3)2 Rayleigh cs at 10.0 keV: %f" % xraylib.CS_Rayl_CP("Ca(HCO3)2",10.0))

	cdtest = xraylib.CompoundParser("Ca(HCO3)2")
	print ("Ca(HCO3)2 contains %g atoms and %i elements"% (cdtest['nAtomsAll'], cdtest['nElements']))
	for i in range(cdtest['nElements']):
        	print ("Element %i: %lf %%" % (cdtest['Elements'][i],cdtest['massFractions'][i]*100.0))
		
	cdtest = xraylib.CompoundParser("SiO2")
	print ("SiO2 contains %g atoms and %i elements"% (cdtest['nAtomsAll'], cdtest['nElements']))
	for i in range(cdtest['nElements']):
        	print ("Element %i: %lf %%" % (cdtest['Elements'][i],cdtest['massFractions'][i]*100.0))
		

	print ("CS2 Refractive Index at 10.0 keV : %g - %g i" % (xraylib.Refractive_Index_Re("CS2",10.0,1.261),xraylib.Refractive_Index_Im("CS2",10.0,1.261)))
示例#4
0
import xraylib
import math
import numpy as np


xraylib.XRayInit()

print("Example of python program using xraylib")
print("xraylib version: {}".format(xraylib.__version__))
print("Density of pure Al : {} g/cm3".format(xraylib.ElementDensity(13)))
print("Ca K-alpha Fluorescence Line Energy: {}".format(xraylib.LineEnergy(20, xraylib.KA_LINE)))
print("Fe partial photoionization cs of L3 at 6.0 keV: {}".format(xraylib.CS_Photo_Partial(26, xraylib.L3_SHELL,6.0)))
print("Zr L1 edge energy: {}".format(xraylib.EdgeEnergy(40, xraylib.L1_SHELL)))
print("Pb Lalpha XRF production cs at 20.0 keV (jump approx): {}".format(xraylib.CS_FluorLine(82, xraylib.LA_LINE,20.0)))
print("Pb Lalpha XRF production cs at 20.0 keV (Kissel): {}".format(xraylib.CS_FluorLine_Kissel(82, xraylib.LA_LINE,20.0)))
print("Bi M1N2 radiative rate: {}".format(xraylib.RadRate(83, xraylib.M1N2_LINE)))
print("U M3O3 Fluorescence Line Energy: {}".format(xraylib.LineEnergy(92, xraylib.M3O3_LINE)))
print("Ca(HCO3)2 Rayleigh cs at 10.0 keV: {}".format(xraylib.CS_Rayl_CP("Ca(HCO3)2",10.0)))

cdtest = xraylib.CompoundParser("Ca(HCO3)2")
print("Ca(HCO3)2 contains {} atoms, {} elements and has a molar mass of {} g/mol".format(cdtest['nAtomsAll'], cdtest['nElements'], cdtest['molarMass']))
for i in range(cdtest['nElements']):
    print("Element {}: {} % and {} atoms".format(cdtest['Elements'][i], cdtest['massFractions'][i]*100.0, cdtest['nAtoms'][i]))

cdtest = xraylib.CompoundParser("SiO2")
print("SiO2 contains {} atoms, {} elements and has a molar mass of {} g/mol".format(cdtest['nAtomsAll'], cdtest['nElements'], cdtest['molarMass']))
for i in range(cdtest['nElements']):
    print("Element {}: {} % and {} atoms".format(cdtest['Elements'][i], cdtest['massFractions'][i]*100.0, cdtest['nAtoms'][i]))

print("CS2 Refractive Index at 10.0 keV : {} - {} i".format(xraylib.Refractive_Index_Re("CS2",10.0,1.261), xraylib.Refractive_Index_Im("CS2",10.0,1.261)))
print("C16H14O3 Refractive Index at 1 keV : {} - {} i".format(xraylib.Refractive_Index_Re("C16H14O3",1.0,1.2), xraylib.Refractive_Index_Im("C16H14O3",1.0,1.2)))
示例#5
0
def calc_escape_peak_ratios(lineE, detectorelement='Si'):
    """
    Calculate ratio of escape peak to main peak based on emperical calculation
    from Alves et. al. 

    Parameters
    ----------
    detectorelement : string
        "Si" or "Ge"
 
    Returns
    -------
    ratio of a single Si K escape peak to a single input peak 
    or
    ratio of Ge Ka, Kb escape peaks to a single input peak

    References
    ----------
    [1]
    "Experimental X-Ray peak-shape determination for a Si(Li) detector",
     L.C. Alves et al., Nucl. Instr. and Meth. in Phys. Res. B 109|110
    (1996) 129-133.  
    
    """

    if (detectorelement == 'Si'):
        #
        # For Si the K peak is 95% of the transition
        # and the photoionization to total cross section is ~ 95%
        # Si escape peak is typically only 0.2-1% (bigger at lower energies)
        #
        jump = xl.JumpFactor(14, xl.K_SHELL)
        fluy = xl.FluorYield(14, xl.K_SHELL)
        corr = fluy * (jump - 1.0) / jump
        corr_photo = xl.CS_Photo(14, lineE) / xl.CS_Total(14, lineE)
        corr_trans = xl.RadRate(14, xl.KA_LINE) + xl.RadRate(14, xl.KB_LINE)
        mu_si = xl.CS_Total(14, lineE)
        mu_internal = xl.CS_Total(14, 1.73998)
        r = mu_internal / mu_si
        eta = corr_trans * corr_photo * corr * 0.5 * (1.0 -
                                                      r * log(1.0 + 1.0 / r))
        ratio = eta / (1.0 - eta)
        #
        # escape peak sigma should be narrower than  the main peak.
        #
        return ratio
    else:
        #
        # Ge detector...
        # Ge has a large escape peak ratio ~ 5-15% and a Ka and kb component
        #
        if (lineE < 11.5):
            return 0.0, 0.0
        jump = xl.JumpFactor(32, xl.K_SHELL)
        fluy = xl.FluorYield(32, xl.K_SHELL)
        corr = fluy * (jump - 1.0) / jump
        corr_photo = xl.CS_Photo(32, lineE) / xl.CS_Total(32, lineE)
        corr_trans_ka = xl.RadRate(32, xl.KA_LINE)
        corr_trans_kb = xl.RadRate(32, xl.KB_LINE)
        mu_ge = xl.CS_Total(32, lineE)  #
        # one for the Ka and one for the Kb peak...
        mu_internal_ka = xl.CS_Total(32, xl.LineEnergy(32, xl.KA_LINE))
        r_ka = mu_internal_ka / mu_ge
        eta_ka = corr_trans_ka * corr_photo * corr * 0.5 * (
            1.0 - r_ka * log(1.0 + 1.0 / r_ka))
        ratio_ka = eta_ka / (1.0 - eta_ka)

        mu_internal_kb = xl.CS_Total(32, xl.LineEnergy(32, xl.KB_LINE))
        r_kb = mu_internal_kb / mu_ge
        eta_kb = corr_trans_kb * corr_photo * corr * 0.5 * (
            1.0 - r_kb * log(1.0 + 1.0 / r_kb))
        ratio_kb = eta_kb / (1.0 - eta_kb)

        return ratio_ka, ratio_kb