This file is indexed.

/usr/lib/python2.7/dist-packages/PyMca/LShell.py is in pymca 4.7.4+dfsg-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
#/*##########################################################################
# Copyright (C) 2004-2012 European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF by the Software group.
#
# This toolkit is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# PyMca is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# PyMca; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# PyMca follows the dual licensing model of Riverbank's PyQt and cannot be
# used as a free plugin for a non-free program.
#
# Please contact the ESRF industrial unit (industry@esrf.fr) if this license
# is a problem for you.
#############################################################################*/
__revision__ = "$Revision: 1.6 $"
import os
import numpy
try:
    from PyMca import specfile
except ImportError:
    print("LShell.py is importing specfile from local directory")
    import specfile
from PyMca import PyMcaDataDir

dirname   = PyMcaDataDir.PYMCA_DATA_DIR
inputfile = os.path.join(dirname, "LShellRates.dat")
if not os.path.exists(inputfile):
    dirname = os.path.dirname(dirname)
    inputfile = os.path.join(dirname, "LShellRates.dat")
    if dirname.lower().endswith(".zip"):
        dirname = os.path.dirname(dirname)
        inputfile = os.path.join(dirname, "LShellRates.dat")
    if not os.path.exists(inputfile):
        print("Cannot find inputfile ",inputfile)
        raise IOError("Cannot find LShellRates.dat file")
sf=specfile.Specfile(os.path.join(dirname, "LShellRates.dat"))
ElementL1ShellTransitions = sf[0].alllabels()
ElementL2ShellTransitions = sf[1].alllabels()
ElementL3ShellTransitions = sf[2].alllabels()
ElementL1ShellRates = numpy.transpose(sf[0].data()).tolist()
ElementL2ShellRates = numpy.transpose(sf[1].data()).tolist()
ElementL3ShellRates = numpy.transpose(sf[2].data()).tolist()

sf=specfile.Specfile(os.path.join(dirname, "LShellConstants.dat"))
ElementL1ShellConstants = sf[0].alllabels()
ElementL2ShellConstants = sf[1].alllabels()
ElementL3ShellConstants = sf[2].alllabels()
ElementL1ShellValues = numpy.transpose(sf[0].data()).tolist()
ElementL2ShellValues = numpy.transpose(sf[1].data()).tolist()
ElementL3ShellValues = numpy.transpose(sf[2].data()).tolist()
sf=None

EADL97 = False
fname = os.path.join(dirname, "EADL97_LShellConstants.dat")
if os.path.exists(fname):
    sf = specfile.Specfile(fname)
    EADL97_ElementL1ShellConstants = sf[0].alllabels()
    EADL97_ElementL2ShellConstants = sf[1].alllabels()
    EADL97_ElementL3ShellConstants = sf[2].alllabels()
    EADL97_ElementL1ShellValues = numpy.transpose(sf[0].data()).tolist()
    EADL97_ElementL2ShellValues = numpy.transpose(sf[1].data()).tolist()
    EADL97_ElementL3ShellValues = numpy.transpose(sf[2].data()).tolist()
    EADL97 = True
    sf = None

Elements = ['H', 'He', 
            'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne',
            'Na', 'Mg', 'Al', 'Si', 'P', 'S', 'Cl', 'Ar',
            'K', 'Ca', 'Sc', 'Ti', 'V', 'Cr', 'Mn', 'Fe',
            'Co', 'Ni', 'Cu', 'Zn', 'Ga', 'Ge', 'As', 'Se',
            'Br', 'Kr', 'Rb', 'Sr', 'Y', 'Zr', 'Nb', 'Mo',
            'Tc', 'Ru', 'Rh', 'Pd', 'Ag', 'Cd', 'In', 'Sn',
            'Sb', 'Te', 'I', 'Xe', 'Cs', 'Ba', 'La', 'Ce',
            'Pr', 'Nd', 'Pm', 'Sm', 'Eu', 'Gd', 'Tb', 'Dy', 
            'Ho', 'Er', 'Tm', 'Yb', 'Lu', 'Hf', 'Ta', 'W', 
            'Re', 'Os', 'Ir', 'Pt', 'Au', 'Hg', 'Tl', 'Pb', 
            'Bi', 'Po', 'At', 'Rn', 'Fr', 'Ra', 'Ac', 'Th', 
            'Pa', 'U', 'Np', 'Pu', 'Am', 'Cm', 'Bk', 'Cf', 
            'Es', 'Fm', 'Md', 'No', 'Lr', 'Rf', 'Db', 'Sg', 
            'Bh', 'Hs', 'Mt']


