Skip to content

Commit ef9bc82

Browse files
committed
Merge commit '5a62732fc740ff73fb4d52e192c4e36b22f0369f' as 'third-party/fisx'
2 parents b3fbb05 + 5a62732 commit ef9bc82

File tree

95 files changed

+174120
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+174120
-0
lines changed

third-party/fisx/.gitignore

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Compiled Object files
2+
*.slo
3+
*.lo
4+
*.o
5+
6+
# Compiled Dynamic libraries
7+
*.so
8+
*.dylib
9+
10+
# Compiled Static libraries
11+
*.lai
12+
*.la
13+
*.a
14+
15+
#vim
16+
*.swp
17+
*~
18+
19+
# Python .gitignore template follows
20+
# Byte-compiled / optimized / DLL files
21+
__pycache__/
22+
*.py[cod]
23+
24+
#cython generated files added (line commented)
25+
#python/cython/*.cpp
26+
27+
# Distribution / packaging
28+
#bin/
29+
build/
30+
develop-eggs/
31+
dist/
32+
eggs/
33+
lib/
34+
lib64/
35+
#parts/
36+
sdist/
37+
var/
38+
*.egg-info/
39+
.installed.cfg
40+
*.egg
41+
42+
# Installer logs
43+
pip-log.txt
44+
pip-delete-this-directory.txt
45+
46+
# Unit test / coverage reports
47+
.tox/
48+
.coverage
49+
.cache
50+
nosetests.xml
51+
coverage.xml
52+
53+
# Translations
54+
*.mo
55+
56+
# Mr Developer
57+
.mr.developer.cfg
58+
.project
59+
.pydevproject
60+
61+
# Rope
62+
.ropeproject
63+
64+
# Django stuff:
65+
*.log
66+
*.pot
67+
68+
# Sphinx documentation
69+
docs/_build/
70+

third-party/fisx/LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 V. Armando Sole
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

third-party/fisx/MANIFEST.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
include MANIFEST.in
2+
include LICENSE
3+
include changelog.txt
4+
include README.md
5+
include README
6+
include TODO
7+
recursive-include fisx_data *.dat
8+
recursive-include python *.py *.pyx *.pxd *.cpp
9+
recursive-include src *.h *.cpp

third-party/fisx/README

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
fisx
2+
====
3+
4+
C++ port (with enhancements) of the PyMca Physics routines.
5+
6+
This library allows to calculate the expected X-ray fluorescence intensities measured by a detection system.
7+
8+
Account for scondary excitation is made via the reference:
9+
10+
D.K.G. de Boer, X-Ray Spectrometry 19 (1990) 145-154
11+
12+
with the correction mentioned in:
13+
14+
D.K.G. de Boer et al, X-Ray Spectrometry 22 (1993) 33-28
15+
16+
Tertiary excitation is accounted for with an appproximation.
17+
18+
The accuracy of the corrections has been tested against experimental data and Monte Carlo simulations.

