Beispiel #1
0
 def _xrf_intensity(self,z,line):
     if "name" not in [*self.tgt.keys()]:
         sys.stderr.write('Error: _xrf_intensity, tgt has no name\n')
         return 0.
     beamene=self.bem['beamene']
     thickness=self.tgt['thickness']
     density=self.tgt['density']
     nel=self.tgt['nElements']
     els=[*self.tgt['Elements']]# Z
     massfr=[*self.tgt['massFractions']]
     el_ind=np.where(np.array(els)==z)[0][0]
     A_corr = self._selfabs_corr(z,int(line))
     try:
         Q = xrl.CS_FluorLine_Kissel(z,int(line),beamene)
     except:
         Q=0.
     return Q * massfr[el_ind] * density * thickness * A_corr
Beispiel #2
0
    def _calculate_fpm_intensity(input, theta):
        alpha = math.radians(90.0 - theta)
        beta = math.radians(theta)
        discrete = input.excitation.get_energy_discrete(0)
        I0 = discrete.horizontal_intensity + discrete.vertical_intensity
        E0 = discrete.energy
        layer = input.composition.get_layer(0)

        _theta = math.atan(math.sqrt(input.geometry.area_detector / math.pi) / math.fabs(input.geometry.p_detector_window[1]))
        Omega_DET = 2 * math.pi * (1.0 - math.cos(_theta))
        G = Omega_DET / 4.0 / math.pi / math.sin(alpha)

        rv = []
        
        for i in zip(layer.Z, layer.weight):
            (Z, weight) = i
            chi = TestBatchSingle._chi(E0, xrl.LineEnergy(Z, xrl.KL3_LINE), layer, alpha, beta)
            tmp = I0 * G * weight * xrl.CS_FluorLine_Kissel(Z, xrl.KL3_LINE, E0) * \
                (1.0 - math.exp(-1.0 * chi * layer.density * layer.thickness)) / chi
            rv.append(tmp)
        return rv
def phantom_assign_concentration(ph_or, data_type=np.float32):
    """Builds the phantom used in:
    - N. Viganò and V. A. Solé, “Physically corrected forward operators for
    induced emission tomography: a simulation study,” Meas. Sci. Technol., no.
    Advanced X-Ray Tomography, pp. 1–26, Nov. 2017.

    :param ph_or: DESCRIPTION
    :type ph_or: TYPE
    :param data_type: DESCRIPTION, defaults to np.float32
    :type data_type: TYPE, optional

    :return: DESCRIPTION
    :rtype: TYPE
    """
    # ph_air = ph_or < 0.1
    ph_FeO = 0.5 < ph_or
    ph_CaO = np.logical_and(0.25 < ph_or, ph_or < 0.5)
    ph_CaC = np.logical_and(0.1 < ph_or, ph_or < 0.25)

    conv_mm_to_cm = 1e-1
    conv_um_to_mm = 1e-3
    voxel_size_um = 0.5
    voxel_size_cm = voxel_size_um * conv_um_to_mm * conv_mm_to_cm  # cm to micron
    print("Sample size: [%g %g] um" %
          (ph_or.shape[0] * voxel_size_um, ph_or.shape[1] * voxel_size_um))

    import xraylib

    xraylib.XRayInit()
    cp_fo = xraylib.GetCompoundDataNISTByName("Ferric Oxide")
    cp_co = xraylib.GetCompoundDataNISTByName("Calcium Oxide")
    cp_cc = xraylib.GetCompoundDataNISTByName("Calcium Carbonate")

    ca_an = xraylib.SymbolToAtomicNumber("Ca")
    ca_kal = xraylib.LineEnergy(ca_an, xraylib.KA_LINE)

    in_energy_keV = 20
    out_energy_keV = ca_kal

    ph_lin_att_in = (
        ph_FeO * xraylib.CS_Total_CP("Ferric Oxide", in_energy_keV) *
        cp_fo["density"] +
        ph_CaC * xraylib.CS_Total_CP("Calcium Carbonate", in_energy_keV) *
        cp_cc["density"] + ph_CaO *
        xraylib.CS_Total_CP("Calcium Oxide", in_energy_keV) * cp_co["density"])

    ph_lin_att_out = (
        ph_FeO * xraylib.CS_Total_CP("Ferric Oxide", out_energy_keV) *
        cp_fo["density"] +
        ph_CaC * xraylib.CS_Total_CP("Calcium Carbonate", out_energy_keV) *
        cp_cc["density"] +
        ph_CaO * xraylib.CS_Total_CP("Calcium Oxide", out_energy_keV) *
        cp_co["density"])

    vol_att_in = ph_lin_att_in * voxel_size_cm
    vol_att_out = ph_lin_att_out * voxel_size_cm

    ca_cs = xraylib.CS_FluorLine_Kissel(
        ca_an, xraylib.KA_LINE, in_energy_keV)  # fluo production for cm2/g
    ph_CaC_mass_fract = cp_cc["massFractions"][np.where(
        np.array(cp_cc["Elements"]) == ca_an)[0][0]]
    ph_CaO_mass_fract = cp_co["massFractions"][np.where(
        np.array(cp_co["Elements"]) == ca_an)[0][0]]

    ph = ph_CaC * ph_CaC_mass_fract * cp_cc[
        "density"] + ph_CaO * ph_CaO_mass_fract * cp_co["density"]
    ph = ph * ca_cs * voxel_size_cm

    return (ph, vol_att_in, vol_att_out)