def getsymbol(z):
    return Elements[z-1]

def getz(ele):
    return Elements.index(ele)+1

#fluorescence yields
def getomegal1(ele):
    zEle = getz(ele)
    index = ElementL1ShellConstants.index('omegaL1')
    value = ElementL1ShellValues[zEle-1][index]
    if (value <= 0.0) and EADL97:
        #extend with EADL97 values
        if zEle > 99:
            #just to avoid a crash
            #I do not expect any fluorescent analysis of these elements ...
            zEle = 99
        index = EADL97_ElementL1ShellConstants.index('omegaL1')
        value = EADL97_ElementL1ShellValues[zEle-1][index]        
    return value

def getomegal2(ele):
    zEle = getz(ele)
    index = ElementL2ShellConstants.index('omegaL2')
    value = ElementL2ShellValues[zEle-1][index]
    if (value <= 0.0) and EADL97:
        #extend with EADL97 values
        if zEle > 99:
            #just to avoid a crash
            #I do not expect any fluorescent analysis of these elements ...
            zEle = 99
        index = EADL97_ElementL2ShellConstants.index('omegaL2')
        value = EADL97_ElementL2ShellValues[zEle-1][index]
    return value

def getomegal3(ele):
    zEle = getz(ele)
    index = ElementL3ShellConstants.index('omegaL3')
    value = ElementL3ShellValues[zEle-1][index]
    if (value <= 0.0) and EADL97:
        #extend with EADL97 values
        if zEle > 99:
            #just to avoid a crash
            #I do not expect any fluorescent analysis of these elements ...
            zEle = 99
        index = EADL97_ElementL3ShellConstants.index('omegaL3')
        value = EADL97_ElementL3ShellValues[zEle-1][index]        
    return value

def getCosterKronig(ele):
    ck = {}
    transitions = [ 'f12', 'f13', 'f23']
    zEle = getz(ele)
    if zEle > 99:
        #just to avoid a crash
        #I do not expect any fluorescent analysis of these elements ...
        EADL_z = 99
    else:
        EADL_z = zEle
    ckEADL = {}
    ckSum = 0.0
    for t in transitions:
        if   t in ElementL1ShellConstants:
             index   = ElementL1ShellConstants.index(t)
             ck[t]   = ElementL1ShellValues[zEle-1][index]
             if EADL97:
                 #extend with EADL97 values
                 index   = EADL97_ElementL1ShellConstants.index(t)
                 ckEADL[t]   = EADL97_ElementL1ShellValues[EADL_z-1][index]
        elif t in ElementL2ShellConstants:
             index   = ElementL2ShellConstants.index(t)
             ck[t]   = ElementL2ShellValues[zEle-1][index]
             if EADL97:
                 #extend with EADL97 values
                 index     = EADL97_ElementL2ShellConstants.index(t)
                 ckEADL[t] = EADL97_ElementL2ShellValues[EADL_z-1][index]                 
        elif t in ElementL3ShellConstants:
             index   = ElementL3ShellConstants.index(t)
             ck[t]   = ElementL3ShellValues[zEle-1][index]
             if EADL97:
                 #extend with EADL97 values
                 index   = EADL97_ElementL3ShellConstants.index(t)
                 ckEADL[t]   = EADL97_ElementL3ShellValues[EADL_z-1][index]
        else:
            print("%s not in L-Shell Coster-Kronig transitions" % t)
            continue
        ckSum += ck[t]
        
    if ckSum > 0.0:
        #I do not force EADL97 because of compatibility
        #with previous versions. I may offer forcing to
        #EADL97 in the future.
        return ck
    elif EADL97:
        #extended values if defined
        #for instance, the region from Mg to Cl
        return ckEADL
    else:
        return ck

