-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit '5a62732fc740ff73fb4d52e192c4e36b22f0369f' as 'third-par…
…ty/fisx'
- Loading branch information
Showing
95 changed files
with
174,120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Compiled Object files | ||
*.slo | ||
*.lo | ||
*.o | ||
|
||
# Compiled Dynamic libraries | ||
*.so | ||
*.dylib | ||
|
||
# Compiled Static libraries | ||
*.lai | ||
*.la | ||
*.a | ||
|
||
#vim | ||
*.swp | ||
*~ | ||
|
||
# Python .gitignore template follows | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
||
#cython generated files added (line commented) | ||
#python/cython/*.cpp | ||
|
||
# Distribution / packaging | ||
#bin/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
eggs/ | ||
lib/ | ||
lib64/ | ||
#parts/ | ||
sdist/ | ||
var/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
.tox/ | ||
.coverage | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
|
||
# Translations | ||
*.mo | ||
|
||
# Mr Developer | ||
.mr.developer.cfg | ||
.project | ||
.pydevproject | ||
|
||
# Rope | ||
.ropeproject | ||
|
||
# Django stuff: | ||
*.log | ||
*.pot | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2014 V. Armando Sole | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
include MANIFEST.in | ||
include LICENSE | ||
include changelog.txt | ||
include README.md | ||
include README | ||
include TODO | ||
recursive-include fisx_data *.dat | ||
recursive-include python *.py *.pyx *.pxd *.cpp | ||
recursive-include src *.h *.cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
fisx | ||
==== | ||
|
||
C++ port (with enhancements) of the PyMca Physics routines. | ||
|
||
This library allows to calculate the expected X-ray fluorescence intensities measured by a detection system. | ||
|
||
Account for scondary excitation is made via the reference: | ||
|
||
D.K.G. de Boer, X-Ray Spectrometry 19 (1990) 145-154 | ||
|
||
with the correction mentioned in: | ||
|
||
D.K.G. de Boer et al, X-Ray Spectrometry 22 (1993) 33-28 | ||
|
||
Tertiary excitation is accounted for with an appproximation. | ||
|
||
The accuracy of the corrections has been tested against experimental data and Monte Carlo simulations. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
fisx | ||
==== | ||
|
||
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. | ||
|
||
License | ||
------- | ||
|
||
This code is relased under the MIT license as detailed in the LICENSE file. | ||
|
||
Installation | ||
------------ | ||
|
||
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. | ||
|
||
|
||
Example | ||
------- | ||
|
||
This piece of Python code shows how the library can be used via its python binding. | ||
|
||
```python | ||
from fisx import Elements | ||
from fisx import Material | ||
from fisx import Detector | ||
from fisx import XRF | ||
elementsInstance = Elements() | ||
elementsInstance.initializeAsPyMca() | ||
# After the slow initialization (to be made once), the rest is fairly fast. | ||
xrf = XRF() | ||
xrf.setBeam(16.0) # set incident beam as a single photon energy of 16 keV | ||
xrf.setBeamFilters([["Al1", 2.72, 0.11, 1.0]]) # Incident beam filters | ||
# Steel composition of Schoonjans et al, 2012 used to generate table I | ||
steel = {"C": 0.0445, | ||
"N": 0.04, | ||
"Si": 0.5093, | ||
"P": 0.02, | ||
"S": 0.0175, | ||
"V": 0.05, | ||
"Cr":18.37, | ||
"Mn": 1.619, | ||
"Fe":64.314, # calculated by subtracting the sum of all other elements | ||
"Co": 0.109, | ||
"Ni":12.35, | ||
"Cu": 0.175, | ||
"As": 0.010670, | ||
"Mo": 2.26, | ||
"W": 0.11, | ||
"Pb": 0.001} | ||
SRM_1155 = Material("SRM_1155", 1.0, 1.0) | ||
SRM_1155.setComposition(steel) | ||
elementsInstance.addMaterial(SRM_1155) | ||
xrf.setSample([["SRM_1155", 1.0, 1.0]]) # Sample, density and thickness | ||
xrf.setGeometry(45., 45.) # Incident and fluorescent beam angles | ||
detector = Detector("Si1", 2.33, 0.035) # Detector Material, density, thickness | ||
detector.setActiveArea(0.50) # Area and distance in consistent units | ||
detector.setDistance(2.1) # expected cm2 and cm. | ||
xrf.setDetector(detector) | ||
Air = Material("Air", 0.0012048, 1.0) | ||
Air.setCompositionFromLists(["C1", "N1", "O1", "Ar1", "Kr1"], | ||
[0.0012048, 0.75527, 0.23178, 0.012827, 3.2e-06]) | ||
elementsInstance.addMaterial(Air) | ||
xrf.setAttenuators([["Air", 0.0012048, 5.0, 1.0], | ||
["Be1", 1.848, 0.002, 1.0]]) # Attenuators | ||
fluo = xrf.getMultilayerFluorescence(["Cr K", "Fe K", "Ni K"], | ||
elementsInstance, | ||
secondary=2, | ||
useMassFractions=1) | ||
print("Element Peak Energy Rate Secondary Tertiary") | ||
for key in fluo: | ||
for layer in fluo[key]: | ||
peakList = list(fluo[key][layer].keys()) | ||
peakList.sort() | ||
for peak in peakList: | ||
# energy of the peak | ||
energy = fluo[key][layer][peak]["energy"] | ||
# expected measured rate | ||
rate = fluo[key][layer][peak]["rate"] | ||
# primary photons (no attenuation and no detector considered) | ||
primary = fluo[key][layer][peak]["primary"] | ||
# secondary photons (no attenuation and no detector considered) | ||
secondary = fluo[key][layer][peak]["secondary"] | ||
# tertiary photons (no attenuation and no detector considered) | ||
tertiary = fluo[key][layer][peak].get("tertiary", 0.0) | ||
# correction due to secondary excitation | ||
enhancement2 = (primary + secondary) / primary | ||
enhancement3 = (primary + secondary + tertiary) / primary | ||
print("%s %s %.4f %.3g %.5g %.5g" % \ | ||
(key, peak + (13 - len(peak)) * " ", energy, | ||
rate, enhancement2, enhancement3)) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- Add doc strings based on the C++ doxygen information to the python binding. | ||
- Possibility to save and to load the configuration in own fisx format. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
VERSION 1.0.2 | ||
|
||
Give correct weight to elastic scattering contribution. | ||
|
||
VERSION 1.0.1 | ||
|
||
Add conda recipe | ||
|
||
Correct test suite | ||
|
||
Correct bug reading PyMca configuration files | ||
|
||
VERSION 1.0.0 | ||
|
||
First release. | ||
|
||
Secondary excitation due to fluorescence and elastic scattering considered. | ||
|
||
Tertiary implemented via an approximation method. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
%PYTHON% setup.py install | ||
if errorlevel 1 exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$PYTHON setup.py install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package: | ||
name: fisx | ||
version: {{ environ.get('GIT_DESCRIBE_TAG', '')[1:] }} | ||
|
||
source: | ||
git_url: ../ | ||
git_tag: master # change to branch or tag name, as needed | ||
|
||
build: | ||
number: {{ environ.get('GIT_DESCRIBE_NUMBER', 0) }} | ||
|
||
requirements: | ||
build: | ||
- python | ||
- cython | ||
- numpy | ||
run: | ||
- python | ||
- numpy | ||
- pymca | ||
|
||
test: | ||
requires: | ||
- pymca | ||
imports: | ||
- fisx | ||
|
||
about: | ||
license: MIT | ||
home: http://pymca.sourceforge.net | ||
summary: Resources for synchrotron data analysis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#/*########################################################################## | ||
# | ||
# The fisx library for X-Ray Fluorescence | ||
# | ||
# Copyright (c) 2014 V. Armando Sole | ||
# | ||
# This file is part of the fisx X-ray developed by V.A. Sole | ||
# | ||
# This file is a contribution from Darren Dale | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
# | ||
#############################################################################*/ | ||
__author__ = "Darren Dale - CHESS" | ||
import os | ||
import sys | ||
|
||
|
||
if sys.version.startswith('2.6') or sys.version.startswith('3.1'): | ||
import unittest2 as unittest | ||
else: | ||
import unittest | ||
|
||
suite = unittest.TestLoader().discover('fisx') | ||
unittest.TextTestRunner(verbosity=1).run(suite) |
Oops, something went wrong.