Beispiel #4
0
def get_element_xrf_lines(Z,
                          lines='all',
                          incident_energy=100.0,
                          lowE=0.0,
                          highE=100.0,
                          norm_to_one=False,
                          include_escape=True,
                          detector_element='Si'):
    """

    Generate a list of lines that a given element will generate for energy range listed

    

    
    """
    result = {}
    xrf_list = []
    escape_list = []

    #
    #  This isn't very elegant...
    #
    if lines.upper() == 'K':
        linelist = siegbahn_k_list
        namelist = siegbahn_k_name_list
    elif lines.upper() == 'KA':
        linelist = siegbahn_ka_list
        namelist = siegbahn_ka_name_list
    if lines.upper() == 'KB':
        linelist = siegbahn_kb_list
        namelist = siegbahn_kb_name_list
    elif lines.upper() == 'L':
        linelist = siegbahn_l_list
        namelist = siegbahn_l_name_list
    elif lines.upper() == 'LA' or lines.upper() == 'L1':
        linelist = siegbahn_l1_list
        namelist = siegbahn_l1_name_list
    elif lines.upper() == 'LB' or lines.upper() == 'L2':
        linelist = siegbahn_l2_list
        namelist = siegbahn_l2_name_list
    elif lines.upper() == 'LG' or lines.upper() == 'L3':
        linelist = siegbahn_l3_list
        namelist = siegbahn_l3_name_list
    elif lines.upper() == 'M':
        linelist = siegbahn_m_list
        namelist = siegbahn_m_name_list
    elif lines.upper() == 'MA':
        linelist = siegbahn_ma_list
        namelist = siegbahn_ma_name_list
    elif lines.upper() == 'MB':
        linelist = siegbahn_mb_list
        namelist = siegbahn_mb_name_list

    elif lines.upper() == 'MG':
        linelist = siegbahn_mg_list
        namelist = siegbahn_mg_name_list
    else:
        linelist = siegbahn_all_list
        namelist = siegbahn_all_name_list

    for label, line in zip(namelist, linelist):
        lineE = xraylib.LineEnergy(Z, line)
        if lineE > 2.0 and lineE <= highE:
            cs = xraylib.CS_FluorLine_Kissel(Z, line, incident_energy)
            if cs > 0.0:
                #  xrf_list.append(XrayLine(label,lineE,cs))
                xrf_list.append([label, lineE, cs])
                if (include_escape):
                    ratio = calc_escape_peak_ratios(lineE)
                    escape_energy = calc_escape_peak_energy(
                        lineE, detector_element)
                    #    escape_list.append(EscapeLine(label,lineE,escape_energy,cs*ratio))
                    escape_list.append(
                        [label, lineE, escape_energy, cs * ratio])

#   if norm_to_one:
#     for line in xrf_list:
#         line1[2] = line[2]/nsum
#   for line in escape_list:
#       line1[3] = line[3]/nsum

    result["lines"] = xrf_list
    result["escape"] = escape_list
    return result
Beispiel #5
0
import numpy as np

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]))
Beispiel #6
0
#from xraylib import *
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))
		
Beispiel #7
0
def cs_fluorline_kissel(element, line,excitation_energy):
    z = elementDB[element]["Z"]
    if not isinstance(line,LinePair):
        line = _lookupxlsubline(line)
    return xraylib.CS_FluorLine_Kissel(z,line.subline,excitation_energy)