#Jump ratios following Veigele: Atomic Data Tables 5 (1973) 51-111. p 54 and 55
def getjl1(z):
    return 1.2

def getjl2(z):
    return 1.4

def getjl3(z):
    return (80.0/z) + 1.5
    
def getwjump(ele,excitedshells=[1.0,1.0,1.0]):
    """
    wjump represents the probability for a vacancy to be created
    on the respective L-Shell by direct photoeffect on that shell
    """
    z = getz(ele)
    #weights due to photoeffect
    jl  = [getjl1(z), getjl2(z), getjl3(z)]
    wjump = []
    i = 0
    cum = 0.00
    for jump in jl:
        v = excitedshells[i]*(jump-1.0)/jump
        wjump.append(v)
        cum += v
        i+=1
    for i in range(len(wjump)):
        wjump[i] = wjump[i] / cum
    return wjump

def getweights(ele,excitedshells=None):
    if type(ele) == type(" "):
        pass
    else:
        ele = getsymbol(int(ele))
    if excitedshells == None:excitedshells=[1.0,1.0,1.0]
    w = getwjump(ele,excitedshells)
    #weights due to Coster Kronig transitions and fluorescence yields 
    ck= getCosterKronig(ele)
    w[0] *=  1.0
    w[1] *= (1.0 + ck['f12'] * w[0])
    w[2] *= (1.0 + ck['f13'] * w[0] + ck['f23'] * w[1])
    omega = [ getomegal1(ele), getomegal2(ele), getomegal3(ele)]
    for i in range(len(w)):
        w[i] *= omega[i]
    cum = sum(w)
    for i in range(len(w)):
        if cum > 0.0:
            w[i] /= cum        
    return w

if 'TOTAL' in  ElementL1ShellTransitions:
    labeloffset = 2
else:
    labeloffset = 1
ElementLShellTransitions = ElementL1ShellTransitions     +  \
                           ElementL2ShellTransitions[labeloffset:] +  \
                           ElementL3ShellTransitions[labeloffset:]
    
for i in range(len(ElementLShellTransitions)):
    ElementLShellTransitions[i]+="*"    
 
nele = len(ElementL1ShellRates)
elements = range(1,nele+1)
weights = []
for ele in elements:
    weights.append(getweights(ele))
weights = numpy.array(weights).astype(numpy.float)
ElementLShellRates = numpy.zeros((len(ElementL1ShellRates),
                                  len(ElementLShellTransitions)),
                                  numpy.float)
ElementLShellRates[:,0]     = numpy.arange(len(ElementL1ShellRates)) + 1 
n1 = len(ElementL1ShellTransitions)
lo = labeloffset
ElementLShellRates[:,lo:n1] = numpy.array(ElementL1ShellRates).astype(numpy.float)[:,lo:] * \
                              numpy.resize(weights[:,0],(nele,1))
n2 = n1 + len(ElementL2ShellTransitions) - lo
ElementLShellRates[:,n1:n2] = numpy.array(ElementL2ShellRates).astype(numpy.float)[:,lo:]* \
                              numpy.resize(weights[:,1],(nele,1))
n1 = n2
n2 = n1 + len(ElementL3ShellTransitions) - lo
ElementLShellRates[:,n1:n2] = numpy.array(ElementL3ShellRates).astype(numpy.float)[:,lo:]* \
                              numpy.resize(weights[:,2],(nele,1))

if __name__ == "__main__":
    import sys
    if len(sys.argv) > 1:
        ele = sys.argv[1]
        if ele in Elements:
            z = getz(ele)
            print("Atomic  Number = ",z)
            print("L1-shell yield = ",getomegal1(ele))
            print("L2-shell yield = ",getomegal2(ele))
            print("L3-shell yield = ",getomegal3(ele))
            print("L1-shell  jump = ",getjl1(z))
            print("L2-shell  jump = ",getjl2(z))
            print("L3-shell  jump = ",getjl3(z))
            print("Coster-Kronig  = ",getCosterKronig(ele))