third-party/fisx/README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
fisx
2+
====
3+
4+
This software library implements formulas to calculate, given an experimental setup, the expected x-ray fluorescence intensities. The library accounts for secondary and tertiary excitation, K, L and M shell emission lines and de-excitation cascade effects. The basic implementation is written in C++ and a Python binding is provided.
5+
6+
License
7+
-------
8+
9+
This code is relased under the MIT license as detailed in the LICENSE file.
10+
11+
Installation
12+
------------
13+
14+
To build the library for python use, just use the "python setup.py install" approach. It is convenient (but not mandatory) to have cython >= 0.17 installed.
15+
16+
17+
Example
18+
-------
19+
20+
This piece of Python code shows how the library can be used via its python binding.
21+
22+
```python
23+
from fisx import Elements
24+
from fisx import Material
25+
from fisx import Detector
26+
from fisx import XRF
27+
elementsInstance = Elements()
28+
elementsInstance.initializeAsPyMca()
29+
# After the slow initialization (to be made once), the rest is fairly fast.
30+
xrf = XRF()
31+
xrf.setBeam(16.0) # set incident beam as a single photon energy of 16 keV
32+
xrf.setBeamFilters([["Al1", 2.72, 0.11, 1.0]]) # Incident beam filters
33+
# Steel composition of Schoonjans et al, 2012 used to generate table I
34+
steel = {"C": 0.0445,
35+
"N": 0.04,
36+
"Si": 0.5093,
37+
"P": 0.02,
38+
"S": 0.0175,
39+
"V": 0.05,
40+
"Cr":18.37,
41+
"Mn": 1.619,
42+
"Fe":64.314, # calculated by subtracting the sum of all other elements
43+
"Co": 0.109,
44+
"Ni":12.35,
45+
"Cu": 0.175,
46+
"As": 0.010670,
47+
"Mo": 2.26,
48+
"W": 0.11,
49+
"Pb": 0.001}
50+
SRM_1155 = Material("SRM_1155", 1.0, 1.0)
51+
SRM_1155.setComposition(steel)
52+
elementsInstance.addMaterial(SRM_1155)
53+
xrf.setSample([["SRM_1155", 1.0, 1.0]]) # Sample, density and thickness
54+
xrf.setGeometry(45., 45.) # Incident and fluorescent beam angles
55+
detector = Detector("Si1", 2.33, 0.035) # Detector Material, density, thickness
56+
detector.setActiveArea(0.50) # Area and distance in consistent units
57+
detector.setDistance(2.1) # expected cm2 and cm.
58+
xrf.setDetector(detector)
59+
Air = Material("Air", 0.0012048, 1.0)
60+
Air.setCompositionFromLists(["C1", "N1", "O1", "Ar1", "Kr1"],
61+
[0.0012048, 0.75527, 0.23178, 0.012827, 3.2e-06])
62+
elementsInstance.addMaterial(Air)
63+
xrf.setAttenuators([["Air", 0.0012048, 5.0, 1.0],
64+
["Be1", 1.848, 0.002, 1.0]]) # Attenuators
65+
fluo = xrf.getMultilayerFluorescence(["Cr K", "Fe K", "Ni K"],
66+
elementsInstance,
67+
secondary=2,
68+
useMassFractions=1)
69+
print("Element Peak Energy Rate Secondary Tertiary")
70+
for key in fluo:
71+
for layer in fluo[key]:
72+
peakList = list(fluo[key][layer].keys())
73+
peakList.sort()
74+
for peak in peakList:
75+
# energy of the peak
76+
energy = fluo[key][layer][peak]["energy"]
77+
# expected measured rate
78+
rate = fluo[key][layer][peak]["rate"]
79+
# primary photons (no attenuation and no detector considered)
80+
primary = fluo[key][layer][peak]["primary"]
81+
# secondary photons (no attenuation and no detector considered)
82+
secondary = fluo[key][layer][peak]["secondary"]
83+
# tertiary photons (no attenuation and no detector considered)
84+
tertiary = fluo[key][layer][peak].get("tertiary", 0.0)
85+
# correction due to secondary excitation
86+
enhancement2 = (primary + secondary) / primary
87+
enhancement3 = (primary + secondary + tertiary) / primary
88+
print("%s %s %.4f %.3g %.5g %.5g" % \
89+
(key, peak + (13 - len(peak)) * " ", energy,
90+
rate, enhancement2, enhancement3))
91+
```

third-party/fisx/TODO

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Add doc strings based on the C++ doxygen information to the python binding.
2+
- Possibility to save and to load the configuration in own fisx format.

third-party/fisx/changelog.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
VERSION 1.0.2
2+
3+
Give correct weight to elastic scattering contribution.
4+
5+
VERSION 1.0.1
6+
7+
Add conda recipe
8+
9+
Correct test suite
10+
11+
Correct bug reading PyMca configuration files
12+
13+
VERSION 1.0.0
14+
15+
First release.
16+
17+
Secondary excitation due to fluorescence and elastic scattering considered.
18+
19+
Tertiary implemented via an approximation method.

third-party/fisx/conda.recipe/bld.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
%PYTHON% setup.py install
2+
if errorlevel 1 exit 1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$PYTHON setup.py install
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package:
2+
name: fisx
3+
version: {{ environ.get('GIT_DESCRIBE_TAG', '')[1:] }}
4+
5+
source:
6+
git_url: ../
7+
git_tag: master # change to branch or tag name, as needed
8+
9+
build:
10+
number: {{ environ.get('GIT_DESCRIBE_NUMBER', 0) }}
11+
12+
requirements:
13+
build:
14+
- python
15+
- cython
16+
- numpy
17+
run:
18+
- python
19+
- numpy
20+
- pymca
21+
22+
test:
23+
requires:
24+
- pymca
25+
imports:
26+
- fisx
27+
28+
about:
29+
license: MIT
30+
home: http://pymca.sourceforge.net
31+
summary: Resources for synchrotron data analysis
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#/*##########################################################################
2+
#
3+
# The fisx library for X-Ray Fluorescence
4+
#
5+
# Copyright (c) 2014 V. Armando Sole
6+
#
7+
# This file is part of the fisx X-ray developed by V.A. Sole
8+
#
9+
# This file is a contribution from Darren Dale
10+
#
11+
# Permission is hereby granted, free of charge, to any person obtaining a copy
12+
# of this software and associated documentation files (the "Software"), to deal
13+
# in the Software without restriction, including without limitation the rights
14+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15+
# copies of the Software, and to permit persons to whom the Software is
16+
# furnished to do so, subject to the following conditions:
17+
#
18+
# The above copyright notice and this permission notice shall be included in
19+
# all copies or substantial portions of the Software.
20+
#
21+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27+
# THE SOFTWARE.
28+
#
29+
#############################################################################*/
30+
__author__ = "Darren Dale - CHESS"
31+
import os
32+
import sys
33+
34+
35+
if sys.version.startswith('2.6') or sys.version.startswith('3.1'):
36+
import unittest2 as unittest
37+
else:
38+
import unittest
39+
40+
suite = unittest.TestLoader().discover('fisx')
41+
unittest.TextTestRunner(verbosity=1).run(suite)

0 commit comments

Comments
 (0)